1#![allow(clippy::new_without_default)]
4
5use std::convert::TryInto;
6use std::mem;
7use std::os::unix::io::RawFd;
8
9use crate::squeue::Entry;
10use crate::squeue::Entry128;
11use crate::sys;
12use crate::types::{self, sealed};
13
14macro_rules! assign_fd {
15 ( $sqe:ident . fd = $opfd:expr ) => {
16 match $opfd {
17 sealed::Target::Fd(fd) => $sqe.fd = fd,
18 sealed::Target::Fixed(idx) => {
19 $sqe.fd = idx as _;
20 $sqe.flags |= crate::squeue::Flags::FIXED_FILE.bits();
21 }
22 }
23 };
24}
25
26macro_rules! opcode {
27 (@type impl sealed::UseFixed ) => {
28 sealed::Target
29 };
30 (@type impl sealed::UseFd ) => {
31 RawFd
32 };
33 (@type $name:ty ) => {
34 $name
35 };
36 (
37 $( #[$outer:meta] )*
38 pub struct $name:ident {
39 $( #[$new_meta:meta] )*
40
41 $( $field:ident : { $( $tnt:tt )+ } ),*
42
43 $(,)?
44
45 ;;
46
47 $(
48 $( #[$opt_meta:meta] )*
49 $opt_field:ident : $opt_tname:ty = $default:expr
50 ),*
51
52 $(,)?
53 }
54
55 pub const CODE = $opcode:expr;
56
57 $( #[$build_meta:meta] )*
58 pub fn build($self:ident) -> $entry:ty $build_block:block
59 ) => {
60 $( #[$outer] )*
61 pub struct $name {
62 $( $field : opcode!(@type $( $tnt )*), )*
63 $( $opt_field : $opt_tname, )*
64 }
65
66 impl $name {
67 $( #[$new_meta] )*
68 #[inline]
69 pub fn new($( $field : $( $tnt )* ),*) -> Self {
70 $name {
71 $( $field: $field.into(), )*
72 $( $opt_field: $default, )*
73 }
74 }
75
76 pub const CODE: u8 = $opcode as _;
80
81 $(
82 $( #[$opt_meta] )*
83 #[inline]
84 pub const fn $opt_field(mut self, $opt_field: $opt_tname) -> Self {
85 self.$opt_field = $opt_field;
86 self
87 }
88 )*
89
90 $( #[$build_meta] )*
91 #[inline]
92 pub fn build($self) -> $entry $build_block
93 }
94 }
95}
96
97#[inline(always)]
99fn sqe_zeroed() -> sys::io_uring_sqe {
100 unsafe { mem::zeroed() }
101}
102
103opcode! {
104 #[derive(Debug)]
108 pub struct Nop { ;; }
109
110 pub const CODE = sys::IORING_OP_NOP;
111
112 pub fn build(self) -> Entry {
113 let Nop {} = self;
114
115 let mut sqe = sqe_zeroed();
116 sqe.opcode = Self::CODE;
117 sqe.fd = -1;
118 Entry(sqe)
119 }
120}
121
122opcode! {
123 #[derive(Debug)]
125 pub struct Readv {
126 fd: { impl sealed::UseFixed },
127 iovec: { *const libc::iovec },
128 len: { u32 },
129 ;;
130 ioprio: u16 = 0,
131 offset: u64 = 0,
132 rw_flags: i32 = 0,
135 buf_group: u16 = 0
136 }
137
138 pub const CODE = sys::IORING_OP_READV;
139
140 pub fn build(self) -> Entry {
141 let Readv {
142 fd,
143 iovec, len, offset,
144 ioprio, rw_flags,
145 buf_group
146 } = self;
147
148 let mut sqe = sqe_zeroed();
149 sqe.opcode = Self::CODE;
150 assign_fd!(sqe.fd = fd);
151 sqe.ioprio = ioprio;
152 sqe.__bindgen_anon_2.addr = iovec as _;
153 sqe.len = len;
154 sqe.__bindgen_anon_1.off = offset;
155 sqe.__bindgen_anon_3.rw_flags = rw_flags as _;
156 sqe.__bindgen_anon_4.buf_group = buf_group;
157 Entry(sqe)
158 }
159}
160
161opcode! {
162 #[derive(Debug)]
164 pub struct Writev {
165 fd: { impl sealed::UseFixed },
166 iovec: { *const libc::iovec },
167 len: { u32 },
168 ;;
169 ioprio: u16 = 0,
170 offset: u64 = 0,
171 rw_flags: i32 = 0,
174 write_stream: u8 = 0
177 }
178
179 pub const CODE = sys::IORING_OP_WRITEV;
180
181 pub fn build(self) -> Entry {
182 let Writev {
183 fd,
184 iovec, len, offset,
185 ioprio, rw_flags,
186 write_stream
187 } = self;
188
189 let mut sqe = sqe_zeroed();
190 sqe.opcode = Self::CODE;
191 assign_fd!(sqe.fd = fd);
192 sqe.ioprio = ioprio;
193 sqe.__bindgen_anon_2.addr = iovec as _;
194 sqe.len = len;
195 sqe.__bindgen_anon_1.off = offset;
196 sqe.__bindgen_anon_3.rw_flags = rw_flags as _;
197 sqe.__bindgen_anon_5.__bindgen_anon_2.write_stream = write_stream;
198 Entry(sqe)
199 }
200}
201
202opcode! {
203 #[derive(Debug)]
218 pub struct Fsync {
219 fd: { impl sealed::UseFixed },
220 ;;
221 offset: u64 = 0,
224 len: u32 = 0,
227 flags: types::FsyncFlags = types::FsyncFlags::empty()
231 }
232
233 pub const CODE = sys::IORING_OP_FSYNC;
234
235 pub fn build(self) -> Entry {
236 let Fsync {
237 fd,
238 offset,
239 len,
240 flags,
241 } = self;
242
243 let mut sqe = sqe_zeroed();
244 sqe.opcode = Self::CODE;
245 assign_fd!(sqe.fd = fd);
246 sqe.len = len;
247 sqe.__bindgen_anon_1.off = offset;
248 sqe.__bindgen_anon_3.fsync_flags = flags.bits();
249 Entry(sqe)
250 }
251}
252
253opcode! {
254 #[derive(Debug)]
259 pub struct ReadFixed {
260 fd: { impl sealed::UseFixed },
261 buf: { *mut u8 },
262 len: { u32 },
263 buf_index: { u16 },
264 ;;
265 ioprio: u16 = 0,
266 offset: u64 = 0,
268 rw_flags: i32 = 0
271 }
272
273 pub const CODE = sys::IORING_OP_READ_FIXED;
274
275 pub fn build(self) -> Entry {
276 let ReadFixed {
277 fd,
278 buf, len, offset,
279 buf_index,
280 ioprio, rw_flags
281 } = self;
282
283 let mut sqe = sqe_zeroed();
284 sqe.opcode = Self::CODE;
285 assign_fd!(sqe.fd = fd);
286 sqe.ioprio = ioprio;
287 sqe.__bindgen_anon_2.addr = buf as _;
288 sqe.len = len;
289 sqe.__bindgen_anon_1.off = offset;
290 sqe.__bindgen_anon_3.rw_flags = rw_flags as _;
291 sqe.__bindgen_anon_4.buf_index = buf_index;
292 Entry(sqe)
293 }
294}
295
296opcode! {
297 #[derive(Debug)]
302 pub struct WriteFixed {
303 fd: { impl sealed::UseFixed },
304 buf: { *const u8 },
305 len: { u32 },
306 buf_index: { u16 },
307 ;;
308 ioprio: u16 = 0,
309 offset: u64 = 0,
311 rw_flags: i32 = 0,
314 write_stream: u8 = 0
317 }
318
319 pub const CODE = sys::IORING_OP_WRITE_FIXED;
320
321 pub fn build(self) -> Entry {
322 let WriteFixed {
323 fd,
324 buf, len, offset,
325 buf_index,
326 ioprio, rw_flags,
327 write_stream
328 } = self;
329
330 let mut sqe = sqe_zeroed();
331 sqe.opcode = Self::CODE;
332 assign_fd!(sqe.fd = fd);
333 sqe.ioprio = ioprio;
334 sqe.__bindgen_anon_2.addr = buf as _;
335 sqe.len = len;
336 sqe.__bindgen_anon_1.off = offset;
337 sqe.__bindgen_anon_3.rw_flags = rw_flags as _;
338 sqe.__bindgen_anon_5.__bindgen_anon_2.write_stream = write_stream;
339 sqe.__bindgen_anon_4.buf_index = buf_index;
340 Entry(sqe)
341 }
342}
343
344opcode! {
345 #[derive(Debug)]
357 pub struct PollAdd {
358 fd: { impl sealed::UseFixed },
361 flags: { u32 },
362 ;;
363 multi: bool = false
364 }
365
366 pub const CODE = sys::IORING_OP_POLL_ADD;
367
368 pub fn build(self) -> Entry {
369 let PollAdd { fd, flags, multi } = self;
370
371 let mut sqe = sqe_zeroed();
372 sqe.opcode = Self::CODE;
373 assign_fd!(sqe.fd = fd);
374 if multi {
375 sqe.len = sys::IORING_POLL_ADD_MULTI;
376 }
377
378 #[cfg(target_endian = "little")] {
379 sqe.__bindgen_anon_3.poll32_events = flags;
380 }
381
382 #[cfg(target_endian = "big")] {
383 let x = flags << 16;
384 let y = flags >> 16;
385 let flags = x | y;
386 sqe.__bindgen_anon_3.poll32_events = flags;
387 }
388
389 Entry(sqe)
390 }
391}
392
393opcode! {
394 #[derive(Debug)]
399 pub struct PollRemove {
400 user_data: { u64 }
401 ;;
402 }
403
404 pub const CODE = sys::IORING_OP_POLL_REMOVE;
405
406 pub fn build(self) -> Entry {
407 let PollRemove { user_data } = self;
408
409 let mut sqe = sqe_zeroed();
410 sqe.opcode = Self::CODE;
411 sqe.fd = -1;
412 sqe.__bindgen_anon_2.addr = user_data;
413 Entry(sqe)
414 }
415}
416
417opcode! {
418 #[derive(Debug)]
420 pub struct SyncFileRange {
421 fd: { impl sealed::UseFixed },
422 len: { u32 },
423 ;;
424 offset: u64 = 0,
426 flags: u32 = 0
428 }
429
430 pub const CODE = sys::IORING_OP_SYNC_FILE_RANGE;
431
432 pub fn build(self) -> Entry {
433 let SyncFileRange {
434 fd,
435 len, offset,
436 flags
437 } = self;
438
439 let mut sqe = sqe_zeroed();
440 sqe.opcode = Self::CODE;
441 assign_fd!(sqe.fd = fd);
442 sqe.len = len;
443 sqe.__bindgen_anon_1.off = offset;
444 sqe.__bindgen_anon_3.sync_range_flags = flags;
445 Entry(sqe)
446 }
447}
448
449opcode! {
450 #[derive(Debug)]
455 pub struct SendMsg {
456 fd: { impl sealed::UseFixed },
457 msg: { *const libc::msghdr },
458 ;;
459 ioprio: u16 = 0,
460 flags: u32 = 0
461 }
462
463 pub const CODE = sys::IORING_OP_SENDMSG;
464
465 pub fn build(self) -> Entry {
466 let SendMsg { fd, msg, ioprio, flags } = self;
467
468 let mut sqe = sqe_zeroed();
469 sqe.opcode = Self::CODE;
470 assign_fd!(sqe.fd = fd);
471 sqe.ioprio = ioprio;
472 sqe.__bindgen_anon_2.addr = msg as _;
473 sqe.len = 1;
474 sqe.__bindgen_anon_3.msg_flags = flags;
475 Entry(sqe)
476 }
477}
478
479opcode! {
480 #[derive(Debug)]
484 pub struct RecvMsg {
485 fd: { impl sealed::UseFixed },
486 msg: { *mut libc::msghdr },
487 ;;
488 ioprio: u16 = 0,
489 flags: u32 = 0,
490 buf_group: u16 = 0
491 }
492
493 pub const CODE = sys::IORING_OP_RECVMSG;
494
495 pub fn build(self) -> Entry {
496 let RecvMsg { fd, msg, ioprio, flags, buf_group } = self;
497
498 let mut sqe = sqe_zeroed();
499 sqe.opcode = Self::CODE;
500 assign_fd!(sqe.fd = fd);
501 sqe.ioprio = ioprio;
502 sqe.__bindgen_anon_2.addr = msg as _;
503 sqe.len = 1;
504 sqe.__bindgen_anon_3.msg_flags = flags;
505 sqe.__bindgen_anon_4.buf_group = buf_group;
506 Entry(sqe)
507 }
508}
509
510opcode! {
511 #[derive(Debug)]
534 pub struct RecvMsgMulti {
535 fd: { impl sealed::UseFixed },
536 msg: { *const libc::msghdr },
537 buf_group: { u16 },
538 ;;
539 ioprio: u16 = 0,
540 flags: u32 = 0
541 }
542
543 pub const CODE = sys::IORING_OP_RECVMSG;
544
545 pub fn build(self) -> Entry {
546 let RecvMsgMulti { fd, msg, buf_group, ioprio, flags } = self;
547
548 let mut sqe = sqe_zeroed();
549 sqe.opcode = Self::CODE;
550 assign_fd!(sqe.fd = fd);
551 sqe.__bindgen_anon_2.addr = msg as _;
552 sqe.len = 1;
553 sqe.__bindgen_anon_3.msg_flags = flags;
554 sqe.__bindgen_anon_4.buf_group = buf_group;
555 sqe.flags |= crate::squeue::Flags::BUFFER_SELECT.bits();
556 sqe.ioprio = ioprio | (sys::IORING_RECV_MULTISHOT as u16);
557 Entry(sqe)
558 }
559}
560
561opcode! {
562 #[derive(Debug)]
571 pub struct Timeout {
572 timespec: { *const types::Timespec },
573 ;;
574 count: u32 = 0,
578
579 flags: types::TimeoutFlags = types::TimeoutFlags::empty()
580 }
581
582 pub const CODE = sys::IORING_OP_TIMEOUT;
583
584 pub fn build(self) -> Entry {
585 let Timeout { timespec, count, flags } = self;
586
587 let mut sqe = sqe_zeroed();
588 sqe.opcode = Self::CODE;
589 sqe.fd = -1;
590 sqe.__bindgen_anon_2.addr = timespec as _;
591 sqe.len = 1;
592 sqe.__bindgen_anon_1.off = count as _;
593 sqe.__bindgen_anon_3.timeout_flags = flags.bits();
594 Entry(sqe)
595 }
596}
597
598opcode! {
601 pub struct TimeoutRemove {
603 user_data: { u64 },
604 ;;
605 }
606
607 pub const CODE = sys::IORING_OP_TIMEOUT_REMOVE;
608
609 pub fn build(self) -> Entry {
610 let TimeoutRemove { user_data } = self;
611
612 let mut sqe = sqe_zeroed();
613 sqe.opcode = Self::CODE;
614 sqe.fd = -1;
615 sqe.__bindgen_anon_2.addr = user_data;
616 Entry(sqe)
617 }
618}
619
620opcode! {
621 pub struct TimeoutUpdate {
624 user_data: { u64 },
625 timespec: { *const types::Timespec },
626 ;;
627 flags: types::TimeoutFlags = types::TimeoutFlags::empty()
628 }
629
630 pub const CODE = sys::IORING_OP_TIMEOUT_REMOVE;
631
632 pub fn build(self) -> Entry {
633 let TimeoutUpdate { user_data, timespec, flags } = self;
634
635 let mut sqe = sqe_zeroed();
636 sqe.opcode = Self::CODE;
637 sqe.fd = -1;
638 sqe.__bindgen_anon_1.off = timespec as _;
639 sqe.__bindgen_anon_2.addr = user_data;
640 sqe.__bindgen_anon_3.timeout_flags = flags.bits() | sys::IORING_TIMEOUT_UPDATE;
641 Entry(sqe)
642 }
643}
644
645opcode! {
646 pub struct Accept {
648 fd: { impl sealed::UseFixed },
649 addr: { *mut libc::sockaddr },
650 addrlen: { *mut libc::socklen_t },
651 ;;
652 file_index: Option<types::DestinationSlot> = None,
653 flags: i32 = 0
654 }
655
656 pub const CODE = sys::IORING_OP_ACCEPT;
657
658 pub fn build(self) -> Entry {
659 let Accept { fd, addr, addrlen, file_index, flags } = self;
660
661 let mut sqe = sqe_zeroed();
662 sqe.opcode = Self::CODE;
663 assign_fd!(sqe.fd = fd);
664 sqe.__bindgen_anon_2.addr = addr as _;
665 sqe.__bindgen_anon_1.addr2 = addrlen as _;
666 sqe.__bindgen_anon_3.accept_flags = flags as _;
667 if let Some(dest) = file_index {
668 sqe.__bindgen_anon_5.file_index = dest.kernel_index_arg();
669 }
670 Entry(sqe)
671 }
672}
673
674opcode! {
675 pub struct SetSockOpt {
677 fd: { impl sealed::UseFixed },
678 level: { u32 },
679 optname: { u32 },
680 optval: { *const libc::c_void },
681 optlen: { u32 },
682 ;;
683 flags: u32 = 0
684 }
685
686 pub const CODE = sys::IORING_OP_URING_CMD;
687
688 pub fn build(self) -> Entry {
689 let SetSockOpt { fd, level, optname, optval, optlen, flags } = self;
690 let mut sqe = sqe_zeroed();
691 sqe.opcode = Self::CODE;
692 assign_fd!(sqe.fd = fd);
693 sqe.__bindgen_anon_1.__bindgen_anon_1.cmd_op = sys::SOCKET_URING_OP_SETSOCKOPT;
694
695 sqe.__bindgen_anon_2.__bindgen_anon_1.level = level;
696 sqe.__bindgen_anon_2.__bindgen_anon_1.optname = optname;
697 sqe.__bindgen_anon_3.uring_cmd_flags = flags;
698 sqe.__bindgen_anon_5.optlen = optlen;
699 unsafe { *sqe.__bindgen_anon_6.optval.as_mut() = optval as u64 };
700 Entry(sqe)
701 }
702}
703
704opcode! {
705 pub struct GetSockOpt {
711 fd: { impl sealed::UseFixed },
712 level: { u32 },
713 optname: { u32 },
714 optval: { *mut libc::c_void },
715 optlen: { u32 },
716 ;;
717 flags: u32 = 0
718 }
719
720 pub const CODE = sys::IORING_OP_URING_CMD;
721
722 pub fn build(self) -> Entry {
723 let GetSockOpt { fd, level, optname, optval, optlen, flags } = self;
724 let mut sqe = sqe_zeroed();
725 sqe.opcode = Self::CODE;
726 assign_fd!(sqe.fd = fd);
727 sqe.__bindgen_anon_1.__bindgen_anon_1.cmd_op = sys::SOCKET_URING_OP_GETSOCKOPT;
728
729 sqe.__bindgen_anon_2.__bindgen_anon_1.level = level;
730 sqe.__bindgen_anon_2.__bindgen_anon_1.optname = optname;
731 sqe.__bindgen_anon_3.uring_cmd_flags = flags;
732 sqe.__bindgen_anon_5.optlen = optlen;
733 unsafe { *sqe.__bindgen_anon_6.optval.as_mut() = optval as u64 };
734 Entry(sqe)
735 }
736}
737
738opcode! {
739 pub struct AsyncCancel {
741 user_data: { u64 }
742 ;;
743
744 }
746
747 pub const CODE = sys::IORING_OP_ASYNC_CANCEL;
748
749 pub fn build(self) -> Entry {
750 let AsyncCancel { user_data } = self;
751
752 let mut sqe = sqe_zeroed();
753 sqe.opcode = Self::CODE;
754 sqe.fd = -1;
755 sqe.__bindgen_anon_2.addr = user_data;
756 Entry(sqe)
757 }
758}
759
760opcode! {
761 pub struct LinkTimeout {
765 timespec: { *const types::Timespec },
766 ;;
767 flags: types::TimeoutFlags = types::TimeoutFlags::empty()
768 }
769
770 pub const CODE = sys::IORING_OP_LINK_TIMEOUT;
771
772 pub fn build(self) -> Entry {
773 let LinkTimeout { timespec, flags } = self;
774
775 let mut sqe = sqe_zeroed();
776 sqe.opcode = Self::CODE;
777 sqe.fd = -1;
778 sqe.__bindgen_anon_2.addr = timespec as _;
779 sqe.len = 1;
780 sqe.__bindgen_anon_3.timeout_flags = flags.bits();
781 Entry(sqe)
782 }
783}
784
785opcode! {
786 pub struct Connect {
788 fd: { impl sealed::UseFixed },
789 addr: { *const libc::sockaddr },
790 addrlen: { libc::socklen_t }
791 ;;
792 }
793
794 pub const CODE = sys::IORING_OP_CONNECT;
795
796 pub fn build(self) -> Entry {
797 let Connect { fd, addr, addrlen } = self;
798
799 let mut sqe = sqe_zeroed();
800 sqe.opcode = Self::CODE;
801 assign_fd!(sqe.fd = fd);
802 sqe.__bindgen_anon_2.addr = addr as _;
803 sqe.__bindgen_anon_1.off = addrlen as _;
804 Entry(sqe)
805 }
806}
807
808opcode! {
811 pub struct Fallocate {
813 fd: { impl sealed::UseFixed },
814 len: { u64 },
815 ;;
816 offset: u64 = 0,
817 mode: i32 = 0
818 }
819
820 pub const CODE = sys::IORING_OP_FALLOCATE;
821
822 pub fn build(self) -> Entry {
823 let Fallocate { fd, len, offset, mode } = self;
824
825 let mut sqe = sqe_zeroed();
826 sqe.opcode = Self::CODE;
827 assign_fd!(sqe.fd = fd);
828 sqe.__bindgen_anon_2.addr = len;
829 sqe.len = mode as _;
830 sqe.__bindgen_anon_1.off = offset;
831 Entry(sqe)
832 }
833}
834
835opcode! {
836 pub struct OpenAt {
838 dirfd: { impl sealed::UseFd },
839 pathname: { *const libc::c_char },
840 ;;
841 file_index: Option<types::DestinationSlot> = None,
842 flags: i32 = 0,
843 mode: libc::mode_t = 0
844 }
845
846 pub const CODE = sys::IORING_OP_OPENAT;
847
848 pub fn build(self) -> Entry {
849 let OpenAt { dirfd, pathname, file_index, flags, mode } = self;
850
851 let mut sqe = sqe_zeroed();
852 sqe.opcode = Self::CODE;
853 sqe.fd = dirfd;
854 sqe.__bindgen_anon_2.addr = pathname as _;
855 sqe.len = mode;
856 sqe.__bindgen_anon_3.open_flags = flags as _;
857 if let Some(dest) = file_index {
858 sqe.__bindgen_anon_5.file_index = dest.kernel_index_arg();
859 }
860 Entry(sqe)
861 }
862}
863
864opcode! {
865 pub struct Close {
869 fd: { impl sealed::UseFixed },
870 ;;
871 }
872
873 pub const CODE = sys::IORING_OP_CLOSE;
874
875 pub fn build(self) -> Entry {
876 let Close { fd } = self;
877
878 let mut sqe = sqe_zeroed();
879 sqe.opcode = Self::CODE;
880 match fd {
881 sealed::Target::Fd(fd) => sqe.fd = fd,
882 sealed::Target::Fixed(idx) => {
883 sqe.fd = 0;
884 sqe.__bindgen_anon_5.file_index = idx + 1;
885 }
886 }
887 Entry(sqe)
888 }
889}
890
891opcode! {
892 pub struct FilesUpdate {
896 fds: { *const RawFd },
897 len: { u32 },
898 ;;
899 offset: i32 = 0
900 }
901
902 pub const CODE = sys::IORING_OP_FILES_UPDATE;
903
904 pub fn build(self) -> Entry {
905 let FilesUpdate { fds, len, offset } = self;
906
907 let mut sqe = sqe_zeroed();
908 sqe.opcode = Self::CODE;
909 sqe.fd = -1;
910 sqe.__bindgen_anon_2.addr = fds as _;
911 sqe.len = len;
912 sqe.__bindgen_anon_1.off = offset as _;
913 Entry(sqe)
914 }
915}
916
917opcode! {
918 pub struct Statx {
920 dirfd: { impl sealed::UseFd },
921 pathname: { *const libc::c_char },
922 statxbuf: { *mut types::statx },
923 ;;
924 flags: i32 = 0,
925 mask: u32 = 0
926 }
927
928 pub const CODE = sys::IORING_OP_STATX;
929
930 pub fn build(self) -> Entry {
931 let Statx {
932 dirfd, pathname, statxbuf,
933 flags, mask
934 } = self;
935
936 let mut sqe = sqe_zeroed();
937 sqe.opcode = Self::CODE;
938 sqe.fd = dirfd;
939 sqe.__bindgen_anon_2.addr = pathname as _;
940 sqe.len = mask;
941 sqe.__bindgen_anon_1.off = statxbuf as _;
942 sqe.__bindgen_anon_3.statx_flags = flags as _;
943 Entry(sqe)
944 }
945}
946
947opcode! {
948 pub struct Read {
959 fd: { impl sealed::UseFixed },
960 buf: { *mut u8 },
961 len: { u32 },
962 ;;
963 offset: u64 = 0,
969 ioprio: u16 = 0,
970 rw_flags: i32 = 0,
971 buf_group: u16 = 0
972 }
973
974 pub const CODE = sys::IORING_OP_READ;
975
976 pub fn build(self) -> Entry {
977 let Read {
978 fd,
979 buf, len, offset,
980 ioprio, rw_flags,
981 buf_group
982 } = self;
983
984 let mut sqe = sqe_zeroed();
985 sqe.opcode = Self::CODE;
986 assign_fd!(sqe.fd = fd);
987 sqe.ioprio = ioprio;
988 sqe.__bindgen_anon_2.addr = buf as _;
989 sqe.len = len;
990 sqe.__bindgen_anon_1.off = offset;
991 sqe.__bindgen_anon_3.rw_flags = rw_flags as _;
992 sqe.__bindgen_anon_4.buf_group = buf_group;
993 Entry(sqe)
994 }
995}
996
997opcode! {
998 pub struct Write {
1009 fd: { impl sealed::UseFixed },
1010 buf: { *const u8 },
1011 len: { u32 },
1012 ;;
1013 offset: u64 = 0,
1019 ioprio: u16 = 0,
1020 rw_flags: i32 = 0,
1021 write_stream: u8 = 0
1025 }
1026
1027 pub const CODE = sys::IORING_OP_WRITE;
1028
1029 pub fn build(self) -> Entry {
1030 let Write {
1031 fd,
1032 buf, len, offset,
1033 ioprio, rw_flags,
1034 write_stream
1035 } = self;
1036
1037 let mut sqe = sqe_zeroed();
1038 sqe.opcode = Self::CODE;
1039 assign_fd!(sqe.fd = fd);
1040 sqe.ioprio = ioprio;
1041 sqe.__bindgen_anon_2.addr = buf as _;
1042 sqe.len = len;
1043 sqe.__bindgen_anon_1.off = offset;
1044 sqe.__bindgen_anon_3.rw_flags = rw_flags as _;
1045 sqe.__bindgen_anon_5.__bindgen_anon_2.write_stream = write_stream;
1046 Entry(sqe)
1047 }
1048}
1049
1050opcode! {
1051 pub struct Fadvise {
1053 fd: { impl sealed::UseFixed },
1054 len: { libc::off_t },
1055 advice: { i32 },
1056 ;;
1057 offset: u64 = 0,
1058 }
1059
1060 pub const CODE = sys::IORING_OP_FADVISE;
1061
1062 pub fn build(self) -> Entry {
1063 let Fadvise { fd, len, advice, offset } = self;
1064
1065 let mut sqe = sqe_zeroed();
1066 sqe.opcode = Self::CODE;
1067 assign_fd!(sqe.fd = fd);
1068 sqe.len = len as _;
1069 sqe.__bindgen_anon_1.off = offset;
1070 sqe.__bindgen_anon_3.fadvise_advice = advice as _;
1071 Entry(sqe)
1072 }
1073}
1074
1075opcode! {
1076 pub struct Madvise {
1078 addr: { *const libc::c_void },
1079 len: { libc::off_t },
1080 advice: { i32 },
1081 ;;
1082 }
1083
1084 pub const CODE = sys::IORING_OP_MADVISE;
1085
1086 pub fn build(self) -> Entry {
1087 let Madvise { addr, len, advice } = self;
1088
1089 let mut sqe = sqe_zeroed();
1090 sqe.opcode = Self::CODE;
1091 sqe.fd = -1;
1092 sqe.__bindgen_anon_2.addr = addr as _;
1093 sqe.len = len as _;
1094 sqe.__bindgen_anon_3.fadvise_advice = advice as _;
1095 Entry(sqe)
1096 }
1097}
1098
1099opcode! {
1100 pub struct Send {
1102 fd: { impl sealed::UseFixed },
1103 buf: { *const u8 },
1104 len: { u32 },
1105 ;;
1106 ioprio: u16 = 0,
1107 flags: i32 = 0,
1108 buf_group: u16 = 0,
1109
1110 dest_addr: *const libc::sockaddr = core::ptr::null(),
1115 dest_addr_len: libc::socklen_t = 0,
1116 }
1117
1118 pub const CODE = sys::IORING_OP_SEND;
1119
1120 pub fn build(self) -> Entry {
1121 let Send { fd, buf, len, ioprio, flags, buf_group, dest_addr, dest_addr_len } = self;
1122
1123 let mut sqe = sqe_zeroed();
1124 sqe.opcode = Self::CODE;
1125 assign_fd!(sqe.fd = fd);
1126 sqe.__bindgen_anon_2.addr = buf as _;
1127 sqe.__bindgen_anon_1.addr2 = dest_addr as _;
1128 sqe.__bindgen_anon_5.__bindgen_anon_1.addr_len = dest_addr_len as _;
1129 sqe.len = len;
1130 sqe.ioprio = ioprio;
1131 sqe.__bindgen_anon_3.msg_flags = flags as _;
1132 sqe.__bindgen_anon_4.buf_group = buf_group;
1133 Entry(sqe)
1134 }
1135}
1136
1137opcode! {
1138 pub struct Recv {
1140 fd: { impl sealed::UseFixed },
1141 buf: { *mut u8 },
1142 len: { u32 },
1143 ;;
1144 ioprio: u16 = 0,
1145 flags: i32 = 0,
1146 buf_group: u16 = 0
1147 }
1148
1149 pub const CODE = sys::IORING_OP_RECV;
1150
1151 pub fn build(self) -> Entry {
1152 let Recv { fd, buf, len, ioprio, flags, buf_group } = self;
1153
1154 let mut sqe = sqe_zeroed();
1155 sqe.opcode = Self::CODE;
1156 assign_fd!(sqe.fd = fd);
1157 sqe.__bindgen_anon_2.addr = buf as _;
1158 sqe.len = len;
1159 sqe.ioprio = ioprio;
1160 sqe.__bindgen_anon_3.msg_flags = flags as _;
1161 sqe.__bindgen_anon_4.buf_group = buf_group;
1162 Entry(sqe)
1163 }
1164}
1165
1166opcode! {
1167 pub struct RecvMulti {
1183 fd: { impl sealed::UseFixed },
1184 buf_group: { u16 },
1185 ;;
1186 flags: i32 = 0,
1187 len: u32 = 0,
1188 }
1189
1190 pub const CODE = sys::IORING_OP_RECV;
1191
1192 pub fn build(self) -> Entry {
1193 let RecvMulti { fd, buf_group, flags, len } = self;
1194
1195 let mut sqe = sqe_zeroed();
1196 sqe.opcode = Self::CODE;
1197 assign_fd!(sqe.fd = fd);
1198 sqe.len = len;
1199 sqe.__bindgen_anon_3.msg_flags = flags as _;
1200 sqe.__bindgen_anon_4.buf_group = buf_group;
1201 sqe.flags |= crate::squeue::Flags::BUFFER_SELECT.bits();
1202 sqe.ioprio = sys::IORING_RECV_MULTISHOT as _;
1203 Entry(sqe)
1204 }
1205}
1206
1207opcode! {
1208 pub struct OpenAt2 {
1210 dirfd: { impl sealed::UseFd },
1211 pathname: { *const libc::c_char },
1212 how: { *const types::OpenHow }
1213 ;;
1214 file_index: Option<types::DestinationSlot> = None,
1215 }
1216
1217 pub const CODE = sys::IORING_OP_OPENAT2;
1218
1219 pub fn build(self) -> Entry {
1220 let OpenAt2 { dirfd, pathname, how, file_index } = self;
1221
1222 let mut sqe = sqe_zeroed();
1223 sqe.opcode = Self::CODE;
1224 sqe.fd = dirfd;
1225 sqe.__bindgen_anon_2.addr = pathname as _;
1226 sqe.len = mem::size_of::<sys::open_how>() as _;
1227 sqe.__bindgen_anon_1.off = how as _;
1228 if let Some(dest) = file_index {
1229 sqe.__bindgen_anon_5.file_index = dest.kernel_index_arg();
1230 }
1231 Entry(sqe)
1232 }
1233}
1234
1235opcode! {
1236 pub struct EpollCtl {
1238 epfd: { impl sealed::UseFixed },
1239 fd: { impl sealed::UseFd },
1240 op: { i32 },
1241 ev: { *const types::epoll_event },
1242 ;;
1243 }
1244
1245 pub const CODE = sys::IORING_OP_EPOLL_CTL;
1246
1247 pub fn build(self) -> Entry {
1248 let EpollCtl { epfd, fd, op, ev } = self;
1249
1250 let mut sqe = sqe_zeroed();
1251 sqe.opcode = Self::CODE;
1252 assign_fd!(sqe.fd = epfd);
1253 sqe.__bindgen_anon_2.addr = ev as _;
1254 sqe.len = op as _;
1255 sqe.__bindgen_anon_1.off = fd as _;
1256 Entry(sqe)
1257 }
1258}
1259
1260opcode! {
1263 pub struct Splice {
1268 fd_in: { impl sealed::UseFixed },
1269 off_in: { i64 },
1270 fd_out: { impl sealed::UseFixed },
1271 off_out: { i64 },
1272 len: { u32 },
1273 ;;
1274 flags: u32 = 0
1276 }
1277
1278 pub const CODE = sys::IORING_OP_SPLICE;
1279
1280 pub fn build(self) -> Entry {
1281 let Splice { fd_in, off_in, fd_out, off_out, len, mut flags } = self;
1282
1283 let mut sqe = sqe_zeroed();
1284 sqe.opcode = Self::CODE;
1285 assign_fd!(sqe.fd = fd_out);
1286 sqe.len = len;
1287 sqe.__bindgen_anon_1.off = off_out as _;
1288
1289 sqe.__bindgen_anon_5.splice_fd_in = match fd_in {
1290 sealed::Target::Fd(fd) => fd,
1291 sealed::Target::Fixed(idx) => {
1292 flags |= sys::SPLICE_F_FD_IN_FIXED;
1293 idx as _
1294 }
1295 };
1296
1297 sqe.__bindgen_anon_2.splice_off_in = off_in as _;
1298 sqe.__bindgen_anon_3.splice_flags = flags;
1299 Entry(sqe)
1300 }
1301}
1302
1303opcode! {
1304 pub struct ProvideBuffers {
1308 addr: { *mut u8 },
1309 len: { i32 },
1310 nbufs: { u16 },
1311 bgid: { u16 },
1312 bid: { u16 }
1313 ;;
1314 }
1315
1316 pub const CODE = sys::IORING_OP_PROVIDE_BUFFERS;
1317
1318 pub fn build(self) -> Entry {
1319 let ProvideBuffers { addr, len, nbufs, bgid, bid } = self;
1320
1321 let mut sqe = sqe_zeroed();
1322 sqe.opcode = Self::CODE;
1323 sqe.fd = nbufs as _;
1324 sqe.__bindgen_anon_2.addr = addr as _;
1325 sqe.len = len as _;
1326 sqe.__bindgen_anon_1.off = bid as _;
1327 sqe.__bindgen_anon_4.buf_group = bgid;
1328 Entry(sqe)
1329 }
1330}
1331
1332opcode! {
1333 pub struct RemoveBuffers {
1336 nbufs: { u16 },
1337 bgid: { u16 }
1338 ;;
1339 }
1340
1341 pub const CODE = sys::IORING_OP_REMOVE_BUFFERS;
1342
1343 pub fn build(self) -> Entry {
1344 let RemoveBuffers { nbufs, bgid } = self;
1345
1346 let mut sqe = sqe_zeroed();
1347 sqe.opcode = Self::CODE;
1348 sqe.fd = nbufs as _;
1349 sqe.__bindgen_anon_4.buf_group = bgid;
1350 Entry(sqe)
1351 }
1352}
1353
1354opcode! {
1357 pub struct Tee {
1359 fd_in: { impl sealed::UseFixed },
1360 fd_out: { impl sealed::UseFixed },
1361 len: { u32 }
1362 ;;
1363 flags: u32 = 0
1364 }
1365
1366 pub const CODE = sys::IORING_OP_TEE;
1367
1368 pub fn build(self) -> Entry {
1369 let Tee { fd_in, fd_out, len, mut flags } = self;
1370
1371 let mut sqe = sqe_zeroed();
1372 sqe.opcode = Self::CODE;
1373
1374 assign_fd!(sqe.fd = fd_out);
1375 sqe.len = len;
1376
1377 sqe.__bindgen_anon_5.splice_fd_in = match fd_in {
1378 sealed::Target::Fd(fd) => fd,
1379 sealed::Target::Fixed(idx) => {
1380 flags |= sys::SPLICE_F_FD_IN_FIXED;
1381 idx as _
1382 }
1383 };
1384
1385 sqe.__bindgen_anon_3.splice_flags = flags;
1386
1387 Entry(sqe)
1388 }
1389}
1390
1391opcode! {
1394 pub struct Shutdown {
1397 fd: { impl sealed::UseFixed },
1398 how: { i32 },
1399 ;;
1400 }
1401
1402 pub const CODE = sys::IORING_OP_SHUTDOWN;
1403
1404 pub fn build(self) -> Entry {
1405 let Shutdown { fd, how } = self;
1406
1407 let mut sqe = sqe_zeroed();
1408 sqe.opcode = Self::CODE;
1409 assign_fd!(sqe.fd = fd);
1410 sqe.len = how as _;
1411 Entry(sqe)
1412 }
1413}
1414
1415opcode! {
1416 pub struct RenameAt {
1419 olddirfd: { impl sealed::UseFd },
1420 oldpath: { *const libc::c_char },
1421 newdirfd: { impl sealed::UseFd },
1422 newpath: { *const libc::c_char },
1423 ;;
1424 flags: u32 = 0
1425 }
1426
1427 pub const CODE = sys::IORING_OP_RENAMEAT;
1428
1429 pub fn build(self) -> Entry {
1430 let RenameAt {
1431 olddirfd, oldpath,
1432 newdirfd, newpath,
1433 flags
1434 } = self;
1435
1436 let mut sqe = sqe_zeroed();
1437 sqe.opcode = Self::CODE;
1438 sqe.fd = olddirfd;
1439 sqe.__bindgen_anon_2.addr = oldpath as _;
1440 sqe.len = newdirfd as _;
1441 sqe.__bindgen_anon_1.off = newpath as _;
1442 sqe.__bindgen_anon_3.rename_flags = flags;
1443 Entry(sqe)
1444 }
1445}
1446
1447opcode! {
1448 pub struct UnlinkAt {
1451 dirfd: { impl sealed::UseFd },
1452 pathname: { *const libc::c_char },
1453 ;;
1454 flags: i32 = 0
1455 }
1456
1457 pub const CODE = sys::IORING_OP_UNLINKAT;
1458
1459 pub fn build(self) -> Entry {
1460 let UnlinkAt { dirfd, pathname, flags } = self;
1461
1462 let mut sqe = sqe_zeroed();
1463 sqe.opcode = Self::CODE;
1464 sqe.fd = dirfd;
1465 sqe.__bindgen_anon_2.addr = pathname as _;
1466 sqe.__bindgen_anon_3.unlink_flags = flags as _;
1467 Entry(sqe)
1468 }
1469}
1470
1471opcode! {
1474 pub struct MkDirAt {
1476 dirfd: { impl sealed::UseFd },
1477 pathname: { *const libc::c_char },
1478 ;;
1479 mode: libc::mode_t = 0
1480 }
1481
1482 pub const CODE = sys::IORING_OP_MKDIRAT;
1483
1484 pub fn build(self) -> Entry {
1485 let MkDirAt { dirfd, pathname, mode } = self;
1486
1487 let mut sqe = sqe_zeroed();
1488 sqe.opcode = Self::CODE;
1489 sqe.fd = dirfd;
1490 sqe.__bindgen_anon_2.addr = pathname as _;
1491 sqe.len = mode;
1492 Entry(sqe)
1493 }
1494}
1495
1496opcode! {
1497 pub struct SymlinkAt {
1499 newdirfd: { impl sealed::UseFd },
1500 target: { *const libc::c_char },
1501 linkpath: { *const libc::c_char },
1502 ;;
1503 }
1504
1505 pub const CODE = sys::IORING_OP_SYMLINKAT;
1506
1507 pub fn build(self) -> Entry {
1508 let SymlinkAt { newdirfd, target, linkpath } = self;
1509
1510 let mut sqe = sqe_zeroed();
1511 sqe.opcode = Self::CODE;
1512 sqe.fd = newdirfd;
1513 sqe.__bindgen_anon_2.addr = target as _;
1514 sqe.__bindgen_anon_1.addr2 = linkpath as _;
1515 Entry(sqe)
1516 }
1517}
1518
1519opcode! {
1520 pub struct LinkAt {
1522 olddirfd: { impl sealed::UseFd },
1523 oldpath: { *const libc::c_char },
1524 newdirfd: { impl sealed::UseFd },
1525 newpath: { *const libc::c_char },
1526 ;;
1527 flags: i32 = 0
1528 }
1529
1530 pub const CODE = sys::IORING_OP_LINKAT;
1531
1532 pub fn build(self) -> Entry {
1533 let LinkAt { olddirfd, oldpath, newdirfd, newpath, flags } = self;
1534
1535 let mut sqe = sqe_zeroed();
1536 sqe.opcode = Self::CODE;
1537 sqe.fd = olddirfd as _;
1538 sqe.__bindgen_anon_2.addr = oldpath as _;
1539 sqe.len = newdirfd as _;
1540 sqe.__bindgen_anon_1.addr2 = newpath as _;
1541 sqe.__bindgen_anon_3.hardlink_flags = flags as _;
1542 Entry(sqe)
1543 }
1544}
1545
1546opcode! {
1549 pub struct GetXattr {
1551 name: { *const libc::c_char },
1552 value: { *mut libc::c_void },
1553 path: { *const libc::c_char },
1554 len: { u32 },
1555 ;;
1556 }
1557
1558 pub const CODE = sys::IORING_OP_GETXATTR;
1559
1560 pub fn build(self) -> Entry {
1561 let GetXattr { name, value, path, len } = self;
1562
1563 let mut sqe = sqe_zeroed();
1564 sqe.opcode = Self::CODE;
1565 sqe.__bindgen_anon_2.addr = name as _;
1566 sqe.len = len;
1567 sqe.__bindgen_anon_1.off = value as _;
1568 unsafe { sqe.__bindgen_anon_6.__bindgen_anon_1.as_mut().addr3 = path as _ };
1569 sqe.__bindgen_anon_3.xattr_flags = 0;
1570 Entry(sqe)
1571 }
1572}
1573
1574opcode! {
1575 pub struct SetXattr {
1577 name: { *const libc::c_char },
1578 value: { *const libc::c_void },
1579 path: { *const libc::c_char },
1580 len: { u32 },
1581 ;;
1582 flags: i32 = 0
1583 }
1584
1585 pub const CODE = sys::IORING_OP_SETXATTR;
1586
1587 pub fn build(self) -> Entry {
1588 let SetXattr { name, value, path, flags, len } = self;
1589
1590 let mut sqe = sqe_zeroed();
1591 sqe.opcode = Self::CODE;
1592 sqe.__bindgen_anon_2.addr = name as _;
1593 sqe.len = len;
1594 sqe.__bindgen_anon_1.off = value as _;
1595 unsafe { sqe.__bindgen_anon_6.__bindgen_anon_1.as_mut().addr3 = path as _ };
1596 sqe.__bindgen_anon_3.xattr_flags = flags as _;
1597 Entry(sqe)
1598 }
1599}
1600
1601opcode! {
1602 pub struct FGetXattr {
1604 fd: { impl sealed::UseFixed },
1605 name: { *const libc::c_char },
1606 value: { *mut libc::c_void },
1607 len: { u32 },
1608 ;;
1609 }
1610
1611 pub const CODE = sys::IORING_OP_FGETXATTR;
1612
1613 pub fn build(self) -> Entry {
1614 let FGetXattr { fd, name, value, len } = self;
1615
1616 let mut sqe = sqe_zeroed();
1617 sqe.opcode = Self::CODE;
1618 assign_fd!(sqe.fd = fd);
1619 sqe.__bindgen_anon_2.addr = name as _;
1620 sqe.len = len;
1621 sqe.__bindgen_anon_1.off = value as _;
1622 sqe.__bindgen_anon_3.xattr_flags = 0;
1623 Entry(sqe)
1624 }
1625}
1626
1627opcode! {
1628 pub struct FSetXattr {
1630 fd: { impl sealed::UseFixed },
1631 name: { *const libc::c_char },
1632 value: { *const libc::c_void },
1633 len: { u32 },
1634 ;;
1635 flags: i32 = 0
1636 }
1637
1638 pub const CODE = sys::IORING_OP_FSETXATTR;
1639
1640 pub fn build(self) -> Entry {
1641 let FSetXattr { fd, name, value, flags, len } = self;
1642
1643 let mut sqe = sqe_zeroed();
1644 sqe.opcode = Self::CODE;
1645 assign_fd!(sqe.fd = fd);
1646 sqe.__bindgen_anon_2.addr = name as _;
1647 sqe.len = len;
1648 sqe.__bindgen_anon_1.off = value as _;
1649 sqe.__bindgen_anon_3.xattr_flags = flags as _;
1650 Entry(sqe)
1651 }
1652}
1653
1654opcode! {
1657 pub struct MsgRingData {
1659 ring_fd: { impl sealed::UseFd },
1660 result: { i32 },
1661 user_data: { u64 },
1662 user_flags: { Option<u32> },
1663 ;;
1664 opcode_flags: u32 = 0
1665 }
1666
1667 pub const CODE = sys::IORING_OP_MSG_RING;
1668
1669 pub fn build(self) -> Entry {
1670 let MsgRingData { ring_fd, result, user_data, user_flags, opcode_flags } = self;
1671
1672 let mut sqe = sqe_zeroed();
1673 sqe.opcode = Self::CODE;
1674 sqe.__bindgen_anon_2.addr = sys::IORING_MSG_DATA.into();
1675 sqe.fd = ring_fd;
1676 sqe.len = result as u32;
1677 sqe.__bindgen_anon_1.off = user_data;
1678 sqe.__bindgen_anon_3.msg_ring_flags = opcode_flags;
1679 if let Some(flags) = user_flags {
1680 sqe.__bindgen_anon_5.file_index = flags;
1681 unsafe {sqe.__bindgen_anon_3.msg_ring_flags |= sys::IORING_MSG_RING_FLAGS_PASS};
1682 }
1683 Entry(sqe)
1684 }
1685}
1686
1687opcode! {
1690 pub struct AsyncCancel2 {
1694 builder: { types::CancelBuilder }
1695 ;;
1696 }
1697
1698 pub const CODE = sys::IORING_OP_ASYNC_CANCEL;
1699
1700 pub fn build(self) -> Entry {
1701 let AsyncCancel2 { builder } = self;
1702
1703 let mut sqe = sqe_zeroed();
1704 sqe.opcode = Self::CODE;
1705 sqe.fd = builder.to_fd();
1706 sqe.__bindgen_anon_2.addr = builder.user_data.unwrap_or(0);
1707 sqe.__bindgen_anon_3.cancel_flags = builder.flags.bits();
1708 Entry(sqe)
1709 }
1710}
1711
1712opcode! {
1713 pub struct UringCmd16 {
1715 fd: { impl sealed::UseFixed },
1716 cmd_op: { u32 },
1717 ;;
1718 buf_index: Option<u16> = None,
1721 cmd: [u8; 16] = [0u8; 16],
1723 addr: Option<u64> = None,
1728 }
1729
1730 pub const CODE = sys::IORING_OP_URING_CMD;
1731
1732 pub fn build(self) -> Entry {
1733 let UringCmd16 { fd, cmd_op, cmd, buf_index, addr } = self;
1734
1735 let mut sqe = sqe_zeroed();
1736 sqe.opcode = Self::CODE;
1737 assign_fd!(sqe.fd = fd);
1738 sqe.__bindgen_anon_1.__bindgen_anon_1.cmd_op = cmd_op;
1739 unsafe { *sqe.__bindgen_anon_6.cmd.as_mut().as_mut_ptr().cast::<[u8; 16]>() = cmd };
1740 if let Some(buf_index) = buf_index {
1741 sqe.__bindgen_anon_4.buf_index = buf_index;
1742 unsafe {
1743 sqe.__bindgen_anon_3.uring_cmd_flags |= sys::IORING_URING_CMD_FIXED;
1744 }
1745 }
1746 if let Some(addr) = addr {
1747 sqe.__bindgen_anon_2.addr = addr;
1748 }
1749 Entry(sqe)
1750 }
1751}
1752
1753opcode! {
1754 pub struct UringCmd80 {
1756 fd: { impl sealed::UseFixed },
1757 cmd_op: { u32 },
1758 ;;
1759 buf_index: Option<u16> = None,
1762 cmd: [u8; 80] = [0u8; 80],
1764 addr: Option<u64> = None,
1769 }
1770
1771 pub const CODE = sys::IORING_OP_URING_CMD;
1772
1773 pub fn build(self) -> Entry128 {
1774 let UringCmd80 { fd, cmd_op, cmd, buf_index, addr } = self;
1775
1776 let cmd1 = cmd[..16].try_into().unwrap();
1777 let cmd2 = cmd[16..].try_into().unwrap();
1778
1779 let mut sqe = sqe_zeroed();
1780 sqe.opcode = Self::CODE;
1781 assign_fd!(sqe.fd = fd);
1782 sqe.__bindgen_anon_1.__bindgen_anon_1.cmd_op = cmd_op;
1783 unsafe { *sqe.__bindgen_anon_6.cmd.as_mut().as_mut_ptr().cast::<[u8; 16]>() = cmd1 };
1784 if let Some(buf_index) = buf_index {
1785 sqe.__bindgen_anon_4.buf_index = buf_index;
1786 unsafe {
1787 sqe.__bindgen_anon_3.uring_cmd_flags |= sys::IORING_URING_CMD_FIXED;
1788 }
1789 }
1790 if let Some(addr) = addr {
1791 sqe.__bindgen_anon_2.addr = addr;
1792 }
1793 Entry128(Entry(sqe), cmd2)
1794 }
1795}
1796
1797opcode! {
1798 pub struct Socket {
1808 domain: { i32 },
1809 socket_type: { i32 },
1810 protocol: { i32 },
1811 ;;
1812 file_index: Option<types::DestinationSlot> = None,
1813 flags: i32 = 0,
1814 }
1815
1816 pub const CODE = sys::IORING_OP_SOCKET;
1817
1818 pub fn build(self) -> Entry {
1819 let Socket { domain, socket_type, protocol, file_index, flags } = self;
1820
1821 let mut sqe = sqe_zeroed();
1822 sqe.opcode = Self::CODE;
1823 sqe.fd = domain as _;
1824 sqe.__bindgen_anon_1.off = socket_type as _;
1825 sqe.len = protocol as _;
1826 sqe.__bindgen_anon_3.rw_flags = flags as _;
1827 if let Some(dest) = file_index {
1828 sqe.__bindgen_anon_5.file_index = dest.kernel_index_arg();
1829 }
1830 Entry(sqe)
1831 }
1832}
1833
1834opcode! {
1835 pub struct AcceptMulti {
1841 fd: { impl sealed::UseFixed },
1842 ;;
1843 allocate_file_index: bool = false,
1844 flags: i32 = 0
1845 }
1846
1847 pub const CODE = sys::IORING_OP_ACCEPT;
1848
1849 pub fn build(self) -> Entry {
1850 let AcceptMulti { fd, allocate_file_index, flags } = self;
1851
1852 let mut sqe = sqe_zeroed();
1853 sqe.opcode = Self::CODE;
1854 assign_fd!(sqe.fd = fd);
1855 sqe.ioprio = sys::IORING_ACCEPT_MULTISHOT as u16;
1856 sqe.__bindgen_anon_3.accept_flags = flags as _;
1859 if allocate_file_index {
1860 sqe.__bindgen_anon_5.file_index = sys::IORING_FILE_INDEX_ALLOC as u32;
1861 }
1862 Entry(sqe)
1863 }
1864}
1865
1866opcode! {
1869 pub struct MsgRingSendFd {
1871 ring_fd: { impl sealed::UseFd },
1872 fixed_slot_src: { types::Fixed },
1873 dest_slot_index: { types::DestinationSlot },
1874 user_data: { u64 },
1875 ;;
1876 opcode_flags: u32 = 0
1877 }
1878
1879 pub const CODE = sys::IORING_OP_MSG_RING;
1880
1881 pub fn build(self) -> Entry {
1882 let MsgRingSendFd { ring_fd, fixed_slot_src, dest_slot_index, user_data, opcode_flags } = self;
1883
1884 let mut sqe = sqe_zeroed();
1885 sqe.opcode = Self::CODE;
1886 sqe.__bindgen_anon_2.addr = sys::IORING_MSG_SEND_FD.into();
1887 sqe.fd = ring_fd;
1888 sqe.__bindgen_anon_1.off = user_data;
1889 unsafe { sqe.__bindgen_anon_6.__bindgen_anon_1.as_mut().addr3 = fixed_slot_src.0 as u64 };
1890 sqe.__bindgen_anon_5.file_index = dest_slot_index.kernel_index_arg();
1891 sqe.__bindgen_anon_3.msg_ring_flags = opcode_flags;
1892 Entry(sqe)
1893 }
1894}
1895
1896opcode! {
1899 pub struct SendZc {
1913 fd: { impl sealed::UseFixed },
1914 buf: { *const u8 },
1915 len: { u32 },
1916 ;;
1917 buf_index: Option<u16> = None,
1924 dest_addr: *const libc::sockaddr = core::ptr::null(),
1925 dest_addr_len: libc::socklen_t = 0,
1926 flags: i32 = 0,
1927 zc_flags: u16 = 0,
1928 }
1929
1930 pub const CODE = sys::IORING_OP_SEND_ZC;
1931
1932 pub fn build(self) -> Entry {
1933 let SendZc { fd, buf, len, buf_index, dest_addr, dest_addr_len, flags, zc_flags } = self;
1934
1935 let mut sqe = sqe_zeroed();
1936 sqe.opcode = Self::CODE;
1937 assign_fd!(sqe.fd = fd);
1938 sqe.__bindgen_anon_2.addr = buf as _;
1939 sqe.len = len;
1940 sqe.__bindgen_anon_3.msg_flags = flags as _;
1941 sqe.ioprio = zc_flags;
1942 if let Some(buf_index) = buf_index {
1943 sqe.__bindgen_anon_4.buf_index = buf_index;
1944 sqe.ioprio |= sys::IORING_RECVSEND_FIXED_BUF as u16;
1945 }
1946 sqe.__bindgen_anon_1.addr2 = dest_addr as _;
1947 sqe.__bindgen_anon_5.__bindgen_anon_1.addr_len = dest_addr_len as _;
1948 Entry(sqe)
1949 }
1950}
1951
1952opcode! {
1955 #[derive(Debug)]
1960 pub struct SendMsgZc {
1961 fd: { impl sealed::UseFixed },
1962 msg: { *const libc::msghdr },
1963 ;;
1964 ioprio: u16 = 0,
1965 flags: u32 = 0,
1966 buf_index: Option<u16> = None
1972 }
1973
1974 pub const CODE = sys::IORING_OP_SENDMSG_ZC;
1975
1976 pub fn build(self) -> Entry {
1977 let SendMsgZc { fd, msg, ioprio, flags, buf_index } = self;
1978
1979 let mut sqe = sqe_zeroed();
1980 sqe.opcode = Self::CODE;
1981 assign_fd!(sqe.fd = fd);
1982 sqe.ioprio = ioprio;
1983 if let Some(buf_index) = buf_index {
1984 sqe.__bindgen_anon_4.buf_index = buf_index;
1985 sqe.ioprio |= sys::IORING_RECVSEND_FIXED_BUF as u16;
1986 }
1987 sqe.__bindgen_anon_2.addr = msg as _;
1988 sqe.len = 1;
1989 sqe.__bindgen_anon_3.msg_flags = flags;
1990 Entry(sqe)
1991 }
1992}
1993
1994opcode! {
1997 pub struct ReadMulti {
1999 fd: { impl sealed::UseFixed },
2000 len: { u32 },
2001 buf_group: { u16 },
2002 ;;
2003 offset: u64 = 0,
2004 }
2005
2006 pub const CODE = sys::IORING_OP_READ_MULTISHOT;
2007
2008 pub fn build(self) -> Entry {
2009 let Self { fd, len, buf_group, offset } = self;
2010
2011 let mut sqe = sqe_zeroed();
2012 sqe.opcode = Self::CODE;
2013 assign_fd!(sqe.fd = fd);
2014 sqe.__bindgen_anon_1.off = offset;
2015 sqe.len = len;
2016 sqe.__bindgen_anon_4.buf_group = buf_group;
2017 sqe.flags |= crate::squeue::Flags::BUFFER_SELECT.bits();
2018 Entry(sqe)
2019 }
2020}
2021
2022opcode! {
2023 #[derive(Debug)]
2032 pub struct FutexWait {
2033 futex: { *const u32 },
2034 val: { u64 },
2035 mask: { u64 },
2036 futex_flags: { u32 },
2037 ;;
2038 flags: u32 = 0
2039 }
2040
2041 pub const CODE = sys::IORING_OP_FUTEX_WAIT;
2042
2043 pub fn build(self) -> Entry {
2044 let FutexWait { futex, val, mask, futex_flags, flags } = self;
2045
2046 let mut sqe = sqe_zeroed();
2047 sqe.opcode = Self::CODE;
2048 sqe.fd = futex_flags as _;
2049 sqe.__bindgen_anon_2.addr = futex as usize as _;
2050 sqe.__bindgen_anon_1.off = val;
2051 unsafe { sqe.__bindgen_anon_6.__bindgen_anon_1.as_mut().addr3 = mask };
2052 sqe.__bindgen_anon_3.futex_flags = flags;
2053 Entry(sqe)
2054 }
2055}
2056
2057opcode! {
2058 #[derive(Debug)]
2066 pub struct FutexWake {
2067 futex: { *const u32 },
2068 val: { u64 },
2069 mask: { u64 },
2070 futex_flags: { u32 },
2071 ;;
2072 flags: u32 = 0
2073 }
2074
2075 pub const CODE = sys::IORING_OP_FUTEX_WAKE;
2076
2077 pub fn build(self) -> Entry {
2078 let FutexWake { futex, val, mask, futex_flags, flags } = self;
2079
2080 let mut sqe = sqe_zeroed();
2081 sqe.opcode = Self::CODE;
2082 sqe.fd = futex_flags as _;
2083 sqe.__bindgen_anon_2.addr = futex as usize as _;
2084 sqe.__bindgen_anon_1.off = val;
2085 unsafe { sqe.__bindgen_anon_6.__bindgen_anon_1.as_mut().addr3 = mask };
2086 sqe.__bindgen_anon_3.futex_flags = flags;
2087 Entry(sqe)
2088 }
2089}
2090
2091opcode! {
2092 #[derive(Debug)]
2098 pub struct FutexWaitV {
2099 futexv: { *const types::FutexWaitV },
2100 nr_futex: { u32 },
2101 ;;
2102 flags: u32 = 0
2103 }
2104
2105 pub const CODE = sys::IORING_OP_FUTEX_WAITV;
2106
2107 pub fn build(self) -> Entry {
2108 let FutexWaitV { futexv, nr_futex, flags } = self;
2109
2110 let mut sqe = sqe_zeroed();
2111 sqe.opcode = Self::CODE;
2112 sqe.__bindgen_anon_2.addr = futexv as usize as _;
2113 sqe.len = nr_futex;
2114 sqe.__bindgen_anon_3.futex_flags = flags;
2115 Entry(sqe)
2116 }
2117}
2118
2119opcode! {
2120 #[derive(Debug)]
2124 pub struct WaitId {
2125 idtype: { libc::idtype_t },
2126 id: { libc::id_t },
2127 options: { libc::c_int },
2128 ;;
2129 infop: *const libc::siginfo_t = std::ptr::null(),
2130 flags: libc::c_uint = 0,
2131 }
2132
2133 pub const CODE = sys::IORING_OP_WAITID;
2134
2135 pub fn build(self) -> Entry {
2136 let mut sqe = sqe_zeroed();
2137 sqe.opcode = Self::CODE;
2138 sqe.fd = self.id as _;
2139 sqe.len = self.idtype as _;
2140 sqe.__bindgen_anon_3.waitid_flags = self.flags;
2141 sqe.__bindgen_anon_5.file_index = self.options as _;
2142 sqe.__bindgen_anon_1.addr2 = self.infop as _;
2143 Entry(sqe)
2144 }
2145}
2146
2147opcode! {
2150 #[derive(Debug)]
2155 pub struct FixedFdInstall {
2156 fd: { types::Fixed },
2157 file_flags: { u32 },
2158 ;;
2159 }
2160
2161 pub const CODE = sys::IORING_OP_FIXED_FD_INSTALL;
2162
2163 pub fn build(self) -> Entry {
2164 let FixedFdInstall { fd, file_flags } = self;
2165
2166 let mut sqe = sqe_zeroed();
2167 sqe.opcode = Self::CODE;
2168 sqe.fd = fd.0 as _;
2169 sqe.flags = crate::squeue::Flags::FIXED_FILE.bits();
2170 sqe.__bindgen_anon_3.install_fd_flags = file_flags;
2171 Entry(sqe)
2172 }
2173}
2174
2175opcode! {
2178 #[derive(Debug)]
2180 pub struct Ftruncate {
2181 fd: { impl sealed::UseFixed },
2182 len: { u64 },
2183 ;;
2184 }
2185
2186 pub const CODE = sys::IORING_OP_FTRUNCATE;
2187
2188 pub fn build(self) -> Entry {
2189 let Ftruncate { fd, len } = self;
2190
2191 let mut sqe = sqe_zeroed();
2192 sqe.opcode = Self::CODE;
2193 assign_fd!(sqe.fd = fd);
2194 sqe.__bindgen_anon_1.off = len;
2195 Entry(sqe)
2196 }
2197}
2198
2199opcode! {
2202 pub struct SendBundle {
2204 fd: { impl sealed::UseFixed },
2205 buf_group: { u16 },
2206 ;;
2207 flags: i32 = 0,
2208 len: u32 = 0
2209 }
2210
2211 pub const CODE = sys::IORING_OP_SEND;
2212
2213 pub fn build(self) -> Entry {
2214 let SendBundle { fd, len, flags, buf_group } = self;
2215
2216 let mut sqe = sqe_zeroed();
2217 sqe.opcode = Self::CODE;
2218 assign_fd!(sqe.fd = fd);
2219 sqe.len = len;
2220 sqe.__bindgen_anon_3.msg_flags = flags as _;
2221 sqe.ioprio |= sys::IORING_RECVSEND_BUNDLE as u16;
2222 sqe.flags |= crate::squeue::Flags::BUFFER_SELECT.bits();
2223 sqe.__bindgen_anon_4.buf_group = buf_group;
2224 Entry(sqe)
2225 }
2226}
2227
2228opcode! {
2229 pub struct RecvBundle {
2239 fd: { impl sealed::UseFixed },
2240 buf_group: { u16 },
2241 ;;
2242 flags: i32 = 0
2243 }
2244
2245 pub const CODE = sys::IORING_OP_RECV;
2246
2247 pub fn build(self) -> Entry {
2248 let RecvBundle { fd, buf_group, flags } = self;
2249
2250 let mut sqe = sqe_zeroed();
2251 sqe.opcode = Self::CODE;
2252 assign_fd!(sqe.fd = fd);
2253 sqe.__bindgen_anon_3.msg_flags = flags as _;
2254 sqe.__bindgen_anon_4.buf_group = buf_group;
2255 sqe.flags |= crate::squeue::Flags::BUFFER_SELECT.bits();
2256 sqe.ioprio |= sys::IORING_RECVSEND_BUNDLE as u16;
2257 Entry(sqe)
2258 }
2259}
2260
2261opcode! {
2262 pub struct RecvMultiBundle {
2280 fd: { impl sealed::UseFixed },
2281 buf_group: { u16 },
2282 ;;
2283 flags: i32 = 0
2284 }
2285
2286 pub const CODE = sys::IORING_OP_RECV;
2287
2288 pub fn build(self) -> Entry {
2289 let RecvMultiBundle { fd, buf_group, flags } = self;
2290
2291 let mut sqe = sqe_zeroed();
2292 sqe.opcode = Self::CODE;
2293 assign_fd!(sqe.fd = fd);
2294 sqe.__bindgen_anon_3.msg_flags = flags as _;
2295 sqe.__bindgen_anon_4.buf_group = buf_group;
2296 sqe.flags |= crate::squeue::Flags::BUFFER_SELECT.bits();
2297 sqe.ioprio = sys::IORING_RECV_MULTISHOT as _;
2298 sqe.ioprio |= sys::IORING_RECVSEND_BUNDLE as u16;
2299 Entry(sqe)
2300 }
2301}
2302
2303opcode! {
2306 pub struct Bind {
2308 fd: { impl sealed::UseFixed },
2309 addr: { *const libc::sockaddr },
2310 addrlen: { libc::socklen_t }
2311 ;;
2312 }
2313
2314 pub const CODE = sys::IORING_OP_BIND;
2315
2316 pub fn build(self) -> Entry {
2317 let Bind { fd, addr, addrlen } = self;
2318
2319 let mut sqe = sqe_zeroed();
2320 sqe.opcode = Self::CODE;
2321 assign_fd!(sqe.fd = fd);
2322 sqe.__bindgen_anon_2.addr = addr as _;
2323 sqe.__bindgen_anon_1.off = addrlen as _;
2324 Entry(sqe)
2325 }
2326}
2327
2328opcode! {
2329 pub struct Listen {
2331 fd: { impl sealed::UseFixed },
2332 backlog: { i32 },
2333 ;;
2334 }
2335
2336 pub const CODE = sys::IORING_OP_LISTEN;
2337
2338 pub fn build(self) -> Entry {
2339 let Listen { fd, backlog } = self;
2340
2341 let mut sqe = sqe_zeroed();
2342 sqe.opcode = Self::CODE;
2343 assign_fd!(sqe.fd = fd);
2344 sqe.len = backlog as _;
2345 Entry(sqe)
2346 }
2347}
2348
2349opcode! {
2352 pub struct RecvZc {
2354 fd: { impl sealed::UseFixed },
2355 len: { u32 },
2356 ;;
2357 ifq: u32 = 0,
2358 ioprio: u16 = 0,
2359 }
2360
2361 pub const CODE = sys::IORING_OP_RECV_ZC;
2362
2363 pub fn build(self) -> Entry {
2364 let Self { fd, len, ifq, ioprio } = self;
2365
2366 let mut sqe = sqe_zeroed();
2367 sqe.opcode = Self::CODE;
2368 assign_fd!(sqe.fd = fd);
2369 sqe.len = len;
2370 sqe.ioprio = ioprio | sys::IORING_RECV_MULTISHOT as u16;
2371 sqe.__bindgen_anon_5.zcrx_ifq_idx = ifq;
2372 Entry(sqe)
2373 }
2374}
2375
2376opcode! {
2377 pub struct EpollWait {
2379 fd: { impl sealed::UseFixed },
2380 events: { *mut types::epoll_event },
2381 max_events: { u32 },
2382 ;;
2383 flags: u32 = 0,
2384 }
2385
2386 pub const CODE = sys::IORING_OP_EPOLL_WAIT;
2387
2388 pub fn build(self) -> Entry {
2389 let Self { fd, events, max_events, flags } = self;
2390
2391 let mut sqe = sqe_zeroed();
2392 sqe.opcode = Self::CODE;
2393 assign_fd!(sqe.fd = fd);
2394 sqe.__bindgen_anon_2.addr = events as u64;
2395 sqe.len = max_events;
2396 sqe.__bindgen_anon_3.poll32_events = flags;
2397 Entry(sqe)
2398 }
2399}
2400
2401opcode! {
2402 pub struct ReadvFixed {
2404 fd: { impl sealed::UseFixed },
2405 iovec: { *const ::libc::iovec },
2406 len: { u32 },
2407 buf_index: { u16 },
2408 ;;
2409 ioprio: u16 = 0,
2410 offset: u64 = 0,
2411 rw_flags: i32 = 0,
2412 }
2413
2414 pub const CODE = sys::IORING_OP_READV_FIXED;
2415
2416 pub fn build(self) -> Entry {
2417 let Self { fd, iovec, len, buf_index, offset, ioprio, rw_flags } = self;
2418
2419 let mut sqe = sqe_zeroed();
2420 sqe.opcode = Self::CODE;
2421 assign_fd!(sqe.fd = fd);
2422 sqe.__bindgen_anon_1.off = offset as _;
2423 sqe.__bindgen_anon_2.addr = iovec as _;
2424 sqe.len = len;
2425 sqe.__bindgen_anon_4.buf_index = buf_index;
2426 sqe.ioprio = ioprio;
2427 sqe.__bindgen_anon_3.rw_flags = rw_flags as _;
2428 Entry(sqe)
2429 }
2430}
2431
2432opcode! {
2433 pub struct WritevFixed {
2435 fd: { impl sealed::UseFixed },
2436 iovec: { *const ::libc::iovec },
2437 len: { u32 },
2438 buf_index: { u16 },
2439 ;;
2440 ioprio: u16 = 0,
2441 offset: u64 = 0,
2442 rw_flags: i32 = 0,
2443 write_stream: u8 = 0,
2446 }
2447
2448 pub const CODE = sys::IORING_OP_WRITEV_FIXED;
2449
2450 pub fn build(self) -> Entry {
2451 let Self { fd, iovec, len, buf_index, offset, ioprio, rw_flags, write_stream } = self;
2452
2453 let mut sqe = sqe_zeroed();
2454 sqe.opcode = Self::CODE;
2455 assign_fd!(sqe.fd = fd);
2456 sqe.__bindgen_anon_1.off = offset as _;
2457 sqe.__bindgen_anon_2.addr = iovec as _;
2458 sqe.len = len;
2459 sqe.__bindgen_anon_4.buf_index = buf_index;
2460 sqe.ioprio = ioprio;
2461 sqe.__bindgen_anon_3.rw_flags = rw_flags as _;
2462 sqe.__bindgen_anon_5.__bindgen_anon_2.write_stream = write_stream;
2463 Entry(sqe)
2464 }
2465}
2466
2467opcode! {
2470 pub struct Pipe {
2472 fds: { *mut RawFd },
2473 ;;
2474 flags: u32 = 0,
2475 file_index: Option<types::DestinationSlot> = None,
2476 }
2477
2478 pub const CODE = sys::IORING_OP_PIPE;
2479
2480 pub fn build(self) -> Entry {
2481 let Self { fds, flags, file_index } = self;
2482
2483 let mut sqe = sqe_zeroed();
2484 sqe.opcode = Self::CODE;
2485 sqe.fd = 0;
2486 sqe.__bindgen_anon_2.addr = fds as _;
2487 sqe.__bindgen_anon_3.pipe_flags = flags;
2488 if let Some(dest) = file_index {
2489 sqe.__bindgen_anon_5.file_index = dest.kernel_index_arg();
2490 }
2491 Entry(sqe)
2492 }
2493}