mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-08 18:26:48 +00:00
实现fat文件系统的truncate方法 (#428)
This commit is contained in:
parent
df2f5051ac
commit
04babc3fab
@ -1511,6 +1511,17 @@ impl IndexNode for LockedFATInode {
|
||||
}
|
||||
}
|
||||
|
||||
fn truncate(&self, len: usize) -> Result<(), SystemError> {
|
||||
let guard: SpinLockGuard<FATInode> = self.0.lock();
|
||||
let old_size = guard.metadata.size as usize;
|
||||
if len < old_size {
|
||||
drop(guard);
|
||||
self.resize(len)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn list(&self) -> Result<Vec<String>, SystemError> {
|
||||
let mut guard: SpinLockGuard<FATInode> = self.0.lock();
|
||||
let fatent: &FATDirEntry = &guard.inode_type;
|
||||
|
@ -357,6 +357,8 @@ pub const SYS_IOCTL: usize = 16;
|
||||
#[allow(dead_code)]
|
||||
pub const SYS_WRITEV: usize = 20;
|
||||
|
||||
pub const SYS_MADVISE: usize = 28;
|
||||
|
||||
pub const SYS_DUP: usize = 32;
|
||||
pub const SYS_DUP2: usize = 33;
|
||||
|
||||
@ -1128,6 +1130,11 @@ impl Syscall {
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
SYS_MADVISE => {
|
||||
kwarn!("SYS_MADVISE has not yet been implemented");
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
_ => panic!("Unsupported syscall ID: {}", syscall_num),
|
||||
};
|
||||
return r;
|
||||
|
Loading…
x
Reference in New Issue
Block a user