[CRIU] [PATCH v2 2/5] introduce fsname_is_auto(name) and FSTYPE__AUTO

Oleg Nesterov oleg at redhat.com
Thu Apr 9 10:46:30 PDT 2015


The comment in find_fstype_by_name() says:

	just mounting anything is wrong

and this is true in general, but:

	almost every fs has its own features

this is not true in a sense that a lot of supported filesystems do not
need any special processing: FSTYPE__PROC, FSTYPE__SYSFS, and more. More
importantly, this logic does not allow to spicify from the command line
that (say) currently unsupported hugetlbfs can "just work", do_new_mount()
should only pass the right name/options.

This patch adds the new FSTYPE__AUTO code, find_fstype_by_name(name) adds
the new entry if fsname_is_auto(name) returns true. We do not care that
different fstype's can have the same FSTYPE__AUTO code, fstype->code has
no meaning unless we need to do something special with this fs, but in
this case it should not be FSTYPE__AUTO by definition.

Note: currently find_fstype_by_name() just returns true, it is obviously
pointless to "dump" until we teach "restore" to handle FSTYPE__AUTO.

Signed-off-by: Oleg Nesterov <oleg at redhat.com>
---
 mount.c            |   18 ++++++++++++++++--
 protobuf/mnt.proto |    1 +
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/mount.c b/mount.c
index 1485caf..ddb162f 100644
--- a/mount.c
+++ b/mount.c
@@ -1117,6 +1117,11 @@ static struct fstype fstypes[32] = {
 	},
 };
 
+static bool fsname_is_auto(const char *name)
+{
+	return false;
+}
+
 struct fstype *find_fstype_by_name(char *fst)
 {
 	int i;
@@ -1132,13 +1137,22 @@ struct fstype *find_fstype_by_name(char *fst)
 	for (i = 1; i < ARRAY_SIZE(fstypes); i++) {
 		struct fstype *fstype = fstypes + i;
 
-		if (!fstype->name)
-			break;
+		if (!fstype->name) {
+			if (!fsname_is_auto(fst))
+				break;
+
+			fstype->name = xstrdup(fst);
+			fstype->code = FSTYPE__AUTO;
+			return fstype;
+		}
 
 		if (!strcmp(fstype->name, fst))
 			return fstype;
 	}
 
+	if (i == ARRAY_SIZE(fstypes)) /* ensure we have a room for auto */
+		pr_err_once("fstypes[] overflow!\n");
+
 	return &fstypes[0];
 }
 
diff --git a/protobuf/mnt.proto b/protobuf/mnt.proto
index 343bd6d..9bb920d 100644
--- a/protobuf/mnt.proto
+++ b/protobuf/mnt.proto
@@ -16,6 +16,7 @@ enum fstype {
 	CGROUP			= 12;
 	AUFS			= 13;
 	MQUEUE			= 14;
+	AUTO			= 15;
 };
 
 message mnt_entry {
-- 
1.5.5.1



More information about the CRIU mailing list