arc_summary3: just read /s/m/{mod}/version instead of spawning cat

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11859
This commit is contained in:
наб 2021-04-07 18:02:35 +02:00 committed by Brian Behlendorf
parent 2ae2892235
commit b3bb604a4c
1 changed files with 5 additions and 15 deletions

View File

@ -161,21 +161,11 @@ elif sys.platform.startswith('linux'):
# The original arc_summary called /sbin/modinfo/{spl,zfs} to get # The original arc_summary called /sbin/modinfo/{spl,zfs} to get
# the version information. We switch to /sys/module/{spl,zfs}/version # the version information. We switch to /sys/module/{spl,zfs}/version
# to make sure we get what is really loaded in the kernel # to make sure we get what is really loaded in the kernel
command = ["cat", "/sys/module/{0}/version".format(request)] try:
req = request.upper() with open("/sys/module/{}/version".format(request)) as f:
return f.read().strip()
# The recommended way to do this is with subprocess.run(). However, except:
# some installed versions of Python are < 3.5, so we offer them return "(unknown)"
# the option of doing it the old way (for now)
if 'run' in dir(subprocess):
info = subprocess.run(command, stdout=subprocess.PIPE,
universal_newlines=True)
version = info.stdout.strip()
else:
info = subprocess.check_output(command, universal_newlines=True)
version = info.strip()
return version
def get_descriptions(request): def get_descriptions(request):
"""Get the descriptions of the Solaris Porting Layer (SPL) or the """Get the descriptions of the Solaris Porting Layer (SPL) or the