diff mbox series

[2/3] sstate-cache-management: skip directories it cannot read

Message ID 20261005065322.30522-4-alex.kiernan@gmail.com
State New
Headers show
Series [1/3] sstate-cache-management: find work-shared stamps too | expand

Commit Message

Alex Kiernan Oct. 5, 2026, 6:53 a.m. UTC
collect_sstate_paths() walks the cache assuming every entry is a
directory, and only tolerates NotADirectoryError. A directory the user
cannot read raises PermissionError instead, which aborts the whole run
with a traceback. The usual one is lost+found, whenever SSTATE_DIR is
the root of a filesystem - a dedicated disk, a volume, an NFS export -
and the script is run as the build user rather than root.

Warn on stderr and carry on, as find did in the shell script this
replaced. stderr keeps the warning out of the list -D prints.

Run as a non-root user against a cache at the root of an ext4
filesystem: before, PermissionError on lost+found and exit 1; after,
"Skipping .../lost+found: Permission denied" and a complete run.

Fixes: 2fa1b25d7485 ("sstate-cache-management: Rewrite in python")
AI-Generated: Claude Opus 5.5
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
---
 scripts/sstate-cache-management.py | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/scripts/sstate-cache-management.py b/scripts/sstate-cache-management.py
index d088878a92df..c361c3d5a07f 100755
--- a/scripts/sstate-cache-management.py
+++ b/scripts/sstate-cache-management.py
@@ -125,6 +125,9 @@  def collect_sstate_paths(args):
 
         except NotADirectoryError:
             pass
+        except PermissionError as e:
+            # e.g. lost+found when the cache is the root of a filesystem
+            print(f"Skipping {path}: {e.strerror}", file=sys.stderr)
 
     paths = set()
     # TODO: parellise scandir