Skip to content

Commit 21b4577

Browse files
committed
Remove global uses for statx and fix typo
1 parent 79bc6d4 commit 21b4577

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/libstd/sys/unix/fs.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ use libc::{stat64, fstat64, lstat64, off64_t, ftruncate64, lseek64, dirent64, re
2020
use libc::fstatat64;
2121
#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "android"))]
2222
use libc::dirfd;
23-
// We only use struct `statx`, not the function `statx`.
24-
// Instead, use `syscall` to check if it is available at runtime.
25-
#[cfg(target_os = "linux")]
26-
use libc::{statx, makedev};
2723
#[cfg(target_os = "android")]
2824
use libc::{stat as stat64, fstat as fstat64, fstatat as fstatat64, lstat as lstat64, lseek64,
2925
dirent as dirent64, open as open64};
@@ -79,15 +75,15 @@ unsafe fn try_statx(
7975
pathname: *const libc::c_char,
8076
flags: c_int,
8177
mask: libc::c_uint,
82-
statxbuf: *mut statx
78+
statxbuf: *mut libc::statx
8379
) -> c_int
8480
}
8581

8682
if !HAS_STATX.load(Ordering::Relaxed) {
8783
return None;
8884
}
8985

90-
let mut buf: statx = mem::zeroed();
86+
let mut buf: libc::statx = mem::zeroed();
9187
let ret = cvt(statx(fd, path, flags, mask, &mut buf));
9288
match ret {
9389
Err(err) => match err.raw_os_error() {
@@ -100,13 +96,13 @@ unsafe fn try_statx(
10096
Ok(_) => {
10197
// We cannot fill `stat64` exhaustively because of private padding fields.
10298
let mut stat: stat64 = mem::zeroed();
103-
stat.st_dev = makedev(buf.stx_dev_major, buf.stx_dev_minor);
99+
stat.st_dev = libc::makedev(buf.stx_dev_major, buf.stx_dev_minor);
104100
stat.st_ino = buf.stx_ino;
105101
stat.st_nlink = buf.stx_nlink as u64;
106102
stat.st_mode = buf.stx_mode as u32;
107103
stat.st_uid = buf.stx_uid;
108104
stat.st_gid = buf.stx_gid;
109-
stat.st_rdev = makedev(buf.stx_rdev_major, buf.stx_rdev_minor);
105+
stat.st_rdev = libc::makedev(buf.stx_rdev_major, buf.stx_rdev_minor);
110106
stat.st_size = buf.stx_size as i64;
111107
stat.st_blksize = buf.stx_blksize as i64;
112108
stat.st_blocks = buf.stx_blocks as i64;
@@ -264,7 +260,7 @@ impl FileAttr {
264260
} else {
265261
Err(io::Error::new(
266262
io::ErrorKind::Other,
267-
"creation time is not available for the filesystam",
263+
"creation time is not available for the filesystem",
268264
))
269265
};
270266
}

0 commit comments

Comments
 (0)