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 <[email protected]>
---
 scripts/sstate-cache-management.py | 3 +++
 1 file changed, 3 insertions(+)

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
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#247218): 
https://lists.openembedded.org/g/openembedded-core/message/247218
Mute This Topic: https://lists.openembedded.org/mt/121587343/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to