blob: fad81acf1bfb5e6c79a16242d9dde1eb6f314253 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
class LinuxKernel:
__kernel_vars = {}
def __init__(self):
self.parse_kernel_cmdline()
def parse_kernel_cmdline(self):
cmdline = open('/proc/cmdline', 'rb').read().decode()
cmd_array = cmdline.split()
i = 0
for f in cmdline.split():
pos = f.find('=')
if pos == -1:
cmd_array[i - 1] = cmd_array[i - 1] + " " + f
cmd_array.remove(cmd_array[i])
else:
i += 1
self.__kernel_vars = {}
for f in cmd_array:
dat = f.split('=')
self.__kernel_vars[dat[0]] = dat[1]
def getkvar(self, vName, vdefault):
if vName in self.__kernel_vars:
return self.__kernel_vars[vName]
return vdefault
|