summaryrefslogtreecommitdiff
path: root/src/disk/inode.rs
diff options
context:
space:
mode:
authorChuyan Zhang <me@zcy.moe>2023-11-26 02:33:01 -0800
committerChuyan Zhang <me@zcy.moe>2023-11-26 02:33:01 -0800
commit9d1368b0ea380a9446b4697af668d1685464b6c7 (patch)
tree2103af418264cc70addc9cfc6ed7acac640f5151 /src/disk/inode.rs
parent777d5e01a34b8ebe6f1a5751b593266f93e88499 (diff)
downloadmyfs-9d1368b0ea380a9446b4697af668d1685464b6c7.tar.gz
myfs-9d1368b0ea380a9446b4697af668d1685464b6c7.zip
more code idk what they are im so tired ohno
Diffstat (limited to 'src/disk/inode.rs')
-rw-r--r--src/disk/inode.rs26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/disk/inode.rs b/src/disk/inode.rs
index 256d2f5..6f9d338 100644
--- a/src/disk/inode.rs
+++ b/src/disk/inode.rs
@@ -1,6 +1,6 @@
+use crate::utils;
use bitflags::bitflags;
use fuser::{FileAttr, FileType};
-use crate::utils;
pub const DIRECT_NUMBER: usize = 15;
@@ -103,7 +103,6 @@ impl From<InodeMode> for u8 {
}
}
-
/// Pretty much the same with ext2, with minor changes:
/// - removed OS dependent attributes (osd1 & osd2)
/// - removed i_faddr since fragmentation is not supported
@@ -153,7 +152,7 @@ impl Inode {
mtime: time,
crtime: time,
gid,
- n_links: 0,
+ n_links: 1,
n_blocks: 0,
flags,
direct: [0; DIRECT_NUMBER],
@@ -242,7 +241,26 @@ impl Inode {
}
pub fn empty() -> Self {
- Self::new(InodeMode(0), 0, 0, 0, 0, 0, 0, 0)
+ Self {
+ mode: InodeMode(0),
+ uid: 0,
+ size: 0,
+ atime: 0,
+ ctime: 0,
+ mtime: 0,
+ crtime: 0,
+ gid: 0,
+ n_links: 0,
+ n_blocks: 0,
+ flags: 0,
+ direct: [0; 15],
+ single_indirect: 0,
+ double_indirect: 0,
+ triple_indirect: 0,
+ generation: 0,
+ file_acl: 0,
+ dir_acl: 0,
+ }
}
}
pub const INODE_SIZE: usize = std::mem::size_of::<Inode>();