Unverified Commit c7841597 authored by Christian Brauner's avatar Christian Brauner
Browse files

selftests/filesystems: add chown() test for anonymous inodes

parent 1ed95281
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2,3 +2,4 @@
dnotify_test
devpts_pts
file_stressor
anon_inode_test
+1 −1
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0

CFLAGS += $(KHDR_INCLUDES)
TEST_GEN_PROGS := devpts_pts file_stressor
TEST_GEN_PROGS := devpts_pts file_stressor anon_inode_test
TEST_GEN_PROGS_EXTENDED := dnotify_test

include ../lib.mk
+26 −0
Original line number Diff line number Diff line
// 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 "overlayfs/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_HARNESS_MAIN