mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-21 01:06:58 +00:00
Make two mounts, binds of the same file system, the first has root "/" and the second has a cut root "/auxiliary". This insures that on restore criu will mount the first mount first and latter bind the second from it. After set the first mount unbindable to check if restoring these flag does not interfere with restoring mounts. Before the fix in these series we had the error: (00.031286) 1: mnt: Mounting tmpfs @/tmp/.criu.mntns.wGroPU/12-0000000000/zdtm/static/unbindable.test/bind_of_unbindable (0) (00.031298) 1: mnt: Bind /tmp/.criu.mntns.wGroPU/12-0000000000/zdtm/static/unbindable.test/unbindable/auxiliary to /tmp/.criu.mntns.wGroPU/12-0000000000/zdtm/static/unbindable.test/bind_of_unbindable (00.031329) 1: Error (criu/mount.c:2298): mnt: Can't mount at /tmp/.criu.mntns.wGroPU/12-0000000000/zdtm/static/unbindable.test/bind_of_unbindable: Invalid argument https://bugs.openvz.org/browse/OVZ-7116 Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
69 lines
1.7 KiB
C
69 lines
1.7 KiB
C
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <sys/mount.h>
|
|
#include <sys/stat.h>
|
|
#include <linux/limits.h>
|
|
|
|
#include "zdtmtst.h"
|
|
|
|
const char *test_doc = "Check unbindable flag does not break mount restore";
|
|
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 unbindable[PATH_MAX], bind_of_unbindable[PATH_MAX];
|
|
char auxiliary[PATH_MAX];
|
|
|
|
test_init(argc, argv);
|
|
mkdir(dirname, 0700);
|
|
|
|
snprintf(unbindable, sizeof(unbindable), "%s/unbindable", dirname);
|
|
if (mkdir(unbindable, 0700)) {
|
|
pr_perror("Unable to mkdir %s", unbindable);
|
|
return 1;
|
|
}
|
|
if (mount("unbindable", unbindable, "tmpfs", 0, NULL)) {
|
|
pr_perror("Unable to mount tmpfs to %s", unbindable);
|
|
return 1;
|
|
}
|
|
|
|
snprintf(auxiliary, sizeof(auxiliary), "%s/unbindable/auxiliary", dirname);
|
|
if (mkdir(auxiliary, 0700)) {
|
|
pr_perror("Unable to mkdir %s", auxiliary);
|
|
return 1;
|
|
}
|
|
|
|
snprintf(bind_of_unbindable, sizeof(bind_of_unbindable), "%s/bind_of_unbindable", dirname);
|
|
if (mkdir(bind_of_unbindable, 0700)) {
|
|
pr_perror("Unable to mkdir %s", bind_of_unbindable);
|
|
return 1;
|
|
}
|
|
if (mount(auxiliary, bind_of_unbindable, NULL, MS_BIND, NULL)) {
|
|
pr_perror("Unable to mount %s to %s", unbindable, bind_of_unbindable);
|
|
return 1;
|
|
}
|
|
|
|
if (mount(NULL, unbindable, NULL, MS_UNBINDABLE, NULL)) {
|
|
pr_perror("Unable to set %s unbindable", unbindable);
|
|
return 1;
|
|
}
|
|
|
|
test_daemon();
|
|
test_waitsig();
|
|
|
|
if (umount(bind_of_unbindable)) {
|
|
pr_perror("Unable to umount %s", bind_of_unbindable);
|
|
return 1;
|
|
}
|
|
|
|
if (umount(unbindable)) {
|
|
pr_perror("Unable to umount %s", unbindable);
|
|
return 1;
|
|
}
|
|
|
|
pass();
|
|
return 0;
|
|
}
|