Commit Graph

65 Commits

Author SHA1 Message Date
SteveLauC
6961f0fabd
refactor: cfg for test/* (#2230)
* refactor: cfg for test/*

* one more netbsdlike

* more cfg
2023-12-09 16:15:41 +00:00
Chris
9b39cf9f0e
Added Flock object for automatic unlock on drop. (#2170)
* Added  object for automatic unlock on drop.

* Added appropriate changelog file.

* Fixed doc error on `Flock`.

* Requested changes to make `fcntl::flock` private and OwnedFd instead of RawFd.

* Indent fix.

* Removed doc links to private item, updated imports.

* More import fixes.

* Format changes.

* Remove unused import for redox.

* Added `Flockable` trait per discussions, added tests for `Flock`.

* Simplified flock error conditionals.

* Added missing cfg flags for `Flockable`.

* Added missing cfg flags for impl of `Flockable` on `File`.

* Update src/fcntl.rs

Co-authored-by: SteveLauC <stevelauc@outlook.com>

* Updated `Flockable` comment per suggestion.

* Finalized `FlockArg` as enum and removed TODO accordingly, removed flock wrapper entirely.

* Implemented `Flockable` for `OwnedFd` as well.

* Fixed linting error.

* Updated changelog accordingly.

* Corrected errno logic in `Flock::lock`.

* Properly dropped inner type for `Flock`.

* Replaced `ManuallyDrop` with `Option` as inner `Flock` type to avoid double-free.

* Fixed linting errors.

* Removed unnecessary cfg condition, updated documentation.

* Modified Flock behavior for drop() and unlock().

* Reverted changes to original `flock()` and `FlockArg` for deprecation period, added EINVAL case if the unlock operation is given to `Flock::lock()`.

* Refactored `Flock` to wrap T directly and avoid a double-free after `unlock()` is used.

* Fixed linting errors.

* More linting fixes.

* Fixed example code for `Flock::unlock()`.

* Made requested changes.

* Removed duplicate import.

* Format change.

---------

Co-authored-by: SteveLauC <stevelauc@outlook.com>
2023-12-03 03:06:23 +00:00
Alan Somers
2afff8194c
Add more cfg aliases (#2205)
* Add more cfg aliases

Add cfg aliases for linux_android, bsd, and freebsdlike.  Use them in
many places, though not everywhere they could theoretically be used.

Fixes #2188

* Use apple_targets in build.rs

Co-authored-by: SteveLauC <stevelauc@outlook.com>

* whitespace

Co-authored-by: SteveLauC <stevelauc@outlook.com>

* Define a "solarish" target alias.

* Describe cfg aliases in CONVENTIONS.md

* solarish in line 803

* solarish in line 845

* fix fmt

---------

Co-authored-by: SteveLauC <stevelauc@outlook.com>
2023-11-25 06:32:06 +00:00
Luís Cruz
49283c9031
Add apple tvos support (#2169) 2023-11-09 01:00:20 +00:00
David CARLIER
b5e1a76e22
fcntl adding few apple extensions (#2155) 2023-11-06 06:15:35 +00:00
SteveLauC
e5cc5cea46
refactor: change dirfd arg of xxxat() to Option<fd> (#2157)
* refactor: change dirfd arg of xxxat() to Option<fd>

* changelog

* gate at_rawfd() with features fs or process

* fix import

* fix test on Android

* simplify at_rawfd()

* update changelog
2023-11-05 06:02:40 +00:00
David CARLIER
ed3ed6ba4f
fcntl update following up with F_GETPATH but with FreeBSD's F_KINFO flag support instead (#2152) 2023-10-06 00:47:14 +00:00
David CARLIER
68c230b37e
fcntl add F_GETPATH support for apple/netbsd/dragonfly (#2142)
* fcntl add F_GETPATH support for apple/netbsd

* changes from review

* CHANGELOG entry

---------

Co-authored-by: SteveLauC <stevelauc@outlook.com>
2023-10-03 09:16:32 +00:00
Carlos B
489621e86a
Changed signature for openat function (#2139)
* Changed signature for openat function

Signed-off-by: carlosb1 <mcflurry0@gmail.com>

* Fixed tests for openat to apply Options

Signed-off-by: carlosb1 <mcflurry0@gmail.com>

* Updated changelog

Signed-off-by: carlosb1 <mcflurry0@gmail.com>

* Fixed num PR

Signed-off-by: carlosb1 <mcflurry0@gmail.com>

---------

Signed-off-by: carlosb1 <mcflurry0@gmail.com>
2023-10-01 11:20:45 +00:00
Jonathan Woollett-Light
8ad064d7b9
feat: I/O safety pipe, pipe2 & write (#2100) 2023-09-30 07:52:11 +00:00
Alan Somers
5d55d8f12f Use AsFd in copy_file_range
And expose it on FreeBSD
2023-08-11 09:21:38 -06:00
Alan Somers
4589411229 Clippy cleanup 2023-07-15 11:52:09 -06:00
Alan Somers
e42c3589a3 Clippy cleanup:
fix the new clippy::non_minimal_cfg lint
2023-05-21 08:52:42 -06:00
Steve Lau
7058bcef55 feat: I/O safety for 'sys/statfs' 2022-12-06 21:45:12 +08:00
Alex Saveau
fb802462a6
Fix clippy lints
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-12-04 13:44:50 -08:00
Alan Somers
0ae109ddad Clippy cleanup with the latest nightly. 2022-11-25 08:27:55 -07:00
Alex Saveau
58f99947bf
Run a round of clippy to fix CI
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-11-06 11:40:46 -08:00
Alan Somers
3aedbfa08e Clippy cleanup 2022-09-11 16:25:33 -06:00
Michael Baikov
a6ee63ac32 fix clippy assertions_on_result_states
https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states
2022-08-04 09:44:40 +08:00
Costin-Robert Sin
3e6cb639f0 Fix all formating problems to pass CI formating test
Signed-off-by: Costin-Robert Sin <sin.costinrobert@gmail.com>
2022-06-24 00:35:52 +03:00
Ryan Zoeller
80f8320ffd Cleanup cfg blocks
Remove obsolete references to target_env = wasi, target_os = nacl,
target_os = osx, and a typo'd target_os = fushsia that didn't compile
when fixed.

 - target_env = wasi is dead: https://github.com/rust-lang/rust/pull/60117
 - target_os = nacl is dead: https://github.com/rust-lang/rust/pull/45041
 - target_os = osx is dead, but I can't find a link.
2022-06-06 18:50:19 -05:00
not_a_seagull
0b58f29772 Replace the IoVec type with IoSlice and IoSliceMut 2022-04-08 12:39:16 -07:00
Jonah Petri
6c4b9133f1 uclibc support 2022-01-24 10:06:35 -05:00
Ryan Zoeller
1eeccb942e Add posix_fallocate on DragonFly 2021-12-27 02:56:19 -06:00
Haruki Okada
a60703430e Fix return value of posix_fadvise
libc::posix_fadvise returns errnos directly rather than in the errno
variable.
2021-09-28 19:17:48 -06:00
Alan Somers
a09b1c8ac6 Clippy cleanup
And this time, start running Clippy in CI
2021-09-19 07:58:15 -06:00
Alan Somers
18c095b367 Ignore vsock tests on Linux aarch64
Apparently AWS Graviton containers don't support it.  socket() retunrs
EAFNOSUPPORT in that environment.

Also, be more selective about skipping tests under QEMU

Instead of skipping them on architectures where we happen to use QEMU,
only skip them when QEMU is actually being used.
2021-08-27 22:31:20 -06:00
Alan Somers
f3cb6b321f Fix building the tests for Redox and Illumos
Also, split the overbroad test_mknod_family into two tests
2021-08-22 10:31:39 -06:00
Tom Boland
1a23312c77 Adding linux specific renameat2() 2021-07-08 22:08:48 +01:00
Alan Somers
2d796eba38 Collapse Error into Errno
Now that Nix's weird error types are eliminated, there's no reason not
to simply use Errno as the Error type.
2021-07-07 20:49:29 -06:00
Alan Somers
6511d02414 Overhaul Nix's error types
For many of Nix's consumers it be convenient to easily convert a Nix
error into a std::io::Error.  That's currently not possible because of
the InvalidPath, InvalidUtf8, and UnsupportedOperation types that have
no equivalent in std::io::Error.

However, very few of Nix's public APIs actually return those unusual
errors.  So a more useful API would be for Nix's standard error type to
implement Into<std::io::Error>.

This commit makes Error a simple NewType around Errno.  For most
functions it's a drop-in replacement.  There are only three exceptions:

* clearenv now returns a bespoke error type.  It was the only Nix
  function whose error couldn't be cleanly mapped onto an Errno.

* sys::signal::signal now returns Error(Errno::ENOTSUP) instead of
  Error::UnsupportedOperation when the user passes an incompatible
  argument to `handler`.

* When a NixPath exceeds PATH_MAX, it will now return
  Error(Errno::ENAMETOOLONG) instead of Error::InvalidPath.

In the latter two cases there is now some abiguity about whether the
error code was generated by Nix or by the OS.  But I think the ambiguity
is worth it for the sake of being able to implement Into<io::Error>.

This commit also introduces Error::Sys() as a migration aid.  Previously
that as an enum variant.  Now it's a function, but it will work in many
of the same contexts as the original.

Fixes #1155
2021-07-07 20:49:28 -06:00
Alan Somers
221eac1e8f Reenable tests that only failed on Travis, since we no longer use it. 2021-06-12 17:22:51 -06:00
Alan Somers
2ba6999e2e Check all tests in CI
Travis didn't compile check tests on platforms that couldn't run tests
in CI, so they bitrotted.  Let's see how bad they are.

Most annoyingly, 32-bit Android defines mode_t as 16 bits, but
stat.st_mode as 32-bits.
2021-04-04 19:32:54 -06:00
Alexander Thaller
d965259685 Fix fcntl for FreeBSD
Need to use the right cfg option for the conditional compilation.
target_os is the right option to use when targeting FreeBSD. target_env
was used before which seems to be a typo.
2021-01-03 00:41:45 +01:00
Alan Somers
bf7a5fd606 Switch all builds from Travis to Cirrus
Travis has been super-slow lately (> 6 hours per build).  Cirrus is much
faster: about 20 minutes.  Cirrus also has slightly better test
coverage, mainly because it doesn't use SECCOMP.

Also,

* Fix the Redox CI build.  The old Travis configuration didn't actually
  build for Redox, so we never noticed that Redox can't be built with a
  stable compiler.  Thanks to @coolreader18 for finding this.

* Disable the udp_offload tests on cross-tested platforms.  These tests
  are failing with ENOPROTOOPT in Cirrus-CI.  I suspect it's due to a
  lack of support in QEMU.  These tests were skipped on Travis because
  its kernel was too old.

* Fix require_kernel_version on Cirrus-CI.  Cirrus reports the Linux
  kernel version as 4.19.112+, which the semver crate can't handle.

* Fix test_setfsuid on Cirrus.  When run on Cirrus, it seems like the
  file in /tmp gets deleted as soon as it's closed.  Probably an
  overzealous temporary file cleaner.  Use /var/tmp, because no
  temporary file cleaner should run in there.

* Skip mount tests on Cirrus.  They fail for an unknown reason.
Issue #1351

* Skip the AF_ALG tests on Cirrus-CI
Issue #1352
2020-12-06 22:35:30 -07:00
Alan Somers
f4698ea3fa Skip the OFD locks tests on OverlayFS and musl
OFD lock functions don't work as expected on overlayfs, which is a type
of union file system.  And OVERLAYFS_SUPER_MAGIC isn't defined on musl,
at least not yet.
2020-07-03 10:47:30 -06:00
Xavier L'Heureux
92e63f61cd
Remove warnings when compiling for Redox 2020-05-17 21:05:46 -04:00
Xavier L'Heureux
e94c139a47
Remove more unsupported functions and make it possible to run tests 2020-05-17 21:05:45 -04:00
Andre Nathan
f7f1d09ae2 Split read and write OFD lock tests 2020-04-01 08:10:08 -03:00
Andre Nathan
5e2d14bef9 i686 -> x86 2020-03-27 20:36:19 -03:00
Andre Nathan
4c4df3c0b6 Explain why OFD tests are disabled in some archs 2020-03-27 20:33:37 -03:00
Andre Nathan
1478315e2c Undo rustfmt reformating 2020-03-27 20:33:37 -03:00
Andre Nathan
3332c08793 One more arch exclusion 2020-03-19 09:30:27 -03:00
Andre Nathan
2d90033ed4 Exclude targets failing on CI 2020-03-19 09:03:21 -03:00
Andre Nathan
87f33c3434 Don't test on mips; replace unwrap for expect 2020-03-18 13:51:44 -03:00
Andre Nathan
6075ce0df7 Fix type of pad field 2020-03-18 12:39:28 -03:00
Andre Nathan
ef01f46254 Add missing libc::flock fields in mips 2020-03-18 11:56:22 -03:00
Andre Nathan
82521425ee Try to get tests working on 32 bits 2020-03-18 11:08:41 -03:00
Andre Nathan
2ae45b8792 Add fcntl tests for OFD locks 2020-03-18 10:14:09 -03:00
Ding Xiang Fei
a348806589 use slices for array comparison 2019-09-12 09:30:54 +08:00