mirror of https://github.com/mkerrisk/man-pages
fanotify.7: tfix
Signed-off-by: Jakub Wilk <jwilk@jwilk.net> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
07b973b2f3
commit
8f397fb4a1
|
@ -927,7 +927,7 @@ and waits until an event of type
|
||||||
.B FAN_CREATE
|
.B FAN_CREATE
|
||||||
has occurred.
|
has occurred.
|
||||||
The event mask indicates which type of filesystem object\(emeither
|
The event mask indicates which type of filesystem object\(emeither
|
||||||
a file or a directory\(emwas created".
|
a file or a directory\(emwas created.
|
||||||
Once all events have been read from the buffer and processed accordingly,
|
Once all events have been read from the buffer and processed accordingly,
|
||||||
the program simply terminates.
|
the program simply terminates.
|
||||||
.PP
|
.PP
|
||||||
|
@ -1008,7 +1008,7 @@ main(int argc, char **argv)
|
||||||
struct fanotify_event_info_fid *fid;
|
struct fanotify_event_info_fid *fid;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
fprintf(stderr, "Invalid number of command line arguments.\e\n");
|
fprintf(stderr, "Invalid number of command line arguments.\en");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1031,7 +1031,7 @@ main(int argc, char **argv)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Listening for events.\e\n");
|
printf("Listening for events.\en");
|
||||||
|
|
||||||
/* Read events from the event queue into a buffer */
|
/* Read events from the event queue into a buffer */
|
||||||
|
|
||||||
|
@ -1047,22 +1047,22 @@ main(int argc, char **argv)
|
||||||
FAN_EVENT_OK(metadata, len);
|
FAN_EVENT_OK(metadata, len);
|
||||||
metadata = FAN_EVENT_NEXT(metadata, len)) {
|
metadata = FAN_EVENT_NEXT(metadata, len)) {
|
||||||
fid = (struct fanotify_event_info_fid *) (metadata + 1);
|
fid = (struct fanotify_event_info_fid *) (metadata + 1);
|
||||||
file_handle = (struct file_handle *) fid->handle;
|
file_handle = (struct file_handle *) fid\->handle;
|
||||||
|
|
||||||
/* Ensure that the event info is of the correct type */
|
/* Ensure that the event info is of the correct type */
|
||||||
|
|
||||||
if (fid->hdr.info_type != FAN_EVENT_INFO_TYPE_FID) {
|
if (fid\->hdr.info_type != FAN_EVENT_INFO_TYPE_FID) {
|
||||||
fprintf(stderr, "Received unexpected event info type.\e\n");
|
fprintf(stderr, "Received unexpected event info type.\en");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metadata->mask == FAN_CREATE)
|
if (metadata\->mask == FAN_CREATE)
|
||||||
printf("FAN_CREATE (file created):");
|
printf("FAN_CREATE (file created):");
|
||||||
|
|
||||||
if (metadata->mask == FAN_CREATE | FAN_ONDIR)
|
if (metadata\->mask == FAN_CREATE | FAN_ONDIR)
|
||||||
printf("FAN_CREATE | FAN_ONDIR (subdirectory created):");
|
printf("FAN_CREATE | FAN_ONDIR (subdirectory created):");
|
||||||
|
|
||||||
/* metadata->fd is set to FAN_NOFD when FAN_REPORT_FID is enabled.
|
/* metadata\->fd is set to FAN_NOFD when FAN_REPORT_FID is enabled.
|
||||||
To obtain a file descriptor for the file object corresponding to
|
To obtain a file descriptor for the file object corresponding to
|
||||||
an event you can use the struct file_handle that\(aqs provided
|
an event you can use the struct file_handle that\(aqs provided
|
||||||
within the fanotify_event_info_fid in conjunction with the
|
within the fanotify_event_info_fid in conjunction with the
|
||||||
|
@ -1074,7 +1074,7 @@ main(int argc, char **argv)
|
||||||
if (ret == \-1) {
|
if (ret == \-1) {
|
||||||
if (errno == ESTALE) {
|
if (errno == ESTALE) {
|
||||||
printf("File handle is no longer valid. "
|
printf("File handle is no longer valid. "
|
||||||
"File has been deleted\e\n");
|
"File has been deleted\en");
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
perror("open_by_handle_at");
|
perror("open_by_handle_at");
|
||||||
|
@ -1093,15 +1093,15 @@ main(int argc, char **argv)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
path[path_len] = \(aq\e\0\(aq;
|
path[path_len] = \(aq\e0\(aq;
|
||||||
printf("\etDirectory \(aq%s\(aq has been modified.\e\n", path);
|
printf("\etDirectory \(aq%s\(aq has been modified.\en", path);
|
||||||
|
|
||||||
/* Close associated file descriptor for this event */
|
/* Close associated file descriptor for this event */
|
||||||
|
|
||||||
close(event_fd);
|
close(event_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("All events processed successfully. Program exiting.\e\n");
|
printf("All events processed successfully. Program exiting.\en");
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
.EE
|
.EE
|
||||||
|
|
Loading…
Reference in New Issue