Commit 926e42ac authored by Pavel Tikhomirov's avatar Pavel Tikhomirov Committed by Andrei Vagin

zdtm: test overmounting with shared parent works

Signed-off-by: 's avatarPavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 2d2381e0
...@@ -269,6 +269,7 @@ TST_DIR = \ ...@@ -269,6 +269,7 @@ TST_DIR = \
mount_paths \ mount_paths \
bind-mount \ bind-mount \
shared_mount_propagation \ shared_mount_propagation \
overmount_with_shared_parent \
inotify00 \ inotify00 \
inotify01 \ inotify01 \
inotify02 \ inotify02 \
......
#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@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;
}
{'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