[CRIU] [PATCH] fsnotify: open mount point relative to a proper root

Pavel Emelyanov xemul at parallels.com
Fri Aug 22 08:26:52 PDT 2014


On 08/21/2014 01:41 PM, Andrew Vagin wrote:
> Each mountpoint belongs to a mount namespace, so we need to
> find a root of the mount namespace and open mountpoint
> ralative to this root.
> 
> The same logic is used in get_mark_path().
> 
> Signed-off-by: Andrew Vagin <avagin at openvz.org>

Would be nice to see the test of mounts' fanotifies get fixed too :)

> ---
>  fsnotify.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/fsnotify.c b/fsnotify.c
> index 77e3332..37c5cbc 100644
> --- a/fsnotify.c
> +++ b/fsnotify.c
> @@ -436,6 +436,7 @@ static int restore_one_fanotify(int fd, struct fsnotify_mark_info *mark)
>  
>  	if (fme->type == MARK_TYPE__MOUNT) {
>  		struct mount_info *m;
> +		int mntns_root;
>  
>  		m = lookup_mnt_id(fme->me->mnt_id);
>  		if (!m) {
> @@ -443,8 +444,17 @@ static int restore_one_fanotify(int fd, struct fsnotify_mark_info *mark)
>  			return -1;
>  		}
>  
> +		mntns_root = mntns_get_root_fd(m->nsid);
> +
> +		target = openat(mntns_root, m->mountpoint, O_PATH);
> +		if (target == -1) {
> +			pr_perror("Unable to open %s\n", m->mountpoint);
> +			goto err;
> +		}
> +
>  		flags |= FAN_MARK_MOUNT;
> -		path = m->mountpoint;
> +		snprintf(buf, sizeof(buf), "/proc/self/fd/%d", target);
> +		path = buf;
>  	} else if (fme->type == MARK_TYPE__INODE) {
>  		path = get_mark_path("fanotify", mark->remap,
>  				     fme->ie->f_handle, fme->ie->i_ino,
> 



More information about the CRIU mailing list