[Devel,vz7,v2] mounts: add unsupported mount helper

Submitted by Stanislav Kinsburskiy on June 20, 2017, 3:44 p.m.

Details

Message ID 20170620154357.37916.17613.stgit@skinsbursky-vz7.qa.sw.ru
State New
Series "mounts: fix check for overmounted NFS"
Headers show

Commit Message

Stanislav Kinsburskiy June 20, 2017, 3:44 p.m.
Call it on mount points tree building and abort in case NFS is overmounted.
This logic replaces the old one, which was checking for unsupported NFS monut
in validate_mounts. And the reason is that call to validate_mounts depends on
user argument, which is unsuitable for this case.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
---
 criu/mount.c |   27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/mount.c b/criu/mount.c
index 942515e..46ad66c 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -397,6 +397,25 @@  static bool mounts_equal(struct mount_info *a, struct mount_info *b)
  */
 static char *mnt_roots;
 
+static bool nfs_mount(const struct mount_info *m)
+{
+	return !strcmp(m->fstype->name, "nfs") ||
+	       !strcmp(m->fstype->name, "nfs4");
+
+}
+
+static bool unsupported_mount(const struct mount_info *m)
+{
+	struct mount_info *parent = m->parent;
+
+	if (m->parent && nfs_mount(parent)) {
+		pr_err("overmounted NFS (%s) is not supported yet:\n",
+				parent->mountpoint);
+		return true;
+	}
+	return false;
+}
+
 static struct mount_info *mnt_build_ids_tree(struct mount_info *list, struct mount_info *yard_mount)
 {
 	struct mount_info *m, *root = NULL;
@@ -457,6 +476,9 @@  static struct mount_info *mnt_build_ids_tree(struct mount_info *list, struct mou
 
 		m->parent = parent;
 		list_add_tail(&m->siblings, &parent->children);
+
+		if (unsupported_mount(m))
+			return NULL;
 	}
 
 	if (!root) {
@@ -809,11 +831,6 @@  skip_fstype:
 					m->mnt_id, m->mountpoint);
 			return -1;
 		}
-
-		if (!strcmp(m->fstype->name, "nfs") && !list_empty(&m->children)) {
-			pr_err("overmounted NFS (%s) is not supported yet\n", m->mountpoint);
-			return -1;
-		}
 	}
 
 	return 0;