[CRIU] [PATCH 4/4] zdtm: test overmounting with shared parent works
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Fri Oct 27 11:21:04 MSK 2017
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
test/zdtm/static/Makefile | 1 +
test/zdtm/static/overmount_with_shared_parent.c | 69 ++++++++++++++++++++++
test/zdtm/static/overmount_with_shared_parent.desc | 1 +
3 files changed, 71 insertions(+)
create mode 100644 test/zdtm/static/overmount_with_shared_parent.c
create mode 100644 test/zdtm/static/overmount_with_shared_parent.desc
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index b9aff8182..4afe51cb5 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -286,6 +286,7 @@ TST_DIR = \
mount_paths \
bind-mount \
shared_mount_propagation \
+ overmount_with_shared_parent \
inotify00 \
inotify01 \
inotify02 \
diff --git a/test/zdtm/static/overmount_with_shared_parent.c b/test/zdtm/static/overmount_with_shared_parent.c
new file mode 100644
index 000000000..8261fb969
--- /dev/null
+++ b/test/zdtm/static/overmount_with_shared_parent.c
@@ -0,0 +1,69 @@
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <linux/limits.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc = "Check overmount on shared parent works";
+const char *test_author = "Pavel Tikhomirov <ptikhomirov at virtuozzo.com>";
+
+char *dirname;
+TEST_OPTION(dirname, string, "directory name", 1);
+
+int main(int argc, char **argv)
+{
+ char dir_a[PATH_MAX], dir_b[PATH_MAX], dir_c[PATH_MAX];
+ char dir_d[PATH_MAX], dir_a_c[PATH_MAX];
+
+ test_init(argc, argv);
+
+ mkdir(dirname, 0700);
+
+ if (mount(dirname, dirname, NULL, MS_BIND, NULL)) {
+ pr_perror("Unable to self bind mount %s", dirname);
+ return 1;
+ }
+
+ if (mount(NULL, dirname, NULL, MS_SHARED, NULL)) {
+ pr_perror("Unable to make shared mount %s", dirname);
+ return 1;
+ }
+
+ snprintf(dir_a, sizeof(dir_a), "%s/a", dirname);
+ snprintf(dir_d, sizeof(dir_d), "%s/d", dirname);
+ mkdir(dir_a, 0700);
+ mkdir(dir_d, 0700);
+
+ snprintf(dir_b, sizeof(dir_a), "%s/b", dir_a);
+ snprintf(dir_c, sizeof(dir_c), "%s/c", dir_b);
+ mkdir(dir_b, 0700);
+ mkdir(dir_c, 0700);
+
+ if (mount(dir_b, dir_a, NULL, MS_BIND, NULL)) {
+ pr_perror("Unable to bind mount %s to %s", dir_b, dir_a);
+ return 1;
+ }
+
+ snprintf(dir_a_c, sizeof(dir_a_c), "%s/c", dir_a);
+
+ if (mount(dir_d, dir_a_c, NULL, MS_BIND, NULL)) {
+ pr_perror("Unable to bind mount %s to %s", dir_d, dir_a_c);
+ return 1;
+ }
+
+ test_daemon();
+ test_waitsig();
+
+ if (umount(dir_a_c)) {
+ pr_perror("Unable to umount %s", dir_a_c);
+ return 1;
+ }
+
+ if (umount(dir_a)) {
+ pr_perror("Unable to umount %s", dir_a);
+ return 1;
+ }
+
+ pass();
+ return 0;
+}
diff --git a/test/zdtm/static/overmount_with_shared_parent.desc b/test/zdtm/static/overmount_with_shared_parent.desc
new file mode 100644
index 000000000..7657ba45c
--- /dev/null
+++ b/test/zdtm/static/overmount_with_shared_parent.desc
@@ -0,0 +1 @@
+{'flavor': 'ns uns', 'flags': 'suid'}
--
2.13.5
More information about the CRIU
mailing list