mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
zdtm: add mnt_ro_root test
It makes root mount readonly and checks that it is still readonly after migration. Make zdtm/static writable for logs via "bind" desc option. v2: explain why we don't have explicit rw/ro flag check v3: use new zdtm "bind" desc option Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This commit is contained in:
parent
6b3826a6fb
commit
5a725266ac
4 changed files with 42 additions and 0 deletions
|
|
@ -57,6 +57,9 @@ static int prepare_mntns(void)
|
|||
if (zdtm_bind) {
|
||||
/*
|
||||
* Bindmount the directory to itself.
|
||||
* e.g.: The mnt_ro_root test makes "/" mount readonly, but we
|
||||
* still want to write logs to /zdtm/static/ so let's make it
|
||||
* separate writable bind mount.
|
||||
*/
|
||||
snprintf(bind_path, sizeof(bind_path), "%s/%s", root, zdtm_bind);
|
||||
if (mount(bind_path, bind_path, NULL, MS_BIND, NULL)) {
|
||||
|
|
|
|||
|
|
@ -423,6 +423,7 @@ TST_DIR = \
|
|||
mntns_ghost \
|
||||
mntns_ghost01 \
|
||||
mntns_ro_root \
|
||||
mnt_ro_root \
|
||||
mntns_link_ghost \
|
||||
mntns_shared_bind \
|
||||
mntns_shared_bind02 \
|
||||
|
|
|
|||
32
test/zdtm/static/mnt_ro_root.c
Normal file
32
test/zdtm/static/mnt_ro_root.c
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#include <sys/mount.h>
|
||||
|
||||
#include "zdtmtst.h"
|
||||
|
||||
const char *test_doc = "Check if root mount remains read-only after c/r";
|
||||
const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>";
|
||||
|
||||
char *dirname;
|
||||
TEST_OPTION(dirname, string, "directory name", 1);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
test_init(argc, argv);
|
||||
|
||||
if (mount(NULL, "/", NULL, MS_REMOUNT | MS_RDONLY | MS_BIND, NULL)) {
|
||||
pr_perror("mount");
|
||||
return 1;
|
||||
}
|
||||
|
||||
test_daemon();
|
||||
test_waitsig();
|
||||
|
||||
/*
|
||||
* Note: In zdtm.py:check_visible_state() we already check for all
|
||||
* tests, that all mounts in the test's mount namespace remain the
|
||||
* same, by comparing mountinfo before and after c/r. So rw/ro mount
|
||||
* option inconsistency will be detected there and we don't need to
|
||||
* check it in the test itself.
|
||||
*/
|
||||
pass();
|
||||
return 0;
|
||||
}
|
||||
6
test/zdtm/static/mnt_ro_root.desc
Normal file
6
test/zdtm/static/mnt_ro_root.desc
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
'flavor': 'ns uns',
|
||||
'flags': 'suid',
|
||||
'feature': 'mnt_id',
|
||||
'bind': 'zdtm/static',
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue