Unverified Commit 56c94c62 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Christian Brauner
Browse files

namespace: extract show_path() helper



To be used by the statmount(2) syscall as well.

Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
Link: https://lore.kernel.org/r/20231025140205.3586473-4-mszeredi@redhat.com


Reviewed-by: default avatarIan Kent <raven@themaw.net>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 2eea9ce4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -83,6 +83,8 @@ int path_mount(const char *dev_name, struct path *path,
		const char *type_page, unsigned long flags, void *data_page);
int path_umount(struct path *path, int flags);

int show_path(struct seq_file *m, struct dentry *root);

/*
 * fs_struct.c
 */
+9 −0
Original line number Diff line number Diff line
@@ -4674,6 +4674,15 @@ SYSCALL_DEFINE5(mount_setattr, int, dfd, const char __user *, path,
	return err;
}

int show_path(struct seq_file *m, struct dentry *root)
{
	if (root->d_sb->s_op->show_path)
		return root->d_sb->s_op->show_path(m, root);

	seq_dentry(m, root, " \t\n\\");
	return 0;
}

static void __init init_mount_tree(void)
{
	struct vfsmount *mnt;
+3 −7
Original line number Diff line number Diff line
@@ -142,13 +142,9 @@ static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt)

	seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id,
		   MAJOR(sb->s_dev), MINOR(sb->s_dev));
	if (sb->s_op->show_path) {
		err = sb->s_op->show_path(m, mnt->mnt_root);
	err = show_path(m, mnt->mnt_root);
	if (err)
		goto out;
	} else {
		seq_dentry(m, mnt->mnt_root, " \t\n\\");
	}
	seq_putc(m, ' ');

	/* mountpoints outside of chroot jail will give SEQ_SKIP on this */