[CRIU] [PATCH v3 5/7] files: open files on overmounted mounts are not supported

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Thu Dec 13 12:02:54 MSK 2018


Files from such mounts can switch on restore to different files on the
overmounting mount, as we yet don't fully control the mount on which
the file is restored.

v3: make mnt_is_overmounted boolean again

Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 criu/files-reg.c     | 13 +++++++++----
 criu/include/mount.h |  1 +
 criu/mount.c         |  2 +-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/criu/files-reg.c b/criu/files-reg.c
index b44581638..cfeb16b53 100644
--- a/criu/files-reg.c
+++ b/criu/files-reg.c
@@ -1303,7 +1303,7 @@ static bool should_check_size(int flags)
 int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p)
 {
 	struct fd_link _link, *link;
-	struct ns_id *nsid;
+	struct mount_info *mi;
 	struct cr_img *rimg;
 	char ext_id[64];
 	FileEntry fe = FILE_ENTRY__INIT;
@@ -1327,13 +1327,18 @@ int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p)
 		goto ext;
 	}
 
-	nsid = lookup_nsid_by_mnt_id(p->mnt_id);
-	if (nsid == NULL) {
+	mi = lookup_mnt_id(p->mnt_id);
+	if (mi == NULL) {
 		pr_err("Can't lookup mount=%d for fd=%d path=%s\n",
 			p->mnt_id, p->fd, link->name + 1);
 		return -1;
 	}
 
+	if (mnt_is_overmounted(mi)) {
+		pr_err("Open files on overmounted mounts are not supported yet\n");
+		return -1;
+	}
+
 	if (p->mnt_id >= 0 && (root_ns_mask & CLONE_NEWNS)) {
 		rfe.mnt_id = p->mnt_id;
 		rfe.has_mnt_id = true;
@@ -1350,7 +1355,7 @@ int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p)
 		return -1;
 	}
 
-	if (check_path_remap(link, p, lfd, id, nsid))
+	if (check_path_remap(link, p, lfd, id, mi->nsid))
 		return -1;
 	rfe.name	= &link->name[1];
 ext:
diff --git a/criu/include/mount.h b/criu/include/mount.h
index 843f3c438..d9b375f5d 100644
--- a/criu/include/mount.h
+++ b/criu/include/mount.h
@@ -143,5 +143,6 @@ extern int check_mnt_id(void);
 
 extern int remount_readonly_mounts(void);
 extern int try_remount_writable(struct mount_info *mi, bool ns);
+extern bool mnt_is_overmounted(struct mount_info *mi);
 
 #endif /* __CR_MOUNT_H__ */
diff --git a/criu/mount.c b/criu/mount.c
index 5801f64a8..6a0f7bd44 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -1152,7 +1152,7 @@ static int get_clean_fd(struct mount_info *mi)
  * root of our mount namespace as it is covered by other mount.
  * mnt_is_overmounted() checks if mount is not visible.
  */
-static bool mnt_is_overmounted(struct mount_info *mi)
+bool mnt_is_overmounted(struct mount_info *mi)
 {
 	struct mount_info *t, *c, *m = mi;
 
-- 
2.17.1



More information about the CRIU mailing list