test/fsnotify: only test on regular files
Doesn't trigger on all file types, skip the test unless it's a regular
file.
#include <unistd.h>
#include <fcntl.h>
#include <sys/fanotify.h>
+#include <sys/stat.h>
#include <sys/wait.h>
#include "liburing.h"
@@ -19,6 +20,7 @@ int main(int argc, char *argv[])
struct io_uring ring;
int fan, ret, fd, err;
char fname[64], *f;
+ struct stat sb;
void *buf;
fan = fanotify_init(FAN_CLASS_NOTIF|FAN_CLASS_CONTENT, 0);
@@ -46,6 +48,16 @@ int main(int argc, char *argv[])
goto out;
}
+ if (fstat(fd, &sb) < 0) {
+ perror("fstat");
+ goto out;
+ }
+ if ((sb.st_mode & S_IFMT) != S_IFREG) {
+ err = T_EXIT_SKIP;
+ close(fd);
+ goto out;
+ }
+
ret = fanotify_mark(fan, FAN_MARK_ADD, FAN_ACCESS|FAN_MODIFY, fd, NULL);
if (ret < 0) {
perror("fanotify_mark");
