From e2c38245c613df5e36dcf0253c7652f928e46abf Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Thu, 9 Apr 2015 19:46:38 +0200 Subject: [PATCH] introduce --enable-fs cli option Finally add --enable-fs option to specify the comma separated list of filesystem names which should be treated as FSTYPE_AUTO. Note: obviously this option is not safe, use at your own risk. "dump" will always succeed if the mntpoint is auto, but "restore" can fail or do something wrong if mount(src, mountpoint, flags, options) can not actually "just work" as FSTYPE_AUTO logic expects. Signed-off-by: Oleg Nesterov Signed-off-by: Pavel Emelyanov --- crtools.c | 8 ++++++++ include/mount.h | 1 + mount.c | 24 +++++++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/crtools.c b/crtools.c index 9a0902dd1..8dfce4ddc 100644 --- a/crtools.c +++ b/crtools.c @@ -204,6 +204,7 @@ int main(int argc, char *argv[], char *envp[]) { "inherit-fd", required_argument, 0, 1062 }, { "feature", required_argument, 0, 1063 }, { "skip-mnt", required_argument, 0, 1064}, + { "enable-fs", required_argument, 0, 1065}, { }, }; @@ -421,6 +422,10 @@ int main(int argc, char *argv[], char *envp[]) if (!add_skip_mount(optarg)) return 1; break; + case 1065: + if (!add_fsname_auto(optarg)) + return 1; + break; case 'M': { char *aux; @@ -648,6 +653,9 @@ usage: " installed into. No controller means that root is the\n" " default for all controllers not specified.\n" " --skip-mnt PATH ignore this mountpoint when dumping the mount namespace.\n" +" --enable-fs FSNAMES a comma separated list of filesystem names or \"all\".\n" +" force criu to (try to) dump/restore these filesystem's\n" +" mountpoints even if fs is not supported.\n" "\n" "* Logging:\n" " -o|--log-file FILE log file name\n" diff --git a/include/mount.h b/include/mount.h index 75721b56f..0d5fc7f3d 100644 --- a/include/mount.h +++ b/include/mount.h @@ -13,6 +13,7 @@ struct proc_mountinfo; extern int open_mount(unsigned int s_dev); extern struct fstype *find_fstype_by_name(char *fst); +extern bool add_fsname_auto(const char *names); struct cr_imgset; extern struct mount_info * collect_mntinfo(struct ns_id *ns, bool for_dump); diff --git a/mount.c b/mount.c index 6fb9b03d2..9216ac0c5 100644 --- a/mount.c +++ b/mount.c @@ -1172,9 +1172,31 @@ static struct fstype fstypes[32] = { }, }; +static char *fsauto_names; + static bool fsname_is_auto(const char *name) { - return false; + const char *p; + + if (!fsauto_names) + return false; + + if (strcmp(fsauto_names, "all") == 0) + return true; + + for (p = strtok(fsauto_names, ","); p; p = strtok(NULL, ",")) { + if (strcmp(name, p) == 0) + return true; + } + + return false; +} + +bool add_fsname_auto(const char *names) +{ + xfree(fsauto_names); + fsauto_names = xstrdup(names); + return fsauto_names != NULL; } static struct fstype *__find_fstype_by_name(char *_fst, bool force_auto)