Skip to content

Commit f092229

Browse files
black-deskMiklos Szeredi
authored andcommitted
fs: fuse: add dev id to /dev/fuse fdinfo
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]>
1 parent 18ee43c commit f092229

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
@@ -23,6 +23,7 @@
2323
#include <linux/swap.h>
2424
#include <linux/splice.h>
2525
#include <linux/sched.h>
26+
#include <linux/seq_file.h>
2627

2728
#define CREATE_TRACE_POINTS
2829
#include "fuse_trace.h"
@@ -2618,6 +2619,17 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd,
26182619
}
26192620
}
26202621

2622+
#ifdef CONFIG_PROC_FS
2623+
static void fuse_dev_show_fdinfo(struct seq_file *seq, struct file *file)
2624+
{
2625+
struct fuse_dev *fud = fuse_get_dev(file);
2626+
if (!fud)
2627+
return;
2628+
2629+
seq_printf(seq, "fuse_connection:\t%u\n", fud->fc->dev);
2630+
}
2631+
#endif
2632+
26212633
const struct file_operations fuse_dev_operations = {
26222634
.owner = THIS_MODULE,
26232635
.open = fuse_dev_open,
@@ -2633,6 +2645,9 @@ const struct file_operations fuse_dev_operations = {
26332645
#ifdef CONFIG_FUSE_IO_URING
26342646
.uring_cmd = fuse_uring_cmd,
26352647
#endif
2648+
#ifdef CONFIG_PROC_FS
2649+
.show_fdinfo = fuse_dev_show_fdinfo,
2650+
#endif
26362651
};
26372652
EXPORT_SYMBOL_GPL(fuse_dev_operations);
26382653

0 commit comments

Comments
 (0)