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.rs21
1 files changed, 9 insertions, 12 deletions
diff --git a/ayafs-core/src/filesystem/trait_impl.rs b/ayafs-core/src/filesystem/trait_impl.rs
index 39dba1a..48afac3 100644
--- a/ayafs-core/src/filesystem/trait_impl.rs
+++ b/ayafs-core/src/filesystem/trait_impl.rs
@@ -497,7 +497,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)) =
+ if let Ok((inode_index, _, mut inode)) =
self.lookup_name(parent, &parent_inode, name)
{
let inode_index = inode_index as usize;
@@ -533,12 +533,11 @@ impl Filesystem for AyaFS {
// 删除 dir entry
if let Err(err_code) =
- self.remove_direntry(parent, &mut parent_inode, name, entry_index)
+ self.remove_direntry(parent, &mut parent_inode, name)
{
reply.error(err_code);
return;
}
- parent_inode.size -= 1;
self.update_inode(parent, parent_inode);
reply.ok();
} else {
@@ -580,7 +579,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)) =
+ if let Ok((inode_index, _, inode)) =
self.lookup_name(parent, &parent_inode, name)
{
let inode_index = inode_index as usize;
@@ -592,7 +591,9 @@ impl Filesystem for AyaFS {
// 一定有 . 和 .. 所以 size == 2 就是空目录
// 目录非空 -> ENOTEMPTY
- if inode.size > 2 {
+ let direntry_map = self.dir_entry_map.get(&inode_index).unwrap();
+ if direntry_map.len() > 2 {
+ trace!("deleting inode {} failed, having {} directory entries", inode_index, direntry_map.len());
reply.error(ENOTEMPTY);
return;
}
@@ -608,13 +609,12 @@ impl Filesystem for AyaFS {
// 删除 dir entry
if let Err(err_code) =
- self.remove_direntry(parent, &mut parent_inode, name, entry_index)
+ self.remove_direntry(parent, &mut parent_inode, name)
{
reply.error(err_code);
return;
}
- parent_inode.size -= 1;
self.update_inode(parent, parent_inode);
reply.ok();
} else {
@@ -810,7 +810,7 @@ impl Filesystem for AyaFS {
let mut parent_inode = parent_inode.clone();
match self.lookup_name(parent, &parent_inode, name) {
- Ok((_inode_index, entry_index, _inode)) => {
+ Ok((_inode_index, _, _inode)) => {
if let Some(new_parent_inode) = self.get_inode(new_parent) {
if !check_access(
req.uid(),
@@ -830,7 +830,7 @@ impl Filesystem for AyaFS {
let mut new_parent_inode = new_parent_inode.clone();
match self.lookup_name(new_parent, &new_parent_inode, new_name) {
- Ok((_new_inode_index, new_entry_index, _new_inode)) => {
+ Ok((_new_inode_index, _, _new_inode)) => {
// 新文件存在
if flags & RENAME_NOREPLACE != 0 {
// 指定 noreplace 之后不允许覆盖文件
@@ -859,7 +859,6 @@ impl Filesystem for AyaFS {
parent,
&mut parent_inode,
name,
- entry_index,
) {
reply.error(err_code);
return;
@@ -868,7 +867,6 @@ impl Filesystem for AyaFS {
new_parent,
&mut new_parent_inode,
new_name,
- new_entry_index,
) {
reply.error(err_code);
return;
@@ -894,7 +892,6 @@ impl Filesystem for AyaFS {
parent,
&mut parent_inode,
name,
- entry_index,
) {
reply.error(err_code);
return;