mkdir umask fix (#12354)

# Description
Fixes how the directory permissions are calculated in `mkdir`. Instead
of subtraction, the umask is actually used as a mask via negation
followed by bitwise and with the default mode. This matches how [uucore
calculates](cac7155fba/src/uu/mkdir/src/mkdir.rs (L61))
the mode.
This commit is contained in:
Ian Manske 2024-04-01 20:14:13 +00:00 committed by GitHub
parent 3bc0b332f4
commit aaefc5e110
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -13,7 +13,7 @@ const DEFAULT_MODE: u32 = 0o777;
#[cfg(not(windows))]
fn get_mode() -> u32 {
DEFAULT_MODE - mode::get_umask()
!mode::get_umask() & DEFAULT_MODE
}
#[cfg(windows)]

View file

@ -141,7 +141,7 @@ fn mkdir_umask_permission() {
assert_eq!(
actual, 0o40755,
"Most *nix systems have 0o00022 as the umask. \
So directory permission should be 0o40755 = 0o40777 - 0o00022"
So directory permission should be 0o40755 = 0o40777 & (!0o00022)"
);
})
}