1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:47:34 +00:00

Kernel+Tests: Make sys$rmdir() fail with EINVAL if basename is "."

Dr. POSIX says that we should reject attempts to rmdir() the file named
"." so this patch does exactly that. We also add a test.

This solves a FIXME from January 2019. :^)
This commit is contained in:
Andreas Kling 2022-12-19 18:47:35 +01:00
parent 42b011b571
commit 8d781d0216
2 changed files with 26 additions and 1 deletions

View file

@ -317,6 +317,26 @@ TEST_CASE(tmpfs_massive_file)
EXPECT_EQ(rc, 0);
}
TEST_CASE(rmdir_dot)
{
int rc = mkdir("/home/anon/rmdir-test-1", 0700);
EXPECT_EQ(rc, 0);
rc = rmdir("/home/anon/rmdir-test-1/.");
EXPECT_NE(rc, 0);
EXPECT_EQ(errno, EINVAL);
rc = chdir("/home/anon/rmdir-test-1");
EXPECT_EQ(rc, 0);
rc = rmdir(".");
VERIFY(rc != 0);
EXPECT_EQ(errno, EINVAL);
rc = rmdir("/home/anon/rmdir-test-1");
EXPECT_EQ(rc, 0);
}
TEST_CASE(rmdir_while_inside_dir)
{
int rc = mkdir("/home/anon/testdir", 0700);