diff options
author | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2022-04-08 16:44:30 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-04-14 09:48:27 +0100 |
commit | 2ab60c7be124d928d304ab1fb73f0dbff29964ae (patch) | |
tree | 6c7f279708ef73f7a08089c6ff45a1f32df2e48c | |
parent | 7358378b90b68111779e6ae72948e5e7a3de00a9 (diff) | |
download | bitbake-2ab60c7be124d928d304ab1fb73f0dbff29964ae.tar.gz |
pyinotify.py: Simplify identification of which event has occurred
Use bitwise operators to manipulate the received event mask in
_ProcessEvent.
Also minor clarification & clean up of the related comments.
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/pyinotify.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/pyinotify.py b/lib/pyinotify.py index 5c9b6d0fe..3c5dab031 100644 --- a/lib/pyinotify.py +++ b/lib/pyinotify.py @@ -595,24 +595,23 @@ class _ProcessEvent: @type event: Event object @return: By convention when used from the ProcessEvent class: - Returning False or None (default value) means keep on - executing next chained functors (see chain.py example). + executing next chained functors (see chain.py example). - Returning True instead means do not execute next processing functions. @rtype: bool @raise ProcessEventError: Event object undispatchable, unknown event. """ - stripped_mask = event.mask - (event.mask & IN_ISDIR) - # Bitbake hack - we see event masks of 0x6, IN_MODIFY & IN_ATTRIB + stripped_mask = event.mask & ~IN_ISDIR + # Bitbake hack - we see event masks of 0x6, i.e., IN_MODIFY & IN_ATTRIB. # The kernel inotify code can set more than one of the bits in the mask, # fsnotify_change() in linux/fsnotify.h is quite clear that IN_ATTRIB, # IN_MODIFY and IN_ACCESS can arrive together. # This breaks the code below which assume only one mask bit is ever - # set in an event. We don't care about attrib or access in bitbake so drop those - if (stripped_mask & IN_MODIFY) and (stripped_mask & IN_ATTRIB): - stripped_mask = stripped_mask - (stripped_mask & IN_ATTRIB) - if (stripped_mask & IN_MODIFY) and (stripped_mask & IN_ACCESS): - stripped_mask = stripped_mask - (stripped_mask & IN_ACCESS) + # set in an event. We don't care about attrib or access in bitbake so + # drop those. + if stripped_mask & IN_MODIFY: + stripped_mask &= ~(IN_ATTRIB | IN_ACCESS) maskname = EventsCodes.ALL_VALUES.get(stripped_mask) if maskname is None: |