From 24bd5fcfff4ffc5c3cc648691a53ab288f0ce69e Mon Sep 17 00:00:00 2001 From: Pavel Tikhomirov Date: Tue, 10 Jul 2018 19:02:26 +0300 Subject: [PATCH] zdtm: check children of shared slaves restore 495 494 0:62 / /zdtm/static/shared_slave_mount_children.test/share rw,relatime shared:235 - tmpfs share rw 496 494 0:62 / /zdtm/static/shared_slave_mount_children.test/slave1 rw,relatime shared:236 master:235 - tmpfs share rw 497 494 0:62 / /zdtm/static/shared_slave_mount_children.test/slave2 rw,relatime shared:236 master:235 - tmpfs share rw 498 496 0:63 / /zdtm/static/shared_slave_mount_children.test/slave1/child rw,relatime shared:237 - tmpfs child rw 499 497 0:63 / /zdtm/static/shared_slave_mount_children.test/slave2/child rw,relatime shared:237 - tmpfs child rw Before the fix we had: (00.167574) 1: Error (criu/mount.c:1769): mnt: A few mount points can't be mounted (00.167577) 1: Error (criu/mount.c:1773): mnt: 498:496 / /tmp/.criu.mntns.o2Op5j/9-0000000000/zdtm/static/shared_slave_mount_children.test/slave1/child child (00.167580) 1: Error (criu/mount.c:1773): mnt: 497:494 / /tmp/.criu.mntns.o2Op5j/9-0000000000/zdtm/static/shared_slave_mount_children.test/slave2 share Signed-off-by: Pavel Tikhomirov --- test/zdtm/static/Makefile | 1 + .../zdtm/static/shared_slave_mount_children.c | 125 ++++++++++++++++++ .../static/shared_slave_mount_children.desc | 1 + 3 files changed, 127 insertions(+) create mode 100644 test/zdtm/static/shared_slave_mount_children.c create mode 100644 test/zdtm/static/shared_slave_mount_children.desc diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile index b7d984d49..6022b8045 100644 --- a/test/zdtm/static/Makefile +++ b/test/zdtm/static/Makefile @@ -337,6 +337,7 @@ TST_DIR = \ sk-unix-mntns \ sk-unix01 \ unsupported_children_collision \ + shared_slave_mount_children \ TST_DIR_FILE = \ chroot \ diff --git a/test/zdtm/static/shared_slave_mount_children.c b/test/zdtm/static/shared_slave_mount_children.c new file mode 100644 index 000000000..75c2513c6 --- /dev/null +++ b/test/zdtm/static/shared_slave_mount_children.c @@ -0,0 +1,125 @@ +#include +#include +#include + +#include "zdtmtst.h" + +const char *test_doc = "Check non-uniform shares restore fine"; +const char *test_author = "Pavel Tikhomirov "; + +char *dirname; +TEST_OPTION(dirname, string, "directory name", 1); + +int main(int argc, char **argv) +{ + char share[PATH_MAX], slave1[PATH_MAX], slave2[PATH_MAX]; + char child[PATH_MAX]; + + test_init(argc, argv); + + if (mkdir(dirname, 0700)) { + pr_perror("mkdir"); + return 1; + } + + if (mount("zdtm_fs", dirname, "tmpfs", 0, NULL)) { + pr_perror("mount"); + return 1; + } + + if (mount(NULL, dirname, NULL, MS_PRIVATE, NULL)) { + pr_perror("mount"); + return 1; + } + + snprintf(share, sizeof(share), "%s/share", dirname); + if (mkdir(share, 0700)) { + pr_perror("mkdir"); + return 1; + } + + if (mount("share", share, "tmpfs", 0, NULL)) { + pr_perror("mount"); + return 1; + } + + if (mount(NULL, share, NULL, MS_SHARED, NULL)) { + pr_perror("mount"); + return 1; + } + + snprintf(slave1, sizeof(slave1), "%s/slave1", dirname); + if (mkdir(slave1, 0700)) { + pr_perror("mkdir"); + return 1; + } + + if (mount(share, slave1, NULL, MS_BIND, NULL)) { + pr_perror("mount"); + return 1; + } + + if (mount(NULL, slave1, NULL, MS_SLAVE, NULL)) { + pr_perror("mount"); + return 1; + } + + if (mount(NULL, slave1, NULL, MS_SHARED, NULL)) { + pr_perror("mount"); + return 1; + } + + snprintf(slave2, sizeof(slave2), "%s/slave2", dirname); + if (mkdir(slave2, 0700)) { + pr_perror("mkdir"); + return 1; + } + + if (mount(slave1, slave2, NULL, MS_BIND, NULL)) { + pr_perror("mount"); + return 1; + } + + snprintf(child, sizeof(child), "%s/slave1/child", dirname); + if (mkdir(child, 0700)) { + pr_perror("mkdir"); + return 1; + } + + if (mount("child", child, "tmpfs", 0, NULL)) { + pr_perror("mount"); + return 1; + } + + test_daemon(); + test_waitsig(); + + if (umount(child)) { + pr_perror("Unable to umount %s", child); + return 1; + } + + if (umount(slave2)) { + pr_perror("Unable to umount %s", slave2); + return 1; + } + + if (umount(slave1)) { + pr_perror("Unable to umount %s", slave1); + return 1; + } + + if (umount(share)) { + pr_perror("Unable to umount %s", share); + return 1; + } + + if (umount(dirname)) { + pr_perror("Unable to umount %s", dirname); + return 1; + } + + pass(); + + return 0; +} diff --git a/test/zdtm/static/shared_slave_mount_children.desc b/test/zdtm/static/shared_slave_mount_children.desc new file mode 100644 index 000000000..7657ba45c --- /dev/null +++ b/test/zdtm/static/shared_slave_mount_children.desc @@ -0,0 +1 @@ +{'flavor': 'ns uns', 'flags': 'suid'}