From 9f178f1ca2434a2ccf87ca9efe35fd3934d35754 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 29 Nov 2023 18:29:28 +0000 Subject: [PATCH] changes from review --- src/unistd.rs | 97 +++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/src/unistd.rs b/src/unistd.rs index cd50ae3c2b..44348e69c6 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -2914,14 +2914,9 @@ mod getres { feature! { #![feature = "process"] #[cfg(target_os = "freebsd")] -pub mod rfork_freebsd { - use crate::errno::Errno; - use crate::Result; - use super::ForkResult; - use super::Pid; - libc_bitflags! { /// Flags for [`rfork`] + /// /// subset of flags supported by FreeBSD 12.x and onwards /// with a safe outcome, thus as `RFMEM` can possibly lead to undefined behavior, /// it is not in the list. And `rfork_thread` is deprecated. @@ -2935,6 +2930,11 @@ pub mod rfork_freebsd { RFFDG; /// a new file descriptor's table will be created RFCFDG; + /// force sharing the sigacts structure between + /// the child and the parent. + /// + /// FIXME: waiting to be in the libc's crate. + // RFSIGSHARE; /// enables kernel thread support. RFTHREAD; /// sets a status to emit at child's exit. @@ -2949,7 +2949,7 @@ pub mod rfork_freebsd { /// and parent process will be sharing, file descriptors, address spaces /// and child exit's behavior. pub unsafe fn rfork(flags: RforkFlags) -> Result { - let res = libc::rfork(flags.bits()); + let res = unsafe { libc::rfork(flags.bits()) }; use ForkResult::*; Errno::result(res).map(|res| match res { @@ -2958,7 +2958,6 @@ pub mod rfork_freebsd { }) } } -} #[cfg(feature = "fs")] libc_bitflags! { @@ -2979,50 +2978,50 @@ libc_bitflags! { feature! { #![feature = "fs"] - /// Checks the file named by `path` for accessibility according to the flags given by `amode` - /// See [access(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/access.html) - pub fn access(path: &P, amode: AccessFlags) -> Result<()> { - let res = path.with_nix_path(|cstr| unsafe { - libc::access(cstr.as_ptr(), amode.bits()) - })?; - Errno::result(res).map(drop) - } +/// Checks the file named by `path` for accessibility according to the flags given by `amode` +/// See [access(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/access.html) +pub fn access(path: &P, amode: AccessFlags) -> Result<()> { + let res = path.with_nix_path(|cstr| unsafe { + libc::access(cstr.as_ptr(), amode.bits()) + })?; + Errno::result(res).map(drop) +} - /// Checks the file named by `path` for accessibility according to the flags given by `mode` - /// - /// If `dirfd` has a value, then `path` is relative to directory associated with the file descriptor. - /// - /// If `dirfd` is `None`, then `path` is relative to the current working directory. - /// - /// # References - /// - /// [faccessat(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/faccessat.html) - // redox: does not appear to support the *at family of syscalls. +/// Checks the file named by `path` for accessibility according to the flags given by `mode` +/// +/// If `dirfd` has a value, then `path` is relative to directory associated with the file descriptor. +/// +/// If `dirfd` is `None`, then `path` is relative to the current working directory. +/// +/// # References +/// +/// [faccessat(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/faccessat.html) +// redox: does not appear to support the *at family of syscalls. #[cfg(not(target_os = "redox"))] - pub fn faccessat( - dirfd: Option, - path: &P, - mode: AccessFlags, - flags: AtFlags, - ) -> Result<()> { - let res = path.with_nix_path(|cstr| unsafe { - libc::faccessat( - at_rawfd(dirfd), - cstr.as_ptr(), - mode.bits(), - flags.bits(), - ) - })?; - Errno::result(res).map(drop) - } +pub fn faccessat( + dirfd: Option, + path: &P, + mode: AccessFlags, + flags: AtFlags, +) -> Result<()> { + let res = path.with_nix_path(|cstr| unsafe { + libc::faccessat( + at_rawfd(dirfd), + cstr.as_ptr(), + mode.bits(), + flags.bits(), + ) + })?; + 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) +/// 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( freebsdlike, all(target_os = "linux", not(target_env = "uclibc")),