[CRIU] [PATCH] Fix AUFS pathname handling when branch is not exposed

Saied Kazemi saied at google.com
Fri Jan 16 12:33:24 PST 2015


The code that fixes up AUFS pathnames associated with vma entries (see
commit d8b41b6525) should handle cases where an entry does not expose
the branch pathname (e.g., pointing to a device like /dev/zero).

Signed-off-by: Saied Kazemi <saied at google.com>
---
 sysfs_parse.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/sysfs_parse.c b/sysfs_parse.c
index 771a236..8e236e9 100644
--- a/sysfs_parse.c
+++ b/sysfs_parse.c
@@ -272,6 +272,7 @@ err:
  */
 int fixup_aufs_vma_fd(struct vma_area *vma)
 {
+	char *file;
 	char path[PATH_MAX];
 	int len;
 
@@ -284,7 +285,15 @@ int fixup_aufs_vma_fd(struct vma_area *vma)
 	if (len < 0)
 		return -1;
 
-	if (len > 0) {
+	if (len == 0) {
+		/*
+		 * The vma is associated with a map_files entry
+		 * that does not expose the branch pathname
+		 * (e.g., /dev/zero).  In this case, we can use
+		 * the path.
+		 */
+		file = &path[1];
+	} else {
 		vma->aufs_rpath = xmalloc(len + 2);
 		if (!vma->aufs_rpath)
 			return -1;
@@ -297,9 +306,10 @@ int fixup_aufs_vma_fd(struct vma_area *vma)
 			sprintf(vma->aufs_fpath, "%s/%s", opts.root, &path[2]);
 		}
 		pr_debug("Saved AUFS paths %s and %s\n", vma->aufs_rpath, vma->aufs_fpath);
+		file = vma->aufs_fpath;
 	}
 
-	if (stat(vma->aufs_fpath, vma->vmst) < 0) {
+	if (stat(file, vma->vmst) < 0) {
 		pr_perror("Failed stat on map %"PRIx64" (%s)",
 				vma->e->start, vma->aufs_fpath);
 		return -1;
-- 
2.2.0.rc0.207.ga3a616c



More information about the CRIU mailing list