aboutsummaryrefslogtreecommitdiff
path: root/mk/meta2deps.py
diff options
context:
space:
mode:
Diffstat (limited to 'mk/meta2deps.py')
-rwxr-xr-xmk/meta2deps.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/mk/meta2deps.py b/mk/meta2deps.py
index 42085e9e7f7d..8543ec4049ea 100755
--- a/mk/meta2deps.py
+++ b/mk/meta2deps.py
@@ -39,7 +39,7 @@ We only pay attention to a subset of the information in the
SPDX-License-Identifier: BSD-2-Clause
RCSid:
- $Id: meta2deps.py,v 1.55 2026/01/13 04:32:45 sjg Exp $
+ $Id: meta2deps.py,v 1.57 2026/07/03 15:45:29 sjg Exp $
Copyright (c) 2011-2025, Simon J. Gerraty
Copyright (c) 2011-2017, Juniper Networks, Inc.
@@ -73,6 +73,13 @@ import re
import sys
import stat
+# Attempt to match bogus filemon data that could potentitally be truncated by
+# the unreliable Linux filemon such as:
+# R 2712488 /X 2712597 0
+# or
+# R 1096904 /path/foo-linuR 1096904 /path/bar.py
+filemon_fused_re = re.compile(r'[CDEFLMRSVWX] [0-9]+ ')
+
def resolve(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr):
"""
Return an absolute path, resolving via cwd or last_dir if needed.
@@ -515,6 +522,17 @@ class MetaFile:
if self.debug > 2:
print('op={} elen={} wlen={} line="{}"'.format(w[0], elen, wlen, line.strip()), file=self.debug_out)
if wlen != elen:
+ if wlen > elen and w[0] in 'CELMRW':
+ # Before assuming spaces in a pathname, make sure this
+ # isn't two records fused onto one line because of
+ # dropped data (unreliable Linux filemon).
+ if filemon_fused_re.search(line.split(None, 2)[2]):
+ raise AssertionError('corrupted filemon data: fused records (dropped newline): {} in: {}'.format(error_name, line.strip()))
+ # It could just be spaces in pathname.
+ # More trouble than its worth, just skip it.
+ if self.debug > 0:
+ print('Skipping: wrong number of words: expected {} got {} in: {}'.format(elen, wlen, line), file=self.debug_out)
+ continue
raise AssertionError('corrupted filemon data: wrong number of words: expected {} got {} in: {}'.format(elen, wlen, line))
pid = int(w[1])