[CRIU] [PATCH 8/9] mounts: find mounts, which are propagated from a current one

Pavel Emelyanov xemul at parallels.com
Tue Jul 9 12:44:43 EDT 2013


On 07/09/2013 03:05 PM, Andrey Vagin wrote:
> A mount is propagated to all members of a parent's shared group
> 
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  mount.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 44 insertions(+), 2 deletions(-)
> 
> diff --git a/mount.c b/mount.c
> index fae9513..42d37db 100644
> --- a/mount.c
> +++ b/mount.c
> @@ -618,6 +618,44 @@ static char *resolve_source(struct mount_info *mi)
>  	return NULL;
>  }
>  
> +static int propogate_mount(struct mount_info *mi)

I don't understand what this function does. Plz, document.

> +{
> +	struct mount_info *t;
> +
> +	list_for_each_entry(t, &mi->mnt_share, mnt_share)
> +		t->bind = mi;
> +
> +	list_for_each_entry(t, &mi->mnt_slave_list, mnt_slave)
> +		t->bind = mi;
> +
> +	/* Mart this mnt as mounted for all who in this group */
> +	list_for_each_entry(t, &mi->parent->mnt_share, mnt_share) {
> +		struct mount_info *c;
> +
> +		list_for_each_entry(c, &t->children, siblings) {
> +			if (mntcmp(mi, c, false))
> +				t->mounted = true;
> +		}
> +	}
> +
> +	list_for_each_entry(t, &mi->parent->mnt_slave_list, mnt_slave) {
> +		struct mount_info *c;
> +		list_for_each_entry(c, &t->children, siblings) {
> +			if (mntcmp(mi, c, false))
> +				t->mounted = true;
> +		}
> +	}
> +
> +	if (fsroot_mounted(mi))
> +		list_for_each_entry(t, &mi->mnt_bind, mnt_bind) {
> +			if (t->bind)
> +				continue;
> +			t->bind = mi;
> +		}
> +
> +	return 0;
> +}
> +
>  static int do_new_mount(struct mount_info *mi)
>  {
>  	char *src;
> @@ -637,8 +675,8 @@ static int do_new_mount(struct mount_info *mi)
>  	if (tp->restore && tp->restore(mi))
>  		return -1;
>  
> -	list_for_each_entry(t, &mi->mnt_bind, mnt_bind)
> -		t->bind = mi;
> +	if (propogate_mount(mi))
> +		return 0;
>  
>  	return 0;
>  }
> @@ -654,6 +692,10 @@ static int do_bind_mount(struct mount_info *mi)
>  		pr_perror("Can't mount at %s", mi->mountpoint);
>  		return -1;
>  	}
> +
> +	if (propogate_mount(mi))
> +		return -1;
> +
>  	return 0;
>  }
>  
> 




More information about the CRIU mailing list