[1/3] mount: Relax ext mounts resolving

Submitted by Pavel Emelianov on Sept. 21, 2016, 9:59 a.m.

Details

Message ID 57E259E8.8020109@virtuozzo.com
State Accepted
Series "Sanitize ext-mount-map usage in mount.c"
Commit d277b660a45fe64272b549ce08e52bc083bfa9d5
Headers show

Commit Message

Pavel Emelianov Sept. 21, 2016, 9:59 a.m.
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/mount.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/mount.c b/criu/mount.c
index f402f6f..021d041 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -473,6 +473,7 @@  static void mnt_tree_show(struct mount_info *tree, int off)
 	pr_info("%*s<--\n", off, "");
 }
 
+/* Returns -1 on error, 1 if external mount resolved, 0 otherwise */
 static int try_resolve_ext_mount(struct mount_info *info)
 {
 	struct ext_mount *em;
@@ -483,7 +484,7 @@  static int try_resolve_ext_mount(struct mount_info *info)
 		pr_info("Found %s mapping for %s mountpoint\n",
 				em->val, info->mountpoint);
 		info->external = em;
-		return 0;
+		return 1;
 	}
 
 	snprintf(devstr, sizeof(devstr), "dev[%d/%d]",
@@ -507,11 +508,11 @@  static int try_resolve_ext_mount(struct mount_info *info)
 			BUG_ON(info->fstype->code != FSTYPE__AUTO);
 			xfree(info->source);
 			info->source = source;
-			return 0;
+			return 1;
 		}
 	}
 
-	return -ENOTSUP;
+	return 0;
 }
 
 static struct mount_info *find_widest_shared(struct mount_info *m)
@@ -822,13 +823,10 @@  static int resolve_external_mounts(struct mount_info *info)
 			continue;
 
 		ret = try_resolve_ext_mount(m);
-		if (ret < 0 && ret != -ENOTSUP) {
-			return -1;
-		} else if (ret == -ENOTSUP && !ext_ns) {
-			continue;
-		} else if (ret == 0) {
+		if (ret < 0)
+			return ret;
+		if (ret == 1 || !ext_ns)
 			continue;
-		}
 
 		match = find_best_external_match(ext_ns->mnt.mntinfo_list, m);
 		if (!match)