I don't think it's possible. Here's why. I took the naive approach, which was to add the pid of the process opening /dev/fuse
to the meta data that fuse creates at mount time, struct fuse_conn
. I then used that information to display a pid=
field in the mount command. The patch is really simple:
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 7354dc1..32b05ca 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -402,6 +402,9 @@ struct fuse_conn {
/** The group id for this mount */
kgid_t group_id;
+ /** The pid mounting process */
+ pid_t pid;
+
/** The fuse mount flags for this mount */
unsigned flags;
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index e8799c1..23a27be 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -554,6 +554,7 @@ static int fuse_show_options(struct seq_file *m, struct dentry *root)
struct super_block *sb = root->d_sb;
struct fuse_conn *fc = get_fuse_conn_super(sb);
+ seq_printf(m, ",pid=%u", fc->pid);
seq_printf(m, ",user_id=%u", from_kuid_munged(&init_user_ns, fc->user_id));
seq_printf(m, ",group_id=%u", from_kgid_munged(&init_user_ns, fc->group_id));
if (fc->flags & FUSE_DEFAULT_PERMISSIONS)
@@ -1042,6 +1043,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
fc->release = fuse_free_conn;
fc->flags = d.flags;
+ fc->pid = current->pid;
fc->user_id = d.user_id;
fc->group_id = d.group_id;
fc->max_read = max_t(unsigned, 4096, d.max_read);
def@fractal [6:37] ~/p/linux -- master
I booted the kernel, mounted sshfs, ran mount:
root@192.168.1.1:/tmp on /root/tmp type fuse.sshfs (rw,nosuid,nodev,relatime,pid=1549,user_id=0,group_id=0)
Success? Unfortunately, not:
root 1552 0.0 0.0 45152 332 ? Ssl 13:39 0:00 sshfs root@192.168.1.1:/tmp tmp
Then I realized: the remaining sshfs process is a child of the one that created the mount. It inherited from the fd. As fuse is implemented, we could have a multitude of processes inheriting from the fd. We could have the fd passed around in UNIX sockets, completely out of the original process tree.
We can obtain the 'who owns this TCP port' information, because sockets have this meta data, and simply parsing /proc tells us that information. Unfortunately, the fuse fd is a regular fd on /dev/fuse
. Unless that fd somehow becomes special, I don't see how this can be implemented.
/proc/mounts
has to be identical to the one you specify topidof
. My NTFS partitions have just (unfortunately) shown the naked truth: the driver shows up asfuseblk
in/proc/mounts
, whilst you have to usepidof
with/sbin/mount.ntfs
(i.e./bin/ntfs-3g
) to get the pids you want. This is far from unified, methinks, and too far to even think of parsing/proc/mounts
for driver names one might want to feed intopidof
. – syntaxerror Apr 26 '15 at 09:07