Commit Graph

992 Commits

Author SHA1 Message Date
Dan Gohman 20ebc0f5ee Add comments to dup2_to_replace_stdio.
And while here, simplify the code to use `println!` to print "hello
world", which we can do now that it's no longer running within the
test harness process.
2022-02-01 08:17:17 -08:00
Dan Gohman df1c27d1de Fix test_linux_hwcap to work on old libc versions.
Use `weak!` to detect support for `getauxval` so that we can test on
platforms which don't have it.
2022-01-31 18:38:34 -08:00
Dan Gohman ee8edc414a Move the dup2_to_replace_stdio test into a separate child process.
This should help it run better on macos and ios, as well as on older
Linux versions and qemu.
2022-01-31 18:38:34 -08:00
Dan Gohman ff294b1f9e Fix VDSO clock_gettime detection on older Linux versions.
On arm, use the `64`-suffixed symbol so that the optimized path only
uses the y2038-safe version.

On risc-v, use the symbol name from the actual kernel code.

And on arm and x86, handle the case where the y2038-safe symbol is not
present.
2022-01-31 18:38:34 -08:00
Dan Gohman 4b00df56d9 Detect arm64-ilp32 just enough to say that it's not supported.
arm64-ilp32 is a 32-bit ABI on a 64-bit platform, just like x32 is a
32-bit abi on x86-64.
2022-01-31 18:38:34 -08:00
Dan Gohman 0c2b700911 Disable the __ehdr_start safety checking in the vdso parsing code.
Older Linux toolchains don't implement `__ehdr_start`, so disable this
check for now.
2022-01-31 18:38:34 -08:00
Dan Gohman d5503146d8 Handle Error::NOSYS in tests for Linux-specific syscalls.
Linux 2.6.32 doesn't support `prlimit64` or `memfd_create`, so handle
`Error::NOSYS` gracefully in tests.
2022-01-31 18:38:34 -08:00
Dan Gohman bb53716407 Don't open /proc directories with NOATIME or PATH.
Linux 2.6.32 doesn't support `OFlags::NOATIME` or `OFlags::PATH` on
/proc. These flags aren't essential, so just disable them for now.
2022-01-31 18:38:34 -08:00
Dan Gohman 9e5d1be65e Fix getrlimit/setrlimit on old Linux versions.
Old linux versions lack `__NR_prlimit64`, even on 64-bit platforms, so
enable the fallback path for 64-bit platforms.
2022-01-31 18:38:34 -08:00
Dan Gohman 9cc0fc7b66 Update to linux-raw 0.0.39. (#200)
* Update to linux-raw 0.0.39.

This version drops support for multiple Linux API versions, so this drops
all the `v5_4::` and `v5_11::` qualifiers.

* Implement fallback for old-style socket timeouts.

Linux socket timeout options moved from y2038-unsafe `timeval` to
y2038-safe `__kernel_timespec`. Optimistically use the new options
first, and implement fallback code to use the old versions if
needed.

* Update to linux-raw-sys 0.0.40, which fixes the riscv64 issues.

* Use `__NR_ugetrlimit` on architectures which have it.

* Factor convertions to/from `Duration` into helper functions.
2022-01-31 09:29:19 -08:00
Dan Gohman eee6cc2dff Expand the comments in the outline asm wrapper code.
Add module-level comments which walk through the purpose for this
code and how the code implements it.
2022-01-31 09:08:44 -08:00
Dan Gohman 72c4182fdb Replace duplicated functions with function aliases.
In the outline assembly code, we don't have separate `_readonly`
implementations, so use function aliases instead of having two copies of
the code.
2022-01-31 09:08:44 -08:00
Dan Gohman 7d22f7b879 Inline the mod reorder modules.
These modules were effectively redundant since they contained
`use super::*` and the following code contained `use reorder::*`.
2022-01-31 09:08:44 -08:00
Dan Gohman 645e05f465 Enable CpuSet::count on Android (#204)
* Enable `CpuSet::count` on Android.
2022-01-31 09:08:09 -08:00
Dan Gohman b33bcd6498 Add a cross-check for aarch64-unknown-linux-musl in CI. 2022-01-31 09:06:20 -08:00
Dan Gohman b9824b5205 Refactor the code that does vDSO checks into a helper function.
Move all the safety checks out of `init_from_sysinfo_ehdr` and into a
helper function. This makes `init_from_sysinfo_ehdr` less huge and
clarifies the split between the safety checks and the actual vDSO
parsing code.
2022-01-31 09:03:05 -08:00
Dan Gohman dedc85afc1 Optimize the build.rs program.
Avoid doing feature tests for features that won't be needed. This
significantly speeds up the speed of the build script.
2022-01-31 09:02:36 -08:00
Dan Gohman 1665ae9140 Remove internal usage of use ...::syscalls::*. (#198)
Remove lines like

> pub(crate) use super::fs::syscalls::*;

from the top-level syscalls.rs files, and just have code reference the
specific modules they need.
2022-01-28 06:36:14 -08:00
Dan Gohman ba2094f93a Split 32-bit fallback routines into their own functions.
In the few places where rustix has fallback code for handling `NOSYS`
errors, split the fallback code into separate functions, so that the
main flow of the code is easier to follow.
2022-01-28 06:31:05 -08:00
Dan Gohman e0b1a1817c Exclude all dotfiles from the crates.io package.
.gitignore, .cirrus.yml, and .rustfmt.toml don't need to be shipped in
the crates.io package, so exclude them.
2022-01-27 12:13:56 -08:00
Dan Gohman ccc301b884 (cargo-release) start next development iteration 0.33.1-alpha.0 2022-01-26 14:11:50 -08:00
Dan Gohman 64712d8911 (cargo-release) version 0.33.0 2022-01-26 14:11:39 -08:00
Mek101 ab95a1c693 Fix ioctl_blk*szget types 2022-01-26 13:29:46 -08:00
Mek101 bd476b2128 Add ioctl_blk*szget android support. 2022-01-26 13:29:46 -08:00
Dan Gohman a0d12692ae Update to io-lifetimes 0.5.1.
The only changes in io-lifetimes are in the Windows support, so there
are no changes for rustix here.
2022-01-26 12:06:45 -08:00
Dan Gohman 20f1d6b95f Factor out several more type conversions in the syscalls code.
This adds conversion functions for converting `Pid`, `Signal`, and
`Advice` values into syscall argument registers.
2022-01-26 12:01:20 -08:00
Dan Gohman 8831f35c3e Implement fcntl_add_seals etc.
Implement `fcntl_add_seals`, and add a `SealFlags` to describe seal flag
values in `fcntl_add_seals` and `fcntl_get_seals`.

Also, add `MFD_HUGETLB` and accompanying flag values.
2022-01-26 12:00:04 -08:00
Dan Gohman 42de227bbe Implement setrlimit and prlimit. (#191)
rustix already had the types defined for `getrlimit`, so this just adds
the new `setrlimit` and Linux-specific `prlimit`.
2022-01-25 13:26:00 -08:00
Dan Gohman e0cf781c0e Cleanup: make an implicit lifetime parameter explicit.
All the other `SyscallNumber` arguments have an explicit lifetime
parameter, so fix this one that didn't, for consistency.
2022-01-25 10:14:29 -08:00
Dan Gohman 6303edf4d7 Add a CI check for the prebuild debug-mode libraries.
The existing CI code checked it for --release builds; this ensures it's
checked for debug builds as well.

This also updates the debug builds which became out of date after
f7e4c56d added comments to the .s files, changing the line numbers in
the .debug_line sections.
2022-01-25 10:14:14 -08:00
Colin Walters 80229bc23f procfs: Add a wrapper to open a directory in /proc
This helper avoids the duplication of the open flags for example,
and is prep for further work.
2022-01-24 14:47:18 -08:00
Colin Walters 6e437aee3b procfs: Don't try to validate the uid/gid of /proc
I typically develop inside a https://github.com/containers/toolbox/
container.  In this scenario:

```
$ ls -ald /proc
dr-xr-xr-x. 526 nobody nobody 0 Jan 12 14:47 /proc
$
```

And that's expected and normal; the real root uid from outside
the user namespace is mapped to `nobody`; distinct from the uid 0
inside the userns.

Honestly, I am still somewhat skeptical of the value of all of
these checks.  We're already validating that `/proc`'s filesystem
magic is `PROC_SUPER_MAGIC` - that seems really more than sufficient.
2022-01-24 10:12:46 -08:00
Colin Walters 2ba2b72ba5 impl Debug for DecInt
This is a best practice to be friendly to users who may want
to add things to their own structs and want to simply `#[derive(Debug)]`
and I'm assuming its omission was accidental.
2022-01-24 06:31:29 -08:00
Colin Walters 76601bc928 tests/statfs: Don't check f_files != 0
At least as far as I can tell, the Linux btrfs code does not
set `f_files`.  I think likely because inode allocations are fully
dynamic.

Testing the block count should be sufficient.
2022-01-24 06:10:05 -08:00
Dan Gohman 281b31fcff Switch from atty to is-terminal. (#183)
The atty crate doesn't support operating on arbitrary streams, and uses
a `Stream` enum which requires it to access stdio streams implicitly.
Begin migrating to a new is-terminal crate, which has an API that takes
an `AsFilelike` argument.
2022-01-24 05:03:56 -08:00
Dan Gohman 6a16b261f0 (cargo-release) start next development iteration 0.32.2-alpha.0 2022-01-19 17:32:16 -08:00
Dan Gohman 0e665876fb (cargo-release) version 0.32.1 2022-01-19 17:32:05 -08:00
Dan Gohman 14dd4c7079 Sync the libc version of PollFd with the linux_raw version.
Port the `set_fd` and `AsFd` implementations from the linux_raw `PollFd`
to the libc `PollFd`.
2022-01-19 17:31:21 -08:00
Dan Gohman b407dd48b8 (cargo-release) start next development iteration 0.32.1-alpha.0 2022-01-19 14:49:19 -08:00
Dan Gohman 2ecf4181c3 (cargo-release) version 0.32.0 2022-01-19 14:49:08 -08:00
Dan Gohman 5ea3227610 Tidy up spurious trailing commas. 2022-01-19 14:30:59 -08:00
Dan Gohman 27d3610c2a Fix compilation errors on illumos.
Make rustix compile under x86_64-unknown-illumos. This configuration is
not yet tested; this just fixes the compilation errors.
2022-01-19 14:30:14 -08:00
Dan Gohman b7b22658a6 Mark several readonly syscalls as readonly. 2022-01-19 13:54:53 -08:00
Dan Gohman fc838cee6d Fix readlinkat syscalls to not be readonly.
The `readlinkat` syscall writes into the output buffer, so it is not
`readonly`, so use a non-`readonly` syscall wrapper for it. I believe
this bug isn't observable outside the crate, due to the restricted
ways that the actual syscall wrapper is used.
2022-01-19 13:54:53 -08:00
Dan Gohman 8089cc7e9e Add minimal documentation comments for io_slice.rs.
This file is derived from Rust upstream, so don't add extensive
comments, but do add links to where more documentation can be found.
2022-01-19 12:44:26 -08:00
Dan Gohman 0362d6b9bf Document epoll, and remove the last allow(missing_docs) overrides. 2022-01-19 12:44:26 -08:00
Dan Gohman 3c80016669 Fix URL formatting in comments. 2022-01-19 12:44:26 -08:00
Dan Gohman 837782dae3 Fix a few more spelling errors and missing code quotes. 2022-01-19 12:44:26 -08:00
Dan Gohman f7e4c56df5 Write more comments.
Make a pass over the crate adding and cleanup up comments and doc aliases.
2022-01-19 12:44:26 -08:00
Dan Gohman 79c366d7a6 Add a note about STATX_ATTR_MOUNT_ROOT.
Add a note about the possibility of using `STATX_ATTR_MOUNT_ROOT` to
detect mountpoints.
2022-01-19 12:43:34 -08:00