summaryrefslogtreecommitdiff
path: root/src/sys/stat.rs
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2017-03-08 00:12:45 +0100
committerJörg Thalheim <joerg@thalheim.io>2017-03-21 01:27:21 +0100
commitb6a8a3c64f63a4f540000084a6ec19d635f48e6c (patch)
tree89c6e13d7113e1a0640c99890ffbc0d6ee53b1f7 /src/sys/stat.rs
parent2b0c63f56dcf69fba328e8d5b2139bc6e5cef930 (diff)
downloadnix-b6a8a3c64f63a4f540000084a6ec19d635f48e6c.zip
add support for `fstatat`
Diffstat (limited to 'src/sys/stat.rs')
-rw-r--r--src/sys/stat.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/sys/stat.rs b/src/sys/stat.rs
index 1ff35923..054aedc1 100644
--- a/src/sys/stat.rs
+++ b/src/sys/stat.rs
@@ -2,6 +2,7 @@ pub use libc::dev_t;
pub use libc::stat as FileStat;
use {Errno, Result, NixPath};
+use fcntl::AtFlags;
use libc::{self, mode_t};
use std::mem;
use std::os::unix::io::RawFd;
@@ -121,3 +122,15 @@ pub fn fstat(fd: RawFd) -> Result<FileStat> {
Ok(dst)
}
+
+pub fn fstatat<P: ?Sized + NixPath>(dirfd: RawFd, pathname: &P, f: AtFlags) -> Result<FileStat> {
+ let mut dst = unsafe { mem::uninitialized() };
+ let res = try!(pathname.with_nix_path(|cstr| {
+ unsafe { libc::fstatat(dirfd, cstr.as_ptr(), &mut dst as *mut FileStat, f.bits() as libc::c_int) }
+ }));
+
+ try!(Errno::result(res));
+
+ Ok(dst)
+}
+