Commit b3243983 authored by Stanislav Kinsburskiy's avatar Stanislav Kinsburskiy Committed by Pavel Emelyanov

check: "autofs" feature added

The only way to check, whether autofs migration is supported  from the kernel
side is to check actual mount point options (search for "pipe_ino" option).
This checker first tries to find autofs on host. If there is no any, temporary
mounts autofs by itself.
Signed-off-by: 's avatarStanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 4cdabe95
......@@ -21,6 +21,7 @@
#include <sys/prctl.h>
#include <sched.h>
#include <linux/aio_abi.h>
#include <sys/mount.h>
#include "proc_parse.h"
#include "sockets.h"
......@@ -825,6 +826,84 @@ static int check_clone_parent_vs_pid()
return 0;
}
static int check_autofs_pipe_ino(void)
{
FILE *f;
char str[1024];
int ret = -ENOENT;
f = fopen_proc(PROC_SELF, "mountinfo");
if (!f) {
pr_perror("Can't open %d mountinfo", getpid());
return -1;
}
while (fgets(str, sizeof(str), f)) {
if (strstr(str, " autofs ")) {
if (strstr(str, "pipe_ino="))
ret = 0;
else {
pr_err("autofs not supported.\n");
ret = -ENOTSUP;
}
break;
}
}
fclose(f);
return ret;
}
static int check_autofs(void)
{
char *dir, *options, template[] = "/tmp/.criu.mnt.XXXXXX";
int ret, pfd[2];
ret = check_autofs_pipe_ino();
if (ret != -ENOENT)
return ret;
if (pipe(pfd) < 0) {
pr_perror("failed to create pipe");
return -1;
}
ret = -1;
options = xsprintf("fd=%d,pgrp=%d,minproto=5,maxproto=5,direct",
pfd[1], getpgrp());
if (!options) {
pr_err("failed to allocate autofs options\n");
goto close_pipe;
}
dir = mkdtemp(template);
if (!dir) {
pr_perror("failed to construct temporary name\n");
goto free_options;
}
if (mount("criu", dir, "autofs", 0, options) < 0) {
pr_perror("failed to mount autofs");
goto unlink_dir;
}
ret = check_autofs_pipe_ino();
if (umount(dir))
pr_perror("failed to umount %s\n", dir);
unlink_dir:
if (rmdir(dir))
pr_perror("failed to unlink %s", dir);
free_options:
free(options);
close_pipe:
close(pfd[0]);
close(pfd[1]);
return ret;
}
static int check_cgroupns(void)
{
int ret;
......@@ -941,8 +1020,7 @@ int cr_check(void)
* Category 3 - experimental.
*/
if (opts.check_experimental_features) {
/* Empty for now */
;
ret |= check_autofs();
}
print_on_level(DEFAULT_LOGLEVEL, "%s\n", ret ? CHECK_MAYBE : CHECK_GOOD);
......@@ -1014,6 +1092,7 @@ static struct feature_list feature_list[] = {
{ "seccomp_filters", check_ptrace_dump_seccomp_filters },
{ "loginuid", check_loginuid },
{ "cgroupns", check_cgroupns },
{ "autofs", check_autofs },
{ NULL, NULL },
};
......
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