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

Stanislav Kinsburskiу skinsbursky at odin.com
Thu Dec 17 00:17:34 PST 2015


17 дек. 2015 г. 9:00 AM пользователь Andrew Vagin <avagin at virtuozzo.com> написал:
>
> We can do the same without additional magic functions. 
>

Yep. Probably, in this case your way is better and simpler.

> On Wed, Dec 16, 2015 at 06:33:09PM +0300, Stanislav Kinsburskiy wrote: 
> > 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] = '.'; 
> mountpoint = '.'; 
> >  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, 
>
> &kmaj, &kmin, &new->root, mountpoint + 1, 
>
> >  &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); 
>
> new->mountpoint = xstrdup(mountpoint); 
>
> >  if (!new->mountpoint) 
> >  goto err; 
> > + new->ns_mountpoint = new->mountpoint; 
>> >  new->s_dev = new->s_dev_rt = MKKDEV(kmaj, kmin); 
> >  new->flags = 0; 
> > 
> > _______________________________________________ 
> > CRIU mailing list 
> > CRIU at openvz.org 
> > https://lists.openvz.org/mailman/listinfo/criu 



More information about the CRIU mailing list