From 490ca718662f97f8d8df2debe8fdedbc98a0e6cf Mon Sep 17 00:00:00 2001 From: Saied Kazemi Date: Mon, 19 Jan 2015 13:05:12 +0300 Subject: [PATCH] Fix AUFS pathname handling when branch is not exposed 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 Signed-off-by: Pavel Emelyanov --- sysfs_parse.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sysfs_parse.c b/sysfs_parse.c index 771a23601..8e236e923 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;