linux/tools/testing/selftests/filesystems/anon_inode_test.c
Mark Brown 4cb6c8af85 selftests/filesystems: Fix build of anon_inode_test
The newly added anon_inode_test test fails to build due to attempting to
include a nonexisting overlayfs/wrapper.h:

  anon_inode_test.c:10:10: fatal error: overlayfs/wrappers.h: No such file or directory
     10 | #include "overlayfs/wrappers.h"
        |          ^~~~~~~~~~~~~~~~~~~~~~

This is due to 0bd92b9fe5 ("selftests/filesystems: move wrapper.h out
of overlayfs subdir") which was added in the vfs-6.16.selftests branch
which was based on -rc5 and did not contain the newly added test so once
things were merged into mainline the build started failing - both parent
commits are fine.

Fixes: 3e406741b1 ("Merge tag 'vfs-6.16-rc1.selftests' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs")
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2025-05-31 08:43:53 -07:00

69 lines
1.2 KiB
C

// SPDX-License-Identifier: GPL-2.0
#define _GNU_SOURCE
#define __SANE_USERSPACE_TYPES__
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
#include "../kselftest_harness.h"
#include "wrappers.h"
TEST(anon_inode_no_chown)
{
int fd_context;
fd_context = sys_fsopen("tmpfs", 0);
ASSERT_GE(fd_context, 0);
ASSERT_LT(fchown(fd_context, 1234, 5678), 0);
ASSERT_EQ(errno, EOPNOTSUPP);
EXPECT_EQ(close(fd_context), 0);
}
TEST(anon_inode_no_chmod)
{
int fd_context;
fd_context = sys_fsopen("tmpfs", 0);
ASSERT_GE(fd_context, 0);
ASSERT_LT(fchmod(fd_context, 0777), 0);
ASSERT_EQ(errno, EOPNOTSUPP);
EXPECT_EQ(close(fd_context), 0);
}
TEST(anon_inode_no_exec)
{
int fd_context;
fd_context = sys_fsopen("tmpfs", 0);
ASSERT_GE(fd_context, 0);
ASSERT_LT(execveat(fd_context, "", NULL, NULL, AT_EMPTY_PATH), 0);
ASSERT_EQ(errno, EACCES);
EXPECT_EQ(close(fd_context), 0);
}
TEST(anon_inode_no_open)
{
int fd_context;
fd_context = sys_fsopen("tmpfs", 0);
ASSERT_GE(fd_context, 0);
ASSERT_GE(dup2(fd_context, 500), 0);
ASSERT_EQ(close(fd_context), 0);
fd_context = 500;
ASSERT_LT(open("/proc/self/fd/500", 0), 0);
ASSERT_EQ(errno, ENXIO);
EXPECT_EQ(close(fd_context), 0);
}
TEST_HARNESS_MAIN