fsnotify: Support FS_ERROR event type

Expose a new type of fsnotify event for filesystems to report errors for
userspace monitoring tools.  fanotify will send this type of
notification for FAN_FS_ERROR events.  This also introduce a helper for
generating the new event.

Link: https://lore.kernel.org/r/20211025192746.66445-18-krisman@collabora.com
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
Gabriel Krisman Bertazi
2021-10-25 16:27:32 -03:00
committed by Jan Kara
parent 4fe595cf1c
commit 9daa811073
2 changed files with 44 additions and 1 deletions

View File

@@ -339,4 +339,17 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
fsnotify_dentry(dentry, mask);
}
static inline int fsnotify_sb_error(struct super_block *sb, struct inode *inode,
int error)
{
struct fs_error_report report = {
.error = error,
.inode = inode,
.sb = sb,
};
return fsnotify(FS_ERROR, &report, FSNOTIFY_EVENT_ERROR,
NULL, NULL, NULL, 0);
}
#endif /* _LINUX_FS_NOTIFY_H */