All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls
@ 2020-02-14 11:35 Viresh Kumar
  2020-02-14 11:35 ` [LTP] [PATCH 1/7] lapi/fsmount: Add definitions for fsmount related syscalls Viresh Kumar
                   ` (7 more replies)
  0 siblings, 8 replies; 32+ messages in thread
From: Viresh Kumar @ 2020-02-14 11:35 UTC (permalink / raw)
  To: ltp

Hello,

This series adds a bunch of LTP tests related to fsmount family of
syscalls.

Thanks

--
viresh

Viresh Kumar (7):
  lapi/fsmount: Add definitions for fsmount related syscalls
  syscalls/fsopen: New tests
  syscalls/fsconfig: New tests
  syscalls/fsmount: New tests
  syscalls/move_mount: New tests
  syscalls/fspick: New tests
  syscalls/open_tree: New tests

 configure.ac                                  |   6 +
 include/lapi/fsmount.h                        | 134 ++++++++++++++++++
 runtest/syscalls                              |  18 +++
 testcases/kernel/syscalls/fsconfig/.gitignore |   2 +
 testcases/kernel/syscalls/fsconfig/Makefile   |   6 +
 .../kernel/syscalls/fsconfig/fsconfig01.c     |  77 ++++++++++
 .../kernel/syscalls/fsconfig/fsconfig02.c     |  97 +++++++++++++
 testcases/kernel/syscalls/fsmount/.gitignore  |   2 +
 testcases/kernel/syscalls/fsmount/Makefile    |   6 +
 testcases/kernel/syscalls/fsmount/fsmount01.c |  71 ++++++++++
 testcases/kernel/syscalls/fsmount/fsmount02.c |  83 +++++++++++
 testcases/kernel/syscalls/fsopen/.gitignore   |   2 +
 testcases/kernel/syscalls/fsopen/Makefile     |   6 +
 testcases/kernel/syscalls/fsopen/fsopen01.c   |  71 ++++++++++
 testcases/kernel/syscalls/fsopen/fsopen02.c   |  56 ++++++++
 testcases/kernel/syscalls/fspick/.gitignore   |   2 +
 testcases/kernel/syscalls/fspick/Makefile     |   6 +
 testcases/kernel/syscalls/fspick/fspick01.c   | 104 ++++++++++++++
 testcases/kernel/syscalls/fspick/fspick02.c   | 110 ++++++++++++++
 .../kernel/syscalls/move_mount/.gitignore     |   2 +
 testcases/kernel/syscalls/move_mount/Makefile |   6 +
 .../kernel/syscalls/move_mount/move_mount01.c |  82 +++++++++++
 .../kernel/syscalls/move_mount/move_mount02.c | 102 +++++++++++++
 .../kernel/syscalls/open_tree/.gitignore      |   2 +
 testcases/kernel/syscalls/open_tree/Makefile  |   6 +
 .../kernel/syscalls/open_tree/open_tree01.c   | 115 +++++++++++++++
 .../kernel/syscalls/open_tree/open_tree02.c   | 110 ++++++++++++++
 27 files changed, 1284 insertions(+)
 create mode 100644 include/lapi/fsmount.h
 create mode 100644 testcases/kernel/syscalls/fsconfig/.gitignore
 create mode 100644 testcases/kernel/syscalls/fsconfig/Makefile
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig01.c
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig02.c
 create mode 100644 testcases/kernel/syscalls/fsmount/.gitignore
 create mode 100644 testcases/kernel/syscalls/fsmount/Makefile
 create mode 100644 testcases/kernel/syscalls/fsmount/fsmount01.c
 create mode 100644 testcases/kernel/syscalls/fsmount/fsmount02.c
 create mode 100644 testcases/kernel/syscalls/fsopen/.gitignore
 create mode 100644 testcases/kernel/syscalls/fsopen/Makefile
 create mode 100644 testcases/kernel/syscalls/fsopen/fsopen01.c
 create mode 100644 testcases/kernel/syscalls/fsopen/fsopen02.c
 create mode 100644 testcases/kernel/syscalls/fspick/.gitignore
 create mode 100644 testcases/kernel/syscalls/fspick/Makefile
 create mode 100644 testcases/kernel/syscalls/fspick/fspick01.c
 create mode 100644 testcases/kernel/syscalls/fspick/fspick02.c
 create mode 100644 testcases/kernel/syscalls/move_mount/.gitignore
 create mode 100644 testcases/kernel/syscalls/move_mount/Makefile
 create mode 100644 testcases/kernel/syscalls/move_mount/move_mount01.c
 create mode 100644 testcases/kernel/syscalls/move_mount/move_mount02.c
 create mode 100644 testcases/kernel/syscalls/open_tree/.gitignore
 create mode 100644 testcases/kernel/syscalls/open_tree/Makefile
 create mode 100644 testcases/kernel/syscalls/open_tree/open_tree01.c
 create mode 100644 testcases/kernel/syscalls/open_tree/open_tree02.c

-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 1/7] lapi/fsmount: Add definitions for fsmount related syscalls
  2020-02-14 11:35 [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
@ 2020-02-14 11:35 ` Viresh Kumar
  2020-02-16  9:09   ` Li Wang
  2020-02-14 11:35 ` [LTP] [PATCH 2/7] syscalls/fsopen: New tests Viresh Kumar
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 32+ messages in thread
From: Viresh Kumar @ 2020-02-14 11:35 UTC (permalink / raw)
  To: ltp

This adds definitions for all fsmount related syscalls which will be
used by multiple syscall tests.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 include/lapi/fsmount.h | 134 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 134 insertions(+)
 create mode 100644 include/lapi/fsmount.h

diff --git a/include/lapi/fsmount.h b/include/lapi/fsmount.h
new file mode 100644
index 000000000000..a384526e6a14
--- /dev/null
+++ b/include/lapi/fsmount.h
@@ -0,0 +1,134 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Linaro Limited. All rights reserved.
+ * Author: Viresh Kumar <viresh.kumar@linaro.org>
+ */
+
+#ifndef FSMOUNT_H
+#define FSMOUNT_H
+
+#include <fcntl.h>
+#include <sys/mount.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+
+#include "config.h"
+#include "lapi/syscalls.h"
+
+#ifndef HAVE_FSOPEN
+int fsopen(const char *fsname, unsigned int flags)
+{
+	return tst_syscall(__NR_fsopen, fsname, flags);
+}
+#endif /* HAVE_FSOPEN */
+
+#ifndef HAVE_FSCONFIG
+int fsconfig(int fd, unsigned int cmd, const char *key,
+	     const void *value, int aux)
+{
+	return tst_syscall(__NR_fsconfig, fd, cmd, key, value, aux);
+}
+#endif /* HAVE_FSCONFIG */
+
+#ifndef HAVE_FSMOUNT
+int fsmount(int fd, unsigned int flags, unsigned int mount_attrs)
+{
+	return tst_syscall(__NR_fsmount, fd, flags, mount_attrs);
+}
+#endif /* HAVE_FSMOUNT */
+
+#ifndef HAVE_FSPICK
+int fspick(int dirfd, const char *pathname, unsigned int flags)
+{
+	return tst_syscall(__NR_fspick, dirfd, pathname, flags);
+}
+#endif /* HAVE_FSPICK */
+
+#ifndef HAVE_MOVE_MOUNT
+int move_mount(int from_dirfd, const char *from_pathname, int to_dirfd,
+	       const char *to_pathname, unsigned int flags)
+{
+	return tst_syscall(__NR_move_mount, from_dirfd, from_pathname, to_dirfd,
+			   to_pathname, flags);
+}
+#endif /* HAVE_MOVE_MOUNT */
+
+#ifndef HAVE_OPEN_TREE
+int open_tree(int dirfd, const char *pathname, unsigned int flags)
+{
+	return tst_syscall(__NR_open_tree, dirfd, pathname, flags);
+}
+#endif /* HAVE_OPEN_TREE */
+
+/*
+ * New headers added in kernel after 5.2 release, create them for old userspace.
+*/
+
+#ifndef OPEN_TREE_CLONE
+
+/*
+ * open_tree() flags.
+ */
+#define OPEN_TREE_CLONE		1		/* Clone the target tree and attach the clone */
+#define OPEN_TREE_CLOEXEC	O_CLOEXEC	/* Close the file on execve() */
+
+/*
+ * move_mount() flags.
+ */
+#define MOVE_MOUNT_F_SYMLINKS		0x00000001 /* Follow symlinks on from path */
+#define MOVE_MOUNT_F_AUTOMOUNTS		0x00000002 /* Follow automounts on from path */
+#define MOVE_MOUNT_F_EMPTY_PATH		0x00000004 /* Empty from path permitted */
+#define MOVE_MOUNT_T_SYMLINKS		0x00000010 /* Follow symlinks on to path */
+#define MOVE_MOUNT_T_AUTOMOUNTS		0x00000020 /* Follow automounts on to path */
+#define MOVE_MOUNT_T_EMPTY_PATH		0x00000040 /* Empty to path permitted */
+#define MOVE_MOUNT__MASK		0x00000077
+
+/*
+ * fsopen() flags.
+ */
+#define FSOPEN_CLOEXEC		0x00000001
+
+/*
+ * fspick() flags.
+ */
+#define FSPICK_CLOEXEC		0x00000001
+#define FSPICK_SYMLINK_NOFOLLOW	0x00000002
+#define FSPICK_NO_AUTOMOUNT	0x00000004
+#define FSPICK_EMPTY_PATH	0x00000008
+
+/*
+ * The type of fsconfig() call made.
+ */
+enum fsconfig_command {
+	FSCONFIG_SET_FLAG	= 0,	/* Set parameter, supplying no value */
+	FSCONFIG_SET_STRING	= 1,	/* Set parameter, supplying a string value */
+	FSCONFIG_SET_BINARY	= 2,	/* Set parameter, supplying a binary blob value */
+	FSCONFIG_SET_PATH	= 3,	/* Set parameter, supplying an object by path */
+	FSCONFIG_SET_PATH_EMPTY	= 4,	/* Set parameter, supplying an object by (empty) path */
+	FSCONFIG_SET_FD		= 5,	/* Set parameter, supplying an object by fd */
+	FSCONFIG_CMD_CREATE	= 6,	/* Invoke superblock creation */
+	FSCONFIG_CMD_RECONFIGURE = 7,	/* Invoke superblock reconfiguration */
+};
+
+/*
+ * fsmount() flags.
+ */
+#define FSMOUNT_CLOEXEC		0x00000001
+
+/*
+ * Mount attributes.
+ */
+#define MOUNT_ATTR_RDONLY	0x00000001 /* Mount read-only */
+#define MOUNT_ATTR_NOSUID	0x00000002 /* Ignore suid and sgid bits */
+#define MOUNT_ATTR_NODEV	0x00000004 /* Disallow access to device special files */
+#define MOUNT_ATTR_NOEXEC	0x00000008 /* Disallow program execution */
+#define MOUNT_ATTR__ATIME	0x00000070 /* Setting on how atime should be updated */
+#define MOUNT_ATTR_RELATIME	0x00000000 /* - Update atime relative to mtime/ctime. */
+#define MOUNT_ATTR_NOATIME	0x00000010 /* - Do not update access times. */
+#define MOUNT_ATTR_STRICTATIME	0x00000020 /* - Always perform atime updates */
+#define MOUNT_ATTR_NODIRATIME	0x00000080 /* Do not update directory access times */
+
+#endif /* OPEN_TREE_CLONE */
+
+
+#endif /* FSMOUNT_H */
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 2/7] syscalls/fsopen: New tests
  2020-02-14 11:35 [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
  2020-02-14 11:35 ` [LTP] [PATCH 1/7] lapi/fsmount: Add definitions for fsmount related syscalls Viresh Kumar
@ 2020-02-14 11:35 ` Viresh Kumar
  2020-02-16 10:11   ` Li Wang
  2020-02-14 11:35 ` [LTP] [PATCH 3/7] syscalls/fsconfig: " Viresh Kumar
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 32+ messages in thread
From: Viresh Kumar @ 2020-02-14 11:35 UTC (permalink / raw)
  To: ltp

Add tests to check working of fsopen() syscall.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 configure.ac                                |  1 +
 runtest/syscalls                            |  3 +
 testcases/kernel/syscalls/fsopen/.gitignore |  2 +
 testcases/kernel/syscalls/fsopen/Makefile   |  6 ++
 testcases/kernel/syscalls/fsopen/fsopen01.c | 71 +++++++++++++++++++++
 testcases/kernel/syscalls/fsopen/fsopen02.c | 56 ++++++++++++++++
 6 files changed, 139 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsopen/.gitignore
 create mode 100644 testcases/kernel/syscalls/fsopen/Makefile
 create mode 100644 testcases/kernel/syscalls/fsopen/fsopen01.c
 create mode 100644 testcases/kernel/syscalls/fsopen/fsopen02.c

diff --git a/configure.ac b/configure.ac
index df4e8c8322fc..4125160a19bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,6 +80,7 @@ AC_CHECK_FUNCS([ \
     execveat \
     fallocate \
     fchownat \
+    fsopen \
     fstatat \
     getdents \
     getdents64 \
diff --git a/runtest/syscalls b/runtest/syscalls
index 0743cf4e3f74..0a56599ebad9 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -542,6 +542,9 @@ fanotify13 fanotify13
 fanotify14 fanotify14
 fanotify15 fanotify15
 
+fsopen01 fsopen01
+fsopen02 fsopen02
+
 ioperm01 ioperm01
 ioperm02 ioperm02
 
diff --git a/testcases/kernel/syscalls/fsopen/.gitignore b/testcases/kernel/syscalls/fsopen/.gitignore
new file mode 100644
index 000000000000..80089dd137a7
--- /dev/null
+++ b/testcases/kernel/syscalls/fsopen/.gitignore
@@ -0,0 +1,2 @@
+fsopen01
+fsopen02
diff --git a/testcases/kernel/syscalls/fsopen/Makefile b/testcases/kernel/syscalls/fsopen/Makefile
new file mode 100644
index 000000000000..5ea7d67db123
--- /dev/null
+++ b/testcases/kernel/syscalls/fsopen/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fsopen/fsopen01.c b/testcases/kernel/syscalls/fsopen/fsopen01.c
new file mode 100644
index 000000000000..3587c67636ea
--- /dev/null
+++ b/testcases/kernel/syscalls/fsopen/fsopen01.c
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic fsopen() test which tries to configure and mount the filesystem as
+ * well.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+#define MNTPOINT	"mntpoint"
+
+static void run(void)
+{
+	int fd, fsmfd;
+
+	TEST(fsopen(tst_device->fs_type, 0));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TFAIL | TERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1) {
+		tst_res(TBROK | TERRNO, "fsconfig() failed");
+		goto out;
+	}
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1) {
+		tst_res(TBROK | TERRNO, "fsconfig() failed");
+		goto out;
+	}
+
+	TEST(fsmount(fd, 0, 0));
+	if (TST_RET == -1) {
+		tst_res(TBROK | TERRNO, "fsmount() failed");
+		goto out;
+	}
+
+	fsmfd = TST_RET;
+
+	TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
+			MOVE_MOUNT_F_EMPTY_PATH));
+
+	SAFE_CLOSE(fsmfd);
+
+	if (TST_RET == -1) {
+		tst_res(TBROK | TERRNO, "move_mount() failed");
+		goto out;
+	}
+
+	SAFE_CLOSE(TST_RET);
+
+	TEST(umount(MNTPOINT));
+
+	tst_res(TPASS, "fsopen() passed");
+
+out:
+	SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.min_kver = "5.2",
+	.test_all = run,
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.format_device = 1,
+	.mntpoint = MNTPOINT,
+};
diff --git a/testcases/kernel/syscalls/fsopen/fsopen02.c b/testcases/kernel/syscalls/fsopen/fsopen02.c
new file mode 100644
index 000000000000..6831a12c696b
--- /dev/null
+++ b/testcases/kernel/syscalls/fsopen/fsopen02.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic fsopen() failure tests.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+const char *invalid_fs = "invalid";
+const char *valid_fs;
+
+static struct tcase {
+	char *name;
+	const char **fs;
+	unsigned int flags;
+	int exp_errno;
+} tcases[] = {
+	{"invalid-fs", &invalid_fs, 0, ENODEV},
+	{"invalid-flags", &valid_fs, 0x10, EINVAL},
+};
+
+static void setup(void)
+{
+	valid_fs = tst_device->fs_type;
+}
+
+static void run(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+
+	TEST(fsopen(*tc->fs, tc->flags));
+
+	if (TST_RET != -1) {
+		SAFE_CLOSE(TST_RET);
+		tst_brk(TFAIL, "%s: fsopen() succeeded unexpectedly (index: %d)",
+			tc->name, n);
+	}
+
+	if (tc->exp_errno != TST_ERR) {
+		tst_brk(TFAIL | TTERRNO, "%s: fsopen() should fail with %s",
+			tc->name, tst_strerrno(tc->exp_errno));
+	}
+
+	tst_res(TPASS | TTERRNO, "%s: fsopen() failed as expected", tc->name);
+}
+
+static struct tst_test test = {
+	.min_kver = "5.2",
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = run,
+	.setup = setup,
+	.needs_root = 1,
+	.needs_device = 1,
+};
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 3/7] syscalls/fsconfig: New tests
  2020-02-14 11:35 [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
  2020-02-14 11:35 ` [LTP] [PATCH 1/7] lapi/fsmount: Add definitions for fsmount related syscalls Viresh Kumar
  2020-02-14 11:35 ` [LTP] [PATCH 2/7] syscalls/fsopen: New tests Viresh Kumar
@ 2020-02-14 11:35 ` Viresh Kumar
  2020-02-14 11:35 ` [LTP] [PATCH 4/7] syscalls/fsmount: " Viresh Kumar
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 32+ messages in thread
From: Viresh Kumar @ 2020-02-14 11:35 UTC (permalink / raw)
  To: ltp

Add tests to check working of fsconfig() syscall.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 configure.ac                                  |  1 +
 runtest/syscalls                              |  3 +
 testcases/kernel/syscalls/fsconfig/.gitignore |  2 +
 testcases/kernel/syscalls/fsconfig/Makefile   |  6 ++
 .../kernel/syscalls/fsconfig/fsconfig01.c     | 77 +++++++++++++++
 .../kernel/syscalls/fsconfig/fsconfig02.c     | 97 +++++++++++++++++++
 6 files changed, 186 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/.gitignore
 create mode 100644 testcases/kernel/syscalls/fsconfig/Makefile
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig01.c
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig02.c

diff --git a/configure.ac b/configure.ac
index 4125160a19bb..f006c53e7df1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,6 +80,7 @@ AC_CHECK_FUNCS([ \
     execveat \
     fallocate \
     fchownat \
+    fsconfig \
     fsopen \
     fstatat \
     getdents \
diff --git a/runtest/syscalls b/runtest/syscalls
index 0a56599ebad9..e27e94d5d17f 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -542,6 +542,9 @@ fanotify13 fanotify13
 fanotify14 fanotify14
 fanotify15 fanotify15
 
+fsconfig01 fsconfig01
+fsconfig02 fsconfig02
+
 fsopen01 fsopen01
 fsopen02 fsopen02
 
diff --git a/testcases/kernel/syscalls/fsconfig/.gitignore b/testcases/kernel/syscalls/fsconfig/.gitignore
new file mode 100644
index 000000000000..8fbb3360f0bb
--- /dev/null
+++ b/testcases/kernel/syscalls/fsconfig/.gitignore
@@ -0,0 +1,2 @@
+fsconfig01
+fsconfig02
diff --git a/testcases/kernel/syscalls/fsconfig/Makefile b/testcases/kernel/syscalls/fsconfig/Makefile
new file mode 100644
index 000000000000..5ea7d67db123
--- /dev/null
+++ b/testcases/kernel/syscalls/fsconfig/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fsconfig/fsconfig01.c b/testcases/kernel/syscalls/fsconfig/fsconfig01.c
new file mode 100644
index 000000000000..c6c95f32cb05
--- /dev/null
+++ b/testcases/kernel/syscalls/fsconfig/fsconfig01.c
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic fsconfig() test which tries to configure and mount the filesystem as
+ * well.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+#define MNTPOINT	"mntpoint"
+
+static void run(void)
+{
+	int fd, fsmfd;
+
+	TEST(fsopen(tst_device->fs_type, 0));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TBROK | TERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1) {
+		tst_res(TFAIL | TERRNO, "fsconfig() failed");
+		goto out;
+	}
+
+	TEST(fsconfig(fd, FSCONFIG_SET_FLAG, "rw", NULL, 0));
+	if (TST_RET == -1) {
+		tst_res(TFAIL | TERRNO, "fsconfig() failed");
+		goto out;
+	}
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1) {
+		tst_res(TFAIL | TERRNO, "fsconfig() failed");
+		goto out;
+	}
+
+	TEST(fsmount(fd, 0, 0));
+	if (TST_RET == -1) {
+		tst_res(TBROK | TERRNO, "fsmount() failed");
+		goto out;
+	}
+
+	fsmfd = TST_RET;
+
+	TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
+			MOVE_MOUNT_F_EMPTY_PATH));
+
+	SAFE_CLOSE(fsmfd);
+
+	if (TST_RET == -1) {
+		tst_res(TBROK | TERRNO, "move_mount() failed");
+		goto out;
+	}
+
+	SAFE_CLOSE(TST_RET);
+
+	TEST(umount(MNTPOINT));
+
+	tst_res(TPASS, "fsconfig() passed");
+
+out:
+	SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.min_kver = "5.2",
+	.test_all = run,
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.format_device = 1,
+	.mntpoint = MNTPOINT,
+};
diff --git a/testcases/kernel/syscalls/fsconfig/fsconfig02.c b/testcases/kernel/syscalls/fsconfig/fsconfig02.c
new file mode 100644
index 000000000000..45a60cc231fb
--- /dev/null
+++ b/testcases/kernel/syscalls/fsconfig/fsconfig02.c
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic fsconfig() failure tests.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+int fd, temp_fd, invalid_fd = -1;
+int aux_0 = 0, aux_1 = 1, aux_fdcwd = AT_FDCWD, aux_minus1 = -1;
+
+static struct tcase {
+	char *name;
+	int *fd;
+	unsigned int cmd;
+	const char *key;
+	const void *value;
+	int *aux;
+	int exp_errno;
+} tcases[] = {
+	{"invalid-fd", &invalid_fd, FSCONFIG_SET_FLAG, "user_xattr", NULL, &aux_0, EINVAL},
+	{"invalid-cmd", &fd, 100, "rw", NULL, &aux_0, EOPNOTSUPP},
+	{"set-flag-key", &fd, FSCONFIG_SET_FLAG, NULL, NULL, &aux_0, EINVAL},
+	{"set-flag-value", &fd, FSCONFIG_SET_FLAG, "rw", "foo", &aux_0, EINVAL},
+	{"set-flag-aux", &fd, FSCONFIG_SET_FLAG, "rw", NULL, &aux_1, EINVAL},
+	{"set-string-key", &fd, FSCONFIG_SET_STRING, NULL, "#grand.central.org:root.cell.", &aux_0, EINVAL},
+	{"set-string-value", &fd, FSCONFIG_SET_STRING, "source", NULL, &aux_0, EINVAL},
+	{"set-string-aux", &fd, FSCONFIG_SET_STRING, "source", "#grand.central.org:root.cell.", &aux_1, EINVAL},
+	{"set-binary-key", &fd, FSCONFIG_SET_BINARY, NULL, "foo", &aux_1, EINVAL},
+	{"set-binary-value", &fd, FSCONFIG_SET_BINARY, "sync", NULL, &aux_1, EINVAL},
+	{"set-binary-aux", &fd, FSCONFIG_SET_BINARY, "sync", "foo", &aux_0, EINVAL},
+	{"set-path-key", &fd, FSCONFIG_SET_PATH, NULL, "/dev/sda1", &aux_fdcwd, EINVAL},
+	{"set-path-value", &fd, FSCONFIG_SET_PATH, "sync", NULL, &aux_fdcwd, EINVAL},
+	{"set-path-aux", &fd, FSCONFIG_SET_PATH, "sync", "/dev/sda1", &aux_minus1, EINVAL},
+	{"set-path-empty-key", &fd, FSCONFIG_SET_PATH_EMPTY, NULL, "/dev/foo", &aux_fdcwd, EINVAL},
+	{"set-path-empty-value", &fd, FSCONFIG_SET_PATH_EMPTY, "sync", NULL, &aux_fdcwd, EINVAL},
+	{"set-path-empty-aux", &fd, FSCONFIG_SET_PATH_EMPTY, "sync", "/dev/foo", &aux_minus1, EINVAL},
+	{"set-fd-key", &fd, FSCONFIG_SET_FD, NULL, NULL, &temp_fd, EINVAL},
+	{"set-fd-value", &fd, FSCONFIG_SET_FD, "sync", "foo", &temp_fd, EINVAL},
+	{"set-fd-aux", &fd, FSCONFIG_SET_FD, "sync", NULL, &aux_minus1, EINVAL},
+	{"cmd-create-key", &fd, FSCONFIG_CMD_CREATE, "foo", NULL, &aux_0, EINVAL},
+	{"cmd-create-value", &fd, FSCONFIG_CMD_CREATE, NULL, "foo", &aux_0, EINVAL},
+	{"cmd-create-aux", &fd, FSCONFIG_CMD_CREATE, NULL, NULL, &aux_1, EINVAL},
+	{"cmd-reconfigure-key", &fd, FSCONFIG_CMD_RECONFIGURE, "foo", NULL, &aux_0, EINVAL},
+	{"cmd-reconfigure-value", &fd, FSCONFIG_CMD_RECONFIGURE, NULL, "foo", &aux_0, EINVAL},
+	{"cmd-reconfigure-aux", &fd, FSCONFIG_CMD_RECONFIGURE, NULL, NULL, &aux_1, EINVAL},
+};
+
+static void setup(void)
+{
+	TEST(fsopen(tst_device->fs_type, 0));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TBROK | TERRNO, "fsopen() failed");
+
+	temp_fd = open("testfile", O_RDWR | O_CREAT, 01444);
+	if (temp_fd == -1)
+		tst_res(TBROK, "Can't obtain temp_fd, open() failed");
+}
+
+static void cleanup(void)
+{
+	SAFE_CLOSE(temp_fd);
+	SAFE_CLOSE(fd);
+}
+
+static void run(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+
+	TEST(fsconfig(*tc->fd, tc->cmd, tc->key, tc->value, *tc->aux));
+
+	if (TST_RET != -1) {
+		tst_brk(TFAIL, "%s: fsconfig() succeeded unexpectedly (index: %d)",
+			tc->name, n);
+	}
+
+	if (tc->exp_errno != TST_ERR) {
+		tst_brk(TFAIL | TTERRNO, "%s: fsconfig() should fail with %s",
+			tc->name, tst_strerrno(tc->exp_errno));
+	}
+
+	tst_res(TPASS | TTERRNO, "%s: fsconfig() failed as expected", tc->name);
+}
+
+static struct tst_test test = {
+	.min_kver = "5.2",
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_device = 1,
+};
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 4/7] syscalls/fsmount: New tests
  2020-02-14 11:35 [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
                   ` (2 preceding siblings ...)
  2020-02-14 11:35 ` [LTP] [PATCH 3/7] syscalls/fsconfig: " Viresh Kumar
@ 2020-02-14 11:35 ` Viresh Kumar
  2020-02-17  8:17   ` Li Wang
  2020-02-14 11:35 ` [LTP] [PATCH 5/7] syscalls/move_mount: " Viresh Kumar
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 32+ messages in thread
From: Viresh Kumar @ 2020-02-14 11:35 UTC (permalink / raw)
  To: ltp

Add tests to check working of fsmount() syscall.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 configure.ac                                  |  1 +
 runtest/syscalls                              |  3 +
 testcases/kernel/syscalls/fsmount/.gitignore  |  2 +
 testcases/kernel/syscalls/fsmount/Makefile    |  6 ++
 testcases/kernel/syscalls/fsmount/fsmount01.c | 71 ++++++++++++++++
 testcases/kernel/syscalls/fsmount/fsmount02.c | 83 +++++++++++++++++++
 6 files changed, 166 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsmount/.gitignore
 create mode 100644 testcases/kernel/syscalls/fsmount/Makefile
 create mode 100644 testcases/kernel/syscalls/fsmount/fsmount01.c
 create mode 100644 testcases/kernel/syscalls/fsmount/fsmount02.c

diff --git a/configure.ac b/configure.ac
index f006c53e7df1..734fb10c4b31 100644
--- a/configure.ac
+++ b/configure.ac
@@ -81,6 +81,7 @@ AC_CHECK_FUNCS([ \
     fallocate \
     fchownat \
     fsconfig \
+    fsmount \
     fsopen \
     fstatat \
     getdents \
diff --git a/runtest/syscalls b/runtest/syscalls
index e27e94d5d17f..0b1def7d4659 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -545,6 +545,9 @@ fanotify15 fanotify15
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 
+fsmount01 fsmount01
+fsmount02 fsmount02
+
 fsopen01 fsopen01
 fsopen02 fsopen02
 
diff --git a/testcases/kernel/syscalls/fsmount/.gitignore b/testcases/kernel/syscalls/fsmount/.gitignore
new file mode 100644
index 000000000000..aaa66d57f417
--- /dev/null
+++ b/testcases/kernel/syscalls/fsmount/.gitignore
@@ -0,0 +1,2 @@
+fsmount01
+fsmount02
diff --git a/testcases/kernel/syscalls/fsmount/Makefile b/testcases/kernel/syscalls/fsmount/Makefile
new file mode 100644
index 000000000000..5ea7d67db123
--- /dev/null
+++ b/testcases/kernel/syscalls/fsmount/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fsmount/fsmount01.c b/testcases/kernel/syscalls/fsmount/fsmount01.c
new file mode 100644
index 000000000000..83fcf0d51f47
--- /dev/null
+++ b/testcases/kernel/syscalls/fsmount/fsmount01.c
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic fsmount() test.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+#define MNTPOINT	"mntpoint"
+
+static int fd, fsmfd;
+
+static void setup(void)
+{
+	TEST(fsopen(tst_device->fs_type, 0));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TBROK | TERRNO, "fsopen() failed");
+}
+
+static void cleanup(void)
+{
+	SAFE_CLOSE(fd);
+}
+
+static void run(void)
+{
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1)
+		tst_brk(TBROK | TERRNO, "fsconfig() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_FLAG, "rw", NULL, 0));
+	if (TST_RET == -1)
+		tst_brk(TBROK | TERRNO, "fsconfig() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1)
+		tst_brk(TBROK | TERRNO, "fsconfig() failed");
+
+	TEST(fsmount(fd, 0, 0));
+	if (TST_RET == -1)
+		tst_brk(TFAIL | TERRNO, "fsmount() failed");
+
+	fsmfd = TST_RET;
+
+	TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
+			MOVE_MOUNT_F_EMPTY_PATH));
+	SAFE_CLOSE(fsmfd);
+
+	if (TST_RET == -1)
+		tst_brk(TBROK | TERRNO, "move_mount() failed");
+
+	SAFE_CLOSE(TST_RET);
+	TEST(umount(MNTPOINT));
+
+	tst_res(TPASS, "fsmount() passed");
+}
+
+static struct tst_test test = {
+	.min_kver = "5.2",
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.format_device = 1,
+	.mntpoint = MNTPOINT,
+};
diff --git a/testcases/kernel/syscalls/fsmount/fsmount02.c b/testcases/kernel/syscalls/fsmount/fsmount02.c
new file mode 100644
index 000000000000..cbe99bf99c1f
--- /dev/null
+++ b/testcases/kernel/syscalls/fsmount/fsmount02.c
@@ -0,0 +1,83 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic fsmount() failure tests.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+int fd, invalid_fd = -1;
+
+static struct tcase {
+	char *name;
+	int *fd;
+	unsigned int flags;
+	unsigned int mount_attrs;
+	int exp_errno;
+} tcases[] = {
+	{"invalid-fd", &invalid_fd, FSMOUNT_CLOEXEC, 0, EBADF},
+	{"invalid-flags", &fd, 0x02, 0, EINVAL},
+	{"invalid-attrs", &fd, FSMOUNT_CLOEXEC, 0x100, EINVAL},
+};
+
+static void cleanup(void)
+{
+	SAFE_CLOSE(fd);
+}
+
+static void setup(void)
+{
+	TEST(fsopen(tst_device->fs_type, 0));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TBROK | TERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsconfig(fd, FSCONFIG_SET_FLAG, "rw", NULL, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET != -1)
+		return;
+
+out:
+	cleanup();
+	tst_brk(TBROK | TERRNO, "fsconfig() failed");
+}
+
+static void run(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+
+	TEST(fsmount(*tc->fd, tc->flags, tc->mount_attrs));
+	if (TST_RET != -1) {
+		SAFE_CLOSE(TST_RET);
+		tst_brk(TFAIL, "%s: fsmount() succeeded unexpectedly (index: %d)",
+			tc->name, n);
+	}
+
+	if (tc->exp_errno != TST_ERR) {
+		tst_brk(TFAIL | TTERRNO, "%s: fsmount() should fail with %s",
+			tc->name, tst_strerrno(tc->exp_errno));
+	}
+
+	tst_res(TPASS | TTERRNO, "%s: fsmount() failed as expected", tc->name);
+}
+
+static struct tst_test test = {
+	.min_kver = "5.2",
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.format_device = 1,
+};
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 5/7] syscalls/move_mount: New tests
  2020-02-14 11:35 [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
                   ` (3 preceding siblings ...)
  2020-02-14 11:35 ` [LTP] [PATCH 4/7] syscalls/fsmount: " Viresh Kumar
@ 2020-02-14 11:35 ` Viresh Kumar
  2020-02-14 11:35 ` [LTP] [PATCH 6/7] syscalls/fspick: " Viresh Kumar
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 32+ messages in thread
From: Viresh Kumar @ 2020-02-14 11:35 UTC (permalink / raw)
  To: ltp

Add tests to check working of move_mount() syscall.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 configure.ac                                  |   1 +
 runtest/syscalls                              |   3 +
 .../kernel/syscalls/move_mount/.gitignore     |   2 +
 testcases/kernel/syscalls/move_mount/Makefile |   6 ++
 .../kernel/syscalls/move_mount/move_mount01.c |  82 ++++++++++++++
 .../kernel/syscalls/move_mount/move_mount02.c | 102 ++++++++++++++++++
 6 files changed, 196 insertions(+)
 create mode 100644 testcases/kernel/syscalls/move_mount/.gitignore
 create mode 100644 testcases/kernel/syscalls/move_mount/Makefile
 create mode 100644 testcases/kernel/syscalls/move_mount/move_mount01.c
 create mode 100644 testcases/kernel/syscalls/move_mount/move_mount02.c

diff --git a/configure.ac b/configure.ac
index 734fb10c4b31..05b7d0a72c0a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,6 +91,7 @@ AC_CHECK_FUNCS([ \
     mkdirat \
     mknodat \
     modify_ldt \
+    move_mount \
     name_to_handle_at \
     openat \
     pidfd_open \
diff --git a/runtest/syscalls b/runtest/syscalls
index 0b1def7d4659..04e11ef4f9d2 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -731,6 +731,9 @@ mount04 mount04
 mount05 mount05
 mount06 mount06
 
+move_mount01 move_mount01
+move_mount02 move_mount02
+
 move_pages01 move_pages01
 move_pages02 move_pages02
 move_pages03 move_pages03
diff --git a/testcases/kernel/syscalls/move_mount/.gitignore b/testcases/kernel/syscalls/move_mount/.gitignore
new file mode 100644
index 000000000000..8e2f4aaf497b
--- /dev/null
+++ b/testcases/kernel/syscalls/move_mount/.gitignore
@@ -0,0 +1,2 @@
+move_mount01
+move_mount02
diff --git a/testcases/kernel/syscalls/move_mount/Makefile b/testcases/kernel/syscalls/move_mount/Makefile
new file mode 100644
index 000000000000..5ea7d67db123
--- /dev/null
+++ b/testcases/kernel/syscalls/move_mount/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/move_mount/move_mount01.c b/testcases/kernel/syscalls/move_mount/move_mount01.c
new file mode 100644
index 000000000000..5b719013fed2
--- /dev/null
+++ b/testcases/kernel/syscalls/move_mount/move_mount01.c
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic move_mount() test.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+#define MNTPOINT	"mntpoint"
+
+static int fd, fsmfd, mmfd = -1;
+
+static void cleanup(void)
+{
+	SAFE_CLOSE(fsmfd);
+
+	if (mmfd != -1) {
+		SAFE_CLOSE(mmfd);
+		TEST(umount(MNTPOINT));
+	}
+
+	SAFE_CLOSE(fd);
+}
+
+static void setup(void)
+{
+	TEST(fsopen(tst_device->fs_type, 0));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TBROK | TERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsconfig(fd, FSCONFIG_SET_FLAG, "rw", NULL, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsmount(fd, 0, 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fd);
+		tst_brk(TBROK | TERRNO, "fsmount() failed");
+	}
+
+	fsmfd = TST_RET;
+	return;
+
+out:
+	SAFE_CLOSE(fd);
+	tst_brk(TBROK | TERRNO, "fsconfig() failed");
+}
+
+static void run(void)
+{
+	TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
+			MOVE_MOUNT_F_EMPTY_PATH));
+	if (TST_RET == -1)
+		tst_brk(TFAIL | TERRNO, "move_mount() failed");
+
+	mmfd = TST_RET;
+
+	tst_res(TPASS, "move_mount() passed");
+}
+
+static struct tst_test test = {
+	.min_kver = "5.2",
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.format_device = 1,
+	.mntpoint = MNTPOINT,
+};
diff --git a/testcases/kernel/syscalls/move_mount/move_mount02.c b/testcases/kernel/syscalls/move_mount/move_mount02.c
new file mode 100644
index 000000000000..8cff7e82069a
--- /dev/null
+++ b/testcases/kernel/syscalls/move_mount/move_mount02.c
@@ -0,0 +1,102 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic move_mount() failure tests.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+#define MNTPOINT	"mntpoint"
+
+int fd, invalid_fd = -1, fsmfd;
+
+static struct tcase {
+	char *name;
+	int *from_dirfd;
+	const char *from_pathname;
+	int to_dirfd;
+	const char *to_pathname;
+	unsigned int flags;
+	int exp_errno;
+} tcases[] = {
+	{"invalid-from-fd", &invalid_fd, "", AT_FDCWD, MNTPOINT, MOVE_MOUNT_F_EMPTY_PATH, EBADF},
+	{"invalid-from-path", &fsmfd, "invalid", AT_FDCWD, MNTPOINT, MOVE_MOUNT_F_EMPTY_PATH, ENOENT},
+	{"invalid-to-fd", &fsmfd, "", -1, MNTPOINT, MOVE_MOUNT_F_EMPTY_PATH, EBADF},
+	{"invalid-to-path", &fsmfd, "", AT_FDCWD, "invalid", MOVE_MOUNT_F_EMPTY_PATH, ENOENT},
+	{"invalid-flags", &fsmfd, "", AT_FDCWD, MNTPOINT, 0x08, EINVAL},
+};
+
+static void cleanup(void)
+{
+	SAFE_CLOSE(fsmfd);
+	SAFE_CLOSE(fd);
+}
+
+static void setup(void)
+{
+	TEST(fsopen(tst_device->fs_type, 0));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TBROK | TERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsconfig(fd, FSCONFIG_SET_FLAG, "rw", NULL, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsmount(fd, 0, 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fd);
+		tst_brk(TBROK | TERRNO, "fsmount() failed");
+	}
+
+	fsmfd = TST_RET;
+	return;
+
+out:
+	SAFE_CLOSE(fd);
+	tst_brk(TBROK | TERRNO, "fsconfig() failed");
+}
+
+static void run(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+
+	TEST(move_mount(*tc->from_dirfd, tc->from_pathname, tc->to_dirfd,
+			tc->to_pathname, tc->flags));
+	if (TST_RET != -1) {
+		SAFE_CLOSE(TST_RET);
+		TEST(umount(MNTPOINT));
+		tst_brk(TFAIL, "%s: move_mount() succeeded unexpectedly (index: %d)",
+			tc->name, n);
+	}
+
+	if (tc->exp_errno != TST_ERR) {
+		tst_brk(TFAIL | TTERRNO, "%s: move_mount() should fail with %s",
+			tc->name, tst_strerrno(tc->exp_errno));
+	}
+
+	tst_res(TPASS | TTERRNO, "%s: move_mount() failed as expected", tc->name);
+}
+
+static struct tst_test test = {
+	.min_kver = "5.2",
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.format_device = 1,
+	.mntpoint = MNTPOINT,
+};
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 6/7] syscalls/fspick: New tests
  2020-02-14 11:35 [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
                   ` (4 preceding siblings ...)
  2020-02-14 11:35 ` [LTP] [PATCH 5/7] syscalls/move_mount: " Viresh Kumar
@ 2020-02-14 11:35 ` Viresh Kumar
  2020-02-14 11:35 ` [LTP] [PATCH 7/7] syscalls/open_tree: " Viresh Kumar
  2020-02-18  6:19 ` [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls Zorro Lang
  7 siblings, 0 replies; 32+ messages in thread
From: Viresh Kumar @ 2020-02-14 11:35 UTC (permalink / raw)
  To: ltp

Add tests to check working of fspick() syscall.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 configure.ac                                |   1 +
 runtest/syscalls                            |   3 +
 testcases/kernel/syscalls/fspick/.gitignore |   2 +
 testcases/kernel/syscalls/fspick/Makefile   |   6 ++
 testcases/kernel/syscalls/fspick/fspick01.c | 104 ++++++++++++++++++
 testcases/kernel/syscalls/fspick/fspick02.c | 110 ++++++++++++++++++++
 6 files changed, 226 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fspick/.gitignore
 create mode 100644 testcases/kernel/syscalls/fspick/Makefile
 create mode 100644 testcases/kernel/syscalls/fspick/fspick01.c
 create mode 100644 testcases/kernel/syscalls/fspick/fspick02.c

diff --git a/configure.ac b/configure.ac
index 05b7d0a72c0a..de767b1413bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -81,6 +81,7 @@ AC_CHECK_FUNCS([ \
     fallocate \
     fchownat \
     fsconfig \
+    fspick \
     fsmount \
     fsopen \
     fstatat \
diff --git a/runtest/syscalls b/runtest/syscalls
index 04e11ef4f9d2..d90e212748a2 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -545,6 +545,9 @@ fanotify15 fanotify15
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 
+fspick01 fspick01
+fspick02 fspick02
+
 fsmount01 fsmount01
 fsmount02 fsmount02
 
diff --git a/testcases/kernel/syscalls/fspick/.gitignore b/testcases/kernel/syscalls/fspick/.gitignore
new file mode 100644
index 000000000000..ddcb2231e58c
--- /dev/null
+++ b/testcases/kernel/syscalls/fspick/.gitignore
@@ -0,0 +1,2 @@
+fspick01
+fspick02
diff --git a/testcases/kernel/syscalls/fspick/Makefile b/testcases/kernel/syscalls/fspick/Makefile
new file mode 100644
index 000000000000..5ea7d67db123
--- /dev/null
+++ b/testcases/kernel/syscalls/fspick/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fspick/fspick01.c b/testcases/kernel/syscalls/fspick/fspick01.c
new file mode 100644
index 000000000000..927435f8741f
--- /dev/null
+++ b/testcases/kernel/syscalls/fspick/fspick01.c
@@ -0,0 +1,104 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic fspick() test.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+#define MNTPOINT	"mntpoint"
+
+static int fd, fsmfd, mmfd;
+
+static void cleanup(void)
+{
+	SAFE_CLOSE(mmfd);
+	SAFE_CLOSE(fsmfd);
+	TEST(umount(MNTPOINT));
+	SAFE_CLOSE(fd);
+}
+
+static void setup(void)
+{
+	char *err = "fsconfig()";
+
+	TEST(fsopen(tst_device->fs_type, 0));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TBROK | TERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsconfig(fd, FSCONFIG_SET_FLAG, "rw", NULL, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsmount(fd, 0, 0));
+	if (TST_RET == -1) {
+		err = "fsmount()";
+		goto out;
+	}
+
+	fsmfd = TST_RET;
+
+	TEST(move_mount(TST_RET, "", AT_FDCWD, MNTPOINT,
+			MOVE_MOUNT_F_EMPTY_PATH));
+	if (TST_RET != -1) {
+		mmfd = TST_RET;
+		return;
+	}
+
+	SAFE_CLOSE(fsmfd);
+
+	err = "move_mount()";
+
+out:
+	SAFE_CLOSE(fd);
+	tst_brk(TBROK | TERRNO, "%s failed", err);
+}
+
+static void run(void)
+{
+	int fspick_fd;
+
+	TEST(fspick(AT_FDCWD, MNTPOINT, FSPICK_NO_AUTOMOUNT | FSPICK_CLOEXEC));
+	if (TST_RET == -1)
+		tst_brk(TFAIL | TERRNO, "fspick() failed");
+
+	fspick_fd = TST_RET;
+
+	TEST(fsconfig(fspick_fd, FSCONFIG_SET_STRING, "user_xattr", "false", 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fspick_fd);
+		tst_brk(TBROK | TERRNO, "fsconfig() failed");
+	}
+
+	TEST(fsconfig(fspick_fd, FSCONFIG_SET_FLAG, "ro", NULL, 0));
+	if (TST_RET == -1) {
+		SAFE_CLOSE(fspick_fd);
+		tst_brk(TBROK | TERRNO, "fsconfig() failed");
+	}
+
+	SAFE_CLOSE(fspick_fd);
+	tst_res(TPASS, "fspick() passed");
+}
+
+static struct tst_test test = {
+	.min_kver = "5.2",
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.format_device = 1,
+	.mntpoint = MNTPOINT,
+};
diff --git a/testcases/kernel/syscalls/fspick/fspick02.c b/testcases/kernel/syscalls/fspick/fspick02.c
new file mode 100644
index 000000000000..4e271aa47d0a
--- /dev/null
+++ b/testcases/kernel/syscalls/fspick/fspick02.c
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic fspick() failure tests.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+#define MNTPOINT	"mntpoint"
+
+int fd, fsmfd, mmfd;
+
+static struct tcase {
+	char *name;
+	int dirfd;
+	const char *pathname;
+	unsigned int flags;
+	int exp_errno;
+} tcases[] = {
+	{"invalid-fd", -1, MNTPOINT, FSPICK_NO_AUTOMOUNT | FSPICK_CLOEXEC, EBADF},
+	{"invalid-path", AT_FDCWD, "invalid", FSPICK_NO_AUTOMOUNT | FSPICK_CLOEXEC, ENOENT},
+	{"invalid-flags", AT_FDCWD, MNTPOINT, 0x10, EINVAL},
+};
+
+static void cleanup(void)
+{
+	SAFE_CLOSE(mmfd);
+	SAFE_CLOSE(fsmfd);
+	TEST(umount(MNTPOINT));
+	SAFE_CLOSE(fd);
+}
+
+static void setup(void)
+{
+	char *err = "fsconfig()";
+
+	TEST(fsopen(tst_device->fs_type, 0));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TBROK | TERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsconfig(fd, FSCONFIG_SET_FLAG, "rw", NULL, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsmount(fd, 0, 0));
+	if (TST_RET == -1) {
+		err = "fsmount()";
+		goto out;
+	}
+
+	fsmfd = TST_RET;
+
+	TEST(move_mount(TST_RET, "", AT_FDCWD, MNTPOINT,
+			MOVE_MOUNT_F_EMPTY_PATH));
+	if (TST_RET != -1) {
+		mmfd = TST_RET;
+		return;
+	}
+
+	SAFE_CLOSE(fsmfd);
+
+	err = "move_mount()";
+
+out:
+	SAFE_CLOSE(fd);
+	tst_brk(TBROK | TERRNO, "%s failed", err);
+}
+
+static void run(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+
+	TEST(fspick(tc->dirfd, tc->pathname, tc->flags));
+	if (TST_RET != -1) {
+		SAFE_CLOSE(TST_RET);
+		tst_brk(TFAIL, "%s: fspick() succeeded unexpectedly (index: %d)",
+			tc->name, n);
+	}
+
+	if (tc->exp_errno != TST_ERR) {
+		tst_brk(TFAIL | TTERRNO, "%s: fspick() should fail with %s",
+			tc->name, tst_strerrno(tc->exp_errno));
+	}
+
+	tst_res(TPASS | TTERRNO, "%s: fspick() failed as expected", tc->name);
+}
+
+static struct tst_test test = {
+	.min_kver = "5.2",
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.format_device = 1,
+	.mntpoint = MNTPOINT,
+};
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 7/7] syscalls/open_tree: New tests
  2020-02-14 11:35 [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
                   ` (5 preceding siblings ...)
  2020-02-14 11:35 ` [LTP] [PATCH 6/7] syscalls/fspick: " Viresh Kumar
@ 2020-02-14 11:35 ` Viresh Kumar
  2020-02-18  6:19 ` [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls Zorro Lang
  7 siblings, 0 replies; 32+ messages in thread
From: Viresh Kumar @ 2020-02-14 11:35 UTC (permalink / raw)
  To: ltp

Add tests to check working of open_tree() syscall.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 configure.ac                                  |   1 +
 runtest/syscalls                              |   3 +
 .../kernel/syscalls/open_tree/.gitignore      |   2 +
 testcases/kernel/syscalls/open_tree/Makefile  |   6 +
 .../kernel/syscalls/open_tree/open_tree01.c   | 115 ++++++++++++++++++
 .../kernel/syscalls/open_tree/open_tree02.c   | 110 +++++++++++++++++
 6 files changed, 237 insertions(+)
 create mode 100644 testcases/kernel/syscalls/open_tree/.gitignore
 create mode 100644 testcases/kernel/syscalls/open_tree/Makefile
 create mode 100644 testcases/kernel/syscalls/open_tree/open_tree01.c
 create mode 100644 testcases/kernel/syscalls/open_tree/open_tree02.c

diff --git a/configure.ac b/configure.ac
index de767b1413bb..a6753d03b884 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,6 +95,7 @@ AC_CHECK_FUNCS([ \
     move_mount \
     name_to_handle_at \
     openat \
+    open_tree \
     pidfd_open \
     pidfd_send_signal \
     pkey_mprotect \
diff --git a/runtest/syscalls b/runtest/syscalls
index d90e212748a2..9cea13141b31 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -844,6 +844,9 @@ openat01 openat01
 openat02 openat02
 openat03 openat03
 
+open_tree01 open_tree01
+open_tree02 open_tree02
+
 mincore01 mincore01
 mincore02 mincore02
 
diff --git a/testcases/kernel/syscalls/open_tree/.gitignore b/testcases/kernel/syscalls/open_tree/.gitignore
new file mode 100644
index 000000000000..dc62a52b03b4
--- /dev/null
+++ b/testcases/kernel/syscalls/open_tree/.gitignore
@@ -0,0 +1,2 @@
+open_tree01
+open_tree02
diff --git a/testcases/kernel/syscalls/open_tree/Makefile b/testcases/kernel/syscalls/open_tree/Makefile
new file mode 100644
index 000000000000..5ea7d67db123
--- /dev/null
+++ b/testcases/kernel/syscalls/open_tree/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/open_tree/open_tree01.c b/testcases/kernel/syscalls/open_tree/open_tree01.c
new file mode 100644
index 000000000000..74feb9556478
--- /dev/null
+++ b/testcases/kernel/syscalls/open_tree/open_tree01.c
@@ -0,0 +1,115 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic open_tree() test.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+#define MNTPOINT	"mntpoint"
+#define OT_MNTPOINT	"ot_mntpoint"
+
+static int fd, fsmfd, mmfd;
+
+static void cleanup(void)
+{
+	if (mmfd != -1)
+		SAFE_CLOSE(mmfd);
+
+	SAFE_CLOSE(fsmfd);
+	TEST(umount(MNTPOINT));
+	SAFE_CLOSE(fd);
+}
+
+static void setup(void)
+{
+	char *err = "fsconfig()";
+
+	TEST(fsopen(tst_device->fs_type, 0));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TBROK | TERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsconfig(fd, FSCONFIG_SET_FLAG, "rw", NULL, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsmount(fd, 0, 0));
+	if (TST_RET == -1) {
+		err = "fsmount()";
+		goto out;
+	}
+
+	fsmfd = TST_RET;
+
+	TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
+			MOVE_MOUNT_F_EMPTY_PATH));
+	if (TST_RET != -1) {
+		mmfd = TST_RET;
+		return;
+	}
+
+	SAFE_CLOSE(fsmfd);
+	err = "move_mount()";
+
+out:
+	SAFE_CLOSE(fd);
+	tst_brk(TBROK | TERRNO, "%s failed", err);
+}
+
+static void run(void)
+{
+	int otfd;
+
+	SAFE_MKDIR(OT_MNTPOINT, 0777);
+
+	TEST(open_tree(AT_FDCWD, MNTPOINT, OPEN_TREE_CLONE));
+	if (TST_RET == -1) {
+		tst_res(TFAIL | TERRNO, "open_tree() failed");
+		goto out;
+	}
+
+	otfd = TST_RET;
+
+	/* Earlier file descriptor isn't valid anymore */
+	mmfd = -1;
+
+	TEST(move_mount(otfd, "", AT_FDCWD, OT_MNTPOINT,
+			MOVE_MOUNT_F_EMPTY_PATH));
+
+	SAFE_CLOSE(otfd);
+
+	if (TST_RET == -1) {
+		tst_res(TBROK | TERRNO, "move_mount() failed");
+		goto out;
+	}
+
+	SAFE_CLOSE(TST_RET);
+	TEST(umount(OT_MNTPOINT));
+
+	tst_res(TPASS, "open_tree() passed");
+out:
+	SAFE_RMDIR(OT_MNTPOINT);
+}
+
+static struct tst_test test = {
+	.min_kver = "5.2",
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.format_device = 1,
+	.mntpoint = MNTPOINT,
+};
diff --git a/testcases/kernel/syscalls/open_tree/open_tree02.c b/testcases/kernel/syscalls/open_tree/open_tree02.c
new file mode 100644
index 000000000000..136c1b25a2b9
--- /dev/null
+++ b/testcases/kernel/syscalls/open_tree/open_tree02.c
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * Description:
+ * Basic open_tree() failure tests.
+ */
+#include "tst_test.h"
+#include "lapi/fsmount.h"
+
+#define MNTPOINT	"mntpoint"
+
+static int fd, fsmfd, mmfd;
+
+static struct tcase {
+	char *name;
+	int dirfd;
+	const char *pathname;
+	unsigned int flags;
+	int exp_errno;
+} tcases[] = {
+	{"invalid-fd", -1, MNTPOINT, OPEN_TREE_CLONE, EBADF},
+	{"invalid-path", AT_FDCWD, "invalid", OPEN_TREE_CLONE, ENOENT},
+	{"invalid-flags", AT_FDCWD, MNTPOINT, 0xFFFFFFFF, EINVAL},
+};
+
+static void cleanup(void)
+{
+	SAFE_CLOSE(mmfd);
+	SAFE_CLOSE(fsmfd);
+	TEST(umount(MNTPOINT));
+	SAFE_CLOSE(fd);
+}
+
+static void setup(void)
+
+{
+	char *err = "fsconfig()";
+
+	TEST(fsopen(tst_device->fs_type, 0));
+	fd = TST_RET;
+
+	if (fd == -1)
+		tst_brk(TBROK | TERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsconfig(fd, FSCONFIG_SET_FLAG, "rw", NULL, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1)
+		goto out;
+
+	TEST(fsmount(fd, 0, 0));
+	if (TST_RET == -1) {
+		err = "fsmount()";
+		goto out;
+	}
+
+	fsmfd = TST_RET;
+
+	TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
+			MOVE_MOUNT_F_EMPTY_PATH));
+	if (TST_RET != -1) {
+		mmfd = TST_RET;
+		return;
+	}
+
+	SAFE_CLOSE(fsmfd);
+	err = "move_mount()";
+
+out:
+	SAFE_CLOSE(fd);
+	tst_brk(TBROK | TERRNO, "%s failed", err);
+}
+
+static void run(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+
+	TEST(open_tree(tc->dirfd, tc->pathname, tc->flags));
+	if (TST_RET != -1) {
+		SAFE_CLOSE(TST_RET);
+		tst_brk(TFAIL, "%s: open_tree() succeeded unexpectedly (index: %d)",
+			tc->name, n);
+	}
+
+	if (tc->exp_errno != TST_ERR) {
+		tst_brk(TFAIL | TTERRNO, "%s: open_tree() should fail with %s",
+			tc->name, tst_strerrno(tc->exp_errno));
+	}
+
+	tst_res(TPASS | TTERRNO, "%s: open_tree() failed as expected", tc->name);
+}
+
+static struct tst_test test = {
+	.min_kver = "5.2",
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.format_device = 1,
+	.mntpoint = MNTPOINT,
+};
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 1/7] lapi/fsmount: Add definitions for fsmount related syscalls
  2020-02-14 11:35 ` [LTP] [PATCH 1/7] lapi/fsmount: Add definitions for fsmount related syscalls Viresh Kumar
@ 2020-02-16  9:09   ` Li Wang
  2020-02-17  8:08     ` Viresh Kumar
  0 siblings, 1 reply; 32+ messages in thread
From: Li Wang @ 2020-02-16  9:09 UTC (permalink / raw)
  To: ltp

Hi Viresh,

Thank you for creating new tests for LTP.

Unfortunately, this 1/7 patch has overlap with zlang@'s patch[1]. It
probably can not be merged if the patch[1] applies first. But the remaining
part is valuable to LTP, you can drop some of this and rebase your code to
make use of the header file again.

[1] http://lists.linux.it/pipermail/ltp/2020-February/015336.html

[CC zlang, pvorel] to have a look at this.

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200216/e4dfdd77/attachment-0001.htm>

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 2/7] syscalls/fsopen: New tests
  2020-02-14 11:35 ` [LTP] [PATCH 2/7] syscalls/fsopen: New tests Viresh Kumar
@ 2020-02-16 10:11   ` Li Wang
  2020-02-17  8:09     ` Viresh Kumar
  2020-02-17 13:36     ` Cyril Hrubis
  0 siblings, 2 replies; 32+ messages in thread
From: Li Wang @ 2020-02-16 10:11 UTC (permalink / raw)
  To: ltp

On Fri, Feb 14, 2020 at 7:36 PM Viresh Kumar <viresh.kumar@linaro.org>
wrote:

> Add tests to check working of fsopen() syscall.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  configure.ac                                |  1 +
>  runtest/syscalls                            |  3 +
>  testcases/kernel/syscalls/fsopen/.gitignore |  2 +
>  testcases/kernel/syscalls/fsopen/Makefile   |  6 ++
>  testcases/kernel/syscalls/fsopen/fsopen01.c | 71 +++++++++++++++++++++
>  testcases/kernel/syscalls/fsopen/fsopen02.c | 56 ++++++++++++++++
>  6 files changed, 139 insertions(+)
>  create mode 100644 testcases/kernel/syscalls/fsopen/.gitignore
>  create mode 100644 testcases/kernel/syscalls/fsopen/Makefile
>  create mode 100644 testcases/kernel/syscalls/fsopen/fsopen01.c
>  create mode 100644 testcases/kernel/syscalls/fsopen/fsopen02.c
>
> diff --git a/configure.ac b/configure.ac
> index df4e8c8322fc..4125160a19bb 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -80,6 +80,7 @@ AC_CHECK_FUNCS([ \
>      execveat \
>      fallocate \
>      fchownat \
> +    fsopen \
>      fstatat \
>      getdents \
>      getdents64 \
> diff --git a/runtest/syscalls b/runtest/syscalls
> index 0743cf4e3f74..0a56599ebad9 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -542,6 +542,9 @@ fanotify13 fanotify13
>  fanotify14 fanotify14
>  fanotify15 fanotify15
>
> +fsopen01 fsopen01
> +fsopen02 fsopen02
> +
>  ioperm01 ioperm01
>  ioperm02 ioperm02
>
> diff --git a/testcases/kernel/syscalls/fsopen/.gitignore
> b/testcases/kernel/syscalls/fsopen/.gitignore
> new file mode 100644
> index 000000000000..80089dd137a7
> --- /dev/null
> +++ b/testcases/kernel/syscalls/fsopen/.gitignore
> @@ -0,0 +1,2 @@
> +fsopen01
> +fsopen02
> diff --git a/testcases/kernel/syscalls/fsopen/Makefile
> b/testcases/kernel/syscalls/fsopen/Makefile
> new file mode 100644
> index 000000000000..5ea7d67db123
> --- /dev/null
> +++ b/testcases/kernel/syscalls/fsopen/Makefile
> @@ -0,0 +1,6 @@
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +
> +top_srcdir             ?= ../../../..
> +
> +include $(top_srcdir)/include/mk/testcases.mk
> +include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/kernel/syscalls/fsopen/fsopen01.c
> b/testcases/kernel/syscalls/fsopen/fsopen01.c
> new file mode 100644
> index 000000000000..3587c67636ea
> --- /dev/null
> +++ b/testcases/kernel/syscalls/fsopen/fsopen01.c
> @@ -0,0 +1,71 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
> + *
> + * Description:
> + * Basic fsopen() test which tries to configure and mount the filesystem
> as
> + * well.
> + */
> +#include "tst_test.h"
> +#include "lapi/fsmount.h"
> +
> +#define MNTPOINT       "mntpoint"
> +
> +static void run(void)
> +{
> +       int fd, fsmfd;
> +
> +       TEST(fsopen(tst_device->fs_type, 0));
> +       fd = TST_RET;
> +
> +       if (fd == -1)
> +               tst_brk(TFAIL | TERRNO, "fsopen() failed");
> +
> +       TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev,
> 0));
> +       if (TST_RET == -1) {
> +               tst_res(TBROK | TERRNO, "fsconfig() failed");
> +               goto out;
> +       }
> +
> +       TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
> +       if (TST_RET == -1) {
> +               tst_res(TBROK | TERRNO, "fsconfig() failed");
> +               goto out;
> +       }
> +
> +       TEST(fsmount(fd, 0, 0));
> +       if (TST_RET == -1) {
> +               tst_res(TBROK | TERRNO, "fsmount() failed");
> +               goto out;
> +       }
> +
> +       fsmfd = TST_RET;
> +
> +       TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
> +                       MOVE_MOUNT_F_EMPTY_PATH));
> +
> +       SAFE_CLOSE(fsmfd);
> +
> +       if (TST_RET == -1) {
> +               tst_res(TBROK | TERRNO, "move_mount() failed");
> +               goto out;
> +       }
> +
> +       SAFE_CLOSE(TST_RET);
> +
> +       TEST(umount(MNTPOINT));
> +
> +       tst_res(TPASS, "fsopen() passed");
> +
> +out:
> +       SAFE_CLOSE(fd);
> +}
> +
> +static struct tst_test test = {
> +       .min_kver = "5.2",
>

I suggest removing .min_kver check in all of the tests to let they can be
running on many distributions(which backport the features).

+       .test_all = run,
> +       .needs_root = 1,
> +       .needs_tmpdir = 1,
>

.needs_tmpdir is not necessary because tst_test->mntpoint helps create that
too.


> +       .format_device = 1,
> +       .mntpoint = MNTPOINT,
>

Maybe to test more filesystems and skip on FUSE? Just like the way in zlang@'s
patch.

+       .all_filesystems = 1,
+       .dev_fs_flags = TST_FS_SKIP_FUSE,

+};
> diff --git a/testcases/kernel/syscalls/fsopen/fsopen02.c
> b/testcases/kernel/syscalls/fsopen/fsopen02.c
> new file mode 100644
> index 000000000000..6831a12c696b
> --- /dev/null
> +++ b/testcases/kernel/syscalls/fsopen/fsopen02.c
> @@ -0,0 +1,56 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
> + *
> + * Description:
> + * Basic fsopen() failure tests.
> + */
> +#include "tst_test.h"
> +#include "lapi/fsmount.h"
> +
> +const char *invalid_fs = "invalid";
> +const char *valid_fs;
> +
> +static struct tcase {
> +       char *name;
> +       const char **fs;
> +       unsigned int flags;
> +       int exp_errno;
> +} tcases[] = {
> +       {"invalid-fs", &invalid_fs, 0, ENODEV},
> +       {"invalid-flags", &valid_fs, 0x10, EINVAL},
> +};
> +
> +static void setup(void)
> +{
> +       valid_fs = tst_device->fs_type;
> +}
> +
> +static void run(unsigned int n)
> +{
> +       struct tcase *tc = &tcases[n];
> +
> +       TEST(fsopen(*tc->fs, tc->flags));
> +
> +       if (TST_RET != -1) {
> +               SAFE_CLOSE(TST_RET);
> +               tst_brk(TFAIL, "%s: fsopen() succeeded unexpectedly
> (index: %d)",
> +                       tc->name, n);
> +       }
> +
> +       if (tc->exp_errno != TST_ERR) {
> +               tst_brk(TFAIL | TTERRNO, "%s: fsopen() should fail with
> %s",
> +                       tc->name, tst_strerrno(tc->exp_errno));
> +       }
> +
> +       tst_res(TPASS | TTERRNO, "%s: fsopen() failed as expected",
> tc->name);
> +}
> +
> +static struct tst_test test = {
> +       .min_kver = "5.2",
>

To delete .min_kver.


> +       .tcnt = ARRAY_SIZE(tcases),
> +       .test = run,
> +       .setup = setup,
> +       .needs_root = 1,
> +       .needs_device = 1,
> +};
> --
> 2.21.0.rc0.269.g1a574e7a288b
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200216/427b4b5f/attachment.htm>

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 1/7] lapi/fsmount: Add definitions for fsmount related syscalls
  2020-02-16  9:09   ` Li Wang
@ 2020-02-17  8:08     ` Viresh Kumar
  0 siblings, 0 replies; 32+ messages in thread
From: Viresh Kumar @ 2020-02-17  8:08 UTC (permalink / raw)
  To: ltp

On 16-02-20, 17:09, Li Wang wrote:
> Hi Viresh,
> 
> Thank you for creating new tests for LTP.
> 
> Unfortunately, this 1/7 patch has overlap with zlang@'s patch[1]. It
> probably can not be merged if the patch[1] applies first. But the remaining
> part is valuable to LTP, you can drop some of this and rebase your code to
> make use of the header file again.

Thanks for pointing that out Li. I will rebase over zlang's patch once it gets
merged.

-- 
viresh

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 2/7] syscalls/fsopen: New tests
  2020-02-16 10:11   ` Li Wang
@ 2020-02-17  8:09     ` Viresh Kumar
  2020-02-17 13:36     ` Cyril Hrubis
  1 sibling, 0 replies; 32+ messages in thread
From: Viresh Kumar @ 2020-02-17  8:09 UTC (permalink / raw)
  To: ltp

On 16-02-20, 18:11, Li Wang wrote:
> > +static struct tst_test test = {
> > +       .min_kver = "5.2",
> >
> 
> I suggest removing .min_kver check in all of the tests to let they can be
> running on many distributions(which backport the features).

I never thought about that earlier, good point. All other comments look fine as
well. Thanks.

-- 
viresh

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 4/7] syscalls/fsmount: New tests
  2020-02-14 11:35 ` [LTP] [PATCH 4/7] syscalls/fsmount: " Viresh Kumar
@ 2020-02-17  8:17   ` Li Wang
  2020-02-17  8:29     ` Viresh Kumar
  0 siblings, 1 reply; 32+ messages in thread
From: Li Wang @ 2020-02-17  8:17 UTC (permalink / raw)
  To: ltp

Viresh Kumar <viresh.kumar@linaro.org> wrote:

....
> +/*
> + * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
> + *
> + * Description:
> + * Basic fsmount() test.
> + */
> +#include "tst_test.h"
> +#include "lapi/fsmount.h"
>

Adding #include "lapi/fcntl.h" in case of ?AT_FDCWD? undeclared. It seems
we have to do this for all the tests involves  ?AT_FDCWD?.

+
> +static void run(void)
> +{
> ...
> +
> +       TEST(fsmount(fd, 0, 0));
>

As this fsmount01.c is duplicated with zlang@'s patch, I suggest rewriting
an enhancement version maybe name fsmount02.c to cover more fsmount
attributes. Since it is named basic fsmount() test, it shouldn't only test
fsmount(fd, 0, 0), right?

+#define MOUNT_ATTR_RDONLY      0x00000001 /* Mount read-only */
+#define MOUNT_ATTR_NOSUID      0x00000002 /* Ignore suid and sgid bits */
+#define MOUNT_ATTR_NODEV       0x00000004 /* Disallow access to device
special files */
+#define MOUNT_ATTR_NOEXEC      0x00000008 /* Disallow program execution */
+#define MOUNT_ATTR__ATIME      0x00000070 /* Setting on how atime should
be updated */
+#define MOUNT_ATTR_RELATIME    0x00000000 /* - Update atime relative to
mtime/ctime. */
+#define MOUNT_ATTR_NOATIME     0x00000010 /* - Do not update access times.
*/
+#define MOUNT_ATTR_STRICTATIME 0x00000020 /* - Always perform atime
updates */
+#define MOUNT_ATTR_NODIRATIME  0x00000080 /* Do not update directory
access times */



> +       if (TST_RET == -1)
> +               tst_brk(TFAIL | TERRNO, "fsmount() failed");
> +
> +       fsmfd = TST_RET;
> +
> +       TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
> +                       MOVE_MOUNT_F_EMPTY_PATH));
> +       SAFE_CLOSE(fsmfd);
>

I guess we probably need a way to verify the move_mount() does work. The
function ismount() in zlang@'s patch could be extracted into the library as
tst_ismount() for all of these tests.
@Petr Vorel <pvorel@suse.cz>  WDT?


> +
> +       if (TST_RET == -1)
> +               tst_brk(TBROK | TERRNO, "move_mount() failed");
> +
> +       SAFE_CLOSE(TST_RET);
> +       TEST(umount(MNTPOINT));
>

SAFE_UMOUNT(MNTPOINT);

+
> +       tst_res(TPASS, "fsmount() passed");
> +}
> +
> +static struct tst_test test = {
>

Suggest referring to my previous comments for this part.

+       .min_kver = "5.2",
> +       .test_all = run,
> +       .setup = setup,
> +       .cleanup = cleanup,
> +       .needs_root = 1,
> +       .needs_tmpdir = 1,
> +       .format_device = 1,
> +       .mntpoint = MNTPOINT,
> +};
>

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200217/0678ec1f/attachment.htm>

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 4/7] syscalls/fsmount: New tests
  2020-02-17  8:17   ` Li Wang
@ 2020-02-17  8:29     ` Viresh Kumar
  2020-02-17  8:54       ` Li Wang
  2020-02-17  8:58       ` Petr Vorel
  0 siblings, 2 replies; 32+ messages in thread
From: Viresh Kumar @ 2020-02-17  8:29 UTC (permalink / raw)
  To: ltp

On 17-02-20, 16:17, Li Wang wrote:
> Viresh Kumar <viresh.kumar@linaro.org> wrote:
> 
> ....
> > +/*
> > + * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
> > + *
> > + * Description:
> > + * Basic fsmount() test.
> > + */
> > +#include "tst_test.h"
> > +#include "lapi/fsmount.h"
> >
> 
> Adding #include "lapi/fcntl.h" in case of ?AT_FDCWD? undeclared. It seems
> we have to do this for all the tests involves  ?AT_FDCWD?.

my fsmount.h header includes <fcntl.h>, won't that be enough ?

> +
> > +static void run(void)
> > +{
> > ...
> > +
> > +       TEST(fsmount(fd, 0, 0));
> >
> 
> As this fsmount01.c is duplicated with zlang@'s patch, I suggest rewriting
> an enhancement version maybe name fsmount02.c to cover more fsmount
> attributes. Since it is named basic fsmount() test, it shouldn't only test
> fsmount(fd, 0, 0), right?
> 
> +#define MOUNT_ATTR_RDONLY      0x00000001 /* Mount read-only */
> +#define MOUNT_ATTR_NOSUID      0x00000002 /* Ignore suid and sgid bits */
> +#define MOUNT_ATTR_NODEV       0x00000004 /* Disallow access to device
> special files */
> +#define MOUNT_ATTR_NOEXEC      0x00000008 /* Disallow program execution */
> +#define MOUNT_ATTR__ATIME      0x00000070 /* Setting on how atime should
> be updated */
> +#define MOUNT_ATTR_RELATIME    0x00000000 /* - Update atime relative to
> mtime/ctime. */
> +#define MOUNT_ATTR_NOATIME     0x00000010 /* - Do not update access times.
> */
> +#define MOUNT_ATTR_STRICTATIME 0x00000020 /* - Always perform atime
> updates */
> +#define MOUNT_ATTR_NODIRATIME  0x00000080 /* Do not update directory
> access times */

Okay, I will give it a try.
 
> > +       if (TST_RET == -1)
> > +               tst_brk(TFAIL | TERRNO, "fsmount() failed");
> > +
> > +       fsmfd = TST_RET;
> > +
> > +       TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
> > +                       MOVE_MOUNT_F_EMPTY_PATH));
> > +       SAFE_CLOSE(fsmfd);
> >
> 
> I guess we probably need a way to verify the move_mount() does work. The
> function ismount() in zlang@'s patch could be extracted into the library as
> tst_ismount() for all of these tests.
> @Petr Vorel <pvorel@suse.cz>  WDT?

Yeah, I will do that.
 
-- 
viresh

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 4/7] syscalls/fsmount: New tests
  2020-02-17  8:29     ` Viresh Kumar
@ 2020-02-17  8:54       ` Li Wang
  2020-02-17  9:58         ` Petr Vorel
  2020-02-17  8:58       ` Petr Vorel
  1 sibling, 1 reply; 32+ messages in thread
From: Li Wang @ 2020-02-17  8:54 UTC (permalink / raw)
  To: ltp

On Mon, Feb 17, 2020 at 4:29 PM Viresh Kumar <viresh.kumar@linaro.org>
wrote:

> ...
> > Adding #include "lapi/fcntl.h" in case of ?AT_FDCWD? undeclared. It seems
> > we have to do this for all the tests involves  ?AT_FDCWD?.
>
> my fsmount.h header includes <fcntl.h>, won't that be enough ?
>

I'm afraid it's not enough.

After having a closer look, the reason is that the AT_FDCWD is defined with
condition __USE_ATFILE,  the __USE_ATFILE depends on _ATFILE_SOURCE
defined, and _ATFILE_SOURCE needs enable _GNU_SOURCE.

So another effective way is to add '#define _GNU_SOURCE' in front of your
test then that <fcntl.h> will be work for you.

# rpm -qa glibc-headers
glibc-headers-2.5-123

# cat /usr/include/fcntl.h |grep AT_FDCWD -B 2 -A 2
#ifdef __USE_ATFILE
# define AT_FDCWD -100   /* Special value used to indicate
                                                the *at functions should
use the
                                                current working directory.
*/


-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200217/cccc37ee/attachment.htm>

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 4/7] syscalls/fsmount: New tests
  2020-02-17  8:29     ` Viresh Kumar
  2020-02-17  8:54       ` Li Wang
@ 2020-02-17  8:58       ` Petr Vorel
  1 sibling, 0 replies; 32+ messages in thread
From: Petr Vorel @ 2020-02-17  8:58 UTC (permalink / raw)
  To: ltp

> On 17-02-20, 16:17, Li Wang wrote:
> > Viresh Kumar <viresh.kumar@linaro.org> wrote:

> > ....
> > > +/*
> > > + * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
> > > + *
> > > + * Description:
> > > + * Basic fsmount() test.
> > > + */
> > > +#include "tst_test.h"
> > > +#include "lapi/fsmount.h"


> > Adding #include "lapi/fcntl.h" in case of ?AT_FDCWD? undeclared. It seems
> > we have to do this for all the tests involves  ?AT_FDCWD?.

> my fsmount.h header includes <fcntl.h>, won't that be enough ?
Unfortunately it won't be enough. LAPI files are here for adding missing
definitions in old distros, which is exactly the case for AT_FDCWD on old RHEL.

I also suggest following change to v7, see diff below (fsmount.h using
"lapi/fcntl.h", thus not needed in fsmount01.c).

> > > +static void run(void)
> > > +{
> > > ...
> > > +
> > > +       TEST(fsmount(fd, 0, 0));


> > As this fsmount01.c is duplicated with zlang@'s patch, I suggest rewriting
> > an enhancement version maybe name fsmount02.c to cover more fsmount
> > attributes. Since it is named basic fsmount() test, it shouldn't only test
> > fsmount(fd, 0, 0), right?
+1.

> > +#define MOUNT_ATTR_RDONLY      0x00000001 /* Mount read-only */
> > +#define MOUNT_ATTR_NOSUID      0x00000002 /* Ignore suid and sgid bits */
> > +#define MOUNT_ATTR_NODEV       0x00000004 /* Disallow access to device
> > special files */
> > +#define MOUNT_ATTR_NOEXEC      0x00000008 /* Disallow program execution */
> > +#define MOUNT_ATTR__ATIME      0x00000070 /* Setting on how atime should
> > be updated */
> > +#define MOUNT_ATTR_RELATIME    0x00000000 /* - Update atime relative to
> > mtime/ctime. */
> > +#define MOUNT_ATTR_NOATIME     0x00000010 /* - Do not update access times.
> > */
> > +#define MOUNT_ATTR_STRICTATIME 0x00000020 /* - Always perform atime
> > updates */
> > +#define MOUNT_ATTR_NODIRATIME  0x00000080 /* Do not update directory
> > access times */

> Okay, I will give it a try.
Great thanks!

> > > +       if (TST_RET == -1)
> > > +               tst_brk(TFAIL | TERRNO, "fsmount() failed");
> > > +
> > > +       fsmfd = TST_RET;
> > > +
> > > +       TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT,
> > > +                       MOVE_MOUNT_F_EMPTY_PATH));
> > > +       SAFE_CLOSE(fsmfd);


> > I guess we probably need a way to verify the move_mount() does work. The
> > function ismount() in zlang@'s patch could be extracted into the library as
> > tst_ismount() for all of these tests.
> > @Petr Vorel <pvorel@suse.cz>  WDT?

> Yeah, I will do that.
+1. But I'd suggest to first merge tests which I sent as v7 [1] (with change
below) and then doing this.

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/project/ltp/list/?series=158902&state=*
[2] https://travis-ci.org/pevik/ltp/builds/651390749

diff --git include/lapi/fsmount.h include/lapi/fsmount.h
index 87f2f229c..97c41629c 100644
--- include/lapi/fsmount.h
+++ include/lapi/fsmount.h
@@ -7,12 +7,12 @@
 #ifndef FSMOUNT_H__
 #define FSMOUNT_H__
 
-#include <fcntl.h>
+#include "config.h"
 #include <sys/mount.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
 
-#include "config.h"
+#include "lapi/fcntl.h"
 #include "lapi/syscalls.h"
 
 #ifndef HAVE_FSOPEN
diff --git testcases/kernel/syscalls/fsmount/fsmount01.c testcases/kernel/syscalls/fsmount/fsmount01.c
index 464458080..6ba226acc 100644
--- testcases/kernel/syscalls/fsmount/fsmount01.c
+++ testcases/kernel/syscalls/fsmount/fsmount01.c
@@ -10,7 +10,6 @@
 #include <sys/mount.h>
 
 #include "tst_test.h"
-#include "lapi/fcntl.h"
 #include "lapi/fsmount.h"
 #include "tst_safe_stdio.h"
 

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 4/7] syscalls/fsmount: New tests
  2020-02-17  8:54       ` Li Wang
@ 2020-02-17  9:58         ` Petr Vorel
  2020-02-17 10:28           ` Li Wang
  0 siblings, 1 reply; 32+ messages in thread
From: Petr Vorel @ 2020-02-17  9:58 UTC (permalink / raw)
  To: ltp

Hi Li,

> On Mon, Feb 17, 2020 at 4:29 PM Viresh Kumar <viresh.kumar@linaro.org>
> wrote:

> > ...
> > > Adding #include "lapi/fcntl.h" in case of ?AT_FDCWD? undeclared. It seems
> > > we have to do this for all the tests involves  ?AT_FDCWD?.

> > my fsmount.h header includes <fcntl.h>, won't that be enough ?


> I'm afraid it's not enough.

> After having a closer look, the reason is that the AT_FDCWD is defined with
> condition __USE_ATFILE,  the __USE_ATFILE depends on _ATFILE_SOURCE
> defined, and _ATFILE_SOURCE needs enable _GNU_SOURCE.

> So another effective way is to add '#define _GNU_SOURCE' in front of your
> test then that <fcntl.h> will be work for you.

OK, we can add #define _GNU_SOURCE to fsmount01.c, which actually needs it
+ keep <fcntl.h> there and load lapi/fsmount.h later (see below).
But generally this will be the approach for all uses of <fcntl.h> (and probably
some other headers) for old distros. IMHO this change is caused by:

c941736c92 Remove _BSD_SOURCE and _SVID_SOURCE. (glibc-2.20)
c688b41960 Add _DEFAULT_SOURCE feature test macro. (glibc-2.19)

So we can either add it to many places or detect this old glibc and compile with
-D_GNU_SOURCE (but this might break other things).
But that's another story.

> # rpm -qa glibc-headers
> glibc-headers-2.5-123

> # cat /usr/include/fcntl.h |grep AT_FDCWD -B 2 -A 2
> #ifdef __USE_ATFILE
> # define AT_FDCWD -100   /* Special value used to indicate
>                                                 the *at functions should
> use the
>                                                 current working directory.
> */

So is this diff to v7 better?

Kind regards,
Petr

diff --git testcases/kernel/syscalls/fsmount/fsmount01.c testcases/kernel/syscalls/fsmount/fsmount01.c
index 464458080..21d0ae50b 100644
--- testcases/kernel/syscalls/fsmount/fsmount01.c
+++ testcases/kernel/syscalls/fsmount/fsmount01.c
@@ -7,10 +7,11 @@
  * to mount a filesystem without any specified mount options.
  */
 
+#define _GNU_SOURCE
 #include <sys/mount.h>
+#include <fcntl.h>
 
 #include "tst_test.h"
-#include "lapi/fcntl.h"
 #include "lapi/fsmount.h"
 #include "tst_safe_stdio.h"
 

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 4/7] syscalls/fsmount: New tests
  2020-02-17  9:58         ` Petr Vorel
@ 2020-02-17 10:28           ` Li Wang
  2020-02-17 10:37             ` Li Wang
  0 siblings, 1 reply; 32+ messages in thread
From: Li Wang @ 2020-02-17 10:28 UTC (permalink / raw)
  To: ltp

On Mon, Feb 17, 2020 at 5:58 PM Petr Vorel <pvorel@suse.cz> wrote:

> Hi Li,
>
> > On Mon, Feb 17, 2020 at 4:29 PM Viresh Kumar <viresh.kumar@linaro.org>
> > wrote:
>
> > > ...
> > > > Adding #include "lapi/fcntl.h" in case of ?AT_FDCWD? undeclared. It
> seems
> > > > we have to do this for all the tests involves  ?AT_FDCWD?.
>
> > > my fsmount.h header includes <fcntl.h>, won't that be enough ?
>
>
> > I'm afraid it's not enough.
>
> > After having a closer look, the reason is that the AT_FDCWD is defined
> with
> > condition __USE_ATFILE,  the __USE_ATFILE depends on _ATFILE_SOURCE
> > defined, and _ATFILE_SOURCE needs enable _GNU_SOURCE.
>
> > So another effective way is to add '#define _GNU_SOURCE' in front of your
> > test then that <fcntl.h> will be work for you.
>
> OK, we can add #define _GNU_SOURCE to fsmount01.c, which actually needs it
> + keep <fcntl.h> there and load lapi/fsmount.h later (see below).
> But generally this will be the approach for all uses of <fcntl.h> (and
> probably
> some other headers) for old distros. IMHO this change is caused by:
>
> c941736c92 Remove _BSD_SOURCE and _SVID_SOURCE. (glibc-2.20)
> c688b41960 Add _DEFAULT_SOURCE feature test macro. (glibc-2.19)
>

Thanks for figure out this.

>
> So we can either add it to many places or detect this old glibc and
> compile with
> -D_GNU_SOURCE (but this might break other things).
>

-1 remove old Glibc is a bad choice.


> But that's another story.
>
> > # rpm -qa glibc-headers
> > glibc-headers-2.5-123
>
> > # cat /usr/include/fcntl.h |grep AT_FDCWD -B 2 -A 2
> > #ifdef __USE_ATFILE
> > # define AT_FDCWD -100   /* Special value used to indicate
> >                                                 the *at functions should
> > use the
> >                                                 current working
> directory.
> > */
>
> So is this diff to v7 better?
>

To use "lapi/fcntl.h" in v7 is simpler I guess, sometimes we just need to
get compile pass on old distros but not perform it indeed. And that's the
purpose why we need lapi/*.

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200217/8ae9c1ca/attachment.htm>

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 4/7] syscalls/fsmount: New tests
  2020-02-17 10:28           ` Li Wang
@ 2020-02-17 10:37             ` Li Wang
  2020-02-17 11:02               ` Petr Vorel
  0 siblings, 1 reply; 32+ messages in thread
From: Li Wang @ 2020-02-17 10:37 UTC (permalink / raw)
  To: ltp

On Mon, Feb 17, 2020 at 6:28 PM Li Wang <liwang@redhat.com> wrote:

> ...
>> So we can either add it to many places or detect this old glibc and
>> compile with
>> -D_GNU_SOURCE (but this might break other things).
>>
>
> -1 remove old Glibc is a bad choice.
>

Sorry, that's a typo. I mean detect Glibc version is not a good idea:).

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200217/e3e0e552/attachment.htm>

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 4/7] syscalls/fsmount: New tests
  2020-02-17 10:37             ` Li Wang
@ 2020-02-17 11:02               ` Petr Vorel
  0 siblings, 0 replies; 32+ messages in thread
From: Petr Vorel @ 2020-02-17 11:02 UTC (permalink / raw)
  To: ltp

Hi Li,

> >> So we can either add it to many places or detect this old glibc and
> >> compile with
> >> -D_GNU_SOURCE (but this might break other things).


> > -1 remove old Glibc is a bad choice.


> Sorry, that's a typo. I mean detect Glibc version is not a good idea:).
Agree. IMHO mostly we should use lapi than libc headers (+ put system headers
into lapi files), that'd keep old distros working.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 2/7] syscalls/fsopen: New tests
  2020-02-16 10:11   ` Li Wang
  2020-02-17  8:09     ` Viresh Kumar
@ 2020-02-17 13:36     ` Cyril Hrubis
  2020-02-18  1:15       ` Li Wang
  1 sibling, 1 reply; 32+ messages in thread
From: Cyril Hrubis @ 2020-02-17 13:36 UTC (permalink / raw)
  To: ltp

Hi!
> > +       SAFE_CLOSE(TST_RET);
> > +
> > +       TEST(umount(MNTPOINT));
> > +
> > +       tst_res(TPASS, "fsopen() passed");
> > +
> > +out:
> > +       SAFE_CLOSE(fd);
> > +}
> > +
> > +static struct tst_test test = {
> > +       .min_kver = "5.2",
> >
> 
> I suggest removing .min_kver check in all of the tests to let they can be
> running on many distributions(which backport the features).

If we do that we have to explicitely check for ENOSYS errno in each
test, quite possibly with a dummy call to the tested syscall in test
setup, because once these calls gets libc wrappers we will no longer
call the tst_syscall() that checks for it.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 2/7] syscalls/fsopen: New tests
  2020-02-17 13:36     ` Cyril Hrubis
@ 2020-02-18  1:15       ` Li Wang
  2020-02-18  8:25         ` Viresh Kumar
                           ` (2 more replies)
  0 siblings, 3 replies; 32+ messages in thread
From: Li Wang @ 2020-02-18  1:15 UTC (permalink / raw)
  To: ltp

On Mon, Feb 17, 2020 at 9:36 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> ...
> > > +static struct tst_test test = {
> > > +       .min_kver = "5.2",
> > >
> >
> > I suggest removing .min_kver check in all of the tests to let they can be
> > running on many distributions(which backport the features).
>
> If we do that we have to explicitely check for ENOSYS errno in each
> test, quite possibly with a dummy call to the tested syscall in test
> setup, because once these calls gets libc wrappers we will no longer
> call the tst_syscall() that checks for it.
>

+1 add dummy call to the tested syscall in the setup.
Agree, thanks for point out this.

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200218/fb9b666c/attachment.htm>

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls
  2020-02-14 11:35 [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
                   ` (6 preceding siblings ...)
  2020-02-14 11:35 ` [LTP] [PATCH 7/7] syscalls/open_tree: " Viresh Kumar
@ 2020-02-18  6:19 ` Zorro Lang
  2020-02-18  6:50   ` Li Wang
  2020-02-18  6:58   ` Viresh Kumar
  7 siblings, 2 replies; 32+ messages in thread
From: Zorro Lang @ 2020-02-18  6:19 UTC (permalink / raw)
  To: ltp

On Fri, Feb 14, 2020 at 05:05:49PM +0530, Viresh Kumar wrote:
> Hello,
> 
> This series adds a bunch of LTP tests related to fsmount family of
> syscalls.

Hi Viresh,

Thanks for all these cases, that's really helpful.

Although you write cases for each new mount API, each xxxxx01.c case looks
nearly do same things.

That's why I only wrote one case for new-mount currently, due to basic mount
test already can through most of new APIs(except open_tree and fspick). I don't
know if we should write nearly same things in different directories.
Actually I prepared open_tree and fspick test cases(planned to name as newmount02
and newmount03. but the newmount01 has been changed to fsmount01 :), but didn't
sent out, due to I hope to the first case(which does basic changes) can be merged
at first.

All of your xxxxx02.c cases are great! I planned to test more different
parameters of fsconfig() later too. Your invalid parameters test are nice.
As you've sent these cases, I think these should be reviewed at first, avoid
we do same things:) I'll try to help to review V2 patchset too, if I can:-P

Thanks,
Zorro

> 
> Thanks
> 
> --
> viresh
> 
> Viresh Kumar (7):
>   lapi/fsmount: Add definitions for fsmount related syscalls
>   syscalls/fsopen: New tests
>   syscalls/fsconfig: New tests
>   syscalls/fsmount: New tests
>   syscalls/move_mount: New tests
>   syscalls/fspick: New tests
>   syscalls/open_tree: New tests
> 
>  configure.ac                                  |   6 +
>  include/lapi/fsmount.h                        | 134 ++++++++++++++++++
>  runtest/syscalls                              |  18 +++
>  testcases/kernel/syscalls/fsconfig/.gitignore |   2 +
>  testcases/kernel/syscalls/fsconfig/Makefile   |   6 +
>  .../kernel/syscalls/fsconfig/fsconfig01.c     |  77 ++++++++++
>  .../kernel/syscalls/fsconfig/fsconfig02.c     |  97 +++++++++++++
>  testcases/kernel/syscalls/fsmount/.gitignore  |   2 +
>  testcases/kernel/syscalls/fsmount/Makefile    |   6 +
>  testcases/kernel/syscalls/fsmount/fsmount01.c |  71 ++++++++++
>  testcases/kernel/syscalls/fsmount/fsmount02.c |  83 +++++++++++
>  testcases/kernel/syscalls/fsopen/.gitignore   |   2 +
>  testcases/kernel/syscalls/fsopen/Makefile     |   6 +
>  testcases/kernel/syscalls/fsopen/fsopen01.c   |  71 ++++++++++
>  testcases/kernel/syscalls/fsopen/fsopen02.c   |  56 ++++++++
>  testcases/kernel/syscalls/fspick/.gitignore   |   2 +
>  testcases/kernel/syscalls/fspick/Makefile     |   6 +
>  testcases/kernel/syscalls/fspick/fspick01.c   | 104 ++++++++++++++
>  testcases/kernel/syscalls/fspick/fspick02.c   | 110 ++++++++++++++
>  .../kernel/syscalls/move_mount/.gitignore     |   2 +
>  testcases/kernel/syscalls/move_mount/Makefile |   6 +
>  .../kernel/syscalls/move_mount/move_mount01.c |  82 +++++++++++
>  .../kernel/syscalls/move_mount/move_mount02.c | 102 +++++++++++++
>  .../kernel/syscalls/open_tree/.gitignore      |   2 +
>  testcases/kernel/syscalls/open_tree/Makefile  |   6 +
>  .../kernel/syscalls/open_tree/open_tree01.c   | 115 +++++++++++++++
>  .../kernel/syscalls/open_tree/open_tree02.c   | 110 ++++++++++++++
>  27 files changed, 1284 insertions(+)
>  create mode 100644 include/lapi/fsmount.h
>  create mode 100644 testcases/kernel/syscalls/fsconfig/.gitignore
>  create mode 100644 testcases/kernel/syscalls/fsconfig/Makefile
>  create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig01.c
>  create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig02.c
>  create mode 100644 testcases/kernel/syscalls/fsmount/.gitignore
>  create mode 100644 testcases/kernel/syscalls/fsmount/Makefile
>  create mode 100644 testcases/kernel/syscalls/fsmount/fsmount01.c
>  create mode 100644 testcases/kernel/syscalls/fsmount/fsmount02.c
>  create mode 100644 testcases/kernel/syscalls/fsopen/.gitignore
>  create mode 100644 testcases/kernel/syscalls/fsopen/Makefile
>  create mode 100644 testcases/kernel/syscalls/fsopen/fsopen01.c
>  create mode 100644 testcases/kernel/syscalls/fsopen/fsopen02.c
>  create mode 100644 testcases/kernel/syscalls/fspick/.gitignore
>  create mode 100644 testcases/kernel/syscalls/fspick/Makefile
>  create mode 100644 testcases/kernel/syscalls/fspick/fspick01.c
>  create mode 100644 testcases/kernel/syscalls/fspick/fspick02.c
>  create mode 100644 testcases/kernel/syscalls/move_mount/.gitignore
>  create mode 100644 testcases/kernel/syscalls/move_mount/Makefile
>  create mode 100644 testcases/kernel/syscalls/move_mount/move_mount01.c
>  create mode 100644 testcases/kernel/syscalls/move_mount/move_mount02.c
>  create mode 100644 testcases/kernel/syscalls/open_tree/.gitignore
>  create mode 100644 testcases/kernel/syscalls/open_tree/Makefile
>  create mode 100644 testcases/kernel/syscalls/open_tree/open_tree01.c
>  create mode 100644 testcases/kernel/syscalls/open_tree/open_tree02.c
> 
> -- 
> 2.21.0.rc0.269.g1a574e7a288b
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp
> 


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls
  2020-02-18  6:19 ` [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls Zorro Lang
@ 2020-02-18  6:50   ` Li Wang
  2020-02-18  6:58   ` Viresh Kumar
  1 sibling, 0 replies; 32+ messages in thread
From: Li Wang @ 2020-02-18  6:50 UTC (permalink / raw)
  To: ltp

On Tue, Feb 18, 2020 at 2:09 PM Zorro Lang <zlang@redhat.com> wrote:

> On Fri, Feb 14, 2020 at 05:05:49PM +0530, Viresh Kumar wrote:
> > Hello,
> >
> > This series adds a bunch of LTP tests related to fsmount family of
> > syscalls.
>
> Hi Viresh,
>
> Thanks for all these cases, that's really helpful.
>
> Although you write cases for each new mount API, each xxxxx01.c case looks
> nearly do same things.
>
Yes, I have the same feelings. Below are my 2 cents:

Probably because the APIs should be used to bind together, but it is best
to reflect the focus of each test case. e.g. fsmount01.c as basic test
needs to cover more parameters to verify that all the functionality is
really working. fsmount02.c more like a test target for all error
conditions.

FYI madvise test:
[1]
https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/madvise/madvise01.c
[2]
https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/madvise/madvise02.c


> That's why I only wrote one case for new-mount currently, due to basic
> mount
> test already can through most of new APIs(except open_tree and fspick). I
> don't
> know if we should write nearly same things in different directories.
> Actually I prepared open_tree and fspick test cases(planned to name as
> newmount02
> and newmount03. but the newmount01 has been changed to fsmount01 :), but
> didn't
> sent out, due to I hope to the first case(which does basic changes) can be
> merged
> at first.
>

It'd be great if those tests can be merged together with Viresh's patch.


>
> All of your xxxxx02.c cases are great! I planned to test more different
> parameters of fsconfig() later too. Your invalid parameters test are nice.
> As you've sent these cases, I think these should be reviewed at first,
> avoid
> we do same things:) I'll try to help to review V2 patchset too, if I can:-P
>

Thank you in advance, Zorro!

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200218/414e45c5/attachment-0001.htm>

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls
  2020-02-18  6:19 ` [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls Zorro Lang
  2020-02-18  6:50   ` Li Wang
@ 2020-02-18  6:58   ` Viresh Kumar
  1 sibling, 0 replies; 32+ messages in thread
From: Viresh Kumar @ 2020-02-18  6:58 UTC (permalink / raw)
  To: ltp

Hi Zorro,

Thanks for taking time and providing your feedback :)

On 18-02-20, 14:19, Zorro Lang wrote:
> On Fri, Feb 14, 2020 at 05:05:49PM +0530, Viresh Kumar wrote:
> Thanks for all these cases, that's really helpful.
> 
> Although you write cases for each new mount API, each xxxxx01.c case looks
> nearly do same things.

I agree, just that they are all slightly different, and perhaps they can be
improved to test different parameters for the success case as well.

I think all the *02.c files are quite different that way, and perhaps *01.c
tests should do the same.

> That's why I only wrote one case for new-mount currently, due to basic mount
> test already can through most of new APIs(except open_tree and fspick). I don't
> know if we should write nearly same things in different directories.
> Actually I prepared open_tree and fspick test cases(planned to name as newmount02
> and newmount03. but the newmount01 has been changed to fsmount01 :), but didn't
> sent out, due to I hope to the first case(which does basic changes) can be merged
> at first.

Heh. I had no clue that anyone else is working on this stuff else I won't have
touched it at all (and saved some time) :)

> All of your xxxxx02.c cases are great! I planned to test more different
> parameters of fsconfig() later too. Your invalid parameters test are nice.
> As you've sent these cases, I think these should be reviewed at first, avoid
> we do same things:) I'll try to help to review V2 patchset too, if I can:-P

Thanks for suggesting this way out, and I agree 100% with you.

FWIW, I am working on V2 which I should be able to send by tomorrow max (if
everything goes as planned). Lets see how it looks after that and I would love
to review any improvement patches you may have after these are merged (Please cc
me directly, I haven't opted for receiving emails from ltp list).

-- 
viresh

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 2/7] syscalls/fsopen: New tests
  2020-02-18  1:15       ` Li Wang
@ 2020-02-18  8:25         ` Viresh Kumar
  2020-02-18  9:02           ` Li Wang
  2020-02-19  8:23         ` Petr Vorel
  2020-02-19  8:50         ` Petr Vorel
  2 siblings, 1 reply; 32+ messages in thread
From: Viresh Kumar @ 2020-02-18  8:25 UTC (permalink / raw)
  To: ltp

On 18-02-20, 09:15, Li Wang wrote:
> On Mon, Feb 17, 2020 at 9:36 PM Cyril Hrubis <chrubis@suse.cz> wrote:
> 
> > ...
> > > > +static struct tst_test test = {
> > > > +       .min_kver = "5.2",
> > > >
> > >
> > > I suggest removing .min_kver check in all of the tests to let they can be
> > > running on many distributions(which backport the features).
> >
> > If we do that we have to explicitely check for ENOSYS errno in each
> > test, quite possibly with a dummy call to the tested syscall in test
> > setup, because once these calls gets libc wrappers we will no longer
> > call the tst_syscall() that checks for it.
> >
> 
> +1 add dummy call to the tested syscall in the setup.
> Agree, thanks for point out this.

Not sure if I understood it very clearly and don't want to spam everyone with an
incorrect patchset still missing this point and so asking here :)

How exactly would the setup() routine look like? Something like this ?

        syscall(#NR, ##__VA_ARGS__);

-- 
viresh

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 2/7] syscalls/fsopen: New tests
  2020-02-18  8:25         ` Viresh Kumar
@ 2020-02-18  9:02           ` Li Wang
  2020-02-18  9:08             ` Viresh Kumar
  0 siblings, 1 reply; 32+ messages in thread
From: Li Wang @ 2020-02-18  9:02 UTC (permalink / raw)
  To: ltp

On Tue, Feb 18, 2020 at 4:25 PM Viresh Kumar <viresh.kumar@linaro.org>
wrote:

> On 18-02-20, 09:15, Li Wang wrote:
> > On Mon, Feb 17, 2020 at 9:36 PM Cyril Hrubis <chrubis@suse.cz> wrote:
> >
> > > ...
> > > > > +static struct tst_test test = {
> > > > > +       .min_kver = "5.2",
> > > > >
> > > >
> > > > I suggest removing .min_kver check in all of the tests to let they
> can be
> > > > running on many distributions(which backport the features).
> > >
> > > If we do that we have to explicitely check for ENOSYS errno in each
> > > test, quite possibly with a dummy call to the tested syscall in test
> > > setup, because once these calls gets libc wrappers we will no longer
> > > call the tst_syscall() that checks for it.
> > >
> >
> > +1 add dummy call to the tested syscall in the setup.
> > Agree, thanks for point out this.
>
> Not sure if I understood it very clearly and don't want to spam everyone
> with an
> incorrect patchset still missing this point and so asking here :)
>
> How exactly would the setup() routine look like? Something like this ?
>
>         syscall(#NR, ##__VA_ARGS__);
>

I suggest to use tst_syscall(...);.

A dummy call in setup() just helps check the ENOSYS errno, something like:

$ cat testcases/cve/cve-2016-7117.c |grep setup -A 10
static void setup(void)
{
        ...
        tst_syscall(__NR_recvmmsg, 0, 0, 0, 0, 0);
}

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200218/b865a981/attachment.htm>

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 2/7] syscalls/fsopen: New tests
  2020-02-18  9:02           ` Li Wang
@ 2020-02-18  9:08             ` Viresh Kumar
  0 siblings, 0 replies; 32+ messages in thread
From: Viresh Kumar @ 2020-02-18  9:08 UTC (permalink / raw)
  To: ltp

On 18-02-20, 17:02, Li Wang wrote:
> On Tue, Feb 18, 2020 at 4:25 PM Viresh Kumar <viresh.kumar@linaro.org>
> wrote:
> 
> > On 18-02-20, 09:15, Li Wang wrote:
> > > On Mon, Feb 17, 2020 at 9:36 PM Cyril Hrubis <chrubis@suse.cz> wrote:
> > >
> > > > ...
> > > > > > +static struct tst_test test = {
> > > > > > +       .min_kver = "5.2",
> > > > > >
> > > > >
> > > > > I suggest removing .min_kver check in all of the tests to let they
> > can be
> > > > > running on many distributions(which backport the features).
> > > >
> > > > If we do that we have to explicitely check for ENOSYS errno in each
> > > > test, quite possibly with a dummy call to the tested syscall in test
> > > > setup, because once these calls gets libc wrappers we will no longer
> > > > call the tst_syscall() that checks for it.
> > > >
> > >
> > > +1 add dummy call to the tested syscall in the setup.
> > > Agree, thanks for point out this.
> >
> > Not sure if I understood it very clearly and don't want to spam everyone
> > with an
> > incorrect patchset still missing this point and so asking here :)
> >
> > How exactly would the setup() routine look like? Something like this ?
> >
> >         syscall(#NR, ##__VA_ARGS__);
> >
> 
> I suggest to use tst_syscall(...);.
> 
> A dummy call in setup() just helps check the ENOSYS errno, something like:
> 
> $ cat testcases/cve/cve-2016-7117.c |grep setup -A 10
> static void setup(void)
> {
>         ...
>         tst_syscall(__NR_recvmmsg, 0, 0, 0, 0, 0);
> }

Okay, thanks.

-- 
viresh

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 2/7] syscalls/fsopen: New tests
  2020-02-18  1:15       ` Li Wang
  2020-02-18  8:25         ` Viresh Kumar
@ 2020-02-19  8:23         ` Petr Vorel
  2020-02-19  8:34           ` Viresh Kumar
  2020-02-19  8:50         ` Petr Vorel
  2 siblings, 1 reply; 32+ messages in thread
From: Petr Vorel @ 2020-02-19  8:23 UTC (permalink / raw)
  To: ltp

Hi Viresh,

as somebody (probably Li) pointed out fsopen/fsopen01.c is similar to fsmount/fsmount01.c,
so please during rebase drop it. BTW for this dropped test I'd use different
approach (close fd in cleanup function and use tst_brk(TFAIL instead of
tst_res(TBROK and goto):

static void cleanup(void)
{
	if (fd > 0)
		SAFE_CLOSE(fd);
}

...
	if (fd == -1)
		tst_brk(TFAIL | TERRNO, "fsopen() failed");

Also you added autotools check for functions (e.g. fsopen) during commits, but I
move them to the first (together with lapi header).

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 2/7] syscalls/fsopen: New tests
  2020-02-19  8:23         ` Petr Vorel
@ 2020-02-19  8:34           ` Viresh Kumar
  0 siblings, 0 replies; 32+ messages in thread
From: Viresh Kumar @ 2020-02-19  8:34 UTC (permalink / raw)
  To: ltp

On 19-02-20, 09:23, Petr Vorel wrote:
> Hi Viresh,
> 
> as somebody (probably Li) pointed out fsopen/fsopen01.c is similar to fsmount/fsmount01.c,
> so please during rebase drop it. BTW for this dropped test I'd use different
> approach (close fd in cleanup function and use tst_brk(TFAIL instead of
> tst_res(TBROK and goto):
> 
> static void cleanup(void)
> {
> 	if (fd > 0)
> 		SAFE_CLOSE(fd);
> }
> 
> ...
> 	if (fd == -1)
> 		tst_brk(TFAIL | TERRNO, "fsopen() failed");

Lets review this comment after my V2 series is posted today. It may be better to
keep separate tests.

> Also you added autotools check for functions (e.g. fsopen) during commits, but I
> move them to the first (together with lapi header).

Yeah, I already saw that. Thanks for that, you did the right thing :)

-- 
viresh

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 2/7] syscalls/fsopen: New tests
  2020-02-18  1:15       ` Li Wang
  2020-02-18  8:25         ` Viresh Kumar
  2020-02-19  8:23         ` Petr Vorel
@ 2020-02-19  8:50         ` Petr Vorel
  2020-02-19  8:51           ` Viresh Kumar
  2 siblings, 1 reply; 32+ messages in thread
From: Petr Vorel @ 2020-02-19  8:50 UTC (permalink / raw)
  To: ltp

Hi,

> On Mon, Feb 17, 2020 at 9:36 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> > ...
> > > > +static struct tst_test test = {
> > > > +       .min_kver = "5.2",


> > > I suggest removing .min_kver check in all of the tests to let they can be
> > > running on many distributions(which backport the features).

> > If we do that we have to explicitely check for ENOSYS errno in each
> > test, quite possibly with a dummy call to the tested syscall in test
> > setup, because once these calls gets libc wrappers we will no longer
> > call the tst_syscall() that checks for it.


> +1 add dummy call to the tested syscall in the setup.
> Agree, thanks for point out this.
Could anybody add it to fsmount/fsmount01.c instead?


If anybody don't mind, I'll rename fsopen02.c to fsopen01.c,
remove .min_kver = "5.2" and replace tst_brk with tst_res + return, and merge it:

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
 *
 * Description:
 * Basic fsopen() failure tests.
 */

#include "tst_test.h"
#include "lapi/fsmount.h"

const char *invalid_fs = "invalid";
const char *valid_fs;

static struct tcase {
	char *name;
	const char **fs;
	unsigned int flags;
	int exp_errno;
} tcases[] = {
	{"invalid-fs", &invalid_fs, 0, ENODEV},
	{"invalid-flags", &valid_fs, 0x10, EINVAL},
};

static void setup(void)
{
	valid_fs = tst_device->fs_type;
}

static void run(unsigned int n)
{
	struct tcase *tc = &tcases[n];

	TEST(fsopen(*tc->fs, tc->flags));

	if (TST_RET != -1) {
		SAFE_CLOSE(TST_RET);
		tst_res(TFAIL, "%s: fsopen() succeeded unexpectedly (index: %d)",
			tc->name, n);
		return;
	}

	if (tc->exp_errno != TST_ERR) {
		tst_res(TFAIL | TTERRNO, "%s: fsopen() should fail with %s",
			tc->name, tst_strerrno(tc->exp_errno));
		return;
	}

	tst_res(TPASS | TTERRNO, "%s: fsopen() failed as expected", tc->name);
}

static struct tst_test test = {
	.tcnt = ARRAY_SIZE(tcases),
	.test = run,
	.setup = setup,
	.needs_root = 1,
	.needs_device = 1,
};

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [LTP] [PATCH 2/7] syscalls/fsopen: New tests
  2020-02-19  8:50         ` Petr Vorel
@ 2020-02-19  8:51           ` Viresh Kumar
  0 siblings, 0 replies; 32+ messages in thread
From: Viresh Kumar @ 2020-02-19  8:51 UTC (permalink / raw)
  To: ltp

On 19-02-20, 09:50, Petr Vorel wrote:
> Hi,
> 
> > On Mon, Feb 17, 2020 at 9:36 PM Cyril Hrubis <chrubis@suse.cz> wrote:
> 
> > > ...
> > > > > +static struct tst_test test = {
> > > > > +       .min_kver = "5.2",
> 
> 
> > > > I suggest removing .min_kver check in all of the tests to let they can be
> > > > running on many distributions(which backport the features).
> 
> > > If we do that we have to explicitely check for ENOSYS errno in each
> > > test, quite possibly with a dummy call to the tested syscall in test
> > > setup, because once these calls gets libc wrappers we will no longer
> > > call the tst_syscall() that checks for it.
> 
> 
> > +1 add dummy call to the tested syscall in the setup.
> > Agree, thanks for point out this.
> Could anybody add it to fsmount/fsmount01.c instead?

I am doing it.

-- 
viresh

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2020-02-19  8:51 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-14 11:35 [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls Viresh Kumar
2020-02-14 11:35 ` [LTP] [PATCH 1/7] lapi/fsmount: Add definitions for fsmount related syscalls Viresh Kumar
2020-02-16  9:09   ` Li Wang
2020-02-17  8:08     ` Viresh Kumar
2020-02-14 11:35 ` [LTP] [PATCH 2/7] syscalls/fsopen: New tests Viresh Kumar
2020-02-16 10:11   ` Li Wang
2020-02-17  8:09     ` Viresh Kumar
2020-02-17 13:36     ` Cyril Hrubis
2020-02-18  1:15       ` Li Wang
2020-02-18  8:25         ` Viresh Kumar
2020-02-18  9:02           ` Li Wang
2020-02-18  9:08             ` Viresh Kumar
2020-02-19  8:23         ` Petr Vorel
2020-02-19  8:34           ` Viresh Kumar
2020-02-19  8:50         ` Petr Vorel
2020-02-19  8:51           ` Viresh Kumar
2020-02-14 11:35 ` [LTP] [PATCH 3/7] syscalls/fsconfig: " Viresh Kumar
2020-02-14 11:35 ` [LTP] [PATCH 4/7] syscalls/fsmount: " Viresh Kumar
2020-02-17  8:17   ` Li Wang
2020-02-17  8:29     ` Viresh Kumar
2020-02-17  8:54       ` Li Wang
2020-02-17  9:58         ` Petr Vorel
2020-02-17 10:28           ` Li Wang
2020-02-17 10:37             ` Li Wang
2020-02-17 11:02               ` Petr Vorel
2020-02-17  8:58       ` Petr Vorel
2020-02-14 11:35 ` [LTP] [PATCH 5/7] syscalls/move_mount: " Viresh Kumar
2020-02-14 11:35 ` [LTP] [PATCH 6/7] syscalls/fspick: " Viresh Kumar
2020-02-14 11:35 ` [LTP] [PATCH 7/7] syscalls/open_tree: " Viresh Kumar
2020-02-18  6:19 ` [LTP] [PATCH 0/7] Add new LTP tests related to fsmount family of syscalls Zorro Lang
2020-02-18  6:50   ` Li Wang
2020-02-18  6:58   ` Viresh Kumar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.