Skip to content

Commit c4b7ed6

Browse files
black-deskopsiff
authored andcommitted
fs: fuse: add dev id to /dev/fuse fdinfo
[ Upstream commit f092229 ] This commit add fuse connection device id to fdinfo of opened /dev/fuse files. Related discussions can be found at links below. Link: https://lore.kernel.org/all/CAJfpegvEYUgEbpATpQx8NqVR33Mv-VK96C+gbTag1CEUeBqvnA@mail.gmail.com/ Signed-off-by: Chen Linxuan <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]> [ Backport from v6.16 ] Signed-off-by: WangYuli <[email protected]>
1 parent 7521109 commit c4b7ed6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

fs/fuse/dev.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/swap.h>
2222
#include <linux/splice.h>
2323
#include <linux/sched.h>
24+
#include <linux/seq_file.h>
2425

2526
MODULE_ALIAS_MISCDEV(FUSE_MINOR);
2627
MODULE_ALIAS("devname:fuse");
@@ -2292,6 +2293,17 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd,
22922293
return res;
22932294
}
22942295

2296+
#ifdef CONFIG_PROC_FS
2297+
static void fuse_dev_show_fdinfo(struct seq_file *seq, struct file *file)
2298+
{
2299+
struct fuse_dev *fud = fuse_get_dev(file);
2300+
if (!fud)
2301+
return;
2302+
2303+
seq_printf(seq, "fuse_connection:\t%u\n", fud->fc->dev);
2304+
}
2305+
#endif
2306+
22952307
const struct file_operations fuse_dev_operations = {
22962308
.owner = THIS_MODULE,
22972309
.open = fuse_dev_open,
@@ -2305,6 +2317,9 @@ const struct file_operations fuse_dev_operations = {
23052317
.fasync = fuse_dev_fasync,
23062318
.unlocked_ioctl = fuse_dev_ioctl,
23072319
.compat_ioctl = compat_ptr_ioctl,
2320+
#ifdef CONFIG_PROC_FS
2321+
.show_fdinfo = fuse_dev_show_fdinfo,
2322+
#endif
23082323
};
23092324
EXPORT_SYMBOL_GPL(fuse_dev_operations);
23102325

0 commit comments

Comments
 (0)