Skip to content

Commit 3f26ea5

Browse files
pkubajoech3
andcommitted
mkfifo: fix build where mode_t is not u32
`rustix::fs::Mode` is a bitflags over `rustix::fs::RawMode`, which aliases `libc::mode_t`. That is `u32` on Linux but `u16` on the BSDs, so handing the `u32` mode straight to `Mode::from_bits_truncate()` fails to compile there: error[E0308]: mismatched types --> src/uu/mkfifo/src/mkfifo.rs:146:50 | 146 | mkfifoat(CWD, path, Mode::from_bits_truncate(mode)) | ------------------------ ^^^^ expected `u16`, found `u32` Cast to `RawMode` first, which is a no-op on Linux and matches what `mkdir` already does in src/uu/mkdir/src/mkdir.rs. Co-authored-by: oech3 <79379754+oech3@users.noreply.github.com>
1 parent 667a82b commit 3f26ea5

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/uu/mkfifo/src/mkfifo.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,12 @@ pub fn uu_app() -> Command {
142142
// the umask so the requested mode is applied atomically (see issue #10020).
143143
#[cfg(not(target_vendor = "apple"))]
144144
fn create_fifo(path: &str, mode: u32) -> Result<(), std::io::Error> {
145-
use rustix::fs::{CWD, mkfifoat};
146-
mkfifoat(CWD, path, Mode::from_bits_truncate(mode)).map_err(std::io::Error::from)
145+
use rustix::fs;
146+
Ok(fs::mkfifoat(
147+
fs::CWD,
148+
path,
149+
Mode::from_bits_truncate(mode as fs::RawMode),
150+
)?)
147151
}
148152

149153
#[cfg(target_vendor = "apple")]

0 commit comments

Comments
 (0)