diff options
author | Julio Merino <julio@meroh.net> | 2018-10-17 06:35:45 -0400 |
---|---|---|
committer | Julio Merino <julio@meroh.net> | 2018-10-19 22:09:13 -0400 |
commit | f3dab48a9221ede9f5409662eacca4b53de34171 (patch) | |
tree | 06607538e84ea1a65828c87cd9960ad4f72a9596 /src/fcntl.rs | |
parent | dc6b2992f5e794cdc67a49a23b239241b0ebafd5 (diff) | |
download | nix-f3dab48a9221ede9f5409662eacca4b53de34171.zip |
Add a fchownat(2) wrapper
Diffstat (limited to 'src/fcntl.rs')
-rw-r--r-- | src/fcntl.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/fcntl.rs b/src/fcntl.rs index 58de3b31..5942506b 100644 --- a/src/fcntl.rs +++ b/src/fcntl.rs @@ -2,6 +2,7 @@ use {Error, Result, NixPath}; use errno::Errno; use libc::{self, c_int, c_uint, c_char, size_t, ssize_t}; use sys::stat::Mode; +use std::os::raw; use std::os::unix::io::RawFd; use std::ffi::OsStr; use std::os::unix::ffi::OsStrExt; @@ -182,6 +183,14 @@ pub fn readlinkat<'a, P: ?Sized + NixPath>(dirfd: RawFd, path: &P, buffer: &'a m wrap_readlink_result(buffer, res) } +/// Computes the raw fd consumed by a function of the form `*at`. +pub(crate) fn at_rawfd(fd: Option<RawFd>) -> raw::c_int { + match fd { + None => libc::AT_FDCWD, + Some(fd) => fd, + } +} + #[cfg(any(target_os = "android", target_os = "linux"))] libc_bitflags!( /// Additional flags for file sealing, which allows for limiting operations on a file. |