hexedit: new applet
[oweals/busybox.git] / miscutils / inotifyd.c
index 908d657fd2f01b11163e77154971beda81c5dcfb..0060797edec5c1a4c003c043c792be8ee9e1cce9 100644 (file)
@@ -12,7 +12,7 @@
  * Use as follows:
  * # inotifyd /user/space/agent dir/or/file/being/watched[:mask] ...
  *
- * When a filesystem event matching the specified mask is occured on specified file (or directory)
+ * When a filesystem event matching the specified mask is occurred on specified file (or directory)
  * a userspace agent is spawned and given the following parameters:
  * $1. actual event(s)
  * $2. file (or directory) name
  *
  * See below for mask names explanation.
  */
+//config:config INOTIFYD
+//config:      bool "inotifyd (3.5 kb)"
+//config:      default n  # doesn't build on Knoppix 5
+//config:      help
+//config:      Simple inotify daemon. Reports filesystem changes. Requires
+//config:      kernel >= 2.6.13
+
+//applet:IF_INOTIFYD(APPLET(inotifyd, BB_DIR_SBIN, BB_SUID_DROP))
+
+//kbuild:lib-$(CONFIG_INOTIFYD) += inotifyd.o
 
 //usage:#define inotifyd_trivial_usage
 //usage:       "PROG FILE1[:MASK]..."
@@ -56,6 +66,7 @@
 //usage:     "\nWhen x event happens for all FILEs, inotifyd exits."
 
 #include "libbb.h"
+#include "common_bufsiz.h"
 #include <sys/inotify.h>
 
 static const char mask_names[] ALIGN1 =
@@ -161,9 +172,10 @@ int inotifyd_main(int argc, char **argv)
 
                // read out all pending events
                // (NB: len must be int, not ssize_t or long!)
-               xioctl(pfd.fd, FIONREAD, &len);
 #define eventbuf bb_common_bufsiz1
-               ie = buf = (len <= sizeof(eventbuf)) ? eventbuf : xmalloc(len);
+               setup_common_bufsiz();
+               xioctl(pfd.fd, FIONREAD, &len);
+               ie = buf = (len <= COMMON_BUFSIZE) ? eventbuf : xmalloc(len);
                len = full_read(pfd.fd, buf, len);
                // process events. N.B. events may vary in length
                while (len > 0) {