From 53958eee4f923c001bea425adcbb9ad80a29315a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 4 May 2020 00:30:33 +1200 Subject: Monitor attribute changes too I'm a bit worried this might cause infinite loops, since we change attributes in the callback as well. --- bin/inotifymask | 8 ++++++-- 1 file 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; -- cgit v1.2.3 From 6545e141d0653c533e537bf79d72bd7bfaf79077 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 4 May 2020 00:30:59 +1200 Subject: Bump VERSION --- bin/inotifymask | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/inotifymask b/bin/inotifymask index fcceecb..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'; -- cgit v1.2.3