From: Amir Goldstein Date: Mon, 22 Mar 2021 17:39:44 +0000 (+0200) Subject: shmem: allow reporting fanotify events with file handles on tmpfs X-Git-Tag: howlett/maple/20220722_2~3261^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=59cda49ecf6c9a32fae4942420701b6e087204f6;p=users%2Fjedix%2Flinux-maple.git shmem: allow reporting fanotify events with file handles on tmpfs Since kernel v5.1, fanotify_init(2) supports the flag FAN_REPORT_FID for identifying objects using file handle and fsid in events. fanotify_mark(2) fails with -ENODEV when trying to set a mark on filesystems that report null f_fsid in stasfs(2). Use the digest of uuid as f_fsid for tmpfs to uniquely identify tmpfs objects as best as possible and allow setting an fanotify mark that reports events with file handles on tmpfs. Link: https://lore.kernel.org/r/20210322173944.449469-3-amir73il@gmail.com Acked-by: Hugh Dickins Reviewed-by: Christian Brauner Signed-off-by: Amir Goldstein Signed-off-by: Jan Kara --- diff --git a/mm/shmem.c b/mm/shmem.c index b2db4ed0fbc7..162d8f8993bb 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2846,6 +2846,9 @@ static int shmem_statfs(struct dentry *dentry, struct kstatfs *buf) buf->f_ffree = sbinfo->free_inodes; } /* else leave those fields 0 like simple_statfs */ + + buf->f_fsid = uuid_to_fsid(dentry->d_sb->s_uuid.b); + return 0; }