fswatch: Notify about L_FSWATCH_EVENT_ATTRIB events
PATCH 1/2 fswatch: Notify about L_FSWATCH_EVENT_ATTRIB events
Also emit events on file attribute changes, this was actually my original intent but I must have missed this bit in the bitmask.
--- ell/fswatch.c | 7 ++++++- ell/fswatch.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-)
ell/fswatch.c +6 -1
@@ -48,7 +48,8 @@ struct l_fswatch { };#define EVENT_MASK (IN_CREATE | IN_DELETE | IN_DELETE_SELF | \ - IN_MODIFY | IN_MOVE | IN_MOVE_SELF) + IN_MODIFY | IN_MOVE | IN_MOVE_SELF | \ + IN_ATTRIB)static void l_fswatch_free (void *data) {
@@ -125,6 +126,10 @@ static bool inotify_read_cb(struct l_io *io, void *user_data) watch->cb (watch, name,L_FSWATCH_EVENT_DELETE , watch->user_data); +if ((event->mask &IN_ATTRIB ) && watch->cb) + watch->cb (watch, name,L_FSWATCH_EVENT_ATTRIB , + watch->user_data); +if (event->mask &IN_IGNORED ) { stale_items = true; watch->cb =NULL ;
ell/fswatch.h +1 -0
@@ -30,6 +30,7 @@ enum l_fswatch_event {L_FSWATCH_EVENT_MOVE ,L_FSWATCH_EVENT_MODIFY ,L_FSWATCH_EVENT_DELETE , + L_FSWATCH_EVENT_ATTRIB, }; typedef void (*l_fswatch_cb_t) (struct l_fswatch *watch, const char *filename,
Signature · 1 line
2.14.1
PATCH 2/2 unit: Make fswatch test pass with new event type
Ignore the L_FSWATCH_EVENT_ATTRIB event seen for files being unlinked that precedes the L_FSWATCH_EVENT_DELETE.
--- unit/test-fswatch.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
unit/test-fswatch.c +5 -1
@@ -140,9 +140,13 @@ static void file_watch_cb(struct l_fswatch *watch, const char *filename,test_file_modify_check ();break ;case TEST_FILE_REMOVE : -assert (event ==L_FSWATCH_EVENT_DELETE ); +assert (event ==L_FSWATCH_EVENT_DELETE || + event ==L_FSWATCH_EVENT_ATTRIB );assert (!(substate &TEST_FILE_REMOVE_FILE_EVENT )); +if (event ==L_FSWATCH_EVENT_ATTRIB ) +break ; + substate |=TEST_FILE_REMOVE_FILE_EVENT ;test_file_remove_check ();
Signature · 1 line
2.14.1
Hi Andrew,
Quoted 7 lines · Andrew Zaborowski
Also emit events on file attribute changes, this was actually my original intent but I must have missed this bit in the bitmask.
--- ell/fswatch.c | 7 ++++++- ell/fswatch.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-)
Both applied, thanks.
Regards,
-Denis