summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2015-10-02 13:31:39 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-10-02 13:31:39 -0300
commit7c557369dab9802084eac4f1fa50bfe9c268a037 (patch)
tree542a3ab89c733da22052790408fd2c5005c27c60
parent1a4c647e7b47d904f183d3083bd6068ed8bfb011 (diff)
downloadpython-linux-procfs-7c557369dab9802084eac4f1fa50bfe9c268a037.tar.gz
cmdline: Document it
Reported-by: Guy Streeter <streeter@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-xprocfs/procfs.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/procfs/procfs.py b/procfs/procfs.py
index 10aad28..fdacba4 100755
--- a/procfs/procfs.py
+++ b/procfs/procfs.py
@@ -351,7 +351,7 @@ class process:
/home/acme
>>> print firefox_process["environ"]["MAIL"]
/var/spool/mail/acme
- >>>
+ >>>
"""
self.environ = {}
f = file("/proc/%d/environ" % self.pid)
@@ -636,6 +636,25 @@ class interrupts:
return irqs
class cmdline:
+ """
+ Parses the kernel command line (/proc/cmdline), turning it into a dictionary."
+
+ Useful to figure out if some kernel boolean knob has been turned on, as well
+ as to find the value associated to other kernel knobs.
+
+ It can also be used to find out about parameters passed to the init process,
+ such as 'BOOT_IMAGE', etc.
+
+ E.g.:
+ >>> import procfs
+ >>> kcmd = procfs.cmdline()
+ >>> print kcmd.keys()
+ ['LANG', 'BOOT_IMAGE', 'quiet', 'rhgb', 'rd.lvm.lv', 'ro', 'root']
+ >>> print kcmd["BOOT_IMAGE"]
+ /vmlinuz-4.3.0-rc1+
+ >>>
+ """
+
def __init__(self):
self.options = {}
self.parse()