summaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2017-03-26 12:14:02 +0900
committerHomu <homu@barosl.com>2017-03-26 12:14:02 +0900
commitc086d23997ca1c887377bc78fd3fa79000a810d7 (patch)
treeceed3cfad4b87db2e817129ea16c74ef5704ae77 /src/sys
parent0eef6515f265428e522eea3e2aa3dd936398c4e0 (diff)
parent55d7b5cef30e525c2b04c02ef4eedf7098505700 (diff)
downloadnix-c086d23997ca1c887377bc78fd3fa79000a810d7.zip
Auto merge of #552 - Mic92:fstatat, r=posborne
add support for openat, fstatat, readlink, readlinkat
Diffstat (limited to 'src/sys')
-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)
+}
+