Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/fs/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ mod long_paths;
#[cfg(not(any(target_os = "haiku", target_os = "wasi")))]
mod makedev;
mod mkdirat;
#[cfg(not(target_os = "wasi"))]
mod mknodat;
mod negative_timestamp;
#[cfg(linux_kernel)]
Expand Down
17 changes: 12 additions & 5 deletions tests/fs/mknodat.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(not(any(apple, target_os = "wasi")))]
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
#[test]
fn test_mknodat() {
use rustix::fs::{
Expand All @@ -8,17 +8,24 @@ fn test_mknodat() {
let tmp = tempfile::tempdir().unwrap();
let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap();

// Create a regular file. Not supported on FreeBSD, OpenBSD, illumos,
// or NetBSD.
#[cfg(not(any(solarish, netbsdlike, target_os = "freebsd")))]
// Create a regular file. Not supported on Apple, FreeBSD, OpenBSD,
// illumos, or NetBSD.
#[cfg(not(any(apple, solarish, netbsdlike, target_os = "freebsd")))]
{
mknodat(&dir, "file", FileType::RegularFile, Mode::empty(), 0).unwrap();
let stat = statat(&dir, "file", AtFlags::empty()).unwrap();
assert_eq!(FileType::from_raw_mode(stat.st_mode), FileType::RegularFile);
unlinkat(&dir, "file", AtFlags::empty()).unwrap();
}

mknodat(&dir, "file", FileType::Fifo, Mode::empty(), 0).unwrap();
match mknodat(&dir, "file", FileType::Fifo, Mode::empty(), 0) {
Ok(()) => (),
#[cfg(apple)]
// Apple platforms before macOS 13.0, iOS 16.0, tvOS 16.0, and
// watchOS 9.0 lack `mknodat`.
Err(rustix::io::Errno::NOSYS) => return,
Err(err) => panic!("{:?}", err),
}
let stat = statat(&dir, "file", AtFlags::empty()).unwrap();
assert_eq!(FileType::from_raw_mode(stat.st_mode), FileType::Fifo);
accessat(&dir, "file", Access::EXISTS, AtFlags::empty()).unwrap();
Expand Down
Loading