[CRIU] [RFC PATCH 2/6] introduce fstype_is_auto(name) and FSTYPE__AUTO

Oleg Nesterov oleg at redhat.com
Fri Mar 27 10:55:47 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 fstype_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            |   15 +++++++++++++--
 protobuf/mnt.proto |    1 +
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/mount.c b/mount.c
index ff2bce5..52156d6 100644
--- a/mount.c
+++ b/mount.c
@@ -1095,6 +1095,11 @@ static struct fstype fstypes[32] = {
 	},
 };
 
+static bool fstype_is_auto(const char *name)
+{
+	return false;
+}
+
 struct fstype *find_fstype_by_name(char *fst)
 {
 	int i;
@@ -1110,8 +1115,14 @@ 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 (!fstype_is_auto(fst))
+				break;
+
+			fstype->name = xstrdup(fst);
+			fstype->code = FSTYPE__AUTO;
+			return fstype;
+		}
 
 		if (!strcmp(fstype->name, fst))
 			return fstype;
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