|
|
bffc8a |
From 15e54577289a29e72c636f8987859e91c3a55a7c Mon Sep 17 00:00:00 2001
|
|
|
bffc8a |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
bffc8a |
Date: Thu, 10 Dec 2020 20:23:03 +0100
|
|
|
bffc8a |
Subject: [PATCH] [report] collect broken symlinks
|
|
|
bffc8a |
|
|
|
bffc8a |
Information about broken symlink destination is useful information
|
|
|
bffc8a |
that sos report should collect. Currently it stops doing so as
|
|
|
bffc8a |
stat-ing the symlink to determine filesize fails.
|
|
|
bffc8a |
|
|
|
bffc8a |
Closes: #2333
|
|
|
bffc8a |
Resolves: #2338
|
|
|
bffc8a |
|
|
|
bffc8a |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
bffc8a |
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
|
|
|
bffc8a |
---
|
|
|
bffc8a |
sos/report/plugins/__init__.py | 16 ++++++++++------
|
|
|
bffc8a |
1 file changed, 10 insertions(+), 6 deletions(-)
|
|
|
bffc8a |
|
|
|
bffc8a |
diff --git a/sos/report/plugins/__init__.py b/sos/report/plugins/__init__.py
|
|
|
bffc8a |
index 510e116e..1527caea 100644
|
|
|
bffc8a |
--- a/sos/report/plugins/__init__.py
|
|
|
bffc8a |
+++ b/sos/report/plugins/__init__.py
|
|
|
bffc8a |
@@ -1449,11 +1449,16 @@ class Plugin(object):
|
|
|
bffc8a |
continue
|
|
|
bffc8a |
|
|
|
bffc8a |
try:
|
|
|
bffc8a |
- filestat = os.stat(_file)
|
|
|
bffc8a |
+ file_size = os.stat(_file)[stat.ST_SIZE]
|
|
|
bffc8a |
except OSError:
|
|
|
bffc8a |
- self._log_info("failed to stat '%s'" % _file)
|
|
|
bffc8a |
- continue
|
|
|
bffc8a |
- current_size += filestat[stat.ST_SIZE]
|
|
|
bffc8a |
+ # if _file is a broken symlink, we should collect it,
|
|
|
bffc8a |
+ # otherwise skip it
|
|
|
bffc8a |
+ if os.path.islink(_file):
|
|
|
bffc8a |
+ file_size = 0
|
|
|
bffc8a |
+ else:
|
|
|
bffc8a |
+ self._log_info("failed to stat '%s', skipping" % _file)
|
|
|
bffc8a |
+ continue
|
|
|
bffc8a |
+ current_size += file_size
|
|
|
bffc8a |
|
|
|
bffc8a |
if sizelimit and current_size > sizelimit:
|
|
|
bffc8a |
limit_reached = True
|
|
|
bffc8a |
@@ -1467,8 +1472,7 @@ class Plugin(object):
|
|
|
bffc8a |
strfile = (
|
|
|
bffc8a |
file_name.replace(os.path.sep, ".") + ".tailed"
|
|
|
bffc8a |
)
|
|
|
bffc8a |
- add_size = (sizelimit + filestat[stat.ST_SIZE]
|
|
|
bffc8a |
- - current_size)
|
|
|
bffc8a |
+ add_size = sizelimit + file_size - current_size
|
|
|
bffc8a |
self.add_string_as_file(tail(_file, add_size), strfile)
|
|
|
bffc8a |
rel_path = os.path.relpath('/', os.path.dirname(_file))
|
|
|
bffc8a |
link_path = os.path.join(rel_path, 'sos_strings',
|
|
|
bffc8a |
--
|
|
|
bffc8a |
2.26.2
|
|
|
bffc8a |
|