opt
/
kaspersky
/
kav4fs
/
src
/
kernel
/
oas
/
small
➕ New
📤 Upload
✎ Editing:
protocol_transport_oper.h
← Back
#ifndef KERNEL__OAS__SMALL__PROTOCOL_TRANSPORT_OPER_H #define KERNEL__OAS__SMALL__PROTOCOL_TRANSPORT_OPER_H #include "protocol_transport_impl.h" #include <errno.h> // SEND // call write once, send as much as possible static int SendBuffer(int fd, TransportBuffer* buf); // call write while buffer not empty static int SendWholeBuffer(int fd, TransportBuffer* buf); // RECEIVE // call read once static int ReceiveData(int fd, TransportBuffer* buf); static int SendBuffer(int fd, TransportBuffer* buf) { if (!buf->length) return 0; int res = write(fd, buf->start, buf->length); if (res == -1) { perror("write error"); return -1; } buf->start += res; buf->length -= res; return res; } int SendWholeBuffer(int fd, TransportBuffer* buf) { while (!buf->length) { if (SendBuffer(fd, buf) == -1) return -1; } return 0; } int ReceiveData(int fd, TransportBuffer* buf) { u_int32_t avail = buf->capacity - buf->length - (buf->start - buf->data); if (avail == 0) { fs_transport_buffer_check_size(buf, buf->capacity / 2); avail = buf->capacity - buf->length - (buf->start - buf->data); } int res = read(fd, buf->start + buf->length, avail); if (res == -1) { if (errno == EINTR) return 0; if (errno != EAGAIN) perror("read error"); return -1; } buf->length += res; return res; } #endif // KERNEL__OAS__SMALL__PROTOCOL_TRANSPORT_OPER_H
💾 Save Changes
Cancel
📤 Upload File
×
Select File
Upload
Cancel
➕ Create New
×
Type
📄 File
📁 Folder
Name
Create
Cancel
✎ Rename Item
×
Current Name
New Name
Rename
Cancel
🔐 Change Permissions
×
Target File
Permission (e.g., 0755, 0644)
0755
0644
0777
Apply
Cancel