diff mbox series

[dunfell,1.46,2/2] utils: Fix lockfile path length issues

Message ID e3db9c2e9eded3c5cb6040714a6054b44f6b3880.1668880159.git.steve@sakoman.com
State New
Headers show
Series [dunfell,1.46,1/2] utils: Handle lockfile filenames that are too long for filesystems | expand

Commit Message

Steve Sakoman Nov. 19, 2022, 5:51 p.m. UTC
From: Richard Purdie <richard.purdie@linuxfoundation.org>

If the path to bitbake.lock is in a deep directory, bitbake will hang. The
reason was that the max file length limiting code (to 255 chars) was including
the directory name and it should only act on the filename within the directory.
Fix it to just use the base filename.

[YOCTO #14766]

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 89d70e7b71eecfe06592202f326e566c579ba01d)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
 lib/bb/utils.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff mbox series


diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 210e535f..82602466 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -461,13 +461,16 @@  def lockfile(name, shared=False, retry=True, block=False):
     consider the possibility of sending a signal to the process to break
     out - at which point you want block=True rather than retry=True.
-    if len(name) > 255:
-        root, ext = os.path.splitext(name)
-        name = root[:255 - len(ext)] + ext
+    basename = os.path.basename(name)
+    if len(basename) > 255:
+        root, ext = os.path.splitext(basename)
+        basename = root[:255 - len(ext)] + ext
     dirname = os.path.dirname(name)
+    name = os.path.join(dirname, basename)
     if not os.access(dirname, os.W_OK):
         logger.error("Unable to acquire lock '%s', directory is not writable",