]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
namespace: extract show_path() helper
authorMiklos Szeredi <mszeredi@redhat.com>
Wed, 25 Oct 2023 14:02:01 +0000 (16:02 +0200)
committerChristian Brauner <brauner@kernel.org>
Sat, 18 Nov 2023 13:56:16 +0000 (14:56 +0100)
To be used by the statmount(2) syscall as well.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Link: https://lore.kernel.org/r/20231025140205.3586473-4-mszeredi@redhat.com
Reviewed-by: Ian Kent <raven@themaw.net>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/internal.h
fs/namespace.c
fs/proc_namespace.c

index 58e43341aebf07d92245f789fd1cdf8d5415cebd..16bfe50747c68abf5f241b20813d2a7ee01335f5 100644 (file)
@@ -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
  */
index bbe94096e26216116e918759702818163949a16a..d3665d025acb86d68fad7fb01fd740f50efabe0d 100644 (file)
@@ -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;
index 73d2274d5f59cf007be0aa2d59056dfe2e324578..0a808951b7d3709bf659974d8389342265c6ad5c 100644 (file)
@@ -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);
-               if (err)
-                       goto out;
-       } else {
-               seq_dentry(m, mnt->mnt_root, " \t\n\\");
-       }
+       err = show_path(m, mnt->mnt_root);
+       if (err)
+               goto out;
        seq_putc(m, ' ');
 
        /* mountpoints outside of chroot jail will give SEQ_SKIP on this */