Skip to content

Commit 19c7f64

Browse files
j5awrysylvestre
authored andcommitted
mkdir: cast mode bits to rustix::fs::RawMode
rustix::fs::Mode::from_bits_truncated accepts u32 on Linux and u16 on MacOS. Casting to rustix::fs::RawMode makes the value compatible on either platform.
1 parent 8296884 commit 19c7f64

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/uu/mkdir/src/mkdir.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ fn create_single_dir(path: &Path, is_parent: bool, config: &Config) -> UResult<(
287287
#[cfg(unix)]
288288
let (mkdir_mode, shaped_umask) = {
289289
let umask = mode::get_umask();
290-
let umask_bits = rustix::fs::Mode::from_bits_truncate(umask);
290+
let umask_bits = rustix::fs::Mode::from_bits_truncate(umask as rustix::fs::RawMode);
291291
if is_parent {
292292
// Parent directories are never affected by -m (matches GNU behavior).
293293
// We pass 0o777 as the mode and shape the umask so it cannot block
@@ -297,12 +297,15 @@ fn create_single_dir(path: &Path, is_parent: bool, config: &Config) -> UResult<(
297297
// grandparent — through the normal mkdir(2) path.
298298
(
299299
DEFAULT_PERM,
300-
umask_bits & !rustix::fs::Mode::from_bits_truncate(0o300),
300+
umask_bits & !rustix::fs::Mode::from_bits_truncate(0o300 as rustix::fs::RawMode),
301301
)
302302
} else {
303303
match config.mode {
304304
// Explicit -m: shape umask so it cannot block explicitly requested bits.
305-
Some(m) => (m, umask_bits & !rustix::fs::Mode::from_bits_truncate(m)),
305+
Some(m) => (
306+
m,
307+
umask_bits & !rustix::fs::Mode::from_bits_truncate(m as rustix::fs::RawMode),
308+
),
306309
// No -m: leave umask fully intact; kernel applies umask + ACL naturally.
307310
None => (DEFAULT_PERM, umask_bits),
308311
}

0 commit comments

Comments
 (0)