[CRIU] [PATCH 4/4] zdtm: add a test to check a case when two mounts in the same directory

Andrey Vagin avagin at openvz.org
Thu May 12 15:34:57 PDT 2016


From: Andrew Vagin <avagin at virtuozzo.com>

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 test/zdtm/.gitignore                  |  1 +
 test/zdtm/static/Makefile             |  1 +
 test/zdtm/static/mntns_overmount.c    | 70 +++++++++++++++++++++++++++++++++++
 test/zdtm/static/mntns_overmount.desc |  1 +
 4 files changed, 73 insertions(+)
 create mode 100644 test/zdtm/static/mntns_overmount.c
 create mode 100644 test/zdtm/static/mntns_overmount.desc

diff --git a/test/zdtm/.gitignore b/test/zdtm/.gitignore
index 7a19868..2e2ac2b 100644
--- a/test/zdtm/.gitignore
+++ b/test/zdtm/.gitignore
@@ -77,6 +77,7 @@
 /static/mntns_link_ghost
 /static/mntns_link_remap
 /static/mntns_open
+/static/mntns_overmount
 /static/mntns_rw_ro_rw
 /static/mntns_shared_bind
 /static/mntns_shared_bind02
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index afad959..5889782 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -228,6 +228,7 @@ TST_DIR		=				\
 		mntns_shared_bind02		\
 		mntns_root_bind			\
 		mntns_root_bind02		\
+		mntns_overmount			\
 		mntns_shared_vs_private		\
 		mnt_ext_auto			\
 		mnt_ext_master			\
diff --git a/test/zdtm/static/mntns_overmount.c b/test/zdtm/static/mntns_overmount.c
new file mode 100644
index 0000000..541355c
--- /dev/null
+++ b/test/zdtm/static/mntns_overmount.c
@@ -0,0 +1,70 @@
+#define _GNU_SOURCE
+#include <stdbool.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc	= "Check two mounts in the same directory";
+const char *test_author	= "Andrew Vagin <avagin at parallels.com>";
+
+char *dirname;
+TEST_OPTION(dirname, string, "directory name", 1);
+
+
+int main(int argc, char **argv)
+{
+	char d1[PATH_MAX], d2[PATH_MAX], f1[PATH_MAX], f2[PATH_MAX];
+	struct stat st;
+
+	test_init(argc, argv);
+
+	snprintf(d1, sizeof(d1), "%s/1/", dirname);
+	snprintf(d2, sizeof(d2), "%s/2/", dirname);
+
+	if (mkdir(dirname, 0700) ||
+	    mkdir(d1, 0777) ||
+	    mkdir(d2, 0700)) {
+		pr_perror("mkdir");
+		return 1;
+	}
+
+	if (mount("zdtm_d1", d1, "sysfs", 0, NULL) ||
+	    mount(NULL, d1, NULL, MS_SHARED, NULL) ||
+            mount(d1, d2, NULL, MS_BIND, NULL) ||
+            mount(NULL, d2, NULL, MS_SLAVE, NULL)) {
+		pr_perror("mount");
+		return 1;
+	}
+
+	snprintf(f1, sizeof(f1), "%s/devices", d1);
+	snprintf(f2, sizeof(f2), "%s/devices", d2);
+
+	if (mount("zdtm_d1", d1, "tmpfs", 0, NULL)) {
+		pr_perror("mount");
+		return 1;
+	}
+
+	test_daemon();
+	test_waitsig();
+
+	if (umount(d1)) {
+		pr_perror("umount");
+		return 1;
+	}
+
+	if (stat(f1, &st) || stat(f2, &st)) {
+		pr_perror("stat");
+		return 1;
+	}
+
+	pass();
+
+	return 0;
+}
diff --git a/test/zdtm/static/mntns_overmount.desc b/test/zdtm/static/mntns_overmount.desc
new file mode 100644
index 0000000..3fd8e03
--- /dev/null
+++ b/test/zdtm/static/mntns_overmount.desc
@@ -0,0 +1 @@
+{'flavor': 'ns', 'flags': 'suid', 'feature': 'mnt_id'}
-- 
2.7.4



More information about the CRIU mailing list