I'm working on a file monitoring daemon written in PHP, using the inotify PECL extension. I've nearly got it finished, as in it tells me when an inotify event happens.
The return value of inotify_read($fd) is an array that looks like this:
Array
(
[0] => Array
(
[wd] => 2
[mask] => 1073741840
[cookie] => 0
[name] => collaphoto
)
[1] => Array
(
[wd] => 2
[mask] => 1073741856
[cookie] => 0
[name] => filewatcher
)
[2] => Array
(
[wd] => 2
[mask] => 1073741840
[cookie] => 0
[name] => filewatcher
)
)
If I understand it correctly, each sub array is an individual event, with information about that event. wd is the descriptor of the inotify instance, mask is the integer value of the flags that triggered the event, eg IN_ATTRIB or IN_ACCESS, cookie is a unique ID to connect this event to another event in the queue, and name is the directory or file that was changed. The name is only given if a directory is being watched by inotify.
My question is how do I figure out what Bit Mask triggered the event based on the mask value given? I'm still fairly inexperienced with dealing with Bit Masks, so go easy on me.