[1/5] mount: Delete slash handle from binfmt_misc

Submitted by Kirill Tkhai on July 15, 2017, 3:25 p.m.

Details

Message ID 150013230427.12956.8130482230023608080.stgit@localhost.localdomain
State New
Series "binfmt_misc: Switch to dumpee user_ns before mount"
Headers show

Commit Message

Kirill Tkhai July 15, 2017, 3:25 p.m.
Review shown, that mounts without slash at end are
not impossible in criu. So, delete this workaround.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/mount.c |   20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/mount.c b/criu/mount.c
index 83915b7b2..f258caaf5 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -1194,7 +1194,6 @@  int open_mountpoint(struct mount_info *pm)
 static __maybe_unused int add_cr_time_mount(struct mount_info *root, char *fsname, const char *path, unsigned int s_dev)
 {
 	struct mount_info *mi, *t, *parent;
-	bool add_slash = false;
 	int len;
 
 	if (!root->nsid) {
@@ -1210,25 +1209,20 @@  static __maybe_unused int add_cr_time_mount(struct mount_info *root, char *fsnam
 		}
 	}
 
-	mi = mnt_entry_alloc();
-	if (!mi)
-		return -1;
-
 	len = strlen(root->mountpoint);
-	/* It may be "./" or "./path/to/dir" */
-	if (root->mountpoint[len - 1] != '/') {
-		add_slash = true;
-		len++;
+	if (root->mountpoint[len-1] != '/') {
+		pr_err("Wrong root: %s\n", root->mountpoint);
+		return -1;
 	}
 
+	mi = mnt_entry_alloc();
+	if (!mi)
+		return -1;
 	mi->mountpoint = xmalloc(len + strlen(path) + 1);
 	if (!mi->mountpoint)
 		return -1;
 	mi->ns_mountpoint = mi->mountpoint;
-	if (!add_slash)
-		sprintf(mi->mountpoint, "%s%s", root->mountpoint, path);
-	else
-		sprintf(mi->mountpoint, "%s/%s", root->mountpoint, path);
+	sprintf(mi->mountpoint, "%s%s", root->mountpoint, path);
 	mi->mnt_id = CRTIME_MNT_ID;
 	mi->flags = mi->sb_flags = 0;
 	mi->root = xstrdup("/");