[CRIU] [RFC PATCH v2 4/6] populate FSTYPE__AUTO fstypes during restore
Oleg Nesterov
oleg at redhat.com
Fri Mar 27 11:36:34 PDT 2015
On 03/27, Oleg Nesterov wrote:
>
> + * all once. decode_fstype() below must find it.
> */
> - pr_warn("XXX FSTYPE__AUTO name:[%s]\n", me->fsname);
> + __find_fstype_by_name(me->fsname, true);
OOPS, sorry, sent the wrong version. See the fixed patch below.
-------------------------------------------------------------------------------
Subject: [RFC PATCH v2 4/6] populate FSTYPE__AUTO fstypes during restore
Turn find_fstype_by_name(name) into __find_fstype_by_name(name, force_auto)
and reimplement find_fstype_by_name() as a trivial wrapper on top.
Change collect_mnt_from_image() to do __find_fstype_by_name(fsname, true)
when fstype = FSTYPE__AUTO.
TODO: Note the "#if 0" block in __find_fstype_by_name(), imo makes sense
but we don't have WARN_ON() yet.
Signed-off-by: Oleg Nesterov <oleg at redhat.com>
---
mount.c | 26 +++++++++++++++-----------
1 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/mount.c b/mount.c
index e05b599..e274410 100644
--- a/mount.c
+++ b/mount.c
@@ -1100,7 +1100,7 @@ static bool fstype_is_auto(const char *name)
return false;
}
-struct fstype *find_fstype_by_name(char *fst)
+static struct fstype *__find_fstype_by_name(char *fst, bool force_auto)
{
int i;
@@ -1116,7 +1116,7 @@ struct fstype *find_fstype_by_name(char *fst)
struct fstype *fstype = fstypes + i;
if (!fstype->name) {
- if (!fstype_is_auto(fst))
+ if (!force_auto && !fstype_is_auto(fst))
break;
fstype->name = xstrdup(fst);
@@ -1128,9 +1128,18 @@ struct fstype *find_fstype_by_name(char *fst)
return fstype;
}
+#if 0
+ WARN_ON(i == ARRAY_SIZE(fstypes)); /* auto should have a room */
+ WARN_ON(force_auto);
+#endif
return &fstypes[0];
}
+struct fstype *find_fstype_by_name(char *fst)
+{
+ return __find_fstype_by_name(fst, false);
+}
+
static struct fstype *decode_fstype(u32 fst)
{
int i;
@@ -1887,23 +1896,18 @@ static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid)
BUG_ON((me->fstype == FSTYPE__AUTO) !=
(me->fsname != NULL));
+ /* FIXME: abort unsupported early */
if (me->fstype == FSTYPE__AUTO) {
/*
* TODO: this is ugly and suboptimal. We should dump
* the list of FSTYPE__AUTO fsnames and restore them
* all once
*/
-
- /*
- * XXX: just print the dumped/restored ->fsname till
- * the next patch.
- */
- pr_warn("XXX FSTYPE__AUTO name:[%s]\n", me->fsname);
+ pm->fstype = __find_fstype_by_name(me->fsname, true);
+ } else {
+ pm->fstype = decode_fstype(me->fstype);
}
- /* FIXME: abort unsupported early */
- pm->fstype = decode_fstype(me->fstype);
-
if (me->ext_mount) {
struct ext_mount *em;
--
1.5.5.1
More information about the CRIU
mailing list