[CRIU] [PATCH 1/4] [v3] mount: don't add a separate entry for each enabled file systems

Pavel Emelyanov xemul at virtuozzo.com
Thu May 5 05:13:46 PDT 2016


>  
> -struct fstype *find_fstype_by_name(char *fst)
> -{
> -	return __find_fstype_by_name(fst, false);
> -}
> -
>  static struct fstype *decode_fstype(u32 fst, char *fsname)

The fsname arguments becomes unused.

>  {
>  	int i;
>  
> -	if (fst == FSTYPE__AUTO)
> -		return __find_fstype_by_name(fsname, true);
> -
>  	if (fst == FSTYPE__UNSUPPORTED)
>  		goto uns;
>  
> @@ -1882,7 +1868,7 @@ static int dump_one_mountpoint(struct mount_info *pm, struct cr_img *img)
>  	me.fstype		= pm->fstype->code;
>  
>  	if (me.fstype == FSTYPE__AUTO)
> -		me.fsname = pm->fstype->name;
> +		me.fsname = pm->fsname;
>  
>  	if (pm->parent && !pm->dumped && !pm->need_plugin && !pm->external &&
>  	    pm->fstype->dump && fsroot_mounted(pm)) {
> @@ -2280,6 +2266,13 @@ static int do_simple_mount(struct mount_info *mi, const char *src, const
>  	return mount(src, mi->mountpoint, fstype, mountflags, mi->options);
>  }
>  
> +static char *mnt_fsname(struct mount_info *mi)
> +{
> +	if (mi->fstype->code == FSTYPE__AUTO)
> +		return mi->fsname;
> +	return mi->fstype->name;
> +}
> +
>  static int do_new_mount(struct mount_info *mi)
>  {
>  	unsigned long sflags = mi->sb_flags;
> @@ -2302,7 +2295,7 @@ static int do_new_mount(struct mount_info *mi)
>  	if (remount_ro)
>  		sflags &= ~MS_RDONLY;
>  
> -	if (do_mount(mi, src, tp->name, sflags) < 0) {
> +	if (do_mount(mi, src, mnt_fsname(mi), sflags) < 0) {
>  		pr_perror("Can't mount at %s", mi->mountpoint);
>  		return -1;
>  	}
> @@ -2746,6 +2739,7 @@ void mnt_entry_free(struct mount_info *mi)
>  		xfree(mi->mountpoint);
>  		xfree(mi->source);
>  		xfree(mi->options);
> +		xfree(mi->fsname);
>  		xfree(mi);
>  	}
>  }
> @@ -2958,6 +2952,11 @@ static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid)
>  
>  		/* FIXME: abort unsupported early */

Here should go

	if (me->fsname && me->fstype != AUTO) {
		pr_err("Error in image\n");
		goto err;
	}

or smth like this.


>  		pm->fstype = decode_fstype(me->fstype, me->fsname);
> +		if (me->fsname) {
> +			pm->fsname = xstrdup(me->fsname);
> +			if (!pm->fsname)
> +				goto err;
> +		}
>  
>  		if (get_mp_root(me, pm))
>  			goto err;
> diff --git a/criu/proc_parse.c b/criu/proc_parse.c
> index 04ab14e..00939b5 100644
> --- a/criu/proc_parse.c
> +++ b/criu/proc_parse.c
> @@ -1301,6 +1301,10 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new, char **fsname)
>  
>  	cure_path(new->source);
>  
> +	new->fsname = xstrdup(*fsname);
> +	if (!new->fsname)
> +		goto err;
> +
>  	/*
>  	 * The kernel reports "subtypes" sometimes and the valid
>  	 * type-vs-subtype delimiter is the dot symbol. We disregard
> 



More information about the CRIU mailing list