mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
zdtm: add mntns_pivot_root_ro test
This checks that superblock readonly flag is applied to nested mntns roots on restore. Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This commit is contained in:
parent
2a3d2bc284
commit
a379d4d945
4 changed files with 35 additions and 0 deletions
|
|
@ -402,6 +402,7 @@ TST_DIR = \
|
|||
mnt_ext_root \
|
||||
mnt_ext_collision \
|
||||
mntns_pivot_root \
|
||||
mntns_pivot_root_ro \
|
||||
mnt_tracefs \
|
||||
mntns_deleted \
|
||||
unlink_regular00 \
|
||||
|
|
@ -580,6 +581,7 @@ socket-tcp-closed-last-ack: CFLAGS += -D ZDTM_TCP_LAST_ACK
|
|||
socket-tcp-skip-in-flight: CFLAGS += -D ZDTM_IPV4V6
|
||||
tun_ns: CFLAGS += -DTUN_NS
|
||||
mnt_ext_manual: CFLAGS += -D ZDTM_EXTMAP_MANUAL
|
||||
mntns_pivot_root_ro: CFLAGS += -DMNTNS_PIVOT_ROOT_RO
|
||||
sigpending: LDLIBS += -lrt
|
||||
vdso01: LDLIBS += -lrt
|
||||
scm01: CFLAGS += -DKEEP_SENT_FD
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <linux/limits.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "zdtmtst.h"
|
||||
#include "lock.h"
|
||||
|
|
@ -86,6 +87,21 @@ static int child(void)
|
|||
}
|
||||
close(fd);
|
||||
|
||||
#ifdef MNTNS_PIVOT_ROOT_RO
|
||||
/*
|
||||
* Hack to make cr_pivot_root work on readonly mntns root,
|
||||
* normally nested containers have /tmp directory
|
||||
*/
|
||||
mkdir("tmp", 0755);
|
||||
/*
|
||||
* Make superblock readonly
|
||||
*/
|
||||
if (mount(NULL, "/", NULL, MS_REMOUNT | MS_RDONLY, NULL)) {
|
||||
pr_perror("remount_ro");
|
||||
goto err;
|
||||
}
|
||||
#endif
|
||||
|
||||
futex_set_and_wake(futex, TEST_CHILD);
|
||||
futex_wait_while_lt(futex, TEST_CHECK);
|
||||
|
||||
|
|
@ -94,6 +110,21 @@ static int child(void)
|
|||
goto err;
|
||||
}
|
||||
|
||||
#ifdef MNTNS_PIVOT_ROOT_RO
|
||||
/*
|
||||
* Check superblock readonly
|
||||
*/
|
||||
fd = open(testfile, O_WRONLY);
|
||||
if (fd >= 0) {
|
||||
pr_err("Open on readonly superblock should fail\n");
|
||||
close(fd);
|
||||
goto err;
|
||||
} else if (errno != EROFS) {
|
||||
pr_perror("open write");
|
||||
goto err;
|
||||
}
|
||||
#endif
|
||||
|
||||
futex_set_and_wake(futex, TEST_EXIT);
|
||||
return 0;
|
||||
err:
|
||||
|
|
|
|||
1
test/zdtm/static/mntns_pivot_root_ro.c
Symbolic link
1
test/zdtm/static/mntns_pivot_root_ro.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
mntns_pivot_root.c
|
||||
1
test/zdtm/static/mntns_pivot_root_ro.desc
Symbolic link
1
test/zdtm/static/mntns_pivot_root_ro.desc
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
mntns_pivot_root.desc
|
||||
Loading…
Add table
Add a link
Reference in a new issue