Commit Graph

49 Commits

Author SHA1 Message Date
SteveLauC
1c189d99bc
feat: Add associated constants UTIME_OMIT UTIME_NOW to TimeSpec (#1879)
* feat: support UTIME_NOW & UTIME_OMIT

* fmt

* fmt

* linux x32 type cast

* fmt
2023-12-10 00:27:36 +00:00
SteveLauC
6961f0fabd
refactor: cfg for test/* (#2230)
* refactor: cfg for test/*

* one more netbsdlike

* more cfg
2023-12-09 16:15:41 +00:00
David CARLIER
2ab5558e08
fix, mostly, solaris build. (#2248)
With few exceptions as newer interfaces like preadv/pwritev unsupported
only on solaris.
2023-12-08 19:29:11 +00:00
Luís Cruz
49283c9031
Add apple tvos support (#2169) 2023-11-09 01:00:20 +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
SteveLauC
347915bdb5 format code 2022-08-09 12:17:27 +08:00
SteveLauC
d458ecd4e1 remove deprecated items 2022-08-09 12:15:52 +08: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
Al Hoang
d02e27476c add haiku support
* enabled as much functionality and defines that match
  updated libc definitions for haiku
2022-05-14 18:45:18 -05:00
Ryan Zoeller
9fe9432181 Disable mknod and mknodat tests on DragonFly 2021-12-24 21:47:39 -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
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
Luca BRUNO
6e2158bc71
sys/stat: add a safe wrapper for mknodat(2)
This introduces a new `mknodat` helper.

Ref: https://pubs.opengroup.org/onlinepubs/9699919799/functions/mknod.html
2021-07-28 12:36:59 +00: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
7b7d954005 misc Clippy cleanup
* Fix race conditions in the tests.  Two tests were grabbing a mutex but
  immediately dropping it.  Thank you, Clippy.

* Remove vestigial Windows support.  Remove some code added to support
  Windows in 2015.  Nix is no longer intended to ever run on Windows.

* Various other minor Clippy lints.
2021-05-30 20:12:41 -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
Alan Somers
1ae5dd8b16 Convert the crate to edition 2018 2020-05-31 19:07:15 -06:00
Xavier L'Heureux
92e63f61cd
Remove warnings when compiling for Redox 2020-05-17 21:05:46 -04:00
Xavier L'Heureux
9e5e9344c6
Remove temporarily the failing tests for Redox
TODO: Fix them in Relibc
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
Xavier L'Heureux
bbc42e7845 Where relevant, replace equality checks in assert! with assert_eq!
`assert_eq!` gives more debug info when the test fails by default than
`assert!`. This should help make debugging easier.
2019-09-19 22:20:25 -04:00
Kevin Wern
c006491521 sys/stat: implement mkdirat 2019-06-15 23:13:20 -04:00
Alan Somers
d26749e33a Fix some bugs with multithreaded tests:
* kmod tests must run exclusively, because they load and unload a module
  with a constant name.
* A few tests were doing some variant of chdir, but weren't taking the
  CWD_MTX.
* The kmod tests read files by path relative to CWD, so they need the
  CWD_MTX.  But they don't need it exclusively, so convert the CWD_MTX
  into an RwLock.
* Tests that do change the cwd need to change it back when they're done.
2019-06-06 08:54:51 -06:00
Andrei-Marius Radu
bdca86b8f7 Fix build and tests issues on OpenBSD 6.4+
1)  lutimes doesn't exist on OpenBSD so it needs to be under conditional
    compilation.

    The only "reference" that I could find related to this is the discussion
    here: https://github.com/rust-lang/libc/pull/790 .

2)  fexecve doesn't exist on OpenBSD so add conditional compilation for it
    in unistd and in related tests.

    The only "reference" that I could find is a mention that fexecve is
    not implemented on OpenBSD in the manual pages for signal(3) and
    sigaction(2):

    Official repository (search for "fexecve"):
    https://cvsweb.openbsd.org/src/lib/libc/sys/sigaction.2?rev=1.75&content-type=text/x-cvsweb-markup

    Github mirror:
    https://github.com/openbsd/src/blob/master/lib/libc/sys/sigaction.2#L619

3)  AIO doesn't work on OpenBSD so put test_aio_drop under conditional
    compilation.

4)  Add relevant changelog entries.

P.S. On OpenBSD remains the issue of test_scm_rights which builds
correctly but fails at runtime.
2019-01-15 00:53:52 +02:00
Tom Pusateri
d1395511a6 Allow 'cargo test' to complete successfully on NetBSD 8.0.
Some tests have been disabled and will need further review.
2018-12-16 22:16:27 -05:00
Julio Merino
12f10c76a5 Add a wrapper for lutimes(2)
PR #944 added wrappers for the more-modern futimens(2) and utimesat(2),
but unfortunately these APIs are not available on old-ish systems.

In particular, macOS Sierra and below don't implement them, making the
new APIs unusable.  Whether we should care about such "old" systems is
debatable, but the problem is that, at the moment, this is the only
macOS version usable on Travis to test kexts and, thus, to test FUSE
file systems.

This should have been part of PR #946, which added a wrapper for
utimes(2) following this same rationale, but missed lutimes(2) because
I simply didn't notice it existed.
2018-11-07 15:19:53 -05:00
Alan Somers
682bd37b48 Eliminate compiler warnings, especially on non-Linux platforms 2018-10-15 15:01:44 -06:00
Julio Merino
06be3ee604 Add a wrapper for utimes(2)
PR #944 added wrappers for the more-modern futimens(2) and utimesat(2),
but unfortunately these APIs are not available on old-ish systems.

In particular, macOS Sierra and below don't implement them, making the
new APIs unusable.  Whether we should care about such "old" systems is
debatable, but the problem is that, at the moment, this is the only
macOS version usable on Travis to test kexts and, thus, to test FUSE
file systems.
2018-10-02 10:50:05 -04:00
Julio Merino
886c76cfbb Add wrappers for futimens(2) and utimesat(2) 2018-09-29 21:08:53 -04:00
Igor Gnatenko
ecad72a18e
deps: update tempfile to 3
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2018-09-01 11:39:36 +02:00
Anton Ageev
d315804a1f Add fchmod, fchmodat functions. 2018-03-23 21:36:47 +03:00
Bryant Mairs
46fe1319a7 Remove useless Err(_) match arms 2017-12-20 07:05:04 -08:00
Jörg Thalheim
63a7af156d test/test_stat.rs: use matching tempdir name for test_fstatat 2017-09-04 17:32:21 +01:00
Jörg Thalheim
c3ff44c80b test/test_stat.rs: test correct stat function 2017-09-04 08:28:04 +01:00
Jörg Thalheim
b6a8a3c64f
add support for fstatat 2017-03-21 01:27:21 +01:00
Mattis Marjak
73dd2e05b8 update libc to 0.2.2 2016-01-18 21:29:38 -08:00
Kamal Marhubi
4450b96399 Use tempdir for temporary files in tests 2016-01-13 09:56:14 -08:00
Kamal Marhubi
b40046e985 Fix compiler warnings in tests 2016-01-13 09:31:54 -08:00
Geoffrey Thomas
1f4b0b7f8c test_stat: Remove st_rdev test
On FreeBSD, st_rdev seems to be set to a unique value (correlated with,
but not identical to, st_ino) per file. Neither the FreeBSD nor Linux
man page makes any promises on st_rdev for regular files; useful test
coverage of st_rdev would check it on a special file.

All tests now pass on FreeBSD.
2015-09-03 13:14:20 -07:00
Tim JIANG
08a55288d1 Make it compatible for Android.
* Fixed an unused_import error in `termios.rs` for Android.
* Fixed undefined references to `preadv` and `pwritev` for Android -
  At least they don't exist from API level 3 to 21.
* Fixed the uid > 0 and gid > 0 checks in `stat`'s tests - Running the
  tests by root is possible, especially when running on a rooted Android
  device.

Those changes made rust-nix buildable (again) on Android. All the tests
passed as well.
2015-07-27 10:31:26 -07:00
Carl Lerche
a5e9cc637b Fix comparison 2015-07-10 13:54:17 -07:00
Alex Newman
ca14371749 Fix unit tests as blank files can still have blocks
On an encrypted filesystem everything acts like a symlink

$ stat baz
  File: ‘baz’
  Size: 0         	Blocks: 16         IO Block: 4096   regular empty file
Device: 26h/38d	Inode: 6835152     Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/ posix4e)   Gid: ( 1000/ posix4e)
Access: 2015-07-10 11:11:21.846851777 -0700
Modify: 2015-07-10 11:11:21.846851777 -0700
Change: 2015-07-10 11:11:21.846851777 -0700
 Birth: -
2015-07-10 11:14:35 -07:00
Skyler Hawthorne
ecbbf1a817 Add lstat 2015-05-08 14:11:44 -07:00
Carl Lerche
0d5ea0b16d Track Rust master 2015-03-25 10:52:05 -07:00
Carl Lerche
47d2332c3c NixResult -> nix::Result; NixError -> nix::Error 2015-03-24 23:25:10 -07:00
Markus Jais
b20b6c80cd added test for fstat 2015-03-13 16:11:19 -07:00
Carl Lerche
60ccee778b Cleanup readv & writev + tests 2015-02-21 14:33:27 -08:00