fatrace.c (fatrace-0.16.3) | : | fatrace.c (fatrace-0.17.0) | ||
---|---|---|---|---|
skipping to change at line 152 | skipping to change at line 152 | |||
get_fid_event_fd (const struct fanotify_event_metadata *data) | get_fid_event_fd (const struct fanotify_event_metadata *data) | |||
{ | { | |||
const struct fanotify_event_info_fid *fid = (const struct fanotify_event_inf o_fid *) (data + 1); | const struct fanotify_event_info_fid *fid = (const struct fanotify_event_inf o_fid *) (data + 1); | |||
int fd; | int fd; | |||
if (fid->hdr.info_type != FAN_EVENT_INFO_TYPE_FID) | if (fid->hdr.info_type != FAN_EVENT_INFO_TYPE_FID) | |||
errx (EXIT_FAILURE, "Received unexpected event info type %i", fid->hdr.i nfo_type); | errx (EXIT_FAILURE, "Received unexpected event info type %i", fid->hdr.i nfo_type); | |||
/* get affected file fd from fanotify_event_info_fid */ | /* get affected file fd from fanotify_event_info_fid */ | |||
fd = open_by_handle_at (get_mount_id ((const fsid_t *) &fid->fsid), | fd = open_by_handle_at (get_mount_id ((const fsid_t *) &fid->fsid), | |||
(struct file_handle *) fid->handle, O_RDONLY); | (struct file_handle *) fid->handle, O_RDONLY|O_NONBL OCK|O_LARGEFILE|O_PATH); | |||
/* ignore ESTALE for deleted fds between the notification and handling it */ | /* ignore ESTALE for deleted fds between the notification and handling it */ | |||
if (fd < 0 && errno != ESTALE) | if (fd < 0 && errno != ESTALE) | |||
warn ("open_by_handle_at"); | warn ("open_by_handle_at"); | |||
return fd; | return fd; | |||
} | } | |||
#else /* defined(FAN_REPORT_FID) */ | #else /* defined(FAN_REPORT_FID) */ | |||
#define add_fsid(...) | #define add_fsid(...) | |||
skipping to change at line 311 | skipping to change at line 311 | |||
snprintf (pathname, sizeof (pathname), "(deleted)"); | snprintf (pathname, sizeof (pathname), "(deleted)"); | |||
} | } | |||
/* print event */ | /* print event */ | |||
if (option_timestamp == 1) { | if (option_timestamp == 1) { | |||
strftime (printbuf, sizeof (printbuf), "%H:%M:%S", localtime (&event_tim e->tv_sec)); | strftime (printbuf, sizeof (printbuf), "%H:%M:%S", localtime (&event_tim e->tv_sec)); | |||
printf ("%s.%06li ", printbuf, event_time->tv_usec); | printf ("%s.%06li ", printbuf, event_time->tv_usec); | |||
} else if (option_timestamp == 2) { | } else if (option_timestamp == 2) { | |||
printf ("%li.%06li ", event_time->tv_sec, event_time->tv_usec); | printf ("%li.%06li ", event_time->tv_sec, event_time->tv_usec); | |||
} | } | |||
printf ("%s(%i): %s %s\n", procname[0] == '\0' ? "unknown" : procname, data- >pid, mask2str (data->mask), pathname); | printf ("%s(%i): %-3s %s\n", procname[0] == '\0' ? "unknown" : procname, dat a->pid, mask2str (data->mask), pathname); | |||
} | } | |||
static void | static void | |||
do_mark (int fan_fd, const char *dir, bool fatal) | do_mark (int fan_fd, const char *dir, bool fatal) | |||
{ | { | |||
int res; | int res; | |||
uint64_t mask = FAN_ACCESS | FAN_MODIFY | FAN_OPEN | FAN_CLOSE | FAN_ONDIR | FAN_EVENT_ON_CHILD; | uint64_t mask = FAN_ACCESS | FAN_MODIFY | FAN_OPEN | FAN_CLOSE | FAN_ONDIR | FAN_EVENT_ON_CHILD; | |||
#ifdef FAN_REPORT_FID | #ifdef FAN_REPORT_FID | |||
if (fid_mode) | if (fid_mode) | |||
skipping to change at line 381 | skipping to change at line 381 | |||
mounts = setmntent ("/proc/self/mounts", "r"); | mounts = setmntent ("/proc/self/mounts", "r"); | |||
if (mounts == NULL) | if (mounts == NULL) | |||
err (EXIT_FAILURE, "setmntent"); | err (EXIT_FAILURE, "setmntent"); | |||
while ((mount = getmntent (mounts)) != NULL) { | while ((mount = getmntent (mounts)) != NULL) { | |||
/* Only consider mounts which have an actual device or bind mount | /* Only consider mounts which have an actual device or bind mount | |||
* point. The others are stuff like proc, sysfs, binfmt_misc etc. which | * point. The others are stuff like proc, sysfs, binfmt_misc etc. which | |||
* are virtual and do not actually cause disk access. */ | * are virtual and do not actually cause disk access. */ | |||
if (mount->mnt_fsname == NULL || access (mount->mnt_fsname, F_OK) != 0 | | | if (mount->mnt_fsname == NULL || access (mount->mnt_fsname, F_OK) != 0 | | | |||
mount->mnt_fsname[0] != '/') { | mount->mnt_fsname[0] != '/') { | |||
debug ("ignore: fsname: %s dir: %s type: %s", mount->mnt_fsname, mou | /* zfs mount point don't start with a "/" so allow them anyway */ | |||
nt->mnt_dir, mount->mnt_type); | if (strcmp(mount->mnt_type, "zfs") != 0) { | |||
continue; | debug ("ignore: fsname: %s dir: %s type: %s", mount->mnt_fsname, | |||
mount->mnt_dir, mount->mnt_type); | ||||
continue; | ||||
} | ||||
} | } | |||
/* root dir already added above */ | /* root dir already added above */ | |||
if (strcmp (mount->mnt_dir, "/") == 0) | if (strcmp (mount->mnt_dir, "/") == 0) | |||
continue; | continue; | |||
debug ("add watch for %s mount %s", mount->mnt_type, mount->mnt_dir); | debug ("add watch for %s mount %s", mount->mnt_type, mount->mnt_dir); | |||
do_mark (fan_fd, mount->mnt_dir, false); | do_mark (fan_fd, mount->mnt_dir, false); | |||
add_fsid (mount->mnt_dir); | add_fsid (mount->mnt_dir); | |||
} | } | |||
End of changes. 3 change blocks. | ||||
5 lines changed or deleted | 8 lines changed or added |