[CRIU] [PATCH v3 05/16] fstype: "mount" callback introduced

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Thu Dec 10 07:16:31 PST 2015


It will be used to mount AutoFS, because context creation is required in
addition to actual mount operation.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
 include/proc_parse.h |    4 ++++
 mount.c              |   10 +++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/proc_parse.h b/include/proc_parse.h
index e45d93f..dbb7e46 100644
--- a/include/proc_parse.h
+++ b/include/proc_parse.h
@@ -101,12 +101,16 @@ struct proc_status_creds {
 
 bool proc_status_creds_eq(struct proc_status_creds *o1, struct proc_status_creds *o2);
 
+typedef int (*mount_fn_t)(struct mount_info *mi, const char *src, const
+			  char *fstype, unsigned long mountflags);
+
 struct fstype {
 	char *name;
 	int code;
 	int (*dump)(struct mount_info *pm);
 	int (*restore)(struct mount_info *pm);
 	int (*parse)(struct mount_info *pm);
+	mount_fn_t mount;
 };
 
 struct vm_area_list;
diff --git a/mount.c b/mount.c
index 8b92538..932871b 100644
--- a/mount.c
+++ b/mount.c
@@ -1955,6 +1955,13 @@ skip_parent:
  */
 #define MS_MNT_KNOWN_FLAGS (MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_NOATIME | \
 				MS_NODIRATIME | MS_RELATIME | MS_RDONLY)
+
+static int do_simple_mount(struct mount_info *mi, const char *src, const
+			   char *fstype, unsigned long mountflags)
+{
+	return mount(src, mi->mountpoint, fstype, mountflags, mi->options);
+}
+
 static int do_new_mount(struct mount_info *mi)
 {
 	unsigned long sflags = mi->sb_flags;
@@ -1962,6 +1969,7 @@ static int do_new_mount(struct mount_info *mi)
 	char *src;
 	struct fstype *tp = mi->fstype;
 	bool remount_ro = (tp->restore && mi->sb_flags & MS_RDONLY);
+	mount_fn_t do_mount = (tp->mount) ? tp->mount : do_simple_mount;
 
 	src = resolve_source(mi);
 	if (!src)
@@ -1976,7 +1984,7 @@ static int do_new_mount(struct mount_info *mi)
 	if (remount_ro)
 		sflags &= ~MS_RDONLY;
 
-	if (mount(src, mi->mountpoint, tp->name, sflags, mi->options) < 0) {
+	if (do_mount(mi, src, tp->name, sflags) < 0) {
 		pr_perror("Can't mount at %s", mi->mountpoint);
 		return -1;
 	}



More information about the CRIU mailing list