Age | Commit message (Collapse) | Author |
|
repr(transparent) is required in order to safely cast between an FFI
type and its NewType. This commit applies that attribute to PollFd,
EpollEvent, IpMembershipRequest, Ipv6MembershipRequest, TimeVal, and
IoVec.
Fixes #1241
|
|
See https://netbsd.gw.com/cgi-bin/man-cgi?pipe2+2+NetBSD-current and
http://man7.org/linux/man-pages/man2/pipe.2.html
|
|
1231: Add support for reading symlinks longer than `PATH_MAX` to `readlink` and `readlinkat` r=asomers a=SolraBizna
This is in response to issue #1178.
The new logic uses the following approach.
- At any time, if `readlink` returns an error, or a value ≥ 0 and < (not ≤!) the buffer size, we're done.
- Attempt to `readlink` into a `PATH_MAX` sized buffer. (This will almost always succeed, and saves a system call over calling `lstat` first.)
- Try to `lstat` the link. If it succeeds and returns a sane value, allocate the buffer to be that large plus one byte. Otherwise, allocate the buffer to be `PATH_MAX.max(128) << 1` bytes.
- Repeatedly attempt to `readlink`. Any time its result is ≥ (not >!) the buffer size, double the buffer size and try again.
While testing this, I discovered that ext4 doesn't allow creation of a symlink > 4095 (Linux's `PATH_MAX` minus one) bytes long. This is in spite of Linux happily allowing paths in other contexts to be longer than this—including on ext4! This was probably instated to avoid breaking programs that assume `PATH_MAX` will always be enough, but ironically hindered my attempt to test support for *not* assuming. I tested the code using an artificially small `PATH_MAX` and (separately) a wired-to-fail `lstat`. `strace` showed the code behaving precisely as expected. Unfortunately, I can't add an automatic test for this.
Other changes made by this PR:
- `wrap_readlink_result` now calls `shrink_to_fit` on the buffer before returning, potentially reclaiming kilobytes of memory per call. This could be very important if the returned buffer is long-lived.
- `readlink` and `readlink_at` now both call an `inner_readlink` function that contains the bulk of the logic, avoiding copy-pasting of code. (This is much more important now that the logic is more than a few lines long.)
Notably, this PR does *not* add support for systems that don't define `PATH_MAX` at all. As far as I know, I don't have access to any POSIX-ish OS that doesn't have `PATH_MAX`, and I suspect it would have other compatibility issues with `nix` anyway.
Co-authored-by: Solra Bizna <solra@bizna.name>
|
|
`readlinkat`
|
|
This is available only on Linux as far I know,
[socket(7)](https://linux.die.net/man/7/socket) has some information
about the `SO_BINDTODEVICE` sockopt. In simple words it binds a socket
to an specific network device (specified as an string like "wlo1",
"eth0", etc.), to only process packets from that device.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
|
|
|
|
1215: Remove sys::socket::addr::from_libc_sockaddr from the public API r=posborne a=asomers
This function never should've been public, since it's basically
impossible to use directly. It's only public due to an oversight from
PR #667 .
Co-authored-by: Alan Somers <asomers@gmail.com>
|
|
|
|
|
|
1209: Support UDP GSO and GRO on linux r=asomers a=glebpom
This PR implements support for UDP GSO and GRO on Linux. It provides the way to send/receive UDP payloads bigger than interface MTU. The goal is to improve UDP performance.
GSO was introduced in Linux 4.18, GRO in 5.3
Co-authored-by: Gleb Pomykalov <gleb@lancastr.com>
|
|
1221: Fix compilation on DragonFly (statfs) r=asomers a=mneumann
Co-authored-by: Michael Neumann <mneumann@ntecs.de>
|
|
|
|
|
|
Don't try to use PTRACE_[GS]ETREGS, PTRACE_[GS]ETFPREGS or
PTRACE_[GS]ETFPXREGS on riscv64, they are legacy-only.
|
|
1210: impl io::{Read,Write} for PtyMaster r=asomers a=cuviper
`PtyMaster` acts like an owned file descriptor, even closing on `Drop`.
Implementing `io::Read` and `io::Write` lets it be used directly in
standard I/O operations.
Co-authored-by: Josh Stone <jistone@redhat.com>
|
|
1211: Feature/hugepage size r=asomers a=GuillaumeDIDIER
Should solve #1194 .
Co-authored-by: GuillaumeDIDIER <guillaume.didier95@hotmail.fr>
|
|
`PtyMaster` acts like an owned file descriptor, even closing on `Drop`.
Implementing `io::Read` and `io::Write` lets it be used directly in
standard I/O operations.
|
|
Closes #1194
Use git libc for development
(Remember to reset this to released version for the next nix release, once libc has released >=0.2.69)
|
|
1207: Add select::FdSet::fds() method r=asomers a=zombiezen
To be more consistent with most Rust APIs and enable cloning of the iterator, I made `FdSet::contains` operate on an immutable borrow instead of a mutable one by copying the set. If this is not desirable, I can roll that back from this PR and focus purely on the `fds()` method.
Co-authored-by: Ross Light <ross@zombiezen.com>
|
|
1206: Fix unaligned casting of cmsg data to af_alg_iv r=asomers a=glebpom
Casting a pointer to `cmsg_data` to `af_alg_iv` is incorrect since it's not properly aligned. As of the [`cmsg` man page](http://man7.org/linux/man-pages/man3/cmsg.3.html) "Applications should not cast it to a pointer type matching the payload, but should instead use memcpy(3) to copy data to or from a suitably declared object."
Co-authored-by: Gleb Pomykalov <gleb@lancastr.com>
|
|
|
|
|
|
|
|
This function never should've been public, since it's basically
impossible to use directly. It's only public due to an oversight from
PR #667 .
|
|
The old code tried to zero-initialize an enum for which 0 is not a valid
value. That worked for older compilers, but triggers a panic with Rust
1.44.0. The correct technique is to use mem::MaybeUninit.
Fixes #1212
|
|
|
|
|
|
1195: Implement open file descriptor locks in fcntl r=asomers a=andrenth
Hello
This PR updates libc to 0.2.68, which adds the `F_OFD_*` fcntl commands, and uses them in `nix::fcntl::fcntl`.
Co-authored-by: Andre Nathan <andre@digirati.com.br>
|
|
|
|
Functions such as Group::from_anything use reserve_double_buffer_size
in a loop, expecting it to return ERANGE if the passed limit is
reached.
However, the returned vector is passed as pointer to a libc function
that writes data into memory and doesn't update the length of the
Vec. Because of this, the previous code would never return ERANGE and
the calling loops would never exit if they hit a case where the
required buffer was larger than the maximum buffer.
This fixes the problem by checking the capacity rather than the
length.
Signed-off-by: Steven Danna <steve@chef.io>
|
|
Update CHANGELOG for #1198
|
|
Untested, done on github.
Fixes #1200
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1176: Add RISC-V support on GNU/Linux r=asomers a=msizanoen1
Co-authored-by: msizanoen1 <qtmlabs@protonmail.com>
|
|
The file documenting ioctl number assignment in the Linux kernel has been converted to ReStructuredText (see https://lwn.net/Articles/705224/ for some background), the file extension has naturally changed.
|
|
http://man7.org/linux/man-pages/man3/sysconf.3.html says that the
corresponding variable is obsolete, but I think that just means the
constant defined in limits.h is obsolete. Checking the value using
sysconf is still valid.
|
|
|
|
|
|
We were assuming the wrong types for f_iosize and f_ffree in struct
statfs on OpenBSD.
Fixes #1125
|
|
|
|
|
|
ignore really is the correct things to do for these doc tests.
compile_fail should only be used for examples that demonstrate a compile
failure by design, not for stuff that only works on one platform.
|
|
The old From implementation was actually falliable, and would panic on
failure.
|
|
Replace it with mem::zeroed. It isn't perfect, but it's better than it
was.
Issue #1115
|
|
1156: Remove the deprecated CmsgSpace r=asomers a=asomers
This eliminates one of the last remaining uninitialized memory accesses
in Nix.
Fixes #1142
Co-authored-by: Alan Somers <asomers@gmail.com>
|