Skip to content

Commit 32a0a96

Browse files
committed
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>
1 parent 55d4860 commit 32a0a96

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

fs/proc/internal.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,16 @@ static inline void pde_force_lookup(struct proc_dir_entry *pde)
349349
/* /proc/net/ entries can be changed under us by setns(CLONE_NEWNET) */
350350
pde->proc_dops = &proc_net_dentry_ops;
351351
}
352+
353+
/*
354+
* Add a new procfs dentry that can't serve as a mountpoint. That should
355+
* encompass anything that is ephemeral and can just disappear while the
356+
* process is still around.
357+
*/
358+
static inline struct dentry *proc_splice_unmountable(struct inode *inode,
359+
struct dentry *dentry, const struct dentry_operations *d_ops)
360+
{
361+
d_set_d_op(dentry, d_ops);
362+
dont_mount(dentry);
363+
return d_splice_alias(inode, dentry);
364+
}

0 commit comments

Comments
 (0)