aboutsummaryrefslogtreecommitdiffstats
path: root/lib/pyinotify.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-04-03 11:12:04 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-04-03 17:51:18 +0100
commit7fb93c2ce6dacd9b53fc3a227133a3493e6a6a1d (patch)
tree182245e1118cfe57366a7b474bd97cc1285695a7 /lib/pyinotify.py
parent3df322a200c28b45af1f2c92478c85eb7d20c38b (diff)
downloadbitbake-7fb93c2ce6dacd9b53fc3a227133a3493e6a6a1d.tar.gz
pyinotify: Handle potential latent bug
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. We don't care about two of these from a bitbake perspective but it probably explains why in real world builds, we've seen: pyinotify.ProcessEventError: Unknown mask 0x00000006 This module code assumes only one mask bit can be present. Since we don't care about two of these events, just mask them out for now. The "upstream" code is unmainained since 2015. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/pyinotify.py')
-rw-r--r--lib/pyinotify.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/pyinotify.py b/lib/pyinotify.py
index 8c94b3e33..5c9b6d0fe 100644
--- a/lib/pyinotify.py
+++ b/lib/pyinotify.py
@@ -603,6 +603,17 @@ class _ProcessEvent:
unknown event.
"""
stripped_mask = event.mask - (event.mask & IN_ISDIR)
+ # Bitbake hack - we see event masks of 0x6, 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)
+
maskname = EventsCodes.ALL_VALUES.get(stripped_mask)
if maskname is None:
raise ProcessEventError("Unknown mask 0x%08x" % stripped_mask)