Commit Graph

1311 Commits

Author SHA1 Message Date
Dan Gohman ef9a77313a Tidy up uses. 2022-11-28 08:58:36 -08:00
Dan Gohman 8fca74091c Tidy up cfgs. 2022-11-28 08:58:36 -08:00
Dan Gohman f6f44b7b05 Implement unshare. (#461)
Fixes #452.
2022-11-28 08:52:24 -08:00
Alex Saveau b5c2ea7127 Add zero-compromise directory iteration (#457)
* Add zero-compromise directory iteration

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>

* Address review feedback

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>

* Vastly simplify file_name calculation and remove pointer manipulation BS, yielding a 2x instruction count reduction

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>

* Implement docs changes I mentioned

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>

* Fix debug impl

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>

* Support libc backend

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>

* Clarify portability of fixed-sized buffers

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>

* Turns out from_ptr is faster, oh well

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>

* Make cookie a u64

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>

* Fix cfgs

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-11-23 15:42:07 -08:00
Dan Gohman 2aa66b2435 chore: Release rustix version 0.36.3 2022-11-22 10:39:10 -08:00
Dan Gohman 28d40939ca Minor formatting cleanups. (#459) 2022-11-21 11:18:59 -08:00
Dan Gohman c7146a721e Fix compilation with --no-default-features. (#454)
Move `fcntl_getfd`, `fcntl_setfd`, and `fcntl_dupfd_cloexec` out of
the `fs` module and into the `io` module, since they're not specific
to files, directories or memfd. This allows them to be used with the
"fs" feature is not enabled.

Also, add public aliases for then in `fs`, for compatibility, and to
have a place where all `fcntl` function are present.

And add a CI check for --no-default-features with no API features.

Fixes #453.
2022-11-21 10:56:46 -08:00
Dan Gohman d6164939a7 Fix a few clippy lints. (#458)
Fix a few minor clippy lints, and add clippy overrides for warnings that
we can't easily fix due to our MSRV, or due to our support of multiple targets.
2022-11-21 08:30:40 -08:00
Alex Saveau 74c56f3e70 Fix clippy lint (#455)
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-11-21 06:51:33 -08:00
Dan Gohman fefe0652d7 chore: Release rustix version 0.36.2 2022-11-18 08:26:52 -08:00
Dan Gohman 8b5196283a Fix test compilation when "threads" or "procfs" aren't enabled. 2022-11-18 08:19:32 -08:00
Dan Gohman 2fc4f1be16 Disable the internal fs module when the "fs" feature isn't enabled. (#449)
Rustix no longer has anything in the tree that needs the `fs` module
when the public "fs" feature isn't enabled, so make the `fd` module
conditional on `cfg(feature = "fs")`.
2022-11-16 12:19:50 -08:00
Alex Saveau 663a74364a Use stdlib with_c_str implementation (#448) 2022-11-16 12:19:21 -08:00
Dan Gohman 2a2ef7e1c8 Remove the uid/gid checks from the procfs code entirely. (#450)
As a followup to #444, remove the uid/gid checks from the procfs code
entirely. Procfs files can have their owner changed to root:root under
`PR_SET_DUMPABLE`, and root can be remapped to nobody by user
namespaces.

This check wasn't guarding against a known problem, and it's complex
to make sure it doesn't spuriously fail under any vald configuration,
so just remove it.
2022-11-15 16:21:16 -08:00
Dan Gohman 19af9c3943 Update to actions/cache@v3. 2022-11-15 14:17:13 -08:00
Dan Gohman 962ec8ab9a Change the procfs code to be tolerate of files being owned by root:root. (#444)
When a process is marked as non-dumpable, Linux changes the permissions
of the files under /proc/<pid> as owned by root:root. Relax the procfs
code, including removing use of `O_NOATIME`, so that it works on files
owned by `root:root`.

Fixes #441.
2022-11-15 10:32:38 -08:00
niluxv 701cd6392c Fix compilation on macos without std (#442) 2022-11-14 06:28:37 -08:00
Dan Gohman b116f6d749 Temporarily disable the async-std, tokio, mio, and socket2 impls. (#443)
Temporarily disable io-lifetimes impls for third-party crates which don't
yet have have trait impls for the I/O safety traits.
2022-11-14 06:27:26 -08:00
Dan Gohman 812364ace3 Update to actions/checkout@v3. 2022-11-13 07:23:30 -08:00
Dan Gohman bf60c1099d chore: Release rustix version 0.36.1 2022-11-07 17:39:57 -08:00
Dan Gohman 12dd67ff6a Enable the "close" feature for io-lifetimes. (#440)
* Enable the "close" feature for io-lifetimes.

This follows up on #422, but enables "close" on the regular dependency
too, and not just the dev-dependency.

* Temporarily disable the backends no-libc test.
2022-11-07 17:39:05 -08:00
Dan Gohman e15a462fd3 chore: Release rustix version 0.36.0 2022-11-07 10:15:58 -08:00
Dan Gohman aac5e72ba2 Update to io-lifetimes 1.0. 2022-11-07 09:51:08 -08:00
Dan Gohman dd139fbfaa Update dependency versions. (#438)
Update the github action to node16. And update to memoffset 0.7.1 and
criterion 0.4.
2022-11-07 09:00:19 -08:00
niluxv 70b6814802 Use platform independent IpAddr and SocketAddr (#433)
Update `src/net/ip.rs` and `src/net/addr.rs` to use the new std code,
making these structures platform independent.

Doesn't include the new Debug/Display formatting code for these
structures, although that could have been added now that it doesn't
depend on std anymore.
2022-11-07 08:25:20 -08:00
niluxv 760c0b517c Add part of the FreeBSD procctl API (#429) 2022-11-07 07:39:44 -08:00
niluxv 65a9bcfd7f Add missing FreeBSD specific MapFlags constants (#436) 2022-11-02 13:17:23 -07:00
niluxv 058514e544 Fix compilation of libc backend without std (#430) 2022-10-23 15:38:41 -07:00
Dan Gohman 1d62edeade (cargo-release) version 0.36.0-rc3 2022-10-23 09:58:49 -07:00
messense 6f603e0f33 Update windows-sys to 0.42.0 (#431)
* Update windows-sys to 0.42.0

* Update io-lifetimes to 1.0.0-rc2
2022-10-22 16:21:30 -07:00
nivkner e3dd07d50b add splice syscall (#421)
* add splice function

* add documentation to splice function

* add libc backend for splice

* update linux-raw-sys

* add linux_raw backend

* export splice items

* add tests for splice

* add cfgs

* remove unsafe vmsplice flag

* add IoSliceRaw to linux backend

* add IoSliceRaw to libc backend

* export IoSliceRaw

* add vmsplice function

* implement linux backend vmsplice

* implement libc backend vmsplice

* export vmsplice

* change description of splice

* add documentation of vmsplice

* add vmsplice tests

* Revert "remove unsafe vmsplice flag"

This reverts commit 9a2781e1d91d091e3f069c3c48d7e4a9bb51a45c.

* add vmsplice gift safety docs

* add lifetime parameter to IoSliceRaw

* change splice offsets to in-out args
2022-10-20 14:30:00 -07:00
Aleksandr Trukhin 36d79738cc Fix dir iterator in case of an error.
Do not resize internal buffer on error, otherwise iterator gets stuck in
infinite loop with zeroed `dirent`s after the first error. Correct
behavior is to return error indefinitely if it persists.
Error can be ENOENT if the directory is unlinked while iterating, for
example.

Signed-off-by: Aleksandr Trukhin <alxtry@gmail.com>
2022-10-12 13:37:26 -07:00
Dan Gohman b72d4291d2 Add a proc_self_status function for reading /proc/self/status on Linux.
Fixes #423.
2022-10-12 13:27:49 -07:00
Dan Gohman 5a75324605 Update the comment about the Rust version requirement for no_std.
Fixes #426.
2022-10-12 13:27:26 -07:00
Dan Gohman 378ac49422 Add logic to build.rs to autodetect whether we need to use thumb-mode.
`#[cfg(target_feature = "thumb-mode")]` isn't available on stable, so
use a build.rs script to detect whether we can use `r7` in inline asm
on ARM targets.
2022-10-10 13:29:21 -07:00
Philipp Gesang f1426a9635 Add "close" to io-lifetimes feature set
Without this feature enabled the eventfd test crashes on my box:

    ---- eventfd::test_eventfd stdout ----
    thread 'eventfd::test_eventfd' panicked at 'internal error: entered unreachable code: drop called without the "close" feature in io-lifetimes', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/io-lifetimes-1.0.0-rc1/src/types.rs:763:13
    stack backtrace:
       0: rust_begin_unwind
                 at /datastore/rpmbuild/BUILD/rustc-1.57.0-src/library/std/src/panicking.rs:517:5
       1: core::panicking::panic_fmt
                 at /datastore/rpmbuild/BUILD/rustc-1.57.0-src/library/core/src/panicking.rs:100:14
       2: <io_lifetimes::types::OwnedFd as core::ops::drop::Drop>::drop
                 at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/io-lifetimes-1.0.0-rc1/src/types.rs:763:13
       3: core::ptr::drop_in_place<io_lifetimes::types::OwnedFd>
                 at /datastore/rpmbuild/BUILD/rustc-1.57.0-src/library/core/src/ptr/mod.rs:188:1
       4: io::eventfd::test_eventfd
                 at ./tests/io/eventfd.rs:24:1
       5: io::eventfd::test_eventfd::{{closure}}
                 at ./tests/io/eventfd.rs:3:1
       6: core::ops::function::FnOnce::call_once
                 at /datastore/rpmbuild/BUILD/rustc-1.57.0-src/library/core/src/ops/function.rs:227:5
       7: core::ops::function::FnOnce::call_once
                 at /datastore/rpmbuild/BUILD/rustc-1.57.0-src/library/core/src/ops/function.rs:227:5
    note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
2022-10-05 17:37:35 -07:00
Brian Silverman 2702ea5548 Pass --target=$TARGET when running rustc in build.rs
I'm using this in an environment where only the `$TARGET` rust standard
library is available, which means `use std::arch::asm;` doesn't work for
the host platform when cross compiling, even when it works for the
target platform. Also in general, this is trying to detect things about
the target, not the host.

For context, I'm using [Bazel](https://bazel.build/) with
[rules_rust's cargo_build_script](http://bazelbuild.github.io/rules_rust/flatten.html#cargo_build_script),
via [cargo-raze](https://github.com/google/cargo-raze). Native
x86_64-unknown-linux-gnu compilation works fine without this patch, but
cross compiling to aarch64-unknown-linux-gnu requires this patch.
2022-09-29 16:53:43 -07:00
Dan Gohman 638463f230 (cargo-release) version 0.36.0-rc2 2022-09-27 15:13:04 -07:00
Dan Gohman 35e62e6467 Fix linux-raw inline asm for thumb-mode. (#416)
* Fix linux-raw inline asm for thumb-mode.

In thumb-mode, r7 is reserved as the frame pointer and isn't permitted
as an inline asm operand. It's still the syscall-number operand in
syscalls though, so pass the syscall-number operand in in a separate
register, copy it into r7 inside the inline asm, and then restore the
value of r7 when we're done.

* Add a thumbv7neon-unknown-linux-gnueabihf line to CI.
2022-09-27 15:11:40 -07:00
Qiu Chaofan 467b770383 Support AIX operating system (#406)
* Support AIX operating system

* Fix unused imports

* Rustfmt and fix ordering.

Co-authored-by: Dan Gohman <dev@sunfishcode.online>
2022-09-27 13:29:58 -07:00
Dan Gohman 350877a391 Fix compilation on sparc targets. (#417)
* Fix compilation on sparc targets.

Adjust cfg's as needed to fix compilation errors on sparc.

Fixes #408.

* Rust's 32-bit sparc Linux target has a 32-bit time_t.
2022-09-27 10:05:29 -07:00
ETKNeil 8925af59e8 Add ipv6 multicast hops support 2022-09-27 10:05:01 -07:00
Dan Gohman bb2855958e Add a CI check for building on Haiku. 2022-09-26 06:57:24 -07:00
Dan Gohman a4434a6c12 Fix various compilation errors on haiku. (#411)
This builds on top of #407!
2022-09-25 18:20:34 -07:00
Dan Gohman e5d9aa159f More fixes for compilation on x86_64-unknown-dragonfly. (#410)
Add a tier-3 CI check for x86_64-unknown-dragonfly, and fix the
compilation errors needed to compile with --features=all-apis.

This builds on top of #409!
2022-09-25 13:15:28 -07:00
Al Hoang 175c20e182 haiku support (#407)
* haiku support

* cargo format

Co-authored-by: Al Hoang <3811822-hoanga@users.noreply.gitlab.com>
2022-09-25 12:25:02 -07:00
David Carlier 4302598df7 dragonflybsd build fix proposal. 2022-09-25 12:23:47 -07:00
Dan Gohman 95efd8ad02 Pin once_cell to 1.14 in Rust 1.48 builds. 2022-09-21 11:06:42 -07:00
Koutheir Attouchi 974f83d24b Add support for setns(). (#398) 2022-09-20 10:15:24 -07:00
ETKNeil 7ebfc094da Fix libc removing unsafe on makedev 2022-09-20 10:14:13 -07:00