Lgtm

On Apr 8, 2010 3:59 PM, "John Admanski" <[email protected]> wrote:

Add a generic function to get and set sysctl values. Also fix a bug in the
sysctl_kernel function where it would interpret value=0 as an attempt to get
a value and not an attempt to set a value to zero.

Signed-off-by: John Admanski <[email protected]>

--- autotest/client/bin/base_utils.py   2010-04-08 15:56:33.000000000 -0700
+++ autotest/client/bin/base_utils.py   2010-04-08 15:56:33.000000000 -0700
@@ -369,9 +369,23 @@
    return phys_kbytes


+def sysctl(key, value=None):
+    """Generic implementation of sysctl, to read and write.
+
+    @param key: A location under /proc/sys
+    @param value: If not None, a value to write into the sysctl.
+
+    @return The single-line sysctl value as a string.
+    """
+    path = '/proc/sys/%s' % key
+    if value is not None:
+        utils.write_one_line(path, str(value))
+    return utils.read_one_line(path)
+
+
 def sysctl_kernel(key, value=None):
    """(Very) partial implementation of sysctl, for kernel params"""
-    if value:
+    if value is not None:
        # write
        utils.write_one_line('/proc/sys/kernel/%s' % key, str(value))
    else:
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to