aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-11-17 22:19:18 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-11-17 22:19:18 +0000
commita09a42cd83a0365b5b52dfdcce20b3c9932be801 (patch)
tree7b77e84c7b1b829bad250c5e4c9ee58705a89723 /miscutils
parent249d948e3944eacf380e9ab8704535161d8a6603 (diff)
downloadbusybox-w32-a09a42cd83a0365b5b52dfdcce20b3c9932be801.tar.gz
busybox-w32-a09a42cd83a0365b5b52dfdcce20b3c9932be801.tar.bz2
busybox-w32-a09a42cd83a0365b5b52dfdcce20b3c9932be801.zip
inotify: add x, o, and u events
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/inotifyd.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/miscutils/inotifyd.c b/miscutils/inotifyd.c
index 2a1355156..656510453 100644
--- a/miscutils/inotifyd.c
+++ b/miscutils/inotifyd.c
@@ -43,7 +43,14 @@ static const char mask_names[] ALIGN1 =
43 "d" // 0x00000200 Subfile was deleted 43 "d" // 0x00000200 Subfile was deleted
44 "D" // 0x00000400 Self was deleted 44 "D" // 0x00000400 Self was deleted
45 "M" // 0x00000800 Self was moved 45 "M" // 0x00000800 Self was moved
46 "\0" // 0x00001000 (unused)
47 "u" // 0x00002000 Backing fs was unmounted
48 "o" // 0x00004000 Event queued overflowed
49 "x" // 0x00008000 File is no longer watched (usually deleted)
46; 50;
51enum {
52 MASK_BITS = sizeof(mask_names) - 1
53};
47 54
48extern int inotify_init(void); 55extern int inotify_init(void);
49extern int inotify_add_watch(int fd, const char *path, uint32_t mask); 56extern int inotify_add_watch(int fd, const char *path, uint32_t mask);
@@ -76,10 +83,10 @@ int inotifyd_main(int argc UNUSED_PARAM, char **argv)
76 // convert mask names to mask bitset 83 // convert mask names to mask bitset
77 mask = 0; 84 mask = 0;
78 while (*++masks) { 85 while (*++masks) {
79 int i = strchr(mask_names, *masks) - mask_names; 86 const char *found;
80 if (i >= 0) { 87 found = memchr(mask_names, *masks, MASK_BITS);
81 mask |= (1 << i); 88 if (found)
82 } 89 mask |= (1 << (found - mask_names));
83 } 90 }
84 } 91 }
85 // add watch 92 // add watch
@@ -124,21 +131,23 @@ int inotifyd_main(int argc UNUSED_PARAM, char **argv)
124 // process events. N.B. events may vary in length 131 // process events. N.B. events may vary in length
125 while (len > 0) { 132 while (len > 0) {
126 int i; 133 int i;
127 char events[sizeof(mask_names)]; 134 // cache relevant events mask
128 char *s = events; 135 unsigned m = ie->mask & ((1 << MASK_BITS) - 1);
129 unsigned m = ie->mask; 136 if (m) {
130 137 char events[MASK_BITS + 1];
131 for (i = 0; i < sizeof(mask_names)-1; ++i, m >>= 1) { 138 char *s = events;
132 if (m & 1) 139 for (i = 0; i < MASK_BITS; ++i, m >>= 1) {
133 *s++ = mask_names[i]; 140 if ((m & 1) && (mask_names[i] != '\0'))
141 *s++ = mask_names[i];
142 }
143 *s = '\0';
144// bb_error_msg("exec %s %08X\t%s\t%s\t%s", args[0],
145// ie->mask, events, watched[ie->wd], ie->len ? ie->name : "");
146 args[1] = events;
147 args[2] = watched[ie->wd];
148 args[3] = ie->len ? ie->name : NULL;
149 wait4pid(xspawn((char **)args));
134 } 150 }
135 *s = '\0';
136 //bb_error_msg("exec %s %08X\t%s\t%s\t%s", agent,
137 // ie->mask, events, watched[ie->wd], ie->len ? ie->name : "");
138 args[1] = events;
139 args[2] = watched[ie->wd];
140 args[3] = ie->len ? ie->name : NULL;
141 wait4pid(xspawn((char **)args));
142 // next event 151 // next event
143 i = sizeof(struct inotify_event) + ie->len; 152 i = sizeof(struct inotify_event) + ie->len;
144 len -= i; 153 len -= i;