aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/filesystems/mount-notify
diff options
context:
space:
mode:
authorAmir Goldstein <[email protected]>2025-05-09 13:32:38 +0000
committerChristian Brauner <[email protected]>2025-05-12 09:40:12 +0000
commite897b9b1334bab7427f062e4ec1f4297676c60da (patch)
tree76853a7be279852a55894efaa9a8a2a95b0f57be /tools/testing/selftests/filesystems/mount-notify
parentselftests/fs/mount-notify: build with tools include dir (diff)
downloadkernel-e897b9b1334bab7427f062e4ec1f4297676c60da.tar.gz
kernel-e897b9b1334bab7427f062e4ec1f4297676c60da.zip
selftests/filesystems: create get_unique_mnt_id() helper
Add helper to utils.c and use it in mount-notify and statmount tests. Linking with utils.c drags in a dependecy with libcap, so add it to the Makefile of the tests. Reviewed-by: John Hubbard <[email protected]> Signed-off-by: Amir Goldstein <[email protected]> Link: https://lore.kernel.org/[email protected] Reviewed-by: Christian Brauner <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
Diffstat (limited to 'tools/testing/selftests/filesystems/mount-notify')
-rw-r--r--tools/testing/selftests/filesystems/mount-notify/Makefile3
-rw-r--r--tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c13
2 files changed, 5 insertions, 11 deletions
diff --git a/tools/testing/selftests/filesystems/mount-notify/Makefile b/tools/testing/selftests/filesystems/mount-notify/Makefile
index 41ebfe558a0a..55a2e5399e8a 100644
--- a/tools/testing/selftests/filesystems/mount-notify/Makefile
+++ b/tools/testing/selftests/filesystems/mount-notify/Makefile
@@ -1,7 +1,10 @@
# SPDX-License-Identifier: GPL-2.0-or-later
CFLAGS += -Wall -O2 -g $(KHDR_INCLUDES) $(TOOLS_INCLUDES)
+LDLIBS += -lcap
TEST_GEN_PROGS := mount-notify_test
include ../../lib.mk
+
+$(OUTPUT)/mount-notify_test: ../utils.c
diff --git a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
index 4f0f325379b5..63ce708d93ed 100644
--- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
+++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
@@ -13,6 +13,7 @@
#include "../../kselftest_harness.h"
#include "../statmount/statmount.h"
+#include "../utils.h"
// Needed for linux/fanotify.h
#ifndef __kernel_fsid_t
@@ -23,16 +24,6 @@ typedef struct {
#include <sys/fanotify.h>
-static uint64_t get_mnt_id(struct __test_metadata *const _metadata,
- const char *path)
-{
- struct statx sx;
-
- ASSERT_EQ(statx(AT_FDCWD, path, 0, STATX_MNT_ID_UNIQUE, &sx), 0);
- ASSERT_TRUE(!!(sx.stx_mask & STATX_MNT_ID_UNIQUE));
- return sx.stx_mnt_id;
-}
-
static const char root_mntpoint_templ[] = "/tmp/mount-notify_test_root.XXXXXX";
static const int mark_cmds[] = {
@@ -81,7 +72,7 @@ FIXTURE_SETUP(fanotify)
ASSERT_EQ(mkdir("b", 0700), 0);
- self->root_id = get_mnt_id(_metadata, "/");
+ self->root_id = get_unique_mnt_id("/");
ASSERT_NE(self->root_id, 0);
for (i = 0; i < NUM_FAN_FDS; i++) {