Skip to content

Commit facd251

Browse files
douglas-raillard-armmarcbonnici
authored andcommitted
collector/dmesg: Fix dmesg variant detection
Check for all the CLI options we are going to use when deciding whether to use the system's dmesg or the one we ship via busybox.
1 parent a3765cc commit facd251

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

devlib/collector/dmesg.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,16 @@ def __init__(self, target, level=LOG_LEVELS[-1], facility='kern', empty_buffer=F
203203
))
204204
self.level = level
205205

206-
# Check if dmesg is the BusyBox one, or the one from util-linux in a
207-
# recent version.
208-
# Note: BusyBox dmesg does not support -h, but will still print the
209-
# help with an exit code of 1
210-
self.basic_dmesg = '--force-prefix' not in \
211-
self.target.execute('dmesg -h', check_exit_code=False)
206+
# Check if we have a dmesg from a recent util-linux build, rather than
207+
# e.g. busybox's dmesg or the one shipped on some Android versions
208+
# (toybox). Note: BusyBox dmesg does not support -h, but will still
209+
# print the help with an exit code of 1
210+
help_ = self.target.execute('dmesg -h', check_exit_code=False)
211+
self.basic_dmesg = not all(
212+
opt in help_
213+
for opt in ('--facility', '--force-prefix', '--decode', '--level')
214+
)
215+
212216
self.facility = facility
213217
try:
214218
needs_root = target.read_sysctl('kernel.dmesg_restrict')

0 commit comments

Comments
 (0)