[CRIU] [PATCH 2/7] proc_parse: use construct string to create new->mountpoint

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Wed Dec 16 07:33:09 PST 2015


Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
 proc_parse.c |   14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/proc_parse.c b/proc_parse.c
index 2eef21a..3a62ac2 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -1115,21 +1115,16 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new, char **fsname)
 	unsigned int kmaj, kmin;
 	int ret, n;
 	char *sub, *opt = NULL;
+	char mountpoint[PATH_MAX];
 
-	new->mountpoint = xmalloc(PATH_MAX);
-	if (new->mountpoint == NULL)
-		goto err;
-	new->ns_mountpoint = new->mountpoint;
-
-	new->mountpoint[0] = '.';
 	ret = sscanf(str, "%i %i %u:%u %ms %s %ms %n",
 			&new->mnt_id, &new->parent_mnt_id,
-			&kmaj, &kmin, &new->root, new->mountpoint + 1,
+			&kmaj, &kmin, &new->root, mountpoint,
 			&opt, &n);
 	if (ret != 7)
 		goto err;
 
-	cure_path(new->mountpoint);
+	cure_path(mountpoint);
 	cure_path(new->root);
 
 	root_link.len = strlen(new->root);
@@ -1139,9 +1134,10 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new, char **fsname)
 		new->deleted = true;
 	}
 
-	new->mountpoint = xrealloc(new->mountpoint, strlen(new->mountpoint) + 1);
+	new->mountpoint = construct_string(".%s", mountpoint);
 	if (!new->mountpoint)
 		goto err;
+	new->ns_mountpoint = new->mountpoint;
 
 	new->s_dev = new->s_dev_rt = MKKDEV(kmaj, kmin);
 	new->flags = 0;



More information about the CRIU mailing list