예제 #1
0
/*
 * AUFS support to compensate for the kernel bug
 * exposing branch pathnames in map_files.
 *
 * If the link points inside a branch, save the
 * relative pathname from the root of the mount
 * namespace as well as the full pathname from
 * globl root (/) for later use in dump_filemap()
 * and parse_smaps().
 */
int fixup_aufs_vma_fd(struct vma_area *vma)
{
	char path[PATH_MAX];
	int len;

	path[0] = '.';
	len = read_fd_link(vma->vm_file_fd, &path[1], sizeof path - 1);
	if (len < 0)
		return -1;

	len = fixup_aufs_path(&path[1], sizeof path - 1);
	if (len < 0)
		return -1;

	if (len > 0) {
		vma->aufs_rpath = xmalloc(len + 2);
		if (!vma->aufs_rpath)
			return -1;
		strcpy(vma->aufs_rpath, path);
		if (opts.root) {
			vma->aufs_fpath = xmalloc(strlen(opts.root) + 1 + len + 1);
			if (!vma->aufs_fpath)
				return -1;
			/* skip ./ in path */
			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);
	}

	return 0;
}
예제 #2
0
파일: sysfs_parse.c 프로젝트: 8472/criu
/*
 * AUFS support to compensate for the kernel bug
 * exposing branch pathnames in map_files and providing
 * a wrong mnt_id value in /proc/<pid>/fdinfo/<fd>.
 *
 * If the link points inside a branch, save the
 * relative pathname from the root of the mount
 * namespace as well as the full pathname from
 * globl root (/) for later use in dump_filemap()
 * and parse_smaps().
 */
int fixup_aufs_vma_fd(struct vma_area *vma)
{
	char path[PATH_MAX];
	int len;

	path[0] = '.';
	len = read_fd_link(vma->vm_file_fd, &path[1], sizeof path - 1);
	if (len < 0)
		return -1;

	len = fixup_aufs_path(&path[1], sizeof path - 1);
	if (len <= 0)
		return len;

	vma->aufs_rpath = xmalloc(len + 2);
	if (!vma->aufs_rpath)
		return -1;

	strcpy(vma->aufs_rpath, path);
	if (opts.root) {
		/* skip ./ in path */
		vma->aufs_fpath = xsprintf("%s/%s", opts.root, &path[2]);
		if (!vma->aufs_fpath)
			return -1;
	}
	pr_debug("Saved AUFS paths %s and %s\n", vma->aufs_rpath, vma->aufs_fpath);

	if (stat(vma->aufs_fpath, vma->vmst) < 0) {
		pr_perror("Failed stat on map %"PRIx64" (%s)",
				vma->e->start, vma->aufs_fpath);
		return -1;
	}

	/* tell parse_smap() not to call get_fd_mntid() */
	vma->mnt_id = -1;
	return len;
}