Exemplo n.º 1
0
        /// <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;
            }
        }
Exemplo n.º 2
0
        /// <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;
            }
        }
Exemplo n.º 3
0
        // 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;
            }
        }
Exemplo n.º 4
0
        /// <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;
            }
        }
Exemplo n.º 5
0
        /// <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;
            }
        }
Exemplo n.º 6
0
        /// <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;
            }
        }
Exemplo n.º 7
0
        /// <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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
 public static extern int truncate(byte *path, off_t length);
Exemplo n.º 10
0
 public static extern int ftruncate(int fd, off_t length);
Exemplo n.º 11
0
 public static extern int posix_fadvise(int fd, off_t offset, off_t length, int advice);
Exemplo n.º 12
0
 public static extern ssize_t pwrite(int fd, void *buf, size_t count, off_t offset);
Exemplo n.º 13
0
 public static extern int fallocate(int fd, int mode, off_t offset, off_t length);
Exemplo n.º 14
0
 public static extern int posix_fallocate(int fd, off_t offset, off_t length);
Exemplo n.º 15
0
 public static extern ssize_t readahead(int fd, off_t pos, size_t len);
Exemplo n.º 16
0
 public static extern int sync_file_range(int fd, off_t pos, off_t len, uint flags);
Exemplo n.º 17
0
 /// <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);
Exemplo n.º 18
0
 public static extern void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
Exemplo n.º 19
0
 public static extern int lockf(int fd, int cmd, off_t len);
Exemplo n.º 20
0
 internal static extern int ftruncate(int fd, off_t length);
Exemplo n.º 21
0
 /// <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);
Exemplo n.º 22
0
 public static extern off_t lseek(int fd, off_t offset, int whence);
Exemplo n.º 23
0
        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);
        }