Skip to content

Commit f9db609

Browse files
authored
Add fixed buffer support to uring_cmd (#260)
1 parent 92bef36 commit f9db609

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/opcode.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,20 +1492,29 @@ opcode! {
14921492
fd: { impl sealed::UseFixed },
14931493
cmd_op: { u32 },
14941494
;;
1495+
/// The `buf_index` is an index into an array of fixed buffers,
1496+
/// and is only valid if fixed buffers were registered.
1497+
buf_index: Option<u16> = None,
14951498
/// Arbitrary command data.
14961499
cmd: [u8; 16] = [0u8; 16]
14971500
}
14981501

14991502
pub const CODE = sys::IORING_OP_URING_CMD;
15001503

15011504
pub fn build(self) -> Entry {
1502-
let UringCmd16 { fd, cmd_op, cmd } = self;
1505+
let UringCmd16 { fd, cmd_op, cmd, buf_index } = self;
15031506

15041507
let mut sqe = sqe_zeroed();
15051508
sqe.opcode = Self::CODE;
15061509
assign_fd!(sqe.fd = fd);
15071510
sqe.__bindgen_anon_1.__bindgen_anon_1.cmd_op = cmd_op;
15081511
unsafe { *sqe.__bindgen_anon_6.cmd.as_mut().as_mut_ptr().cast::<[u8; 16]>() = cmd };
1512+
if let Some(buf_index) = buf_index {
1513+
sqe.__bindgen_anon_4.buf_index = buf_index;
1514+
unsafe {
1515+
sqe.__bindgen_anon_3.uring_cmd_flags |= sys::IORING_URING_CMD_FIXED;
1516+
}
1517+
}
15091518
Entry(sqe)
15101519
}
15111520
}
@@ -1516,14 +1525,17 @@ opcode! {
15161525
fd: { impl sealed::UseFixed },
15171526
cmd_op: { u32 },
15181527
;;
1528+
/// The `buf_index` is an index into an array of fixed buffers,
1529+
/// and is only valid if fixed buffers were registered.
1530+
buf_index: Option<u16> = None,
15191531
/// Arbitrary command data.
15201532
cmd: [u8; 80] = [0u8; 80]
15211533
}
15221534

15231535
pub const CODE = sys::IORING_OP_URING_CMD;
15241536

15251537
pub fn build(self) -> Entry128 {
1526-
let UringCmd80 { fd, cmd_op, cmd } = self;
1538+
let UringCmd80 { fd, cmd_op, cmd, buf_index } = self;
15271539

15281540
let cmd1 = cmd[..16].try_into().unwrap();
15291541
let cmd2 = cmd[16..].try_into().unwrap();
@@ -1533,6 +1545,12 @@ opcode! {
15331545
assign_fd!(sqe.fd = fd);
15341546
sqe.__bindgen_anon_1.__bindgen_anon_1.cmd_op = cmd_op;
15351547
unsafe { *sqe.__bindgen_anon_6.cmd.as_mut().as_mut_ptr().cast::<[u8; 16]>() = cmd1 };
1548+
if let Some(buf_index) = buf_index {
1549+
sqe.__bindgen_anon_4.buf_index = buf_index;
1550+
unsafe {
1551+
sqe.__bindgen_anon_3.uring_cmd_flags |= sys::IORING_URING_CMD_FIXED;
1552+
}
1553+
}
15361554
Entry128(Entry(sqe), cmd2)
15371555
}
15381556
}

0 commit comments

Comments
 (0)