Clarification of st_mode bits extraction code.

This commit is contained in:
4lDO2
2025-11-12 12:10:11 +01:00
parent 860a8e6e4b
commit 512c4f0aa8
2 changed files with 9 additions and 6 deletions
+4 -1
View File
@@ -3,7 +3,10 @@ use super::*;
// TODO: Hashmap?
use alloc::collections::BTreeMap;
use core::{cell::{Cell, RefCell}, sync::atomic::{AtomicUsize, Ordering}};
use core::{
cell::{Cell, RefCell},
sync::atomic::{AtomicUsize, Ordering},
};
use crate::{header::errno::EINVAL, sync::Mutex};
+5 -5
View File
@@ -116,13 +116,13 @@ impl Pal for Sys {
let Resugid { ruid, rgid, .. } = redox_rt::sys::posix_getresugid();
let perms = if stat.st_uid == ruid {
stat.st_mode >> (3 * 2 & 0o7)
let perms = (if stat.st_uid == ruid {
stat.st_mode >> (3 * 2)
} else if stat.st_gid == rgid {
stat.st_mode >> (3 * 1 & 0o7)
stat.st_mode >> (3 * 1)
} else {
stat.st_mode & 0o7
};
stat.st_mode
}) & 0o7;
if (mode & R_OK == R_OK && perms & 0o4 != 0o4)
|| (mode & W_OK == W_OK && perms & 0o2 != 0o2)
|| (mode & X_OK == X_OK && perms & 0o1 != 0o1)