diff options
-rw-r--r-- | procps/sysctl.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/procps/sysctl.c b/procps/sysctl.c index 5303460f9..6d77185ca 100644 --- a/procps/sysctl.c +++ b/procps/sysctl.c | |||
@@ -56,9 +56,32 @@ enum { | |||
56 | 56 | ||
57 | static void sysctl_dots_to_slashes(char *name) | 57 | static void sysctl_dots_to_slashes(char *name) |
58 | { | 58 | { |
59 | char *cptr, *last_good, *end; | 59 | char *cptr, *last_good, *end, *slash; |
60 | char end_ch; | 60 | char end_ch; |
61 | 61 | ||
62 | end = strchrnul(name, '='); | ||
63 | |||
64 | slash = strchrnul(name, '/'); | ||
65 | if (slash < end | ||
66 | && strchrnul(name, '.') < slash | ||
67 | ) { | ||
68 | /* There are both dots and slashes, and 1st dot is | ||
69 | * before 1st slash. | ||
70 | * (IOW: not raw, unmangled a/b/c.d format) | ||
71 | * | ||
72 | * procps supports this syntax for names with dots: | ||
73 | * net.ipv4.conf.eth0/100.mc_forwarding | ||
74 | * (dots and slashes are simply swapped) | ||
75 | */ | ||
76 | while (end != name) { | ||
77 | end--; | ||
78 | if (*end == '.') *end = '/'; | ||
79 | else if (*end == '/') *end = '.'; | ||
80 | } | ||
81 | return; | ||
82 | } | ||
83 | /* else: use our old behavior: */ | ||
84 | |||
62 | /* Convert minimum number of '.' to '/' so that | 85 | /* Convert minimum number of '.' to '/' so that |
63 | * we end up with existing file's name. | 86 | * we end up with existing file's name. |
64 | * | 87 | * |
@@ -77,7 +100,6 @@ static void sysctl_dots_to_slashes(char *name) | |||
77 | * | 100 | * |
78 | * To set up testing: modprobe 8021q; vconfig add eth0 100 | 101 | * To set up testing: modprobe 8021q; vconfig add eth0 100 |
79 | */ | 102 | */ |
80 | end = strchrnul(name, '='); | ||
81 | end_ch = *end; | 103 | end_ch = *end; |
82 | *end = '.'; /* trick the loop into trying full name too */ | 104 | *end = '.'; /* trick the loop into trying full name too */ |
83 | 105 | ||
@@ -114,6 +136,8 @@ static int sysctl_act_on_setting(char *setting) | |||
114 | while (*cptr) { | 136 | while (*cptr) { |
115 | if (*cptr == '/') | 137 | if (*cptr == '/') |
116 | *cptr = '.'; | 138 | *cptr = '.'; |
139 | else if (*cptr == '.') | ||
140 | *cptr = '/'; | ||
117 | cptr++; | 141 | cptr++; |
118 | } | 142 | } |
119 | 143 | ||