Unverified Commit 08582d67 authored by Amir Goldstein's avatar Amir Goldstein Committed by Christian Brauner
Browse files

fs: create helper file_user_path() for user displayed mapped file path



Overlayfs uses backing files with "fake" overlayfs f_path and "real"
underlying f_inode, in order to use underlying inode aops for mapped
files and to display the overlayfs path in /proc/<pid>/maps.

In preparation for storing the overlayfs "fake" path instead of the
underlying "real" path in struct backing_file, define a noop helper
file_user_path() that returns f_path for now.

Use the new helper in procfs and kernel logs whenever a path of a
mapped file is displayed to users.

Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
Link: https://lore.kernel.org/r/20231009153712.1566422-3-amir73il@gmail.com


Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 83bc1d29
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -90,10 +90,12 @@ static void show_faulting_vma(unsigned long address)
	 */
	if (vma) {
		char buf[ARC_PATH_MAX];
		char *nm = "?";
		char *nm = "anon";

		if (vma->vm_file) {
			nm = file_path(vma->vm_file, buf, ARC_PATH_MAX-1);
			/* XXX: can we use %pD below and get rid of buf? */
			nm = d_path(file_user_path(vma->vm_file), buf,
				    ARC_PATH_MAX-1);
			if (IS_ERR(nm))
				nm = "?";
		}
+1 −1
Original line number Diff line number Diff line
@@ -2218,7 +2218,7 @@ static int map_files_get_link(struct dentry *dentry, struct path *path)
	rc = -ENOENT;
	vma = find_exact_vma(mm, vm_start, vm_end);
	if (vma && vma->vm_file) {
		*path = vma->vm_file->f_path;
		*path = *file_user_path(vma->vm_file);
		path_get(path);
		rc = 0;
	}
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)

	if (file) {
		seq_pad(m, ' ');
		seq_file_path(m, file, "");
		seq_path(m, file_user_path(file), "");
	}

	seq_putc(m, '\n');
+2 −2
Original line number Diff line number Diff line
@@ -296,7 +296,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma)
		if (anon_name)
			seq_printf(m, "[anon_shmem:%s]", anon_name->name);
		else
			seq_file_path(m, file, "\n");
			seq_path(m, file_user_path(file), "\n");
		goto done;
	}

@@ -1967,7 +1967,7 @@ static int show_numa_map(struct seq_file *m, void *v)

	if (file) {
		seq_puts(m, " file=");
		seq_file_path(m, file, "\n\t= ");
		seq_path(m, file_user_path(file), "\n\t= ");
	} else if (vma_is_initial_heap(vma)) {
		seq_puts(m, " heap");
	} else if (vma_is_initial_stack(vma)) {
+1 −1
Original line number Diff line number Diff line
@@ -157,7 +157,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma)

	if (file) {
		seq_pad(m, ' ');
		seq_file_path(m, file, "");
		seq_path(m, file_user_path(file), "");
	} else if (mm && vma_is_initial_stack(vma)) {
		seq_pad(m, ' ');
		seq_puts(m, "[stack]");
Loading