/// <summary> /// Prepares this Submission Queue Entry as a fallocate. /// </summary> /// <param name="fd">The file to manipulate the allocated disk space for</param> /// <param name="mode">The operation to be performed</param> /// <param name="offset">Offset in bytes into the file</param> /// <param name="len">Number of bytes to operate on</param> /// <param name="userData">User data that will be returned with the respective <see cref="Completion"/></param> /// <param name="options">Options for the handling of the prepared Submission Queue Entry</param> /// <param name="personality">The personality to impersonate for this submission</param> public void PrepareFallocate(int fd, int mode, off_t offset, off_t len, ulong userData = 0, SubmissionOption options = SubmissionOption.None, ushort personality = 0) { var sqe = _sqe; unchecked { sqe->opcode = IORING_OP_FALLOCATE; sqe->flags = (byte)options; sqe->fd = fd; sqe->off = (ulong)(long)offset; sqe->addr = (ulong)(long)len; sqe->len = (uint)mode; sqe->user_data = userData; sqe->personality = personality; } }
/// <summary> /// Prepares this Submission Queue Entry as a sync_file_range. /// </summary> /// <param name="fd">File descriptor to sync</param> /// <param name="offset">Offset in bytes into the file</param> /// <param name="count">Number of bytes to sync</param> /// <param name="flags">Flags for the operation (as per sync_file_range)</param> /// <param name="userData">User data that will be returned with the respective <see cref="Completion"/></param> /// <param name="options">Options for the handling of the prepared Submission Queue Entry</param> /// <param name="personality">The personality to impersonate for this submission</param> public void PrepareSyncFileRange(int fd, off_t offset, off_t count, uint flags, ulong userData = 0, SubmissionOption options = SubmissionOption.None, ushort personality = 0) { var sqe = _sqe; unchecked { sqe->opcode = IORING_OP_SYNC_FILE_RANGE; sqe->flags = (byte)options; sqe->fd = fd; sqe->off = (ulong)(long)offset; sqe->len = (uint)count; sqe->sync_range_flags = flags; sqe->user_data = userData; sqe->personality = personality; } }
// internal for testing internal void PrepareReadWrite(byte op, int fd, void *iov, int count, off_t offset, int flags, ulong userData, SubmissionOption options) { var sqe = _sqe; unchecked { sqe->opcode = op; sqe->flags = (byte)options; sqe->fd = fd; sqe->off = (ulong)(long)offset; sqe->addr = (ulong)iov; sqe->len = (uint)count; sqe->rw_flags = flags; sqe->user_data = userData; } }
/// <summary> /// Prepares this Submission Queue Entry as a write using a registered buffer/file. /// </summary> /// <param name="fd">File descriptor to write to</param> /// <param name="buf">Buffer/file to write</param> /// <param name="count">Number of bytes to write</param> /// <param name="index">Index of buffer/file</param> /// <param name="offset">Offset at which the I/O is performed (as per pwritev)</param> /// <param name="userData">User data that will be returned with the respective <see cref="Completion"/></param> /// <param name="options">Options for the handling of the prepared Submission Queue Entry</param> /// <param name="personality">The personality to impersonate for this submission</param> public void PrepareWriteFixed(int fd, void *buf, size_t count, int index, off_t offset = default, ulong userData = 0, SubmissionOption options = SubmissionOption.None, ushort personality = 0) { var sqe = _sqe; unchecked { sqe->opcode = IORING_OP_WRITE_FIXED; sqe->flags = (byte)options; sqe->fd = fd; sqe->off = (ulong)(long)offset; sqe->addr = (ulong)buf; sqe->len = (uint)count; sqe->buf_index = (ushort)index; sqe->user_data = userData; sqe->personality = personality; } }
/// <summary> /// Prepares this Submission Queue Entry as a writev, pwritev or pwritev2. /// </summary> /// <param name="fd">File descriptor to write to</param> /// <param name="iov">I/O vectors to write</param> /// <param name="count">Number of I/O vectors</param> /// <param name="offset">Offset at which the I/O is performed (as per pwritev)</param> /// <param name="flags">Flags for the I/O (as per pwritev2)</param> /// <param name="userData">User data that will be returned with the respective <see cref="Completion"/></param> /// <param name="options">Options for the handling of the prepared Submission Queue Entry</param> /// <param name="personality">The personality to impersonate for this submission</param> public void PrepareWriteV(int fd, iovec *iov, int count, off_t offset = default, int flags = 0, ulong userData = 0, SubmissionOption options = SubmissionOption.None, ushort personality = 0) { var sqe = _sqe; unchecked { sqe->opcode = IORING_OP_WRITEV; sqe->flags = (byte)options; sqe->fd = fd; sqe->off = (ulong)(long)offset; sqe->addr = (ulong)iov; sqe->len = (uint)count; sqe->rw_flags = flags; sqe->user_data = userData; sqe->personality = personality; } }
/// <summary> /// Prepares this Submission Queue Entry as a readv, preadv or preadv2 with buffer selection. /// </summary> /// <param name="fd">File descriptor to read from</param> /// <param name="iov">I/O vectors to read to</param> /// <param name="count">Number of I/O vectors</param> /// <param name="bgid">Group ID for buffer selection</param> /// <param name="offset">Offset at which the I/O is performed (as per preadv)</param> /// <param name="flags">Flags for the I/O (as per preadv2)</param> /// <param name="userData">User data that will be returned with the respective <see cref="Completion"/></param> /// <param name="options">Options for the handling of the prepared Submission Queue Entry</param> /// <param name="personality">The personality to impersonate for this submission</param> public void PrepareReadV(int fd, iovec *iov, int count, int bgid, off_t offset = default, int flags = 0, ulong userData = 0, SubmissionOption options = SubmissionOption.None, ushort personality = 0) { var sqe = _sqe; unchecked { sqe->opcode = IORING_OP_READV; sqe->flags = (byte)((byte)options | IOSQE_BUFFER_SELECT); sqe->fd = fd; sqe->off = (ulong)(long)offset; sqe->addr = (ulong)iov; sqe->len = (uint)count; sqe->rw_flags = flags; sqe->user_data = userData; sqe->buf_group = (ushort)bgid; sqe->personality = personality; } }
/// <summary> /// Attempts to add a sync_file_range to the Submission Queue without it being submitted. /// The actual submission can be deferred to avoid unnecessary memory barriers. /// </summary> /// <param name="fd">File descriptor to sync</param> /// <param name="offset">Offset in bytes into the file</param> /// <param name="count">Number of bytes to sync</param> /// <param name="flags">Flags for the operation (as per sync_file_range)</param> /// <param name="userData">User data that will be returned with the respective <see cref="Completion"/></param> /// <param name="options">Options for the handling of the prepared Submission Queue Entry</param> /// <returns><code>false</code> if the submission queue is full. <code>true</code> otherwise.</returns> public bool TryPrepareSyncFileRange(int fd, off_t offset, off_t count, uint flags, ulong userData = 0, SubmissionOption options = SubmissionOption.None) { if (!NextSubmissionQueueEntry(out var sqe)) { return(false); } unchecked { sqe->opcode = IORING_OP_SYNC_FILE_RANGE; sqe->user_data = userData; sqe->flags = (byte)options; sqe->fd = fd; sqe->len = (uint)count; sqe->off = (ulong)(long)offset; sqe->sync_range_flags = flags; } return(true); }
private bool TryPrepareReadWrite(byte op, int fd, void *iov, int count, off_t offset, int flags, ulong userData, SubmissionOption options) { if (!NextSubmissionQueueEntry(out var sqe)) { return(false); } unchecked { sqe->opcode = op; sqe->user_data = userData; sqe->flags = (byte)options; sqe->fd = fd; sqe->addr = (ulong)iov; sqe->len = (uint)count; sqe->off = (ulong)(long)offset; sqe->rw_flags = flags; } return(true); }
public static extern int truncate(byte *path, off_t length);
public static extern int ftruncate(int fd, off_t length);
public static extern int posix_fadvise(int fd, off_t offset, off_t length, int advice);
public static extern ssize_t pwrite(int fd, void *buf, size_t count, off_t offset);
public static extern int fallocate(int fd, int mode, off_t offset, off_t length);
public static extern int posix_fallocate(int fd, off_t offset, off_t length);
public static extern ssize_t readahead(int fd, off_t pos, size_t len);
public static extern int sync_file_range(int fd, off_t pos, off_t len, uint flags);
/// <summary> /// Attempts to add a readv, preadv or preadv2 to the Submission Queue without it being submitted. /// The actual submission can be deferred to avoid unnecessary memory barriers. /// </summary> /// <param name="fd">File descriptor to read from</param> /// <param name="iov">I/O vectors to read to</param> /// <param name="count">Number of I/O vectors</param> /// <param name="offset">Offset in bytes into the I/O vectors (as per preadv)</param> /// <param name="flags">Flags for the I/O (as per preadv2)</param> /// <param name="userData">User data that will be returned with the respective <see cref="Completion"/></param> /// <param name="options">Options for the handling of the prepared Submission Queue Entry</param> /// <returns><code>false</code> if the submission queue is full. <code>true</code> otherwise.</returns> public bool TryPrepareReadV( int fd, iovec *iov, int count, off_t offset = default, int flags = 0, ulong userData = 0, SubmissionOption options = SubmissionOption.None) => TryPrepareReadWrite(IORING_OP_READV, fd, iov, count, offset, flags, userData, options);
public static extern void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
public static extern int lockf(int fd, int cmd, off_t len);
internal static extern int ftruncate(int fd, off_t length);
/// <summary> /// Attempts to add a write using a registered buffer/file to the Submission Queue without it being submitted. /// The actual submission can be deferred to avoid unnecessary memory barriers. /// </summary> /// <param name="fd">File descriptor to write to</param> /// <param name="buf">Buffers to write</param> /// <param name="count">Number of buffers</param> /// <param name="index"></param> /// <param name="offset">Offset in bytes into buffer (as per pwritev)</param> /// <param name="userData">User data that will be returned with the respective <see cref="Completion"/></param> /// <param name="options">Options for the handling of the prepared Submission Queue Entry</param> /// <returns><code>false</code> if the submission queue is full. <code>true</code> otherwise.</returns> public bool TryPrepareWrite(int fd, void *buf, size_t count, int index, off_t offset = default, ulong userData = 0, SubmissionOption options = SubmissionOption.None) => TryPrepareReadWriteFixed(IORING_OP_WRITE_FIXED, fd, buf, count, index, offset, userData, options);
public static extern off_t lseek(int fd, off_t offset, int whence);
private bool TryPrepareReadWriteFixed(byte op, int fd, void *buf, size_t count, int index, off_t offset, ulong userData, SubmissionOption options) { if (!NextSubmissionQueueEntry(out var sqe)) { return(false); } unchecked { sqe->opcode = op; sqe->user_data = userData; sqe->flags = (byte)options; sqe->fd = fd; sqe->addr = (ulong)buf; sqe->len = (uint)count; sqe->off = (ulong)(long)offset; sqe->buf_index = (ushort)index; } return(true); }