1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-02 23:22:07 +00:00

Kernel: Trying to sys$link() a directory should fail with EPERM

This commit is contained in:
Andreas Kling 2020-01-15 22:10:38 +01:00
parent e91f03cb39
commit d4d17ce423
2 changed files with 5 additions and 0 deletions

View file

@ -521,6 +521,9 @@ KResult VFS::link(StringView old_path, StringView new_path, Custody& base)
if (!parent_inode.metadata().may_write(current->process())) if (!parent_inode.metadata().may_write(current->process()))
return KResult(-EACCES); return KResult(-EACCES);
if (old_inode.is_directory())
return KResult(-EPERM);
return parent_inode.add_child(old_inode.identifier(), FileSystemPath(new_path).basename(), old_inode.mode()); return parent_inode.add_child(old_inode.identifier(), FileSystemPath(new_path).basename(), old_inode.mode());
} }

View file

@ -255,5 +255,7 @@ int main(int, char**)
test_eoverflow(); test_eoverflow();
test_rmdir_while_inside_dir(); test_rmdir_while_inside_dir();
EXPECT_ERROR_2(EPERM, link, "/", "/home/anon/lolroot");
return 0; return 0;
} }