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:33 +0100 |
commit | c679713a7292c55364aef2ff4dff272ec385dd36 (patch) | |
tree | 21ca63dfc0738a2b02656d7243dce23f13a85194 | |
parent | 33b929192e78b09dfb1ea84c76db2eae4ce444a1 (diff) | |
download | poky-c679713a7292c55364aef2ff4dff272ec385dd36.tar.gz |
bitbake: 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.
(Bitbake rev: 2ab60c7be124d928d304ab1fb73f0dbff29964ae)
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-- | bitbake/lib/pyinotify.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/bitbake/lib/pyinotify.py b/bitbake/lib/pyinotify.py index 5c9b6d0fe2..3c5dab0312 100644 --- a/bitbake/lib/pyinotify.py +++ b/bitbake/lib/pyinotify.py | |||
@@ -595,24 +595,23 @@ class _ProcessEvent: | |||
595 | @type event: Event object | 595 | @type event: Event object |
596 | @return: By convention when used from the ProcessEvent class: | 596 | @return: By convention when used from the ProcessEvent class: |
597 | - Returning False or None (default value) means keep on | 597 | - Returning False or None (default value) means keep on |
598 | executing next chained functors (see chain.py example). | 598 | executing next chained functors (see chain.py example). |
599 | - Returning True instead means do not execute next | 599 | - Returning True instead means do not execute next |
600 | processing functions. | 600 | processing functions. |
601 | @rtype: bool | 601 | @rtype: bool |
602 | @raise ProcessEventError: Event object undispatchable, | 602 | @raise ProcessEventError: Event object undispatchable, |
603 | unknown event. | 603 | unknown event. |
604 | """ | 604 | """ |
605 | stripped_mask = event.mask - (event.mask & IN_ISDIR) | 605 | stripped_mask = event.mask & ~IN_ISDIR |
606 | # Bitbake hack - we see event masks of 0x6, IN_MODIFY & IN_ATTRIB | 606 | # Bitbake hack - we see event masks of 0x6, i.e., IN_MODIFY & IN_ATTRIB. |
607 | # The kernel inotify code can set more than one of the bits in the mask, | 607 | # The kernel inotify code can set more than one of the bits in the mask, |
608 | # fsnotify_change() in linux/fsnotify.h is quite clear that IN_ATTRIB, | 608 | # fsnotify_change() in linux/fsnotify.h is quite clear that IN_ATTRIB, |
609 | # IN_MODIFY and IN_ACCESS can arrive together. | 609 | # IN_MODIFY and IN_ACCESS can arrive together. |
610 | # This breaks the code below which assume only one mask bit is ever | 610 | # This breaks the code below which assume only one mask bit is ever |
611 | # set in an event. We don't care about attrib or access in bitbake so drop those | 611 | # set in an event. We don't care about attrib or access in bitbake so |
612 | if (stripped_mask & IN_MODIFY) and (stripped_mask & IN_ATTRIB): | 612 | # drop those. |
613 | stripped_mask = stripped_mask - (stripped_mask & IN_ATTRIB) | 613 | if stripped_mask & IN_MODIFY: |
614 | if (stripped_mask & IN_MODIFY) and (stripped_mask & IN_ACCESS): | 614 | stripped_mask &= ~(IN_ATTRIB | IN_ACCESS) |
615 | stripped_mask = stripped_mask - (stripped_mask & IN_ACCESS) | ||
616 | 615 | ||
617 | maskname = EventsCodes.ALL_VALUES.get(stripped_mask) | 616 | maskname = EventsCodes.ALL_VALUES.get(stripped_mask) |
618 | if maskname is None: | 617 | if maskname is None: |