summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorChuyan Zhang <me@zcy.moe>2023-11-29 03:29:34 -0800
committerChuyan Zhang <me@zcy.moe>2023-11-29 03:29:34 -0800
commit7af0771f9a3031acc36a6990d07bdb92a61c0c75 (patch)
tree3db3c79b8d385bc949c8486d97def8dadd4323e6 /src/utils
parentceb83a7214000ccd048857b40cc0ebfc54290731 (diff)
downloadmyfs-7af0771f9a3031acc36a6990d07bdb92a61c0c75.tar.gz
myfs-7af0771f9a3031acc36a6990d07bdb92a61c0c75.zip
symlink, probably not working
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/mod.rs20
-rw-r--r--src/utils/permissions.rs4
2 files changed, 2 insertions, 22 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index 0a9b825..468ebdb 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -21,26 +21,6 @@ pub(crate) fn from_systime(system_time: SystemTime) -> u32 {
.as_secs() as u32
}
-pub(crate) fn make_fileattr(inode_index: usize, inode: &Inode) -> FileAttr {
- FileAttr {
- ino: inode_index as u64,
- size: inode.size as u64,
- blocks: inode.n_blocks as u64,
- atime: to_systime(inode.atime),
- mtime: to_systime(inode.atime),
- ctime: to_systime(inode.ctime),
- crtime: to_systime(inode.crtime),
- kind: inode.mode.into(),
- perm: inode.mode.perm(),
- nlink: inode.n_links as u32,
- uid: inode.uid,
- gid: inode.gid,
- rdev: 0, // 我们不会遇到这个的
- blksize: BLOCK_SIZE as u32,
- flags: inode.flags,
- }
-}
-
pub(crate) fn to_systime(time: u32) -> SystemTime {
UNIX_EPOCH + Duration::from_secs(time as u64)
}
diff --git a/src/utils/permissions.rs b/src/utils/permissions.rs
index b1ec999..6773511 100644
--- a/src/utils/permissions.rs
+++ b/src/utils/permissions.rs
@@ -33,14 +33,14 @@ pub(crate) fn check_access(
incoming_gid: u32,
uid: u32,
gid: u32,
- perm: InodeMode,
+ mode: InodeMode,
mut mask: i32,
) -> bool {
if mask == F_OK {
return true;
}
- let perm = i32::from(perm.0);
+ let perm = i32::from(mode.0);
// root
if incoming_uid == 0 {
// 读写任何东西都是可以的, 执行只有 IXOTH/IXGRP/IXUSR 之一设置才可以