summaryrefslogtreecommitdiff
path: root/src/unistd.rs
diff options
context:
space:
mode:
authorSteve Lau <stevelauc@outlook.com>2022-10-13 09:23:09 +0800
committerSteve Lau <stevelauc@outlook.com>2022-10-13 09:23:09 +0800
commit04e409b376615080e1d910e302b28b144dcbff71 (patch)
treeb2cdffd291499aeeac418e74f463555f915305aa /src/unistd.rs
parentb06b216f6e58e6e69d901b8f9fb836c43cd27323 (diff)
downloadnix-04e409b376615080e1d910e302b28b144dcbff71.zip
add eaccess on FreeBSD, DragonFly and Linux (musl and glibc)
Diffstat (limited to 'src/unistd.rs')
-rw-r--r--src/unistd.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/unistd.rs b/src/unistd.rs
index 5be59b6c..dc452d2d 100644
--- a/src/unistd.rs
+++ b/src/unistd.rs
@@ -2931,6 +2931,27 @@ pub fn faccessat<P: ?Sized + NixPath>(dirfd: Option<RawFd>, path: &P, mode: Acce
})?;
Errno::result(res).map(drop)
}
+
+/// Checks the file named by `path` for accessibility according to the flags given
+/// by `mode` using effective UID, effective GID and supplementary group lists.
+///
+/// # References
+///
+/// * [FreeBSD man page](https://www.freebsd.org/cgi/man.cgi?query=eaccess&sektion=2&n=1)
+/// * [Linux man page](https://man7.org/linux/man-pages/man3/euidaccess.3.html)
+#[cfg(any(
+ all(target_os = "linux", not(target_env = "uclibc")),
+ target_os = "freebsd",
+ target_os = "dragonfly"
+))]
+pub fn eaccess<P: ?Sized + NixPath>(path: &P, mode: AccessFlags) -> Result<()> {
+ let res = path.with_nix_path(|cstr| {
+ unsafe {
+ libc::eaccess(cstr.as_ptr(), mode.bits)
+ }
+ })?;
+ Errno::result(res).map(drop)
+}
}
feature! {