Skip to content

Commit 6660b7e

Browse files
committed
refactor: refact the impl structure for different os
1 parent 063f7f7 commit 6660b7e

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

monoio/src/driver/op/statx.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#[cfg(target_os = "linux")]
2-
use std::os::fd::AsRawFd;
31
use std::{ffi::CString, mem::MaybeUninit, path::Path};
42

53
#[cfg(all(target_os = "linux", feature = "iouring"))]
@@ -67,6 +65,8 @@ impl Op<FdStatx> {
6765
impl OpAble for FdStatx {
6866
#[cfg(all(target_os = "linux", feature = "iouring"))]
6967
fn uring_op(&mut self) -> io_uring::squeue::Entry {
68+
use std::os::fd::AsRawFd;
69+
7070
let statxbuf = self.statx_buf.as_mut_ptr() as *mut _;
7171

7272
opcode::Statx::new(types::Fd(self.inner.as_raw_fd()), c"".as_ptr(), statxbuf)

monoio/src/fs/metadata/unix.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::fs::{file_type::FileType, permissions::FilePermissions};
44

55
pub(crate) struct FileAttr {
66
#[cfg(target_os = "linux")]
7-
pub(crate) stat: stat64,
7+
pub(crate) stat: libc::stat64,
88
#[cfg(target_os = "macos")]
99
pub(crate) stat: libc::stat,
1010
#[cfg(target_os = "linux")]
@@ -33,16 +33,16 @@ impl FileAttr {
3333
/// Extra fields that are available in `statx` struct.
3434
#[cfg(target_os = "linux")]
3535
pub(crate) struct StatxExtraFields {
36-
stx_mask: u32,
37-
stx_btime: libc::statx_timestamp,
36+
pub(crate) stx_mask: u32,
37+
pub(crate) stx_btime: libc::statx_timestamp,
3838
}
3939

4040
/// Convert a `statx` struct to not platform-specific `FileAttr`.
4141
/// Current implementation is only for Linux.
4242
#[cfg(target_os = "linux")]
43-
impl From<statx> for FileAttr {
44-
fn from(buf: statx) -> Self {
45-
let mut stat: stat64 = unsafe { std::mem::zeroed() };
43+
impl From<libc::statx> for FileAttr {
44+
fn from(buf: libc::statx) -> Self {
45+
let mut stat: libc::stat64 = unsafe { std::mem::zeroed() };
4646

4747
stat.st_dev = libc::makedev(buf.stx_dev_major, buf.stx_dev_minor) as _;
4848
stat.st_ino = buf.stx_ino as libc::ino64_t;

0 commit comments

Comments
 (0)