aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2020-12-10 20:23:03 +0100
committerJake Hunsaker <jhunsake@redhat.com>2020-12-14 11:19:45 -0500
commit15e54577289a29e72c636f8987859e91c3a55a7c (patch)
tree7981d407fab70054b4f40417f4310184278b890c
parent46d0e38fda9f75d60882557371dd06760792faa6 (diff)
downloadsos-15e54577289a29e72c636f8987859e91c3a55a7c.tar.gz
[report] collect broken symlinks
Information about broken symlink destination is useful information that sos report should collect. Currently it stops doing so as stat-ing the symlink to determine filesize fails. Closes: #2333 Resolves: #2338 Signed-off-by: Pavel Moravec <pmoravec@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/report/plugins/__init__.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/sos/report/plugins/__init__.py b/sos/report/plugins/__init__.py
index 510e116e..1527caea 100644
--- a/sos/report/plugins/__init__.py
+++ b/sos/report/plugins/__init__.py
@@ -1449,11 +1449,16 @@ class Plugin(object):
continue
try:
- filestat = os.stat(_file)
+ file_size = os.stat(_file)[stat.ST_SIZE]
except OSError:
- self._log_info("failed to stat '%s'" % _file)
- continue
- current_size += filestat[stat.ST_SIZE]
+ # if _file is a broken symlink, we should collect it,
+ # otherwise skip it
+ if os.path.islink(_file):
+ file_size = 0
+ else:
+ self._log_info("failed to stat '%s', skipping" % _file)
+ continue
+ current_size += file_size
if sizelimit and current_size > sizelimit:
limit_reached = True
@@ -1467,8 +1472,7 @@ class Plugin(object):
strfile = (
file_name.replace(os.path.sep, ".") + ".tailed"
)
- add_size = (sizelimit + filestat[stat.ST_SIZE]
- - current_size)
+ add_size = sizelimit + file_size - current_size
self.add_string_as_file(tail(_file, add_size), strfile)
rel_path = os.path.relpath('/', os.path.dirname(_file))
link_path = os.path.join(rel_path, 'sos_strings',