summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2023-05-21Clippy cleanup:Alan Somers
fix the new clippy::non_minimal_cfg lint
2023-05-20Merge #2029bors[bot]
2029: Remove 'static mut' usage in features::os::kernel_version. r=asomers a=zachs18 Resolves #2028 Note that this is (AFAICT) the first use of `Atomic*` types in `nix` (other than tests). However, this shouldn't be a portability issue, since `nix` is not `#![no_std]`, and (IIUC) [`std` requires](https://doc.rust-lang.org/std/sync/atomic/#portability) at least loads and stores of pointer-sized atomics (i.e. `AtomicUsize`), which is all this PR uses. Co-authored-by: Zachary S <zasample18+github@gmail.com>
2023-05-09remove unused mut from two variable declarations in sys/socket/mod.rsBob Haarman
This addresses diagnostics like: error: variable does not need to be mutable --> src/sys/socket/mod.rs:1537:13 | 1537 | let mut p = &mut mmsghdr.msg_hdr;
2023-04-29Remove 'static mut' usage in features::os::kernel_version.Zachary S
(re-commit for CI retry after rustix 0.37.18 release)
2023-04-16Merge #2021bors[bot]
2021: Fixing link in rustdoc comments in User::from_name r=asomers a=austinkeeley Link text is correct but the URL goes to the wrong function. Probably just a copy/paste issue from the other function. Co-authored-by: Austin Keeley <austin.keeley@gmail.com>
2023-04-16Quiet a clippy::suspicious_doc_comments lintAlan Somers
2023-04-16Quiet Clippy::manual_slice_size_calculation lintsAlan Somers
2023-04-16Fixing linkAustin Keeley
2023-04-05Merge #2012bors[bot]
2012: Enable socket and select on redox r=asomers a=coolreader18 Co-authored-by: Noa <coolreader18@gmail.com>
2023-04-02Merge #1999bors[bot]
1999: inotify: Add AsFd to allow using with epoll (issue #1998) r=asomers a=VorpalBlade This resolves issue #1998 and allows `Inotify` to be used by `Epoll` by adding AsFd. I'm not entirely sure about the unit test. Maybe it would be possible to do a more comperhensive check by contructing inotify using `from_raw_fd` and checking that I get the same value back. However, that would basically mean duplicating `Inotify::new` and that feels a bit pointless. Another option would be to create an integration test to combine `Inotify` and `Epoll`. Fixes #1998 Co-authored-by: Arvid Norlander <VorpalBlade@users.noreply.github.com>
2023-03-20fix: send ETH_P_ALL in htons formatTodd Neal
2023-03-13Enable select on redoxNoa
2023-03-13Enable socket on redoxNoa
2023-02-19inotify: Add AsFd to allow using with epoll (issue #1998)Arvid Norlander
2023-02-10Merge #1995bors[bot]
1995: Add `AT_EACCESS` to `AtFlags` on all platforms r=asomers a=MatteoNardi On Linux, I need the `AT_EACCESS` flag for `faccessat`: ``` AT_EACCESS Perform access checks using the effective user and group IDs. By default, faccessat() uses the real IDs (like access()). ``` ~~This commit is enabling it for all platforms but redox. I'm not really sure if this is correct of I should have just added a target_os = "linux". A did quick git grep -e AT_EACCESS -e 'AT_REMOVEDIR' on libc and it showed they're available on the same targets, so for consistence I just removed the cfg limitation.~~ CI was helpful and showed me I was wrong: it's undefined on android. Co-authored-by: Matteo Nardi <matteo@exein.io>
2023-02-09Rustier kqueue APIAlan Somers
* Prefer methods instead of functions. * Create a newtype for a kqueue. * Document everything. * Deprecate EVFILT_SENDFILE, because it was never fully implemented upstream. * Add support to the libc_enum! macro to be able to deprecate variants.
2023-02-09Merge #1967bors[bot]
1967: Added LOCAL_PEERPID/LocalPeerPid sockopt for macos r=asomers a=mitsuhiko macOS has a badly documented `LOCAL_PEERPID` sockopt that can be used to retrieve the PID of the connected peer. I intentionally only added this for macOS because I know it exists there, and I'm not sure about ios yet even if it exists there, it's doubtful that the PID information gets any use there. Co-authored-by: Armin Ronacher <armin.ronacher@active-4.com>
2023-02-01Enabled `AtFlags::AT_EACCESS` on all platforms but android and redoxMatteo Nardi
2023-01-31setgroups type mismatches on Solaris #1986gco
2023-01-27Merge #1978bors[bot]
1978: Null-check `libc::group` members before converting r=rtzoeller a=djkoloski This mirrors the approach used for the `From<&libc::passwd> for User` impl. Co-authored-by: David Koloski <djkoloski@gmail.com>
2023-01-24Make `*::from_anything` methods unsafeDavid Koloski
The called function must uphold some invariants about initializing data in order for the calls to `from_anything` to be sound.
2023-01-24Null-check `libc::group` members before convertingDavid Koloski
This mirrors the approach used for the `From<&libc::passwd> for User` impl.
2023-01-17Merge #1971bors[bot]
1971: Document the mount.linux module r=asomers a=asomers Also, deprecate a few flags that should not be used by userland. Co-authored-by: Alan Somers <asomers@gmail.com>
2023-01-15Try enabling LocalPeerPid for iosArmin Ronacher
2023-01-15Document the mount.linux moduleAlan Somers
Also, deprecate a few flags that should not be used by userland.
2023-01-14Added LOCAL_PEERPID/LocalPeerPid sockopt for macosArmin Ronacher
2023-01-13if_nameindex: add illumos targetJohn Gallagher
2023-01-13Merge #1964bors[bot]
1964: Fix endian swap on SocketAddrV6. r=asomers a=aarond10 This is a bug. flowinfo and scope_id should not be byte swapped here. See also https://github.com/nix-rust/nix/issues/1963. Co-authored-by: Aaron Drew <aarond10@gmail.com>
2023-01-13Fix endian swap on SocketAddrV6.Aaron Drew
flowinfo and scope_id should not be byte swapped.
2023-01-10Added `mq_timedreceive` to `::nix::mqueue`.David Collard
2023-01-08feat: I/O safety `ftruncate`Jonathan
2022-12-31fix: clippy::size_of_refJonathan
2022-12-25fix: linux+mips+uclibc unreachable patternXiaobo Liu
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
2022-12-13Added CANbus socket family protocol constants.fpagliughi
2022-12-13Merge #1940bors[bot]
1940: feat: I/O safety for 'sys/select' r=asomers a=SteveLauC #### What this PR does: 1. Adds I/O safety for module `sys/select`. Co-authored-by: Steve Lau <stevelauc@outlook.com>
2022-12-12feat: I/O safety for 'sys/select'Steve Lau
2022-12-11Merge #1923bors[bot]
1923: feat: I/O safety for 'sys/wait' r=asomers a=SteveLauC #### What this PR does: 1. Adds I/O safety for `sys/wait` ---------- Actually, I am not sure about which type to use here: ```rust pub enum Id<'fd> { /// Wait for the child referred to by the given PID file descriptor #[cfg(any(target_os = "android", target_os = "linux"))] PIDFd(RawFd), PIDFd(BorrowedFd<'fd>), } ``` If we use `Fd: AsFd` ```rust pub enum Id<'fd, Fd: AsFd> { /// Wait for the child referred to by the given PID file descriptor #[cfg(any(target_os = "android", target_os = "linux"))] PIDFd(RawFd), PIDFd(&'fd Fd), } ``` then the user has to specify that generic type when using this interface, which is kinda user-unfriendly... ------ The typical usage of this interface will be something like: ```rust // Thought currently we don't have pidfd_open(2) in `Nix` let fd_referring_to_a_process: OwnedFd = pidfd_open().unwrap(); let status = waitid(Id::PIDFd(fd_referring_to_a_process), WaitPidFlag::XXXX).unwrap(); ``` UPDATE: `pidfd_open(2)` will be added in #1859 or #1868 . Co-authored-by: Steve Lau <stevelauc@outlook.com>
2022-12-11Merge #1928 #1938bors[bot]
1928: feat: I/O safety for 'sys/memfd' & 'sys/event' & 'sys/eventfd' r=asomers a=SteveLauC #### What this PR does: Adds I/O safety for moduels: 1. `sys/memfd` 2. `sys/event` 3. `sys/eventfd` ----- BYW, I called `rustfmt` on these 4 files, which introduces some noise, sorry about this. 1938: Deprecate the signalfd function. r=asomers a=asomers The SignalFd type is just as capable and easier to use. CC `@JonathanWoollett-Light` Co-authored-by: Steve Lau <stevelauc@outlook.com> Co-authored-by: Alan Somers <asomers@gmail.com>
2022-12-11Merge #1937bors[bot]
1937: feat: I/O safety for 'poll' r=asomers a=SteveLauC #### What this PR does: 1. Adds I/O safety for module `poll`. Co-authored-by: Steve Lau <stevelauc@outlook.com>
2022-12-11feat: I/O safety for 'sys/poll'Steve Lau
2022-12-11feat: I/O safety for 'sys/wait'Steve Lau
2022-12-11feat: I/O safety for 'sys/memfd' & 'sys/event' & 'sys/eventfd'Steve Lau
2022-12-10Deprecate the signalfd function.Alan Somers
The SignalFd type is just as capable and easier to use.
2022-12-10Merge #1874bors[bot]
1874: signalfd optional file descriptor r=asomers a=JonathanWoollett-Light [`sys::signalfd::signalfd`](https://docs.rs/nix/latest/nix/sys/signalfd/fn.signalfd.html) currently takes a `RawFd` for its `fd` argument. Considering from [the documentation](https://man7.org/linux/man-pages/man2/signalfd.2.html): > If the fd argument is -1, then the call creates a new file descriptor and associates the signal set specified in mask with that file descriptor. If fd is not -1, then it must specify a valid existing signalfd file descriptor, and mask is used to replace the signal set associated with that file descriptor. We can better pass the argument as `Option<BorrowedFd>` which encodes the optional nature of this parameter in an option rather than the value being -1 (invalid) (`size_of::<Option<BorrowedFd>>() == size_of::<RawFd>() == 4`). This removes the error case where `fd < -1`. > EBADF The fd file descriptor is not a valid file descriptor. This does however require additional changes to produce a cohesive implementation, notably changing the type within `Signal` from `RawFd` to `ManuallyDrop<OwnedFd>`, this has no functional affect, but illustrates ownership and allows the type to more easily produce `BorrowedFd`s. To use [`BorrowedFd`](https://doc.rust-lang.org/stable/std/os/unix/io/struct.BorrowedFd.html) requires updating the MSRV to `>= 1.63.0` Co-authored-by: Jonathan <jonathanwoollettlight@gmail.com>
2022-12-10signalfd optional file descriptorJonathan
2022-12-09Formatting only changes for #1928 and #1863Alex Saveau
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-12-09Merge #1913 #1926 #1927 #1931 #1933bors[bot]
1913: feat: I/O safety for 'sys/inotify' r=asomers a=SteveLauC #### What this PR does: 1. Changes the `fd` field of `struct Inotify` from `RawFd` to `OwnedFd` 2. Changes the interfaces of functions in the `impl Inotify {}` > The type of `self` changes from `Self` to `&mut Self`. From: ```rust pub fn add_watch<P: ?Sized + NixPath>( self, path: &P, mask: AddWatchFlags, ) -> Result<WatchDescriptor> pub fn rm_watch(self, wd: WatchDescriptor) -> Result<()> pub fn read_events(self) -> Result<Vec<InotifyEvent>> ``` To: ```rust pub fn add_watch<P: ?Sized + NixPath>( &mut self, path: &P, mask: AddWatchFlags, ) -> Result<WatchDescriptor> pub fn rm_watch(&mut self, wd: WatchDescriptor) -> Result<()> pub fn read_events(&mut self) -> Result<Vec<InotifyEvent>> ``` In the previous implementation, these functions can take `self` by value as `struct Inotify` [was `Copy`](https://docs.rs/nix/latest/nix/sys/inotify/struct.Inotify.html#impl-Copy-for-Inotify). With the changes in `1` applied, `struct Inotify` is no longer `Copy`, so we have to take `self` by reference. ------- Blocks until the merge of #1863 as this PR needs `read(2)` to be I/O-safe. 1926: feat: I/O safety for 'sys/sendfile' r=asomers a=SteveLauC #### What this PR does: 1. Adds I/O safety for module `sys/sendfile`. 1927: feat: I/O safety for 'sys/statvfs' r=asomers a=SteveLauC #### What this PR does: 1. Adds I/O safety for module `sys/statvfs`. 1931: feat: I/O safety for 'sys/uid' & 'sched' r=asomers a=SteveLauC #### What this PR does: Adds I/O safety for modules: 1. `sys/uio` 2. `sched` 1933: feat: I/O safety for 'sys/timerfd' r=asomers a=SteveLauC #### What this PR does: 1. Adds I/O safety for module `sys/timerfd`. Co-authored-by: Steve Lau <stevelauc@outlook.com>
2022-12-09feat: I/O safety for 'sys/timerfd'Steve Lau
2022-12-09feat: I/O safety for 'sys/inotify'Steve Lau
2022-12-09feat: I/O safety for 'sys/sendfile'Steve Lau