2000-04-25 08:04:55 +00:00
|
|
|
--- check_tmp.c.orig Fri Sep 24 13:33:35 1999
|
2000-05-26 19:01:09 +00:00
|
|
|
+++ check_tmp.c Mon May 22 23:49:21 2000
|
|
|
|
@@ -37,7 +37,14 @@
|
|
|
|
char error_buffer[256];
|
2000-04-25 08:04:55 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2000-05-26 19:01:09 +00:00
|
|
|
-
|
|
|
|
+
|
|
|
|
+#if (__FreeBSD_version >= 500001) || (__FreeBSD_version >= 400019 && __FreeBSD_version < 500000)
|
2000-04-25 08:04:55 +00:00
|
|
|
+ struct kevent ev;
|
|
|
|
+ struct kevent *evp;
|
|
|
|
+ int fd;
|
|
|
|
+ struct timespec ts = { 0, 0 };
|
|
|
|
+ int kq = -1;
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
struct listStruct *list = NULL;
|
|
|
|
|
|
|
|
@@ -178,6 +185,22 @@
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2000-05-26 19:01:09 +00:00
|
|
|
+#if (__FreeBSD_version >= 500001) || (__FreeBSD_version >= 400019 && __FreeBSD_version < 500000)
|
2000-04-25 08:04:55 +00:00
|
|
|
+ /* Set up the KQ on the target directory */
|
|
|
|
+ fd = dirfd(dirp);
|
|
|
|
+
|
|
|
|
+ kq = kqueue();
|
|
|
|
+ if (kq < 0)
|
|
|
|
+ err(1, "kqueue");
|
|
|
|
+
|
|
|
|
+ ev.ident = fd;
|
|
|
|
+ ev.filter = EVFILT_VNODE;
|
|
|
|
+ ev.flags = EV_ADD | EV_ENABLE | EV_CLEAR;
|
|
|
|
+ ev.fflags = NOTE_WRITE;
|
|
|
|
+ evp = &ev;
|
|
|
|
+ kevent(kq, 1, &evp, 0, NULL, &ts);
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
/* steup the first element of the list */
|
|
|
|
while ((dp = readdir(dirp)) != NULL){
|
|
|
|
if (!list) /* first time */
|
|
|
|
@@ -266,6 +289,10 @@
|
|
|
|
rewinddir(dirp);
|
|
|
|
|
|
|
|
while (1){
|
|
|
|
+
|
2000-05-26 19:01:09 +00:00
|
|
|
+#if (__FreeBSD_version >= 500001) || (__FreeBSD_version >= 400019 && __FreeBSD_version < 500000)
|
2000-04-25 08:04:55 +00:00
|
|
|
+ if (ev.fflags & NOTE_WRITE) {
|
|
|
|
+#endif
|
|
|
|
while ((dp = readdir(dirp)) != NULL){
|
|
|
|
if (!(checknode(list, watchdir, dp->d_name))){
|
|
|
|
if (replacewatchflag){
|
|
|
|
@@ -352,11 +379,22 @@
|
|
|
|
/* closedir(dirp); */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-#ifdef 0
|
|
|
|
+#if 0
|
|
|
|
walklist(list);
|
|
|
|
#endif
|
|
|
|
list = prunelist(list);
|
|
|
|
rewinddir(dirp);
|
|
|
|
+
|
2000-05-26 19:01:09 +00:00
|
|
|
+#if (__FreeBSD_version >= 500001) || (__FreeBSD_version >= 400019 && __FreeBSD_version < 500000)
|
2000-04-25 08:04:55 +00:00
|
|
|
+ /* Reset event so we don't trigger on the rewinddir */
|
|
|
|
+ kevent(kq, 1, &evp, 0, NULL, &ts);
|
|
|
|
+
|
|
|
|
+ /* Block until the directory changes */
|
|
|
|
+ if (kevent(kq, 0, NULL, 1, &ev, NULL) < 0)
|
|
|
|
+ err(1, "kevent");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
/* closedir(dirp); */
|
|
|
|
|