chiark / gitweb /
changelog: Finalise 2.2
[innduct.git] / filemon.c
index 7ba11b5f19d62a9b945913e0b9ea6e93c3b8d5f9..c531f40c32e15db0b182b701a3d4c40df4d6d001 100644 (file)
--- a/filemon.c
+++ b/filemon.c
@@ -3,25 +3,9 @@
  *  tailing reliable realtime streaming feeder for inn
  *  filemon.c - file monitoring (inotify, kqueue, poll, etc.)
  *
- *  Copyright (C) 2010 Ian Jackson <ijackson@chiark.greenend.org.uk>
- * 
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- * 
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- * 
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *  (I believe that when you compile and link this as part of the inn2
- *  build, with the Makefile runes I have provided, all the libraries
- *  and files which end up included in innduct are licence-compatible
- *  with GPLv3.  If not then please let me know.  -Ian Jackson.)
+ *  Copyright Ian Jackson <ijackson@chiark.greenend.org.uk>
+ *  and contributors; see LICENCE.txt.
+ *  SPDX-License-Identifier: GPL-3.0-or-later
  */
 
 #include "innduct.h"
@@ -48,16 +32,16 @@ static void filemon_method_startfile(InputFile *ipf, Filemon_Perfile *pf) {
   pf->ipf= ipf;
 
   pf->wd= inotify_add_watch(filemon_inotify_fd, ipf->path, IN_MODIFY);
-  if (pf->wd < 0) sysdie("inotify_add_watch %s", ipf->path);
+  if (pf->wd < 0) sysdie("filemon inotify: inotify_add_watch %s", ipf->path);
 
   LIST_ADDHEAD(filemon_inotify_watches, pf);
-  dbg("filemon inotify startfile %p wd=%d pf=%p", ipf, pf->wd, pf);
+  dbg("filemon inotify: startfile %p wd=%d pf=%p", ipf, pf->wd, pf);
 }
 
 static void filemon_method_stopfile(InputFile *ipf, Filemon_Perfile *pf) {
-  dbg("filemon inotify stopfile %p wd=%d pf=%p", ipf, pf->wd, pf);
+  dbg("filemon inotify: stopfile %p wd=%d pf=%p", ipf, pf->wd, pf);
   int r= inotify_rm_watch(filemon_inotify_fd, pf->wd);
-  if (r) syscrash("inotify_rm_watch");
+  if (r) syscrash("filemon inotify: inotify_rm_watch");
   LIST_REMOVE(filemon_inotify_watches, pf);
 }
 
@@ -69,9 +53,10 @@ static void *filemon_inotify_readable(oop_source *lp, int fd,
     int r= read(filemon_inotify_fd, &iev, sizeof(iev));
     if (r==-1) {
       if (isewouldblock(errno)) break;
-      syscrash("read from inotify master");
+      syscrash("filemon inotify: read from inotify master");
     } else if (r!=sizeof(iev)) {
-      crash("inotify read %d bytes wanted struct of %d", r, (int)sizeof(iev));
+      crash("filemon inotify: read %d bytes when wanted struct of %d",
+           r, (int)sizeof(iev));
     }
     Filemon_Perfile *pf;
     FOR_LIST_NODE(pf, filemon_inotify_watches)
@@ -82,7 +67,7 @@ static void *filemon_inotify_readable(oop_source *lp, int fd,
      * unexpected random watch events as normal.  It's not a
      * correctness problem as the watch is just a prod to read a file,
      * which is harmless if it does not need to be read. */
-    dbg("inotify read event on unknown wd=%d", iev.wd);
+    dbg("filemon inotify: read event with unknown wd=%d", iev.wd);
     continue;
     
   found:
@@ -97,13 +82,13 @@ int filemon_method_init(void) {
   LIST_INIT(filemon_inotify_watches);
   filemon_inotify_fd= inotify_init();
   if (filemon_inotify_fd<0) {
-    syswarn("filemon/inotify: inotify_init failed");
+    syswarn("filemon inotify: inotify_init failed");
     return 0;
   }
   xsetnonblock(filemon_inotify_fd, 1);
   loop->on_fd(loop, filemon_inotify_fd, OOP_READ, filemon_inotify_readable, 0);
 
-  dbg("filemon inotify init filemon_inotify_fd=%d", filemon_inotify_fd);
+  dbg("filemon inotify: init filemon_inotify_fd=%d", filemon_inotify_fd);
   return 1;
 }
 
@@ -126,7 +111,7 @@ void filemon_method_dump_info(FILE *f) {
 struct Filemon_Perfile { int dummy; };
 
 int filemon_method_init(void) {
-  warn("filemon/dummy: no filemon method compiled in");
+  warn("filemon dummy: no filemon method compiled in");
   return 0;
 }
 static void filemon_method_startfile(InputFile *ipf, Filemon_Perfile *pf) { }