3
# This file is part of Checkbox.
5
# Copyright 2009 Canonical Ltd.
7
# Checkbox is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License version 3,
9
# as published by the Free Software Foundation.
12
# Checkbox is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
23
# Filename where cpuinfo is stored.
24
MODULES_FILENAME = "/proc/modules"
29
Each line consists of the following information for each module:
31
name: Name of the module.
32
size: Memory size of the module, in bytes.
33
instances: How many instances of the module are currently loaded.
34
dependencies: If the module depends upon another module to be present
35
in order to function, and lists those modules.
36
state: The load state of the module: Live, Loading or Unloading.
37
offset: Current kernel memory offset for the loaded module.
39
(name, size, instances, dependencies, state, offset) = line.split(" ")[:6]
40
if dependencies == "-":
46
"instances": int(instances),
47
"dependencies": dependencies.replace(",", " ").strip(),
49
"offset": int(offset, 16)}
52
def get_modules(filename):
53
file = open(filename, "r")
54
for line in file.readlines():
57
yield get_module(line)
61
modules = get_modules(MODULES_FILENAME)
62
for module in modules:
63
for key, value in module.items():
65
print("%s: %s" % (key, value))
72
if __name__ == "__main__":