Skip to content

Commit 0ce7c12

Browse files
bobrikgregkh
authored andcommittedAug 5, 2023
kernfs: attach uuid for every kernfs and report it in fsid
The following two commits added the same thing for tmpfs: * commit 2b4db79 ("tmpfs: generate random sb->s_uuid") * commit 59cda49 ("shmem: allow reporting fanotify events with file handles on tmpfs") Having fsid allows using fanotify, which is especially handy for cgroups, where one might be interested in knowing when they are created or removed. Signed-off-by: Ivan Babrou <ivan@cloudflare.com> Acked-by: Jan Kara <jack@suse.cz> Acked-by: Christian Brauner <brauner@kernel.org> Link: https://lore.kernel.org/r/20230731184731.64568-1-ivan@cloudflare.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 79038a9 commit 0ce7c12

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed
 

‎fs/kernfs/mount.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <linux/namei.h>
1717
#include <linux/seq_file.h>
1818
#include <linux/exportfs.h>
19+
#include <linux/uuid.h>
20+
#include <linux/statfs.h>
1921

2022
#include "kernfs-internal.h"
2123

@@ -45,8 +47,15 @@ static int kernfs_sop_show_path(struct seq_file *sf, struct dentry *dentry)
4547
return 0;
4648
}
4749

50+
static int kernfs_statfs(struct dentry *dentry, struct kstatfs *buf)
51+
{
52+
simple_statfs(dentry, buf);
53+
buf->f_fsid = uuid_to_fsid(dentry->d_sb->s_uuid.b);
54+
return 0;
55+
}
56+
4857
const struct super_operations kernfs_sops = {
49-
.statfs = simple_statfs,
58+
.statfs = kernfs_statfs,
5059
.drop_inode = generic_delete_inode,
5160
.evict_inode = kernfs_evict_inode,
5261

@@ -351,6 +360,8 @@ int kernfs_get_tree(struct fs_context *fc)
351360
}
352361
sb->s_flags |= SB_ACTIVE;
353362

363+
uuid_gen(&sb->s_uuid);
364+
354365
down_write(&root->kernfs_supers_rwsem);
355366
list_add(&info->node, &info->root->supers);
356367
up_write(&root->kernfs_supers_rwsem);

0 commit comments

Comments
 (0)