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;