Skip to content

Commit

Permalink
Remove global uses for statx and fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
oxalica committed Oct 9, 2019
1 parent 79bc6d4 commit 21b4577
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/libstd/sys/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ use libc::{stat64, fstat64, lstat64, off64_t, ftruncate64, lseek64, dirent64, re
use libc::fstatat64;
#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "android"))]
use libc::dirfd;
// We only use struct `statx`, not the function `statx`.
// Instead, use `syscall` to check if it is available at runtime.
#[cfg(target_os = "linux")]
use libc::{statx, makedev};
#[cfg(target_os = "android")]
use libc::{stat as stat64, fstat as fstat64, fstatat as fstatat64, lstat as lstat64, lseek64,
dirent as dirent64, open as open64};
Expand Down Expand Up @@ -79,15 +75,15 @@ unsafe fn try_statx(
pathname: *const libc::c_char,
flags: c_int,
mask: libc::c_uint,
statxbuf: *mut statx
statxbuf: *mut libc::statx
) -> c_int
}

if !HAS_STATX.load(Ordering::Relaxed) {
return None;
}

let mut buf: statx = mem::zeroed();
let mut buf: libc::statx = mem::zeroed();
let ret = cvt(statx(fd, path, flags, mask, &mut buf));
match ret {
Err(err) => match err.raw_os_error() {
Expand All @@ -100,13 +96,13 @@ unsafe fn try_statx(
Ok(_) => {
// We cannot fill `stat64` exhaustively because of private padding fields.
let mut stat: stat64 = mem::zeroed();
stat.st_dev = makedev(buf.stx_dev_major, buf.stx_dev_minor);
stat.st_dev = libc::makedev(buf.stx_dev_major, buf.stx_dev_minor);
stat.st_ino = buf.stx_ino;
stat.st_nlink = buf.stx_nlink as u64;
stat.st_mode = buf.stx_mode as u32;
stat.st_uid = buf.stx_uid;
stat.st_gid = buf.stx_gid;
stat.st_rdev = makedev(buf.stx_rdev_major, buf.stx_rdev_minor);
stat.st_rdev = libc::makedev(buf.stx_rdev_major, buf.stx_rdev_minor);
stat.st_size = buf.stx_size as i64;
stat.st_blksize = buf.stx_blksize as i64;
stat.st_blocks = buf.stx_blocks as i64;
Expand Down Expand Up @@ -264,7 +260,7 @@ impl FileAttr {
} else {
Err(io::Error::new(
io::ErrorKind::Other,
"creation time is not available for the filesystam",
"creation time is not available for the filesystem",
))
};
}
Expand Down

0 comments on commit 21b4577

Please sign in to comment.