summaryrefslogtreecommitdiff
path: root/ayafs-core/src/filesystem
diff options
context:
space:
mode:
Diffstat (limited to 'ayafs-core/src/filesystem')
-rw-r--r--ayafs-core/src/filesystem/trait_impl.rs26
1 files changed, 16 insertions, 10 deletions
diff --git a/ayafs-core/src/filesystem/trait_impl.rs b/ayafs-core/src/filesystem/trait_impl.rs
index 78673ba..1c3c7b3 100644
--- a/ayafs-core/src/filesystem/trait_impl.rs
+++ b/ayafs-core/src/filesystem/trait_impl.rs
@@ -481,8 +481,9 @@ impl Filesystem for AyaFS {
}
fn unlink(&mut self, req: &Request<'_>, parent: u64, name: &OsStr, reply: ReplyEmpty) {
- debug!("unlink(parent: {:#x?}, name: {:?})", parent, name,);
- if let Some(parent_inode) = self.get_inode(parent as usize) {
+ debug!("unlink(parent: {:#x?}, name: {:?})", parent, name);
+ let parent = parent as usize;
+ if let Some(parent_inode) = self.get_inode(parent) {
// 无权限删除 -> EACCES
if !check_access(
req.uid(),
@@ -511,7 +512,7 @@ impl Filesystem for AyaFS {
let mut parent_inode = parent_inode.clone();
// 不存在 -> No such file or directory
if let Ok((inode_index, entry_index, mut inode)) =
- self.lookup_name(parent as usize, &parent_inode, name)
+ self.lookup_name(parent, &parent_inode, name)
{
let inode_index = inode_index as usize;
@@ -546,11 +547,13 @@ impl Filesystem for AyaFS {
// 删除 dir entry
if let Err(err_code) =
- self.remove_direntry(parent as usize, &mut parent_inode, name, entry_index)
+ self.remove_direntry(parent, &mut parent_inode, name, entry_index)
{
reply.error(err_code);
return;
}
+ parent_inode.size -= 1;
+ self.update_inode(parent, parent_inode);
reply.ok();
} else {
reply.error(ENOENT);
@@ -561,8 +564,9 @@ impl Filesystem for AyaFS {
}
fn rmdir(&mut self, req: &Request<'_>, parent: u64, name: &OsStr, reply: ReplyEmpty) {
- debug!("rmdir(parent: {:#x?}, name: {:?}", parent, name,);
- if let Some(parent_inode) = self.get_inode(parent as usize) {
+ debug!("rmdir(parent: {:#x?}, name: {:?})", parent, name);
+ let parent = parent as usize;
+ if let Some(parent_inode) = self.get_inode(parent) {
// 无权限删除 -> EACCES
if !check_access(
req.uid(),
@@ -591,7 +595,7 @@ impl Filesystem for AyaFS {
let mut parent_inode = parent_inode.clone();
// 不存在 -> No such file or directory
if let Ok((inode_index, entry_index, inode)) =
- self.lookup_name(parent as usize, &parent_inode, name)
+ self.lookup_name(parent, &parent_inode, name)
{
let inode_index = inode_index as usize;
// 要删除的 entry 是一般文件, 不用 rmdir
@@ -618,12 +622,14 @@ impl Filesystem for AyaFS {
// 删除 dir entry
if let Err(err_code) =
- self.remove_direntry(parent as usize, &mut parent_inode, name, entry_index)
+ self.remove_direntry(parent, &mut parent_inode, name, entry_index)
{
reply.error(err_code);
return;
}
+ parent_inode.size -= 1;
+ self.update_inode(parent, parent_inode);
reply.ok();
} else {
reply.error(ENOENT);
@@ -1152,7 +1158,7 @@ impl Filesystem for AyaFS {
_flush: bool,
reply: ReplyEmpty,
) {
- debug!("release(ino: {:#x?}, fh: {}", ino, fh);
+ debug!("release(ino: {:#x?}, fh: {})", ino, fh);
if self.file_handle_map.contains_key(&fh) {
self.file_handle_map.remove(&fh);
reply.ok();
@@ -1266,7 +1272,7 @@ impl Filesystem for AyaFS {
_flags: i32,
reply: ReplyEmpty,
) {
- debug!("releasedir(ino: {:#x?}, fh: {}", ino, fh);
+ debug!("releasedir(ino: {:#x?}, fh: {})", ino, fh);
if self.file_handle_map.contains_key(&fh) {
self.file_handle_map.remove(&fh);
reply.ok();