pidfs: add pidfs_root_path() helper
authorChristian Brauner <brauner@kernel.org>
Tue, 24 Jun 2025 08:29:07 +0000 (10:29 +0200)
committerChristian Brauner <brauner@kernel.org>
Tue, 24 Jun 2025 11:00:09 +0000 (13:00 +0200)
Allow to return the root of the global pidfs filesystem.

Link: https://lore.kernel.org/20250624-work-pidfs-fhandle-v2-4-d02a04858fe3@kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/internal.h
fs/pidfs.c

index 22ba066d1dbaf7cb4b84222b9df85538df1fc67f..ad256bccdc85caba3c56f791f01927249096b7f4 100644 (file)
@@ -353,3 +353,4 @@ int anon_inode_getattr(struct mnt_idmap *idmap, const struct path *path,
                       unsigned int query_flags);
 int anon_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
                       struct iattr *attr);
+void pidfs_get_root(struct path *path);
index 47f5f9e0bdffa5fcd8a977d20dc10abef11ba228..4fc7a7f4a3fefd4779c26bdcb0deea93bc5487a0 100644 (file)
 static struct kmem_cache *pidfs_attr_cachep __ro_after_init;
 static struct kmem_cache *pidfs_xattr_cachep __ro_after_init;
 
+static struct path pidfs_root_path = {};
+
+void pidfs_get_root(struct path *path)
+{
+       *path = pidfs_root_path;
+       path_get(path);
+}
+
 /*
  * Stashes information that userspace needs to access even after the
  * process has been reaped.
@@ -1068,4 +1076,7 @@ void __init pidfs_init(void)
        pidfs_mnt = kern_mount(&pidfs_type);
        if (IS_ERR(pidfs_mnt))
                panic("Failed to mount pidfs pseudo filesystem");
+
+       pidfs_root_path.mnt = pidfs_mnt;
+       pidfs_root_path.dentry = pidfs_mnt->mnt_root;
 }