Skip to content

Commit 6cd4a06

Browse files
authored
Use io_uring_ptr for more io_uring struct fields. (#1368)
For fields which hold pointer values, use `io_uring_ptr` instead of `u64`, to better preserve pointer provenance.
1 parent ddca5cc commit 6cd4a06

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/io_uring/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ pub struct io_uring_probe_op {
15381538
pub struct io_uring_files_update {
15391539
pub offset: u32,
15401540
pub resv: u32,
1541-
pub fds: u64,
1541+
pub fds: io_uring_ptr,
15421542
}
15431543

15441544
#[allow(missing_docs)]
@@ -1548,8 +1548,8 @@ pub struct io_uring_rsrc_register {
15481548
pub nr: u32,
15491549
pub flags: IoringRsrcFlags,
15501550
pub resv2: u64,
1551-
pub data: u64,
1552-
pub tags: u64,
1551+
pub data: io_uring_ptr,
1552+
pub tags: io_uring_ptr,
15531553
}
15541554

15551555
#[allow(missing_docs)]
@@ -1558,7 +1558,7 @@ pub struct io_uring_rsrc_register {
15581558
pub struct io_uring_rsrc_update {
15591559
pub offset: u32,
15601560
pub resv: u32,
1561-
pub data: u64,
1561+
pub data: io_uring_ptr,
15621562
}
15631563

15641564
#[allow(missing_docs)]
@@ -1567,8 +1567,8 @@ pub struct io_uring_rsrc_update {
15671567
pub struct io_uring_rsrc_update2 {
15681568
pub offset: u32,
15691569
pub resv: u32,
1570-
pub data: u64,
1571-
pub tags: u64,
1570+
pub data: io_uring_ptr,
1571+
pub tags: io_uring_ptr,
15721572
pub nr: u32,
15731573
pub resv2: u32,
15741574
}

tests/io_uring/register.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use libc::c_void;
44
use rustix::fd::{AsFd, AsRawFd, BorrowedFd};
55
use rustix::io::{Errno, Result};
66
use rustix::io_uring::{
7-
io_uring_buf, io_uring_buf_reg, io_uring_buf_ring, io_uring_params, io_uring_register_with,
8-
io_uring_rsrc_update, io_uring_setup, IoringFeatureFlags, IoringRegisterFlags,
9-
IoringRegisterOp,
7+
io_uring_buf, io_uring_buf_reg, io_uring_buf_ring, io_uring_params, io_uring_ptr,
8+
io_uring_register_with, io_uring_rsrc_update, io_uring_setup, IoringFeatureFlags,
9+
IoringRegisterFlags, IoringRegisterOp,
1010
};
1111
#[cfg(feature = "mm")]
1212
use rustix::mm::{MapFlags, ProtFlags};
@@ -36,7 +36,7 @@ where
3636

3737
fn register_ring(fd: BorrowedFd<'_>) -> Result<BorrowedFd<'_>> {
3838
let update = io_uring_rsrc_update {
39-
data: fd.as_raw_fd() as u64,
39+
data: io_uring_ptr::new(fd.as_raw_fd() as u64 as *mut c_void),
4040
offset: u32::MAX,
4141
resv: 0,
4242
};
@@ -59,7 +59,7 @@ where
5959
{
6060
let update = io_uring_rsrc_update {
6161
offset: fd.as_raw_fd() as u32,
62-
data: 0,
62+
data: io_uring_ptr::null(),
6363
resv: 0,
6464
};
6565

0 commit comments

Comments
 (0)