Commit Graph

2551 Commits

Author SHA1 Message Date
Alan Somers
c8a9cf3351 Fix the test_acct test
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.
2022-06-07 20:10:46 -06:00
bors[bot]
5dedbc7850
Merge #1729
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>
2022-05-31 23:57:45 +00:00
bors[bot]
b53dfa87c3
Merge #1730
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>
2022-05-31 23:36:31 +00:00
Alex Rawson
0ac338b744 Ignore doctests for unexported macros
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.
2022-05-31 17:51:45 -05:00
Alan Somers
1520d7b316 Enable SockaddrStorage::{as_link_addr, as_link_addr_mut} on Linux.
This was an oversight from #1684.

Fixes #1728
2022-05-31 10:42:35 -06:00
bors[bot]
7e8757f4df
Merge #1727
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>
2022-05-30 22:36:43 +00:00
Keith Koskie
51f1ef33a4 Add infallible conversion from uid_t and gid_t
Implements the following traits:
* From<uid_t> for Uid
* From<gid_t> for Gid
2022-05-30 18:28:56 -04:00
bors[bot]
e3932c466f
Merge #1725
1725: Use released libc version 0.2.126 r=rtzoeller a=asomers



Co-authored-by: Alan Somers <asomers@gmail.com>
2022-05-30 21:20:55 +00:00
bors[bot]
20d2edb706
Merge #1726
1726: Clippy cleanup for latest nightly r=rtzoeller a=asomers



Co-authored-by: Alan Somers <asomers@gmail.com>
2022-05-30 21:04:55 +00:00
Alan Somers
6f1c748938 Clippy cleanup for latest nightly 2022-05-29 14:00:48 -06:00
Alan Somers
06f0446d90 Use released libc version 0.2.126 2022-05-29 13:10:50 -06:00
bors[bot]
b0ab5573ea
Merge #1722
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>
2022-05-16 04:49:20 +00:00
Ryan Zoeller
598925c78f Fix nightly clippy in tests 2022-05-15 23:32:24 -05:00
bors[bot]
6639c59618
Merge #1697
1697: Add ptrace::read_user and ptrace::write_user r=rtzoeller a=nbaksalyar



Co-authored-by: Nikita Baksalyar <nikita.baksalyar@gmail.com>
2022-05-15 23:04:06 +00:00
Nikita Baksalyar
c1c1c6cfe4 Add ptrace::read_user and ptrace::write_user 2022-05-15 23:36:02 +01:00
bors[bot]
1647189816
Merge #1703
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>
2022-05-15 00:20:01 +00:00
Al Hoang
d02e27476c add haiku support
* enabled as much functionality and defines that match
  updated libc definitions for haiku
2022-05-14 18:45:18 -05:00
bors[bot]
69738c0fd0
Merge #1713
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>
2022-05-14 20:17:18 +00:00
Alan Somers
0c07a9e469 Rewrite the aio module
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.
2022-05-14 13:34:11 -06:00
bors[bot]
1c36d49c0b
Merge #1720
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>
2022-05-14 07:04:06 +00:00
Alan Somers
7dff51fbfc Fix "unused_macro_rules" warnings with the latest nightly compiler.
It just so happens that Redox, OpenBSD, Dragonfly, and uclibc don't use
some of the rules for two internal macros.
2022-05-13 21:01:21 -06:00
bors[bot]
6f57f2e11d
Merge #1699
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>
2022-05-11 02:34:14 +00:00
bors[bot]
db41e0b356
Merge #1716
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>
2022-05-09 13:25:37 +00:00
bors[bot]
68f36314e1
Merge #1717
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>
2022-05-07 17:40:43 +00:00
Jakub Jirutka
23f1787d3b Define FsType constants for musl
These constants are provided by Linux (linux/magic.h), not libc.

See rust-lang/libc#2639.
2022-05-07 19:20:35 +02:00
Alan Somers
b4fb5eec7d Future-proof the kevent ABI
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.
2022-05-07 08:12:12 -06:00
bors[bot]
11912bb88e
Merge #1715
1715: Log compiler version in Cirrus CI r=asomers a=rtzoeller



Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-05-07 03:25:32 +00:00
Ryan Zoeller
ad7d45a0bf Log compiler version in Cirrus CI 2022-05-06 22:07:05 -05:00
bors[bot]
3109a6dab4
Merge #1711
1711: Restore conversions from ip v4/6 Sockaddr types to std::net equivalents. r=asomers a=khuey

Fixes #1710

Co-authored-by: Kyle Huey <khuey@kylehuey.com>
2022-05-03 03:28:41 +00:00
Kyle Huey
024c0d7dde Restore conversions from ip v4/6 Sockaddr types to std::net equivalents.
Fixes #1710
2022-05-02 08:53:08 -07:00
bors[bot]
4d79e93904
Merge #1712
1712: Create new Unreleased changelog section r=asomers a=rtzoeller



Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-04-30 23:48:30 +00:00
Ryan Zoeller
bf2fa038cd Create new Unreleased changelog section 2022-04-30 18:12:39 -05:00
bors[bot]
e2f534d7c1
Merge #1708
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>
2022-04-26 23:45:07 +00:00
Ryan Zoeller
fee16e27e1 Upgrade dev-dependencies to the latest versions
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).
2022-04-24 21:14:01 -05:00
bors[bot]
686349a75f
Merge #1707
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>
2022-04-25 01:02:18 +00:00
Ryan Zoeller
e543733a4c Upgrade sysctl to 0.4
Upgrade sysctl dev-dependency to 0.4 and handle its breaking API changes.
2022-04-24 19:25:16 -05:00
Ryan Zoeller
f1a1e2d7c5 (cargo-release) version 0.24.1 2022-04-22 18:46:23 -05:00
bors[bot]
28548883eb
Merge #1702
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>
2022-04-22 21:19:50 +00:00
Alan Somers
db969c59e9 Fix UnixAddr::size on Linux and Android
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.
2022-04-22 14:40:42 -06:00
bors[bot]
9793aafb9c
Merge #1701
1701: Document pushing the release tag to GitHub r=asomers a=rtzoeller



Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-04-21 21:16:39 +00:00
Ryan Zoeller
a06114a99d Document pushing the release tag to GitHub 2022-04-21 16:05:06 -05:00
Ryan Zoeller
7f5907c78d (cargo-release) version 0.24.0 2022-04-20 21:47:48 -05:00
Alan Somers
c5927f3dab Revert "Pin nightly compiler used in CI for uclibc"
This reverts commit 23f18dfc18.

libc v0.2.124 fixes the problem.
2022-04-18 20:23:23 -06:00
bors[bot]
bfb290bf2b
Merge #1698
1698: Update FreeBSD CI image to 12.3.  12.2 is EoL. r=rtzoeller a=asomers



Co-authored-by: Alan Somers <asomers@gmail.com>
2022-04-15 01:44:05 +00:00
bors[bot]
f05789cd22
Merge #1694
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>
2022-04-15 01:24:59 +00:00
Alan Somers
7497b8a9e5 Update FreeBSD CI image to 12.3. 12.2 is EoL. 2022-04-14 09:31:19 -06:00
Alan Somers
23f18dfc18 Pin nightly compiler used in CI for uclibc
Workaround for https://github.com/rust-lang/rust/issues/95866
2022-04-10 12:40:31 -06:00
Alan Somers
145c240cfa Use singular number for all feature names
features => feature
users => user

Neither of these features have yet been included in a release, so it's
ok to rename them.
2022-04-09 16:32:39 -06:00
bors[bot]
256707e8c7
Merge #1643
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>
2022-04-08 20:05:41 +00:00
not_a_seagull
0b58f29772 Replace the IoVec type with IoSlice and IoSliceMut 2022-04-08 12:39:16 -07:00