aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2020-05-04 00:30:33 +1200
committerTom Ryder <tom@sanctum.geek.nz>2020-05-04 00:30:33 +1200
commit53958eee4f923c001bea425adcbb9ad80a29315a (patch)
tree6dbe09ab6d6c09c47213b951dfb62d8d52f00bf1
parentMerge branch 'hotfix/v0.05' (diff)
downloadinotifymask-53958eee4f923c001bea425adcbb9ad80a29315a.tar.gz
inotifymask-53958eee4f923c001bea425adcbb9ad80a29315a.zip
Monitor attribute changes too
I'm a bit worried this might cause infinite loops, since we change attributes in the callback as well.
-rw-r--r--bin/inotifymask8
1 files changed, 6 insertions, 2 deletions
diff --git a/bin/inotifymask b/bin/inotifymask
index d5bfcb0..fcceecb 100644
--- a/bin/inotifymask
+++ b/bin/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;