mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
zdtm: add a test to check a mount tree with overmounts
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
96de90db31
commit
890457ef75
@@ -238,6 +238,7 @@ TST_DIR = \
|
||||
cgroup04 \
|
||||
cgroup_stray \
|
||||
unlink_fstat04 \
|
||||
mntns_remap \
|
||||
mntns_open \
|
||||
mntns_link_remap \
|
||||
mntns_ghost \
|
||||
|
101
test/zdtm/static/mntns_remap.c
Normal file
101
test/zdtm/static/mntns_remap.c
Normal file
@@ -0,0 +1,101 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <sched.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "zdtmtst.h"
|
||||
|
||||
const char *test_doc = "Check a case when one mount overmount another one";
|
||||
const char *test_author = "Andrew Vagin <avagin@virtuozzo.com>";
|
||||
|
||||
char *dirname;
|
||||
TEST_OPTION(dirname, string, "directory name", 1);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
task_waiter_t t;
|
||||
pid_t pid;
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
mkdir(dirname, 0755);
|
||||
if (mount("zdtm", dirname, "tmpfs", 0, NULL)) {
|
||||
pr_perror("mount");
|
||||
return 1;
|
||||
}
|
||||
if (chdir(dirname)) {
|
||||
pr_perror("chdir");
|
||||
return 1;
|
||||
}
|
||||
mkdir("1", 0755);
|
||||
mkdir("2", 0755);
|
||||
if (mount("1", "1", NULL, MS_BIND, NULL)) {
|
||||
pr_perror("mount");
|
||||
return 1;
|
||||
}
|
||||
if (mount(NULL, "1", NULL, MS_PRIVATE, NULL)) {
|
||||
pr_perror("mount");
|
||||
return 1;
|
||||
}
|
||||
if (mount("zdtm", "2", "tmpfs", 0, NULL)) {
|
||||
pr_perror("mount");
|
||||
return 1;
|
||||
}
|
||||
mkdir("1/a", 0755);
|
||||
mkdir("2/a", 0755);
|
||||
if (mount("1/a", "1/a", NULL, MS_BIND, NULL)) {
|
||||
pr_perror("mount");
|
||||
return 1;
|
||||
}
|
||||
if (mount(NULL, "1/a", NULL, MS_SHARED, NULL)) {
|
||||
pr_perror("mount");
|
||||
return 1;
|
||||
}
|
||||
if (mount("1/a", "2/a", NULL, MS_BIND, NULL)) {
|
||||
pr_perror("mount");
|
||||
return 1;
|
||||
}
|
||||
mkdir("1/a/c", 0755);
|
||||
if (mount("zdtm", "1/a/c", "tmpfs", 0, NULL)) {
|
||||
pr_perror("mount");
|
||||
return 1;
|
||||
}
|
||||
if (mount("2", "1", NULL, MS_MOVE, NULL)) {
|
||||
pr_perror("mount");
|
||||
return 1;
|
||||
}
|
||||
|
||||
task_waiter_init(&t);
|
||||
|
||||
pid = fork();
|
||||
if (pid < 0)
|
||||
return -1;
|
||||
|
||||
if (pid == 0) {
|
||||
if (unshare(CLONE_NEWNS))
|
||||
return 1;
|
||||
task_waiter_complete_current(&t);
|
||||
test_waitsig();
|
||||
return 0;
|
||||
}
|
||||
|
||||
task_waiter_wait4(&t, pid);
|
||||
test_daemon();
|
||||
test_waitsig();
|
||||
|
||||
kill(pid, SIGTERM);
|
||||
wait(NULL);
|
||||
|
||||
pass();
|
||||
|
||||
return 0;
|
||||
}
|
1
test/zdtm/static/mntns_remap.desc
Normal file
1
test/zdtm/static/mntns_remap.desc
Normal file
@@ -0,0 +1 @@
|
||||
{'flavor': 'ns', 'flags': 'suid', 'feature': 'mnt_id'}
|
Reference in New Issue
Block a user