Skip to content

Commit a0d8051

Browse files
committed
pidfs: add pidfs_root_path() helper
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>
1 parent f7be8a3 commit a0d8051

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

fs/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,3 +353,4 @@ int anon_inode_getattr(struct mnt_idmap *idmap, const struct path *path,
353353
unsigned int query_flags);
354354
int anon_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
355355
struct iattr *attr);
356+
void pidfs_get_root(struct path *path);

fs/pidfs.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@
3131
static struct kmem_cache *pidfs_attr_cachep __ro_after_init;
3232
static struct kmem_cache *pidfs_xattr_cachep __ro_after_init;
3333

34+
static struct path pidfs_root_path = {};
35+
36+
void pidfs_get_root(struct path *path)
37+
{
38+
*path = pidfs_root_path;
39+
path_get(path);
40+
}
41+
3442
/*
3543
* Stashes information that userspace needs to access even after the
3644
* process has been reaped.
@@ -1068,4 +1076,7 @@ void __init pidfs_init(void)
10681076
pidfs_mnt = kern_mount(&pidfs_type);
10691077
if (IS_ERR(pidfs_mnt))
10701078
panic("Failed to mount pidfs pseudo filesystem");
1079+
1080+
pidfs_root_path.mnt = pidfs_mnt;
1081+
pidfs_root_path.dentry = pidfs_mnt->mnt_root;
10711082
}

0 commit comments

Comments
 (0)