1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// This file is part of linux-support. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/linux-support/master/COPYRIGHT. No part of linux-support, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
// Copyright © 2020 The developers of linux-support. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/linux-support/master/COPYRIGHT.
/// Submission Queue Entry (SQE): IO submission data structure.
#[repr(C)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub(super) struct io_uring_sqe
{
/// Type of operation for this SQE.
pub(super) opcode: IORING_OP,
/// `IOSQE_*` flags.
pub(super) flags: SubmissionQueueEntryFlags,
/// Specifies specifies the I/O priority.
///
/// See `man 2 ioprio_get()` for a description of Linux I/O priorities.
pub(super) ioprio: CompressedIoPriority,
/// Either:-
/// * Index of file descriptor in file descriptors array to do io_uring operation (ie flags contains `SubmissionQueueEntryFlags::FixedFile` is specified).
///
/// Or:-
/// * An actual `RawFd` file descriptor.
///
/// Exceptions when it is only ever a raw fd:-
///
/// * `IORING_OP_CLOSE`,
/// * `IORING_OP_OPENAT`,
/// * `IORING_OP_OPENAT2`,
/// * `IORING_OP_STATX`,
pub(super) fd: FileDescriptorKind,
pub(super) anonymous_1: io_uring_sqe_anonymous_1,
pub(super) anonymous_2: io_uring_sqe_anonymous_2,
/// buffer size or number of iovecs.
pub(super) len: u32,
pub(super) anonymous_3: io_uring_sqe_anonymous_3,
/// This is an application-supplied value that will be copied into the `CompletionQueueEntry` verbatim.
pub(super) user_data: u64,
pub(super) anonymous_4: io_uring_sqe_anonymous_4,
}
impl io_uring_sqe
{
#[inline(always)]
pub(super) fn prepare(&mut self, ioring_operation: IORING_OP, file_descriptor: FileDescriptorKind, address: u64, length: u32, offset: u64, flags: SubmissionQueueEntryFlags, personality: Option<PersonalityCredentialsIdentifier>, io_priority: CompressedIoPriority, user_data: impl UserData)
{
self.opcode = ioring_operation;
self.flags = flags;
self.ioprio = io_priority;
self.fd = file_descriptor;
self.anonymous_1.off = offset;
self.anonymous_2.addr = address;
self.len = length;
self.user_data = user_data.into_u64();
self.anonymous_4.anonymous_1.personality = personality;
self.anonymous_4.__pad2 = unsafe_zeroed()
}
}