diff options
-rw-r--r-- | bin/inotifymask | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/bin/inotifymask b/bin/inotifymask index d5bfcb0..8c8ad98 100644 --- a/bin/inotifymask +++ b/bin/inotifymask @@ -9,7 +9,7 @@ use Const::Fast; use File::stat; use Linux::Inotify2; -our $VERSION = '0.05'; +our $VERSION = '0.06'; const our $SELF => 'inotifymask'; @@ -46,8 +46,12 @@ my $cb = sub { # Get the mode we want for the file, masking off irrelevant file type bits my $mode = $stat->mode & $STAT_MASK; + # # Check that at least one bit of the mask coincides with one bit of the - # present mode, i.e. that we'll be changing anything + # present mode, i.e. that we'll be changing anything; this is important + # because we might otherwise get misleading log entries, and maybe even an + # infinite loop...! + # $mode & $mask or return; @@ -62,7 +66,7 @@ my $cb = sub { # Create object and set up watches with callback, start polling my $in = Linux::Inotify2->new; for (@files) { - $in->watch( $_, IN_CREATE | IN_MOVED_TO, $cb ); + $in->watch( $_, IN_ATTRIB | IN_CREATE | IN_MOVED_TO, $cb ); } while (1) { $in->poll; |