Age | Commit message (Collapse) | Author |
|
|
|
|
|
This patch adds a wrapper for the acct(2) syscall, with two functions
for enabling and disabling process accounting.
|
|
These are mostly to ensure that all the platforms we care about in our
CI can reference these primitives.
|
|
This also adds a test for truncate (obviously) but, while doing so, also
adds a test for the already-existing ftruncate.
|
|
This macro can be used in tests to skip the test if it requires root to sucssfully run.
|
|
|
|
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
|
|
851: Added `getsid` in `::nix::unistd` r=asomers a=ggriffiniii
Resolves Issue #850
|
|
|
|
This module has two functions;
set: set an alarm, and
cancel: cancels a previously set alarm.
|
|
|
|
As of Rust 1.17 'static lifetimes are implied when
declaring consts.
|
|
Several tests make the assumption that all data is written, which
is not guaranteed with write(), so use write_all() instead.
|
|
799: Fix nix on Dragonfly r=Susurrus a=mneumann
This commit replaces pull request https://github.com/nix-rust/nix/pull/684. It fixes building `nix` on DragonFly. All tests pass. This requires most recent libc to build: https://github.com/rust-lang/libc/pull/851.
|
|
* DragonFly does not have a O_DSYNC flag
* Fix type_of_cmsg_data on DragonFly
* No fexecve() on DragonFly
* Do not run aio test cases on DragonFly
* Keep target lists in alphabetical order
* Unscrable #[cfg] directives and use cfg_if! macro instead
* Fix errno on DragonFly
Below follows an explanation why we have to use a C extension
to get errno working on DragonFly:
DragonFly uses a thread-local errno variable, but #[thread_local] is
feature-gated and not available in stable Rust as of this writing (Rust
1.21.0). We have to use a C extension (src/errno_dragonfly.c) to access
it.
Tracking issue for `thread_local` stabilization:
https://github.com/rust-lang/rust/issues/29594
Once this becomes stable, we can remove build.rs, src/errno_dragonfly.c,
remove the build-dependency from Cargo.toml, and use:
extern {
#[thread_local]
static errno: c_int;
}
Now all targets will use the build.rs script, but only on DragonFly this
will do something. Also, there are no additional dependencies for
targets other than DragonFly (no gcc dep).
|
|
All supported non-Apple platforms now use the native syscall. Only ios
and macos lack it. Deprecate pipe2 on those platforms, because it's
impossible to guarantee atomicity with a userland implementation. It
was added in:
* DragonflyBSD 4.2
* FreeBSD 10.0
* NetBSD 6.0
* OpenBSD 5.7
|
|
The libc_bitflags! macro was replaced with a non-recursive one supporting
only public structs. I could not figure out how to make the old macro work
with the upgrade, so I reworked part of the bitflags! macro directly to suit
our needs, much as the original recursive macro was made. There are no uses
of this macro for non-public structs, so this is not a problem for internal code.
|
|
This adds execveat() to `nix::unistd`. It uses the execveat(2) Linux
kernel syscall, which is available since 3.19.
This is a Linux-specific extension which is not covered by POSIX and
does not have any userland libc wrapper.
Ref: http://man7.org/linux/man-pages/man2/execveat.2.html
|
|
|
|
Fix groups mutex name
|
|
|
|
|
|
|
|
This adds fexecve() to `nix::unistd`. It is available in libc since 0.2.29.
Ref: http://pubs.opengroup.org/onlinepubs/9699919799/functions/fexecve.html
|
|
There appears to be some interaction with test_pathconf_limited and
another one when they are run in parallel, causing it to return ENOENT
so the path has been changed from . to /.
|
|
693: fix some tests for Android r=asomers
I tested the crate on an Android emulator and quite all the tests passed. Only 6 were failing.
> failures:
>
> ---- sys::test_pthread::test_pthread_self stdout ----
> thread 'sys::test_pthread::test_pthread_self' panicked at 'assertion failed: tid > 0', test/sys/test_pthread.rs:6
> note: Run with `RUST_BACKTRACE=1` for a backtrace.
>
> ---- sys::test_socket::test_getsockname stdout ----
> thread 'sys::test_socket::test_getsockname' panicked at 'bind failed: Sys(EACCES)', /checkout/src/libcore/result.rs:859
>
> ---- sys::test_socket::test_unixdomain stdout ----
> thread 'sys::test_socket::test_unixdomain' panicked at 'bind failed: Sys(EACCES)', /checkout/src/libcore/result.rs:859
>
> ---- sys::test_termios::test_local_flags stdout ----
> thread 'sys::test_termios::test_local_flags' panicked at 'called `Option::unwrap()` on a `None` value', /checkout/src/libcore/option.rs:329
>
> ---- test_net::test_if_nametoindex stdout ----
> thread 'test_net::test_if_nametoindex' panicked at 'assertion failed: if_nametoindex(&LOOPBACK[..]).is_ok()', test/test_net.rs:11
>
> ---- test_unistd::test_mkstemp stdout ----
> thread 'test_unistd::test_mkstemp' panicked at 'mkstemp failed: ENOENT: No such file or directory', test/test_unistd.rs:73
This PR fixes 3 of those:
- `test_pthread_self`: pthread_t is unsigned, so it can be negative (and it is often the case)
- `test_if_nametoindex`: constant `LOOPBACK` is the same than on Linux
- `test_mkstemp`: directory `/tmp` does not exist in Android
Two are still failing (`test_unixdomain` and `test_getsockname`) because we need some special permissions on Android for playing with sockets. On a rooted physical device, they passed. So, if tests for Android are integrated in CI, we should try to embed the tests to run in an APK with requested permissions or find a way to give the permission to a native program.
`test_local_flags` is still failing also because `O_LARGEFILE` is hardcoded and is not the right value in Android. Then `fcntl::OFlag::from_bits(flags).unwrap()` fails because this flag is then not recognised.
I made a PR in `libc` so that we can rely on libc definitions for all `O_*` flags. (rust-lang/libc#683)
Do you prefer to wait for this one to be fixed for this PR to merged as well ?
|
|
|
|
Some tests were invoking non-async-signal-safe functions from the child
process after a `fork`. Since they might be invoked in parallel, this
could lead to problems.
|
|
|
|
|
|
It was broken when enabled, and currently the libc definition is only
available for windows. This will be re-added when a new libc is released
that supports it across all available platforms
|
|
638: Make aio, chdir, and wait tests thread safe r=Susurrus
Fix thread safety issues in aio, chdir, and wait tests
They have four problems:
* The chdir tests change the process's cwd, which is global. Protect them all with a mutex.
* The wait tests will reap any subprocess, and several tests create subprocesses. Protect them all with a mutex so only one subprocess-creating test will run at a time.
* When a multithreaded test forks, the child process can sometimes block in the stack unwinding code. It blocks on a mutex that was held by a different thread in the parent, but that thread doesn't exist in the child, so a deadlock results. Fix this by immediately calling `std::process:;exit` in the child processes.
* My previous attempt at thread safety in the aio tests didn't work, because anonymous MutexGuards drop immediately. Fix this by naming the SIGUSR2_MTX MutexGuards.
Fixes #251
|
|
They have four problems:
* The chdir tests change the process's cwd, which is global. Protect them
all with a mutex.
* The wait tests will reap any subprocess, and several tests create
subprocesses. Protect them all with a mutex so only one
subprocess-creating test will run at a time.
* When a multithreaded test forks, the child process can sometimes block in
the stack unwinding code. It blocks on a mutex that was held by a
different thread in the parent, but that thread doesn't exist in the
child, so a deadlock results. Fix this by immediately calling
std::process:exit in the child processes.
* My previous attempt at thread safety in the aio tests didn't work, because
anonymous MutexGuards drop immediately. Fix this by naming the
SIGUSR2_MTX MutexGuards.
Fixes #251
|
|
630: Add wrappers for sysconf(3), pathconf(2), and fpathconf(2) r=asomers
|
|
|
|
std::fs::File closes the underlying file descriptor on Drop, without
checking for errors. test_lseek and test_lseek64 also manually close
the file descriptor. That works for single threaded test runs. But for
multithreaded runs, it causes EBADF errors in other tests. Fix the
tests by consuming the File with into_raw_fd(), so its drop method will
never be called.
Also, fix a potential short read bug in the same tests.
|
|
|
|
This introduces a wrapper for fchdir(2), allowing a process to change
directory based on an open file descriptor.
The underlying function is available in libc crate since 0.2.20.
|
|
|
|
its documentation\!), checking the failure of a directory now
|
|
|
|
|
|
|
|
against std::env::current_dir
|
|
the implementation in std
|
|
|
|
directory names, need to be created with mkdir first which doesn't exist yet)
|
|
expect into proper try handling), needs testing still
|
|
llseek and lseek64
impl Whence
fixed formatting
awful typo when refactoring
no llseek
wrong test name
using off64_t
got rid of offset
Added SeekHole/Data; formatted test; SeekCur/Set/End use libc constants
|