Skip to contentSkip to conversation

fs: fuse: add more information to fdinfo

PATCH In review Chen Linxuan 2 participants 4 messages May 11, 2025 – May 15, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 fs: fuse: add more information to fdinfo

This commit add fuse connection device id to
fdinfo of opened fuse files.

Related discussions can be found at links below.

---
 fs/fuse/file.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/fuse/file.c +11 -0
index 754378dd9f715..a34fec685d3db 100644
@@ -3392,6 +3392,14 @@ static ssize_t fuse_copy_file_range(struct file *src_file, loff_t src_off,
 	return ret;
 }
 
+static void fuse_file_show_fdinfo(struct seq_file *seq, struct file *f)
+{
+	struct fuse_file *ff = f->private_data;
+	struct fuse_conn *fc = ff->fm->fc;
+
+	seq_printf(seq, "fuse conn:%u\n", fc->dev);
+}
+
 static const struct file_operations fuse_file_operations = {
 	.llseek		= fuse_file_llseek,
 	.read_iter	= fuse_file_read_iter,
@@ -3411,6 +3419,9 @@ static const struct file_operations fuse_file_operations = {
 	.poll		= fuse_file_poll,
 	.fallocate	= fuse_file_fallocate,
 	.copy_file_range = fuse_copy_file_range,
+#ifdef CONFIG_PROC_FS
+	.show_fdinfo	= fuse_file_show_fdinfo,
+#endif
 };
 
 static const struct address_space_operations fuse_file_aops  = {
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 3 lines · Chen Linxuan

This commit add fuse connection device id to
fdinfo of opened fuse files.

What I meant is adding this to fuse_dev_operations.

Thanks,
Miklos

#2 lore raw
Quoted 1 line · Miklos Szeredi

What I meant is adding this to fuse_dev_operations.

But it doesn't seem like exposing this information here would be a bad idea either, does it?
For example, if a system administrator wants to write a script to abort the FUSE connection
corresponding to a specific directory,
the script could use this information to locate the relevant connection.

Thanks,
Chen Linxuan

#3 lore raw
Quoted 6 lines · Chen Linxuan

But it doesn't seem like exposing this information here would be a bad idea either, does it?
For example, if a system administrator wants to write a script to abort the FUSE connection
corresponding to a specific directory,
the script could use this information to locate the relevant connection.

Oh I see I can get connection id via .st_dev from stat(2)