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

Andrew Vagin avagin at openvz.org
Thu Aug 21 02:41:42 PDT 2014


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>
---
 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,
-- 
1.9.3



More information about the CRIU mailing list