Commit 382756a4 authored by Pavel Tikhomirov's avatar Pavel Tikhomirov Committed by Andrei Vagin

zdtm: add a test for non-uniform shares

Create a tree of shared mounts where shared mounts have different sets
of children (while having the same root):

First share1 is mounted shared tmpfs and second share1/child1 is mounted
inside, third share1 is bind-mounted to share2 (now share1 and share2
have the same shared id, but share2 has no child), fourth share1/child2
is bind-mounted from share1, and also propagated to share2/child2 (now
all except share1/child1 have the same shared id), fifth share1/child3
is mounted and propagates inside the share.

Finally we have four mounts shared between each other with different
sets of children mounts, and even more two of them are children of
another two:

495 494 0:62 / /zdtm/static/non_uniform_share_propagation.test/share1 rw,relatime shared:235 - tmpfs share rw
496 495 0:63 / /zdtm/static/non_uniform_share_propagation.test/share1/child1 rw,relatime shared:236 - tmpfs child1 rw
497 494 0:62 / /zdtm/static/non_uniform_share_propagation.test/share2 rw,relatime shared:235 - tmpfs share rw
498 495 0:62 / /zdtm/static/non_uniform_share_propagation.test/share1/child2 rw,relatime shared:235 - tmpfs share rw
499 497 0:62 / /zdtm/static/non_uniform_share_propagation.test/share2/child2 rw,relatime shared:235 - tmpfs share rw
500 495 0:64 / /zdtm/static/non_uniform_share_propagation.test/share1/child3 rw,relatime shared:237 - tmpfs child3 rw
503 497 0:64 / /zdtm/static/non_uniform_share_propagation.test/share2/child3 rw,relatime shared:237 - tmpfs child3 rw
502 499 0:64 / /zdtm/static/non_uniform_share_propagation.test/share2/child2/child3 rw,relatime shared:237 - tmpfs child3 rw
501 498 0:64 / /zdtm/static/non_uniform_share_propagation.test/share1/child2/child3 rw,relatime shared:237 - tmpfs child3 rw
Signed-off-by: 's avatarPavel Tikhomirov <ptikhomirov@virtuozzo.com>
parent c9cf0b4a
...@@ -338,6 +338,7 @@ TST_DIR = \ ...@@ -338,6 +338,7 @@ TST_DIR = \
sk-unix01 \ sk-unix01 \
unsupported_children_collision \ unsupported_children_collision \
shared_slave_mount_children \ shared_slave_mount_children \
non_uniform_share_propagation \
TST_DIR_FILE = \ TST_DIR_FILE = \
chroot \ chroot \
......
#include <sys/mount.h>
#include <sys/stat.h>
#include <limits.h>
#include "zdtmtst.h"
const char *test_doc = "Check non-uniform shares restore fine";
const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>";
char *dirname;
TEST_OPTION(dirname, string, "directory name", 1);
int main(int argc, char **argv)
{
char share1[PATH_MAX], share2[PATH_MAX];
char child1[PATH_MAX], child2[PATH_MAX], child3[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(share1, sizeof(share1), "%s/share1", dirname);
if (mkdir(share1, 0700)) {
pr_perror("mkdir");
return 1;
}
if (mount("share", share1, "tmpfs", 0, NULL)) {
pr_perror("mount");
return 1;
}
if (mount(NULL, share1, NULL, MS_SHARED, NULL)) {
pr_perror("mount");
return 1;
}
snprintf(child1, sizeof(child1), "%s/share1/child1", dirname);
if (mkdir(child1, 0700)) {
pr_perror("mkdir");
return 1;
}
if (mount("child1", child1, "tmpfs", 0, NULL)) {
pr_perror("mount");
return 1;
}
snprintf(share2, sizeof(share2), "%s/share2", dirname);
if (mkdir(share2, 0700)) {
pr_perror("mkdir");
return 1;
}
if (mount(share1, share2, NULL, MS_BIND, NULL)) {
pr_perror("mount");
return 1;
}
snprintf(child2, sizeof(child2), "%s/share1/child2", dirname);
if (mkdir(child2, 0700)) {
pr_perror("mkdir");
return 1;
}
if (mount(share1, child2, NULL, MS_BIND, NULL)) {
pr_perror("mount");
return 1;
}
snprintf(child3, sizeof(child3), "%s/share1/child3", dirname);
if (mkdir(child3, 0700)) {
pr_perror("mkdir");
return 1;
}
if (mount("child3", child3, "tmpfs", 0, NULL)) {
pr_perror("mount");
return 1;
}
test_daemon();
test_waitsig();
if (umount(child3)) {
pr_perror("Unable to umount %s", child1);
return 1;
}
if (umount(child2)) {
pr_perror("Unable to umount %s", share1);
return 1;
}
if (umount(share2)) {
pr_perror("Unable to umount %s", share2);
return 1;
}
if (umount(child1)) {
pr_perror("Unable to umount %s", child1);
return 1;
}
if (umount(share1)) {
pr_perror("Unable to umount %s", share1);
return 1;
}
if (umount(dirname)) {
pr_perror("Unable to umount %s", dirname);
return 1;
}
pass();
return 0;
}
{'flavor': 'ns uns', 'flags': 'suid'}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment