summaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2024-08-06 18:02:29 +0200
committerChristian Brauner <brauner@kernel.org>2024-08-30 08:22:12 +0200
commit32a0a965b8a5b7b505babae2ee10c513ede376d8 (patch)
tree71e667e1eded96058def71615c50024504d887ad /fs/proc
parentproc: proc_readfdinfo() -> proc_fdinfo_iterate() (diff)
downloadlinux-32a0a965b8a5b7b505babae2ee10c513ede376d8.tar.xz
linux-32a0a965b8a5b7b505babae2ee10c513ede376d8.zip
proc: add proc_splice_unmountable()
Add a tiny procfs helper to splice a dentry that cannot be mounted upon. Link: https://lore.kernel.org/r/20240806-work-procfs-v1-3-fb04e1d09f0c@kernel.org Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/internal.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index a8a8576d8592..9e3f25e4c188 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -349,3 +349,16 @@ static inline void pde_force_lookup(struct proc_dir_entry *pde)
/* /proc/net/ entries can be changed under us by setns(CLONE_NEWNET) */
pde->proc_dops = &proc_net_dentry_ops;
}
+
+/*
+ * Add a new procfs dentry that can't serve as a mountpoint. That should
+ * encompass anything that is ephemeral and can just disappear while the
+ * process is still around.
+ */
+static inline struct dentry *proc_splice_unmountable(struct inode *inode,
+ struct dentry *dentry, const struct dentry_operations *d_ops)
+{
+ d_set_d_op(dentry, d_ops);
+ dont_mount(dentry);
+ return d_splice_alias(inode, dentry);
+}