Skip to content

Commit 540dcf0

Browse files
committed
selftests/nsfs: add ioctl validation tests
Add simple tests to validate that non-nsfs ioctls are rejected. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 7fd511f commit 540dcf0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tools/testing/selftests/filesystems/nsfs/iterate_mntns.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#define _GNU_SOURCE
55
#include <fcntl.h>
6+
#include <linux/auto_dev-ioctl.h>
7+
#include <linux/errno.h>
68
#include <sched.h>
79
#include <stdio.h>
810
#include <string.h>
@@ -146,4 +148,16 @@ TEST_F(iterate_mount_namespaces, iterate_backward)
146148
}
147149
}
148150

151+
TEST_F(iterate_mount_namespaces, nfs_valid_ioctl)
152+
{
153+
ASSERT_NE(ioctl(self->fd_mnt_ns[0], AUTOFS_DEV_IOCTL_OPENMOUNT, NULL), 0);
154+
ASSERT_EQ(errno, ENOTTY);
155+
156+
ASSERT_NE(ioctl(self->fd_mnt_ns[0], AUTOFS_DEV_IOCTL_CLOSEMOUNT, NULL), 0);
157+
ASSERT_EQ(errno, ENOTTY);
158+
159+
ASSERT_NE(ioctl(self->fd_mnt_ns[0], AUTOFS_DEV_IOCTL_READY, NULL), 0);
160+
ASSERT_EQ(errno, ENOTTY);
161+
}
162+
149163
TEST_HARNESS_MAIN

0 commit comments

Comments
 (0)