Commits

Eric Radman committed 433bbd1

Define NOTE_ALL for event registration/removal. Changed description for the 1.6 release

  • Participants
  • Parent commits ab30682

Comments (0)

Files changed (2)

 Releases History
 ----------------
 
-1.6 Respond to RENAME and LINK events _2012-08-10_
+1.6 Works with NFS mounts on Linux _2012-08-10_
 
 1.5 Support interactive applications by opening a TTY _2012-07-29_
 
 void watch_loop(int, int, char *[]);
 void handle_sigint(int sig);
 
+/* events to watch for */
+
+/* Surprisingly, Linux NFS mounts send RENAME and LINK events */
+#define NOTE_ALL NOTE_DELETE|NOTE_WRITE|NOTE_EXTEND|NOTE_RENAME|NOTE_LINK
+
 /* the program */
 
 int
 	if (file->fd == -1)
 		err(errno, "cannot open `%s'", file->fn);
 
-	EV_SET(&evSet, file->fd, EVFILT_VNODE, EV_ADD | EV_CLEAR,
-		NOTE_DELETE|NOTE_WRITE|NOTE_EXTEND|NOTE_RENAME|NOTE_LINK, 0, file);
+	EV_SET(&evSet, file->fd, EVFILT_VNODE, EV_ADD | EV_CLEAR, NOTE_ALL, 0,
+		file);
 	if (kevent(kq, &evSet, 1, NULL, 0, NULL) == -1)
 		err(1, "failed to register VNODE event");
 }
 		if (nev == -1)
 			warnx("kevent error");
 		for (i=0; i<nev; i++) {
+			#ifdef DEBUG
+			fprintf(stderr, "event %d/%d: 0x%x\n", i+1, nev, evList[i].fflags);
+			#endif
 			file = (watch_file_t *)evList[i].udata;
 			if (evList[i].fflags & NOTE_DELETE ||
 				evList[i].fflags & NOTE_WRITE || evList[i].fflags & NOTE_EXTEND) {
 		for (i=0; i<nev; i++) {
 			file = (watch_file_t *)evList[i].udata;
 			if (evList[i].fflags & NOTE_DELETE) {
-				EV_SET(&evSet, file->fd, EVFILT_VNODE, EV_DELETE,
-					NOTE_DELETE|NOTE_WRITE|NOTE_EXTEND, 0, file);
+				EV_SET(&evSet, file->fd, EVFILT_VNODE, EV_DELETE, NOTE_ALL, 0,
+					file);
 				if (kevent(kq, &evSet, 1, NULL, 0, NULL) == -1)
 					err(1, "failed to remove VNODE event");
 				if (close(file->fd) == -1)