aboutsummaryrefslogtreecommitdiffstats
path: root/testcase/tools/findleaves.py
diff options
context:
space:
mode:
authorTom Marshall <tdm.code@gmail.com>2018-02-16 21:44:03 +0100
committerTom Marshall <tdm.code@gmail.com>2018-02-26 20:08:24 +0100
commit570abd86c250686d2a125e654a36fe97ecd3b230 (patch)
treef8775211d212c7902650df9f79b53e50a5a030a6 /testcase/tools/findleaves.py
parentba8fc2c1e62f40291501d2deb8be9ccdc40e14d7 (diff)
downloadandroid_build_kati-lineage-15.1.tar.gz
android_build_kati-lineage-15.1.tar.bz2
android_build_kati-lineage-15.1.zip
Fix findleaves emulator with symlink loopslineage-15.1
This updates the findleaves emulator to match the change "findleaves.py: prevent recursion into symlink loops" Also update findleaves.py to match build/make/tools/findleaves.py Change-Id: I20cf63c7b4e1a8a7b7fa8b4bde04ae821d5d98ea
Diffstat (limited to 'testcase/tools/findleaves.py')
-rwxr-xr-xtestcase/tools/findleaves.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/testcase/tools/findleaves.py b/testcase/tools/findleaves.py
index 72cc024..f152a87 100755
--- a/testcase/tools/findleaves.py
+++ b/testcase/tools/findleaves.py
@@ -26,6 +26,7 @@ import sys
def perform_find(mindepth, prune, dirlist, filenames):
result = []
pruneleaves = set(map(lambda x: os.path.split(x)[1], prune))
+ seen = set()
for rootdir in dirlist:
rootdepth = rootdir.count("/")
for root, dirs, files in os.walk(rootdir, followlinks=True):
@@ -52,6 +53,18 @@ def perform_find(mindepth, prune, dirlist, filenames):
if filename in files:
result.append(os.path.join(root, filename))
del dirs[:]
+
+ # filter out inodes that have already been seen due to symlink loops
+ i = 0
+ while i < len(dirs):
+ st = os.stat(os.path.join(root, dirs[i]))
+ key = (st.st_dev, st.st_ino)
+ if key in seen:
+ del dirs[i]
+ else:
+ i += 1
+ seen.add(key)
+
return result
def usage():