summaryrefslogtreecommitdiff
path: root/ayafs-core/src/utils
diff options
context:
space:
mode:
authorChuyan Zhang <me@zcy.moe>2023-12-01 19:42:13 -0800
committerChuyan Zhang <me@zcy.moe>2023-12-01 19:42:13 -0800
commit4c34414b26bf71e747ea3ecb2586645bab4aba52 (patch)
treeb569935a94c7fb3e0a23a19207f6545b4d7719c3 /ayafs-core/src/utils
parentfd125947c9db0b33761414e65e919f73d9bf1815 (diff)
downloadmyfs-4c34414b26bf71e747ea3ecb2586645bab4aba52.tar.gz
myfs-4c34414b26bf71e747ea3ecb2586645bab4aba52.zip
Multiple bugfix, it works!
Diffstat (limited to 'ayafs-core/src/utils')
-rw-r--r--ayafs-core/src/utils/constants.rs1
-rw-r--r--ayafs-core/src/utils/mod.rs15
2 files changed, 3 insertions, 13 deletions
diff --git a/ayafs-core/src/utils/constants.rs b/ayafs-core/src/utils/constants.rs
deleted file mode 100644
index 8b13789..0000000
--- a/ayafs-core/src/utils/constants.rs
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/ayafs-core/src/utils/mod.rs b/ayafs-core/src/utils/mod.rs
index 468ebdb..d73cb3e 100644
--- a/ayafs-core/src/utils/mod.rs
+++ b/ayafs-core/src/utils/mod.rs
@@ -1,4 +1,3 @@
-mod constants;
pub mod permissions;
use crate::block_device::BLOCK_SIZE;
@@ -7,6 +6,8 @@ use crate::{AyaFS, INODE_PER_BLOCK};
use fuser::{FileAttr, FileType};
use std::time::{Duration, SystemTime, UNIX_EPOCH};
+// pub(crate) const ANON_INODE_FS_MAGIC: libc::__fsword_t = 0x09041934;
+
pub(crate) fn time_now() -> u32 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
@@ -25,16 +26,6 @@ pub(crate) fn to_systime(time: u32) -> SystemTime {
UNIX_EPOCH + Duration::from_secs(time as u64)
}
-// File type code, one of:
-// 0x0 Unknown.
-// 0x1 Regular file.
-// 0x2 Directory.
-// 0x3 Character device file.
-// 0x4 Block device file.
-// 0x5 FIFO.
-// 0x6 Socket.
-// 0x7 Symbolic link.
-
pub(crate) fn from_filetype(file_type: FileType) -> u8 {
match file_type {
FileType::NamedPipe => 0x5,
@@ -85,7 +76,7 @@ impl AyaFS {
/// 输入 inode 编号, 返回它对应的 block number 和 block 内 offset
pub(crate) fn locate_inode(&self, inode_index: usize) -> (usize, usize) {
let block_number =
- inode_index / INODE_PER_BLOCK + 1 + self.inode_bitmap.length + self.data_bitmap.length;
+ inode_index / INODE_PER_BLOCK; // + 1 + self.inode_bitmap.length + self.data_bitmap.length;
let block_offset = inode_index % INODE_PER_BLOCK * INODE_SIZE;
(block_number, block_offset)
}