[CRIU] [PATCH 3/3] zdtm: check bind mounts of the root mount

Andrey Vagin avagin at openvz.org
Thu Apr 10 03:52:34 PDT 2014


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/zdtm.sh                       |  2 ++
 test/zdtm/live/static/Makefile     |  1 +
 test/zdtm/live/static/bind-mount.c | 62 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 65 insertions(+)
 create mode 100644 test/zdtm/live/static/bind-mount.c

diff --git a/test/zdtm.sh b/test/zdtm.sh
index a8e6e2f..d4fbbf4 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -124,6 +124,7 @@ static/mountpoints
 ns/static/session00
 ns/static/session01
 ns/static/tempfs
+ns/static/bind-mount
 static/utsname
 static/ipc_namespace
 static/shm
@@ -159,6 +160,7 @@ rtc
 tempfs
 maps007
 tempfs
+bind-mount
 "
 
 source $(readlink -f `dirname $0`/env.sh) || exit 1
diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index baeedcd..cc77662 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -149,6 +149,7 @@ TST_DIR		=				\
 		overmount_fifo			\
 		overmount_sock			\
 		tempfs				\
+		bind-mount			\
 
 TST_DIR_FILE	=				\
 		chroot				\
diff --git a/test/zdtm/live/static/bind-mount.c b/test/zdtm/live/static/bind-mount.c
new file mode 100644
index 0000000..619306f
--- /dev/null
+++ b/test/zdtm/live/static/bind-mount.c
@@ -0,0 +1,62 @@
+#include <stdbool.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <linux/limits.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc	= "Check bind-mounts";
+const char *test_author	= "Pavel Emelianov <avagin at parallels.com>";
+
+char *dirname;
+TEST_OPTION(dirname, string, "directory name", 1);
+
+int main(int argc, char **argv)
+{
+	char test_dir[PATH_MAX], test_bind[PATH_MAX];
+	char test_file[PATH_MAX], test_bind_file[PATH_MAX];
+	int fd;
+
+	test_init(argc, argv);
+
+	mkdir(dirname, 0700);
+
+	snprintf(test_dir, sizeof(test_dir), "%s/test", dirname);
+	snprintf(test_bind, sizeof(test_bind), "%s/bind", dirname);
+	snprintf(test_file, sizeof(test_file), "%s/test/test.file", dirname);
+	snprintf(test_bind_file, sizeof(test_bind_file), "%s/bind/test.file", dirname);
+
+	mkdir(test_dir, 0700);
+	mkdir(test_bind, 0700);
+
+	if (mount(test_dir, test_bind, NULL, MS_BIND, NULL)) {
+		err("Unable to mount %s to %s", test_dir, test_bind);
+		return 1;
+	}
+
+	test_daemon();
+	test_waitsig();
+
+	fd = open(test_file, O_CREAT | O_WRONLY | O_EXCL, 0600);
+	if (fd < 0) {
+		err("Unable to open %s\n", test_file);
+		return 1;
+	}
+	close(fd);
+
+	if (access(test_bind_file, F_OK)) {
+		err("%s doesn't exist", test_bind_file);
+		return 1;
+	}
+
+	if (umount(test_bind)) {
+		err("Unable to umount %s", test_bind);
+		return 1;
+	}
+
+	pass();
+	return 0;
+}
-- 
1.8.5.3



More information about the CRIU mailing list