Commit Graph

2433 Commits

Author SHA1 Message Date
Ryan Zoeller
3b00f37bfb Fix typo in pread docs 2022-01-29 22:50:29 -06:00
bors[bot]
5cd01a1fd7
Merge #1603
1603: uclibc support r=rtzoeller a=skrap

uclibc is a libc alternative (peer to glibc and musl) which is used in low-resource embedded linux applications.

It's supported in rust as the `target_env` of several tier 3 targets, but `nix` currently doesn't build.  This patch provides a few customizations to get uclibc building.

To test:
* Get nightly rust
* Follow directions for getting a cross toolchain and env setup here: https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/armv7-unknown-linux-uclibceabihf.md

Thanks for your consideration!



Co-authored-by: Jonah Petri <jonah@petri.us>
2022-01-25 03:37:44 +00:00
Jonah Petri
6c4b9133f1 uclibc support 2022-01-24 10:06:35 -05:00
bors[bot]
ae2b7b3552
Merge #1642
1642: InetAddr::from_std should set sin_len/sin6_len on the BSDs r=asomers a=rtzoeller

Resolves #1246.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-23 21:56:25 +00:00
bors[bot]
4c3001b0b2
Merge #1644
1644: Make memoffset dependency optional r=asomers a=rtzoeller

Only the socket feature depends on memoffset. Allow clients to skip pulling memoffset in as a dependency if they don't need it.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-23 21:42:01 +00:00
Ryan Zoeller
50d22ce0e5 Make memoffset dependency optional
Only the socket feature depends on memoffset. Allow clients to skip
pulling memoffset in as a dependency if they don't need it.
2022-01-23 14:52:02 -06:00
Ryan Zoeller
ad7e3c719c InetAddr::from_std should set sin_len/sin6_len on the BSDs 2022-01-23 13:26:32 -06:00
bors[bot]
8ee93662e7
Merge #1640
1640: Add fspacectl on FreeBSD r=rtzoeller a=asomers



Co-authored-by: Alan Somers <asomers@gmail.com>
2022-01-23 16:36:20 +00:00
Alan Somers
e2ce5efece Disable the fspacectl tests
They fail to link prior to FreeBSD 14.0, which we don't use in CI.  So
mark them as no_run.  The only alternative I see would be to add a build
script.
2022-01-23 08:37:56 -07:00
Alan Somers
5419c79601 Add fspacectl on FreeBSD 2022-01-23 07:41:08 -07:00
bors[bot]
0c02ee2630
Merge #1639
1639: Fix Clippy warnings on FreeBSD with the latest nightly r=rtzoeller a=asomers

* Better type safety for mqueue
* Suppress clippy::not_unsafe_ptr_arg_deref warnings in ptrace on BSD

Co-authored-by: Alan Somers <asomers@gmail.com>
2022-01-23 01:57:04 +00:00
Alan Somers
91049bc03b Suppress clippy::not_unsafe_ptr_arg_deref warnings in ptrace on BSD
Technically these functions don't violate Rust's safety rules, because
libc::ptrace doesn't dereference those pointer args.  Instead, it passes
them directly to the kernel.
2022-01-22 14:48:48 -07:00
Alan Somers
475da53d56 Better type safety for mqueue
On some platforms, mqd_t is a pointer.  That means code like the below
can trigger a segfault.  Fix it by defining a Newtype around mqd_t that
prevents use-after-free and dangling pointer scenarios.

```rust
fn invalid_mqd_t() {
    let mqd: libc::mqd_t = std::ptr::null_mut();
    mq_close(mqd).unwrap();
}
```

Also, get test coverage for mqueue in CI on FreeBSD.
2022-01-22 14:48:48 -07:00
bors[bot]
c84316b7fc
Merge #1636
1636: Add MAP_FIXED_NOREPLACE on Linux r=rtzoeller a=rtzoeller

Resolves #1393.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-19 13:55:51 +00:00
bors[bot]
c3731f1e7c
Merge #1634
1634: Define UMOUNT_NOFOLLOW, FUSE_SUPER_MAGIC r=rtzoeller a=rtzoeller

Resolves #1631 and resolves  #1633.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-18 23:13:55 +00:00
Ryan Zoeller
65039212d1 Define UMOUNT_NOFOLLOW, FUSE_SUPER_MAGIC on Linux
Requested-by: jiangliu
2022-01-18 16:52:23 -06:00
Ryan Zoeller
5f0072130e Add MAP_FIXED_NOREPLACE on Linux 2022-01-18 16:48:12 -06:00
bors[bot]
18d1f62b15
Merge #1635
1635: Remove EventFlag::EV_SYSFLAG r=rtzoeller a=rtzoeller

It is not stable across OpenBSD versions and is reserved by the system on FreeBSD and NetBSD.

This should fix the nix build for OpenBSD, which is failing due to https://github.com/rust-lang/libc/pull/2596. Bump the libc dependency to uptake that change.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-18 22:26:20 +00:00
Ryan Zoeller
84e3c56bcc Remove EventFlag::EV_SYSFLAG
It is not stable across OpenBSD versions and is reserved by the system
on FreeBSD and NetBSD.
2022-01-16 10:17:05 -06:00
bors[bot]
916bbfac03
Merge #1610
1610: Re-enable deprecation warnings on DragonFly r=asomers a=rtzoeller

Reverts 0df82ded47 and ac159d9c4e.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-13 04:44:46 +00:00
Ryan Zoeller
3674d58b6f Re-enable deprecation warnings on DragonFly
Use latest nightly compiler.
2022-01-12 22:03:55 -06:00
bors[bot]
f8e27505f5
Merge #1630
1630: Change port used by test_txtime to avoid conflict r=asomers a=rtzoeller

The socket tests request specific ports, and `test_timestamping` and `test_txtime` are currently conflicting in the port they request.

This leads to the second of the tests failing with `EADDRINUSE` when run locally.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-11 05:15:35 +00:00
bors[bot]
b641788f8f
Merge #1628
1628: Add getresuid/gid and setresuid/gid on BSDs r=asomers a=rtzoeller



Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-11 05:00:16 +00:00
Ryan Zoeller
ebd4acebc0 Change port used by test_txtime to avoid conflict 2022-01-10 21:57:55 -06:00
Ryan Zoeller
1b32230831 Add getresuid/gid and setresuid/gid on BSDs 2022-01-10 20:14:34 -06:00
bors[bot]
f6268d9844
Merge #1615
1615: Add sendfile(2) for DragonFly r=rtzoeller a=rtzoeller

The code is copied from the Mac OS and FreeBSD implementations.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-04 02:23:30 +00:00
Ryan Zoeller
4d5c090fcf Add sendfile(2) for DragonFly 2022-01-03 04:05:09 -06:00
bors[bot]
e4e17f2969
Merge #1625
1625: Correct MAP_FIXED documentation for NetBSD r=rtzoeller a=rtzoeller

The previous documentation described the default behavior, rather than the behavior when the flag was set.

Also fix a test which is failing due to passing this flag erroneously.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-03 00:19:50 +00:00
Ryan Zoeller
b7dd35e9b3 Correct MAP_FIXED documentation for NetBSD
The previous documentation described the default behavior, rather than
the behavior when the flag was set.

Also fix a test which is failing due to passing this flag erroneously.
2022-01-02 16:53:42 -06:00
bors[bot]
c1abab9714
Merge #1624
1624: Fix mq tests on NetBSD and DragonFly r=asomers a=rtzoeller

NetBSD (and DragonFly, which borrows its implementation) include additional flags beyond O_NONBLOCK in MqAttr, such as the flags passed to mq_open(). Modify the mq tests to validate _at least_ the expected flags are set, but don't require strict equality on these platforms.

Verified these tests pass on DragonFly and NetBSD locally.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-02 22:32:19 +00:00
bors[bot]
5359b8e945
Merge #1626
1626: Fix intermittency in test_timer::alarm_fires r=rtzoeller a=asomers

The test was disabling the signal handler before disabling the timer.
Fix intermittent failures but reversing the cleanup order.

Also, speed up the timer to make the test suite complete faster.

Co-authored-by: Alan Somers <asomers@gmail.com>
2022-01-02 22:18:03 +00:00
Alan Somers
e5b9b972b2 Fix intermittency in test_timer::alarm_fires
The test was disabling the signal handler before disabling the timer.
Fix intermittent failures by:
* Reversing the cleanup order.
* Sleeping for a while before removing the signal handler, since POSIX
  does not guarantee that timer_delete will clear pending signals.

Also, speed up the timer to make the test suite complete faster.
2022-01-02 15:06:24 -07:00
Ryan Zoeller
58d7c04dfb Fix mq tests on NetBSD and DragonFly
NetBSD (and DragonFly, which borrows its implementation) include
additional flags beyond O_NONBLOCK in MqAttr, such as the flags
passed to mq_open().
2022-01-01 22:44:56 -06:00
bors[bot]
ee0543f126
Merge #1622 #1623
1622: Introduce `timer_*` support  r=asomers a=blt

This commit adds support for the signal timer mechanism in POSIX, the mirror to timerfd on Linux. I wasn't _quite_ sure of how to fit into the project organization but hopefully this patch isn't too far off.

Resolves #1424

Signed-off-by: Brian L. Troutwine <brian@troutwine.us>

1623: Remove cc dependency on DragonFly r=asomers a=rtzoeller

f5ee22db48 removed the need for this dependency.

Co-authored-by: Brian L. Troutwine <brian@troutwine.us>
Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2021-12-31 20:49:28 +00:00
bors[bot]
b5a23c775c
Merge #1618
1618: Refactor UnixAddr r=asomers a=asomers

* Within UnixAddr, replace the path_len variable (length of the sun_path
    field) with sun_len (length of the whole structure).  This is more
    similar to how other sockaddr types work, and it's the same way that the
    BSDs use the sun_len field.
    
    Also, don't require that sun_path be nul-terminated. The OS doesn't
    require it.

* On BSD-derived operating systems, struct sockaddr has a sa_len field
    that holds the length of the structure.  UnixAddr's path_len field is
    redundant.  Remove path_len on BSD-derived OSes, retaining it only for
    Illumos and Linux-based OSes.

Co-authored-by: Alan Somers <asomers@gmail.com>
2021-12-31 20:36:17 +00:00
Brian L. Troutwine
77febe0e6b
Introduce timer_* support
This commit adds support for the signal timer mechanism in POSIX, the
mirror to timerfd on Linux.

Resolves #1424

Signed-off-by: Brian L. Troutwine <brian@troutwine.us>
2021-12-30 20:40:48 -08:00
Alan Somers
f7b62f607c Optimize UnixAddr for the BSDs
On BSD-derived operating systems, struct sockaddr has a sa_len field
that holds the length of the structure.  UnixAddr's path_len field is
redundant.  Remove path_len on BSD-derived OSes, retaining it only for
Illumos and Linux-based OSes.

Also, ensure that two UnixAddrs compare equal if they differ only by the
presence of a trailing NUL.  On Linux, syscalls like getsockname add a
trailing NUL to the sockaddr they return, even if no NUL was present on
the sockaddr originally passed to the kernel via a syscall like bind,
and even though the docs explicitly say that any NUL passed to bind is
not considered to be part of the address.  Work around this bug by
stripping it in UnixAddrKind::get(), so that at least two UnixAddrs will
compare identical even if they differ in the presence of a trailing NUL.
2021-12-30 21:00:32 -07:00
Ryan Zoeller
d74bbe6539 Remove cc dependency on DragonFly
f5ee22db48 removed the need for this dependency.
2021-12-30 20:57:20 -06:00
bors[bot]
b9eb19778a
Merge #1564
1564: Add support for the SO_TXTIME sockopt and SCM_TXTIME control message r=asomers a=ghedo



Co-authored-by: Alessandro Ghedini <alessandro@cloudflare.com>
2021-12-30 02:30:44 +00:00
Alessandro Ghedini
a9829853df Add support for the SO_TXTIME sockopt and SCM_TXTIME control message 2021-12-29 14:15:54 +00:00
bors[bot]
c77a8728b5
Merge #1619
1619: Added getters for the MqAttr struct r=rtzoeller a=fpagliughi

With the existing code, if you call `mq_getattr()`, there does not appear to be a way to get any of the attributes from the returned `MqAttr` struct, other than the flags. This adds getter functions to retrieve the size parameters of the queue, and the current number of messages in the queue.

Co-authored-by: fpagliughi <fpagliughi@mindspring.com>
2021-12-28 01:25:33 +00:00
fpagliughi
80f447b2ac Added getters for the MqAttr struct 2021-12-27 13:50:13 -05:00
bors[bot]
2043bceb5b
Merge #1596 #1621
1596: Add NetBSD configuration for supported process resources r=asomers a=schctl

In addition to existing resources, NetBSD supports `RLIMIT_MEMLOCK`, `RLIMIT_NPROC` and `RLIMIT_RSS`.

https://man.netbsd.org/setrlimit.2

`RLIMIT_AS` is also supported, but it looks like it was added [after version 5.0](https://mail-index.netbsd.org/tech-kern/2009/03/28/msg004702.html), so I'm not sure if that should be enabled.

1621: Add posix_fallocate on DragonFly r=asomers a=rtzoeller

Enable the existing `posix_fallocate()` tests as they are passing locally.

Co-authored-by: Sachin Cherian <sachinctl@protonmail.com>
Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2021-12-27 18:48:12 +00:00
bors[bot]
83cd1da91f
Merge #1620
1620: Fix typos in documentation r=asomers a=rtzoeller



Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2021-12-27 18:33:19 +00:00
Ryan Zoeller
1eeccb942e Add posix_fallocate on DragonFly 2021-12-27 02:56:19 -06:00
Ryan Zoeller
57f41a8898 Fix typos 2021-12-26 20:14:50 -06:00
bors[bot]
a392647f45
Merge #1547
1547: feat: Add glibc::SOF_TIMESTAMPING_* support r=asomers a=pacak

Support for kernel and hardware receive timestamps

Co-authored-by: Michael Baikov <manpacket@gmail.com>
2021-12-24 22:20:36 +00:00
bors[bot]
d38a6567de
Merge #1616
1616: Disable mknod and mknodat tests on DragonFly r=asomers a=rtzoeller

Like FreeBSD, DragonFly does not support creating regular files (i.e. `S_IFREG`) with `mknod` or `mknodat`. These tests should be disabled as they always fail.

There are still a few other failing tests on DragonFly, but it is unclear to me if they are due to faulty/inapplicable test logic or a bug in DragonFly.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2021-12-24 22:03:16 +00:00
Ryan Zoeller
9fe9432181 Disable mknod and mknodat tests on DragonFly 2021-12-24 21:47:39 -06:00
bors[bot]
7be98a4379
Merge #1614
1614: Improve the sockaddr interface: r=asomers a=asomers

* All sockaddr newtypes should be repr(transparent)
* All sockaddr newtypes should be opaque, so the user can't do something
  like change the sa_family field in a way that violates invariants.

This is a prerequisite for #1544.

Co-authored-by: Alan Somers <asomers@gmail.com>
2021-12-24 20:38:53 +00:00