Skip to content

Commit fcf31ec

Browse files
committed
selftests/filesystems: add chmod() test for anonymous inodes
Test that anonymous inodes cannot be chmod()ed. Link: https://lore.kernel.org/[email protected] Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent c784159 commit fcf31ec

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tools/testing/selftests/filesystems/anon_inode_test.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,18 @@ TEST(anon_inode_no_chown)
2222
EXPECT_EQ(close(fd_context), 0);
2323
}
2424

25+
TEST(anon_inode_no_chmod)
26+
{
27+
int fd_context;
28+
29+
fd_context = sys_fsopen("tmpfs", 0);
30+
ASSERT_GE(fd_context, 0);
31+
32+
ASSERT_LT(fchmod(fd_context, 0777), 0);
33+
ASSERT_EQ(errno, EOPNOTSUPP);
34+
35+
EXPECT_EQ(close(fd_context), 0);
36+
}
37+
2538
TEST_HARNESS_MAIN
2639

0 commit comments

Comments
 (0)