With "strong typed" events a correctly written program needs to use the new macros FAN_EVENT_MATCH() FAN_EVENT_MASK_MATCH() to match the reported event mask in the scope of the watcher type. Signed-off-by: Amir Goldstein --- include/uapi/linux/fanotify.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/uapi/linux/fanotify.h b/include/uapi/linux/fanotify.h index 0744b6770b43d..1f9a33d21c03d 100644 --- a/include/uapi/linux/fanotify.h +++ b/include/uapi/linux/fanotify.h @@ -14,6 +14,11 @@ #define FAN_EVENT_TYPE(mask) \ (((mask) & FAN_EVENT_TYPE_MASK) >> FAN_EVENT_TYPE_SHIFT) +/* Match event mask to any event in @event_set of the same watcher type */ +#define FAN_EVENT_MASK_MATCH(mask, event_set) \ + (FAN_EVENT_TYPE(mask) == FAN_EVENT_TYPE(event_set) && \ + ((mask) & (event_set) & ~FAN_EVENT_TYPE_MASK)) + /* * Events that user-space can request when watching filesystems */ @@ -296,4 +301,8 @@ struct fanotify_response_info_audit_rule { (long)(meta)->event_len >= (long)FAN_EVENT_METADATA_LEN && \ (long)(meta)->event_len <= (long)(len)) +/* Was one of the events in @event_set reported in the event? */ +#define FAN_EVENT_MATCH(meta, event_set) \ + FAN_EVENT_MASK_MATCH((meta)->mask, event_set) + #endif /* _UAPI_LINUX_FANOTIFY_H */ -- 2.55.0