VFS: unlink() should fail when called on a directory.

This commit is contained in:
Andreas Kling 2019-01-23 05:35:42 +01:00
parent 754037874c
commit a1b4f719ba
Notes: sideshowbarker 2024-07-19 15:58:37 +09:00

View file

@ -245,6 +245,12 @@ bool VFS::unlink(const String& path, Inode& base, int& error)
return false;
}
auto inode = get_inode(inode_id);
if (inode->is_directory()) {
error = -EISDIR;
return false;
}
auto parent_inode = get_inode(parent_dir);
// FIXME: The reverse_lookup here can definitely be avoided.
if (!parent_inode->remove_child(parent_inode->reverse_lookup(inode_id), error))