diff --git a/Cargo.toml b/Cargo.toml index 85ce27dd..a24ee9f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ keywords = ["async", "fs", "io-uring"] tokio = { version = "1.2", features = ["net", "rt", "sync"] } slab = "0.4.2" libc = "0.2.80" +linux-raw-sys = "0.6" io-uring = "0.6.0" socket2 = { version = "0.4.4", features = ["all"] } bytes = { version = "1.0", optional = true } diff --git a/src/fs/create_dir_all.rs b/src/fs/create_dir_all.rs index 413ef83d..c410778b 100644 --- a/src/fs/create_dir_all.rs +++ b/src/fs/create_dir_all.rs @@ -193,7 +193,11 @@ mod fs_imp { // Uses one asynchronous uring call to determine this. async fn is_dir>(path: P) -> bool { let mut builder = crate::fs::StatxBuilder::new(); - if builder.mask(libc::STATX_TYPE).pathname(path).is_err() { + if builder + .mask(linux_raw_sys::general::STATX_TYPE) + .pathname(path) + .is_err() + { return false; } diff --git a/src/fs/statx.rs b/src/fs/statx.rs index 5a3ccb1b..e1c2ee4d 100644 --- a/src/fs/statx.rs +++ b/src/fs/statx.rs @@ -28,9 +28,9 @@ impl File { /// f.close().await.unwrap(); /// }) /// ``` - pub async fn statx(&self) -> io::Result { + pub async fn statx(&self) -> io::Result { let flags = libc::AT_EMPTY_PATH; - let mask = libc::STATX_ALL; + let mask = linux_raw_sys::general::STATX_ALL; Op::statx(Some(self.fd.clone()), None, flags, mask)?.await } @@ -73,7 +73,7 @@ impl File { file: Some(self.fd.clone()), path: None, flags: libc::AT_EMPTY_PATH, - mask: libc::STATX_ALL, + mask: linux_raw_sys::general::STATX_ALL, } } } @@ -102,7 +102,7 @@ impl File { /// let statx = tokio_uring::fs::statx("foo.txt").await.unwrap(); /// }) /// ``` -pub async fn statx>(path: P) -> io::Result { +pub async fn statx>(path: P) -> io::Result { StatxBuilder::new().pathname(path).unwrap().statx().await } @@ -162,7 +162,7 @@ impl StatxBuilder { file: None, path: None, flags: libc::AT_EMPTY_PATH, - mask: libc::STATX_ALL, + mask: linux_raw_sys::general::STATX_ALL, } } @@ -288,7 +288,7 @@ impl StatxBuilder { /// dir.close().await.unwrap(); /// }) /// ``` - pub async fn statx(&mut self) -> io::Result { + pub async fn statx(&mut self) -> io::Result { // TODO should the statx() terminator be renamed to something like submit()? let fd = self.file.take(); let path = self.path.take(); @@ -303,7 +303,11 @@ impl StatxBuilder { #[allow(dead_code)] pub async fn is_dir_regfile>(path: P) -> (bool, bool) { let mut builder = crate::fs::StatxBuilder::new(); - if builder.mask(libc::STATX_TYPE).pathname(path).is_err() { + if builder + .mask(linux_raw_sys::general::STATX_TYPE) + .pathname(path) + .is_err() + { return (false, false); } diff --git a/src/io/sendmsg.rs b/src/io/sendmsg.rs index 5b02288c..cc057dbc 100644 --- a/src/io/sendmsg.rs +++ b/src/io/sendmsg.rs @@ -55,11 +55,11 @@ impl Op> { match msg_control { Some(ref _msg_control) => { msghdr.msg_control = _msg_control.stable_ptr() as *mut _; - msghdr.msg_controllen = _msg_control.bytes_init(); + msghdr.msg_controllen = _msg_control.bytes_init() as _; } None => { msghdr.msg_control = std::ptr::null_mut(); - msghdr.msg_controllen = 0_usize; + msghdr.msg_controllen = 0; } } diff --git a/src/io/sendmsg_zc.rs b/src/io/sendmsg_zc.rs index e7da9fe5..e337d8ab 100644 --- a/src/io/sendmsg_zc.rs +++ b/src/io/sendmsg_zc.rs @@ -62,11 +62,11 @@ impl Op, MultiCQEFuture> { match msg_control { Some(ref _msg_control) => { msghdr.msg_control = _msg_control.stable_ptr() as *mut _; - msghdr.msg_controllen = _msg_control.bytes_init(); + msghdr.msg_controllen = _msg_control.bytes_init() as _; } None => { msghdr.msg_control = std::ptr::null_mut(); - msghdr.msg_controllen = 0_usize; + msghdr.msg_controllen = 0; } } diff --git a/src/io/statx.rs b/src/io/statx.rs index e7796b0e..43af0d56 100644 --- a/src/io/statx.rs +++ b/src/io/statx.rs @@ -18,7 +18,7 @@ pub(crate) struct Statx { // TODO consider returning this type when the operation is complete so the caller has the boxed value. // The builder could even recycle an old boxed value and pass it in here. - statx: Box, + statx: Box, } impl Op { @@ -53,7 +53,8 @@ impl Op { opcode::Statx::new( types::Fd(raw), statx.path.as_ptr(), - &mut *statx.statx as *mut libc::statx as *mut types::statx, + &mut *statx.statx as *mut linux_raw_sys::general::statx + as *mut types::statx, ) .flags(flags) .mask(mask) @@ -65,7 +66,7 @@ impl Op { } impl Completable for Statx { - type Output = io::Result; + type Output = io::Result; fn complete(self, cqe: CqeResult) -> Self::Output { cqe.result?;