From b6a8a3c64f63a4f540000084a6ec19d635f48e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 8 Mar 2017 00:12:45 +0100 Subject: add support for `fstatat` --- src/sys/stat.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/sys') 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 { Ok(dst) } + +pub fn fstatat(dirfd: RawFd, pathname: &P, f: AtFlags) -> Result { + 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) +} + -- cgit v1.2.3