It has never actually executed its command, so the only reason that it
ever worked is that on most systems there are usually processes starting
and exiting all the time.
1729: Enable SockaddrStorage::{as_link_addr, as_link_addr_mut} on Linux. r=rtzoeller a=asomers
This was an oversight from #1684.
Fixes#1728
Co-authored-by: Alan Somers <asomers@gmail.com>
1730: Ignore doctests for unexported macros r=asomers a=zombiepigdragon
Due to rust-lang/rust#97030, cargo test will fail to doctest macros unless they are exported, breaking the examples for `libc_bitflags!` and `libc_enum!`.
Adds `ignore` to the examples for these macros to stop tests from failing.
`cargo test` already fails on cargo 1.62.0-beta.2, and the above issue makes it seem unlikely that this will be changed on the Rust side. If rust-lang/rust#96630 *does* get reverted, this PR can be closed/unmerged, although the test wasn't running beforehand, and it might be worth making this explicit regardless.
Co-authored-by: Alex Rawson <ajzecrom@gmail.com>
Due to rust-lang/rust#97030, cargo test will fail to doctest macros
unless they are exported, breaking the examples for libc_bitflags! and
libc_enum!.
Adds `ignore` to the examples for these macros to stop tests from
failing.
1727: Add From<uid_t> and From<gid_t> r=rtzoeller a=vkkoskie
Conversions to/from primitive uid_t and gid_t to newtype Uid and Gid types are valid and infallible, but are only implemented in one direction. This provides the counterparts in the other direction.
These conversions are identical in behavior to the from_raw methods. However, using the more idiomatic From trait enables easier interoperability with other crates (e.g., deserialization with serde)
Co-authored-by: Keith Koskie <vkkoskie@gmail.com>
1722: Fix nightly clippy in tests r=asomers a=rtzoeller
`cargo +nightly clippy --tests` currently produces
```
warning: this let-binding has unit value
--> test/sys/test_uio.rs:256:20
|
256 | loop { let _ = pause(); }
| ^^^^^^^^^^^^^^^^ help: omit the `let` binding: `pause();`
|
= note: `#[warn(clippy::let_unit_value)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
```
Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
1703: add haiku support r=rtzoeller a=hoanga
hello,
the following changeset(s) adds support for compiling on haiku.
below is an sample run showing compilation
```sh
> uname -a
Haiku shredder 1 hrev56040 Apr 22 2022 06:24:48 x86_64 x86_64 Haiku
> cargo build
Compiling autocfg v1.1.0
Compiling libc v0.2.123
Compiling bitflags v1.3.2
Compiling cfg-if v1.0.0
Compiling memoffset v0.6.5
Compiling nix v0.24.1 (/boot/home/src/git/rust-libs/nix)
Finished dev [unoptimized + debuginfo] target(s) in 11.09s
```
and some results from running ```cargo test```:
```sh
running 32 tests
test sys::select::tests::fdset_clear ... ok
test sys::select::tests::fdset_insert ... ok
test sys::select::tests::fdset_highest ... ok
test sys::select::tests::fdset_fds ... ok
test sys::select::tests::fdset_remove ... ok
test sys::signal::tests::test_clear ... ok
test sys::select::tests::test_select ... ok
test sys::select::tests::test_select_nfds2 ... ok
test sys::signal::tests::test_contains ... ok
test sys::select::tests::test_select_nfds ... ok
test sys::signal::tests::test_extend ... ok
test sys::signal::tests::test_from_and_into_iterator ... ok
test sys::signal::tests::test_from_str_invalid_value ... ok
test sys::signal::tests::test_from_str_round_trips ... ok
test sys::signal::tests::test_sigaction ... ok
test sys::signal::tests::test_sigwait ... ok
test sys::signal::tests::test_thread_signal_set_mask ... ok
test sys::statvfs::test::fstatvfs_call ... ok
test sys::statvfs::test::statvfs_call ... ok
test sys::termios::test::try_from ... ok
test sys::signal::tests::test_thread_signal_swap ... ok
test sys::signal::tests::test_thread_signal_block ... ok
test sys::signal::tests::test_thread_signal_unblock ... ok
test sys::time::test::test_timespec ... ok
test sys::time::test::test_timespec_from ... ok
test sys::time::test::test_timespec_neg ... ok
test sys::time::test::test_timespec_fmt ... ok
test sys::time::test::test_timespec_ord ... ok
test sys::time::test::test_timeval ... ok
test sys::time::test::test_timeval_neg ... ok
test sys::time::test::test_timeval_fmt ... ok
test sys::time::test::test_timeval_ord ... ok
test result: ok. 32 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running test/test.rs (target/debug/deps/test-6e8a70ba3d8f7447)
running 73 tests
test sys::test_pthread::test_pthread_kill_none ... ok
test sys::test_pthread::test_pthread_self ... ok
test sys::test_select::test_pselect_nfds2 ... ok
test sys::test_select::test_pselect ... ok
test sys::test_signal::test_kill_none ... ok
test sys::test_signal::test_killpg_none ... ok
test sys::test_signal::test_old_sigaction_flags ... ok
test sys::test_signal::test_signal ... ok
test sys::test_signal::test_sigprocmask ... ok
test sys::test_signal::test_signal_sigaction ... ok
test sys::test_signal::test_sigprocmask_noop ... ok
test sys::test_select::test_fdset_negative_fd::contains - should panic ... ok
test sys::test_select::test_fdset_negative_fd::remove - should panic ... ok
test sys::test_select::test_fdset_negative_fd::insert - should panic ... ok
test sys::test_select::test_fdset_too_large_fd::contains - should panic ... ok
test sys::test_select::test_fdset_too_large_fd::insert - should panic ... ok
test sys::test_select::test_fdset_too_large_fd::remove - should panic ... ok
test sys::test_wait::test_wait_exit ... ok
test sys::test_wait::test_waitid_pid ... ok
test sys::test_uio::test_readv ... ok
test sys::test_wait::test_waitstatus_from_raw ... FAILED
test sys::test_wait::test_waitstatus_pid ... ok
test sys::test_uio::test_writev ... ok
test test_net::test_if_nametoindex ... ok
test test_dir::rewind ... ok
test test_poll::test_pollfd_events ... ok
test test_poll::test_pollfd_fd ... ok
test sys::test_uio::test_pwrite ... ok
test sys::test_uio::test_pread ... ok
test test_fcntl::test_readlink ... ok
test test_fcntl::test_openat ... ok
test test_dir::read ... ok
test test_stat::test_fstatat ... ok
test test_stat::test_mkdirat_fail ... ok
test test_time::test_clock_gettime ... ok
test test_stat::test_fchmod ... ok
test test_stat::test_fchmodat ... ok
test test_time::test_clock_id_now ... ok
test test_fcntl::test_renameat ... ok
test test_stat::test_mkdirat_success_path ... ok
test test_stat::test_stat_and_fstat ... ok
test test_unistd::test_execvpe::test_cstr_ref ... ok
test test_unistd::test_access_not_existing ... ok
test test_unistd::test_execvpe::test_cstring ... ok
test test_unistd::test_access_file_exists ... ok
test test_stat::test_stat_fstat_lstat ... ok
test test_unistd::test_fchdir ... ok
test test_unistd::test_fork_and_waitpid ... ok
test test_unistd::test_fchown ... ok
test test_unistd::test_chown ... ok
test test_unistd::test_getpid ... ok
test test_unistd::test_getsid ... ok
test test_unistd::test_fpathconf_limited ... ok
test test_unistd::test_lseek ... ok
test test_unistd::test_mkfifo_directory ... ok
test test_unistd::test_fchownat ... ok
test test_unistd::test_mkstemp_directory ... ok
test test_unistd::test_pathconf_limited ... ok
test test_unistd::test_pipe ... ok
test test_unistd::test_sysconf_limited ... ok
test test_unistd::test_mkfifo ... ok
test test_unistd::test_ttyname_not_pty ... ok
test test_unistd::test_ftruncate ... ok
test test_unistd::test_mkstemp ... ok
test test_poll::test_poll ... ok
test test_unistd::test_wait ... ok
test test_unistd::test_unlinkat_dir_removedir ... ok
test test_unistd::test_unlinkat_file ... ok
test test_unistd::test_unlinkat_dir_noremovedir ... ok
test test_unistd::test_truncate ... ok
test test_unistd::test_getcwd ... ok
test test_unistd::test_alarm ... ok
test test_unistd::test_canceling_alarm ... ok
failures:
---- sys::test_wait::test_waitstatus_from_raw stdout ----
thread 'sys::test_wait::test_waitstatus_from_raw' panicked at 'assertion failed: `(left == right)`
left: `Ok(Exited(Pid(1), 2))`,
right: `Ok(Signaled(Pid(1), SIGINT, false))`', test/sys/test_wait.rs:93:5
failures:
sys::test_wait::test_waitstatus_from_raw
test result: FAILED. 72 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.06s
error: test failed, to rerun pass '--test test'
```
Co-authored-by: Al Hoang <3811822-hoanga@users.noreply.gitlab.com>
1713: Rewrite the aio module r=rtzoeller a=asomers
The existing AIO implementation has some problems:
1) The in_progress field is checked at runtime, not compile time.
2) The mutable field is checked at runtime, not compile time.
4) A downstream lio_listio user must store extra state to track whether
the whole operation is partially, completely, or not at all
submitted.
4) Nix does heap allocation itself, rather than allowing the caller to
choose it. This can result in double (or triple, or quadruple)
boxing.
5) There's no easy way to use lio_listio to submit multiple operations with
a single syscall, but poll each individually.
6) The lio_listio usage is far from transparent and zero-cost.
7) No aio_readv or aio_writev support.
8) priority has type c_int; should be i32
9) aio_return should return a usize instead of an isize, since it only
uses negative values to indicate errors, which Rust represents via
the Result type.
This rewrite solves several problems:
1) Unsolved. I don't think it can be solved without something like
C++'s guaranteed type elision. It might require changing the
signature of Future::poll too.
2) Solved.
3) Solved, by the new in_progress method and by removing the complicated
lio_listio resubmit code.
4) Solved.
5) Solved.
6) Solved, by removing the lio_listo resubmit code. It can be
reimplemented downstream if necessary. Or even in Nix, but it
doesn't fit Nix's theme of zero-cost abstractions.
7) Solved.
8) Solved.
9) Solved.
Co-authored-by: Alan Somers <asomers@gmail.com>
The existing AIO implementation has some problems:
1) The in_progress field is checked at runtime, not compile time.
2) The mutable field is checked at runtime, not compile time.
3) A downstream lio_listio user must store extra state to track whether
the whole operation is partially, completely, or not at all
submitted.
4) Nix does heap allocation itself, rather than allowing the caller to
choose it. This can result in double (or triple, or quadruple)
boxing.
5) There's no easy way to use lio_listio to submit multiple operations with
a single syscall, but poll each individually.
6) The lio_listio usage is far from transparent and zero-cost.
7) No aio_readv or aio_writev support.
8) priority has type c_int; should be i32
9) aio_return should return a usize instead of an isize, since it only
uses negative values to indicate errors, which Rust represents via
the Result type.
This rewrite solves several problems:
1) Unsolved. I don't think it can be solved without something like
C++'s guaranteed type elision. It might require changing the
signature of Future::poll too.
2) Solved.
3) Solved, by the new in_progress method and by removing the complicated
lio_listio resubmit code.
4) Solved.
5) Solved.
6) Solved, by removing the lio_listo resubmit code. It can be
reimplemented downstream if necessary. Or even in Nix, but it
doesn't fit Nix's theme of zero-cost abstractions.
7) Solved.
8) Solved.
9) Solved.
The rewrite includes functions that don't work on FreeBSD, so add CI
testing for FreeBSD 14 too.
By default only enable tests that will pass on FreeBSD 12.3. But run a
CI job on FreeBSD 14 and set a flag that will enable such tests.
1720: Fix a warning on Redox with the latest nightly compiler. r=rtzoeller a=asomers
It just so happens that Redox doesn't use any of the libc_enum entries
that aren't followed by a comma.
Co-authored-by: Alan Somers <asomers@gmail.com>
1699: Revert "Pin nightly compiler used in CI for uclibc" r=rtzoeller a=asomers
This reverts commit 23f18dfc18.
libc v0.2.124 fixes the problem.
Co-authored-by: Alan Somers <asomers@gmail.com>
1716: Future-proof the kevent ABI r=rtzoeller a=asomers
FreeBSD 12 changes struct kevent. For now, libc always binds to the
11-compat ABI. But that will change some day. Adjust Nix's code to
build with either struct definition.
Co-authored-by: Alan Somers <asomers@gmail.com>
1717: Define FsType constants for musl r=asomers a=jirutka
These constants are provided by Linux (linux/magic.h), not libc.
See rust-lang/libc#2639.
Co-authored-by: Jakub Jirutka <jakub@jirutka.cz>
FreeBSD 12 changes struct kevent. For now, libc always binds to the
11-compat ABI. But that will change some day. Adjust Nix's code to
build with either struct definition.
1708: Upgrade dev-dependencies to the latest versions r=asomers a=rtzoeller
Don't change how the versions are specified (i.e. whether a patch version is listed).
parking_lot cannot be upgraded due to 0.12.0 bumping the MSRV to 1.49.
In many cases, nix was one of the only consumers of the current versions (i.e. we are late to upgrade).
Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
Don't change how the versions are specified (i.e. whether a patch
version is listed).
parking_lot cannot be upgraded due to 0.12.0 bumping the MSRV to 1.49.
In many cases, nix was one of the only consumers of the current versions
(i.e. we are late to upgrade).
1707: Upgrade sysctl to 0.4 r=asomers a=rtzoeller
Upgrade sysctl dev-dependency to 0.4 and handle its breaking API changes.
Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
1702: Fix UnixAddr::size on Linux and Android r=rtzoeller a=asomers
SockaddrLike::size() is meant to return the amount of space that can be
used to store the sockaddr. But on Linux-based OSes, UnixAddr contains
an extra field to store the address's length. This field is not part of
the address, and should not contribute to the value of size().
This bug can't cause an out-of-bounds write, and every OS that we test
on can tolerate the greater-than-expected length, but it might confuse
applications that implement functions similar to getsockname in
userland.
Co-authored-by: Alan Somers <asomers@gmail.com>
SockaddrLike::size() is meant to return the amount of space that can be
used to store the sockaddr. But on Linux-based OSes, UnixAddr contains
an extra field to store the address's length. This field is not part of
the address, and should not contribute to the value of size().
This bug can't cause an out-of-bounds write, and every OS that we test
on can tolerate the greater-than-expected length, but it might confuse
applications that implement functions similar to getsockname in
userland.
1694: Use singular number for all feature names r=rtzoeller a=asomers
features => feature
users => user
Neither of these features have yet been included in a release, so it's
ok to rename them.
Co-authored-by: Alan Somers <asomers@gmail.com>
1643: Replace the IoVec struct with IoSlice and IoSliceMut from the standard library r=asomers a=notgull
As per discussion in #1637, the `IoVec<&[u8]>` and `IoVec<&mut [u8]>` types have been replaced with `std::io::IoSlice` and `IoSliceMut`, respectively. Notable changes made in this pull request include:
- The complete replacement of `IoVec` with `IoSlice*` types in both public API, private API, and tests.
- Replacing `IoVec` with `IoSlice` in docs.
- Replacing `&[IoVec<&mut [u8]>]` with `&mut [IoSliceMut]`, note that the slice requires a mutable reference now. This is how it's done in the standard library, and there might be a soundness issue in doing it the other way.
Resolves#1637
Co-authored-by: not_a_seagull <notaseagull048@gmail.com>