[hackers] [ubase] sysctl: Add support for loading key:value pairs from file || sin
commit 191cc71cee5846e680ef12b3e1707f13bf4e0832
Author: sin <sin_AT_2f30.org>
Date: Fri Jun 13 15:20:21 2014 +0100
sysctl: Add support for loading key:value pairs from file
diff --git a/sysctl.8 b/sysctl.8
index 62dc27a..590699a 100644
--- a/sysctl.8
+++ b/sysctl.8
_AT_@ -2,8 +2,12 @@
.SH NAME
BsysctlR - Configure kernel parameters at runtime
.SH SYNOPSIS
-BsysctlR IvariableR[=IvalueR]...
+BsysctlR [B-pR IfileR] IvariableR[=IvalueR]...
.SH DESCRIPTION
BsysctlR modifies kernel parameters at runtime. The parameters available
are those listed under I/proc/sys/R. Procfs is required for sysctl support
in Linux. You can use BsysctlR to both read and write sysctl data.
+.SH OPTIONS
+.TP
+B-pR
+Load the sysctl key:value pairs from IfileR.
diff --git a/sysctl.c b/sysctl.c
index 4aea23c..f6bc141 100644
--- a/sysctl.c
+++ b/sysctl.c
_AT_@ -108,68 +108,101 @@ setsysctl(char *variable, char *value)
return 0;
}
+static int
+parsepair(char *pair)
+{
+ char *p;
+ char *variable;
+ char *value;
+
+ for (p = pair; *p; p++) {
+ if (p[0] == '.' && p[1] == '.') {
+ weprintf("malformed input: %s
", pair);
+ return -1;
+ }
+ }
+ p = strchr(pair, '=');
+ if (p) {
+ if (p[1] == '
Received on Fri Jun 13 2014 - 16:25:38 CEST
This archive was generated by hypermail 2.3.0
: Fri Jun 13 2014 - 16:36:07 CEST