History

fanotify: copy event fid info to user

If group requested FAN_REPORT_FID and event has file identifier, copy that information to user reading the event after event metadata. fid information is formatted as struct fanotify_event_info_fid that includes a generic header struct fanotify_event_info_header, so that other info types could be defined in the future using the same header. metadata->event_len includes the length of the fid information. The fid information includes the filesystem's fsid (see statfs(2)) followed by an NFS file handle of the file that could be passed as an argument to open_by_handle_at(2).

Amir Goldstein committed 7 years ago

Commit 5e469c81 parent e9e0c893 files · +102 −5Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/fanotify.h+20−0
@@ -107,6 +107,26 @@ struct fanotify_event_metadata { · 106 unmodified lines
107107 __s32 pid;
108108 };
109109
110+#define FAN_EVENT_INFO_TYPE_FID 1
111+
112+/* Variable length info record following event metadata */
113+struct fanotify_event_info_header {
114+ __u8 info_type;
115+ __u8 pad;
116+ __u16 len;
117+};
118+
119+/* Unique file identifier info record */
120+struct fanotify_event_info_fid {
121+ struct fanotify_event_info_header hdr;
122+ __kernel_fsid_t fsid;
123+ /*
124+ * Following is an opaque struct file_handle that can be passed as
125+ * an argument to open_by_handle_at(2).
126+ */
127+ unsigned char handle[0];
128+};
129+
110130 struct fanotify_response {
111131 __s32 fd;
112132 __u32 response;