Add tracking of access times
Add the atime field, which tracks the last access time. Only reads update the atime. **BREAKING CHANGE**: One less extent available per block, 4 more bytes for node names.
This commit is contained in:
+13
-7
@@ -14,10 +14,12 @@ pub struct Node {
|
||||
pub ctime_nsec: u32,
|
||||
pub mtime: u64,
|
||||
pub mtime_nsec: u32,
|
||||
pub name: [u8; 222],
|
||||
pub atime: u64,
|
||||
pub atime_nsec: u32,
|
||||
pub name: [u8; 226],
|
||||
pub parent: u64,
|
||||
pub next: u64,
|
||||
pub extents: [Extent; (BLOCK_SIZE as usize - 272)/16],
|
||||
pub extents: [Extent; (BLOCK_SIZE as usize - 288)/16],
|
||||
}
|
||||
|
||||
impl Node {
|
||||
@@ -40,15 +42,17 @@ impl Node {
|
||||
ctime_nsec: 0,
|
||||
mtime: 0,
|
||||
mtime_nsec: 0,
|
||||
name: [0; 222],
|
||||
atime: 0,
|
||||
atime_nsec: 0,
|
||||
name: [0; 226],
|
||||
parent: 0,
|
||||
next: 0,
|
||||
extents: [Extent::default(); (BLOCK_SIZE as usize - 272)/16],
|
||||
extents: [Extent::default(); (BLOCK_SIZE as usize - 288)/16],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(mode: u16, name: &str, parent: u64, ctime: u64, ctime_nsec: u32) -> syscall::Result<Node> {
|
||||
let mut bytes = [0; 222];
|
||||
let mut bytes = [0; 226];
|
||||
if name.len() > bytes.len() {
|
||||
return Err(syscall::Error::new(syscall::ENAMETOOLONG));
|
||||
}
|
||||
@@ -64,10 +68,12 @@ impl Node {
|
||||
ctime_nsec: ctime_nsec,
|
||||
mtime: ctime,
|
||||
mtime_nsec: ctime_nsec,
|
||||
atime: ctime,
|
||||
atime_nsec: ctime_nsec,
|
||||
name: bytes,
|
||||
parent: parent,
|
||||
next: 0,
|
||||
extents: [Extent::default(); (BLOCK_SIZE as usize - 272)/16],
|
||||
extents: [Extent::default(); (BLOCK_SIZE as usize - 288)/16],
|
||||
})
|
||||
}
|
||||
|
||||
@@ -85,7 +91,7 @@ impl Node {
|
||||
}
|
||||
|
||||
pub fn set_name(&mut self, name: &str) -> syscall::Result<()> {
|
||||
let mut bytes = [0; 222];
|
||||
let mut bytes = [0; 226];
|
||||
if name.len() > bytes.len() {
|
||||
return Err(syscall::Error::new(syscall::ENAMETOOLONG));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user