MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / pread

Function pread

src/jrd/os/posix/unix.cpp:1096–1126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1094*/
1095
1096static SLONG pread(int fd, SCHAR* buf, SLONG nbytes, SLONG offset)
1097/**************************************
1098 *
1099 * p r e a d
1100 *
1101 **************************************
1102 *
1103 * Functional description
1104 *
1105 * This function uses Asynchronous I/O calls to implement
1106 * positioned read from a given offset
1107 **************************************/
1108{
1109 struct aiocb io;
1110 io.aio_fildes = fd;
1111 io.aio_offset = offset;
1112 io.aio_buf = buf;
1113 io.aio_nbytes = nbytes;
1114 io.aio_reqprio = 0;
1115 io.aio_sigevent.sigev_notify = SIGEV_NONE;
1116 int err = aio_read(&io); // atomically reads at offset
1117 if (err != 0)
1118 return (err); // errno is set
1119
1120 struct aiocb *list[1];
1121 list[0] = &io;
1122 err = aio_suspend(list, 1, NULL); // wait for I/O to complete
1123 if (err != 0)
1124 return (err); // errno is set
1125 return (aio_return(&io)); // return I/O status
1126}
1127
1128static SLONG pwrite(int fd, SCHAR* buf, SLONG nbytes, SLONG offset)
1129/**************************************

Callers 2

PIO_headerFunction · 0.70
PIO_readFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected