Skip to content

Commit

Permalink
Turn invalid FID type error into warning
Browse files Browse the repository at this point in the history
In some conditions, `fanotify_event_info_fid.info_type` is something
invalid, and fatrace exited with

> fatrace: Received unexpected event info type 64

Turn that into a warning, so that only the wrong event is ignored.

Fixes #30
  • Loading branch information
martinpitt committed Jan 19, 2025
1 parent 12b9db2 commit f6819d1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fatrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ get_fid_event_fd (const struct fanotify_event_metadata *data)
const struct fanotify_event_info_fid *fid = (const struct fanotify_event_info_fid *) (data + 1);
int fd;

if (fid->hdr.info_type != FAN_EVENT_INFO_TYPE_FID)
errx (EXIT_FAILURE, "Received unexpected event info type %i", fid->hdr.info_type);
if (fid->hdr.info_type != FAN_EVENT_INFO_TYPE_FID) {
warnx ("Received unexpected event info type %i, cannot get affected file", fid->hdr.info_type);
return -1;
}

/* get affected file fd from fanotify_event_info_fid */
fd = open_by_handle_at (get_mount_id ((const fsid_t *) &fid->fsid),
Expand Down

0 comments on commit f6819d1

Please sign in to comment.