Skip to content

Commit

Permalink
collector/dmesg: Fix dmesg variant detection
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
douglas-raillard-arm authored and marcbonnici committed Feb 10, 2025
1 parent a3765cc commit facd251
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions devlib/collector/dmesg.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,16 @@ def __init__(self, target, level=LOG_LEVELS[-1], facility='kern', empty_buffer=F
))
self.level = level

# Check if dmesg is the BusyBox one, or the one from util-linux in a
# recent version.
# Note: BusyBox dmesg does not support -h, but will still print the
# help with an exit code of 1
self.basic_dmesg = '--force-prefix' not in \
self.target.execute('dmesg -h', check_exit_code=False)
# Check if we have a dmesg from a recent util-linux build, rather than
# e.g. busybox's dmesg or the one shipped on some Android versions
# (toybox). Note: BusyBox dmesg does not support -h, but will still
# print the help with an exit code of 1
help_ = self.target.execute('dmesg -h', check_exit_code=False)
self.basic_dmesg = not all(
opt in help_
for opt in ('--facility', '--force-prefix', '--decode', '--level')
)

self.facility = facility
try:
needs_root = target.read_sysctl('kernel.dmesg_restrict')
Expand Down

0 comments on commit facd251

Please sign in to comment.