mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 09:54:57 +00:00
Kernel: Count remaining children in VirtualFileSystem::rmdir() manually
To count the remaining children, we simply need to traverse the directory and increment a counter. No need for a custom virtual that all file systems have to implement. :^)
This commit is contained in:
parent
a3f58a5003
commit
d1bbe8b652
1 changed files with 8 additions and 4 deletions
|
@ -747,11 +747,15 @@ KResult VirtualFileSystem::rmdir(StringView path, Custody& base)
|
|||
return EACCES;
|
||||
}
|
||||
|
||||
KResultOr<size_t> dir_count_result = inode.directory_entry_count();
|
||||
if (dir_count_result.is_error())
|
||||
return dir_count_result.result();
|
||||
size_t child_count = 0;
|
||||
auto traversal_result = inode.traverse_as_directory([&child_count](auto&) {
|
||||
++child_count;
|
||||
return true;
|
||||
});
|
||||
if (traversal_result.is_error())
|
||||
return traversal_result;
|
||||
|
||||
if (dir_count_result.value() != 2)
|
||||
if (child_count != 2)
|
||||
return ENOTEMPTY;
|
||||
|
||||
if (custody.is_readonly())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue