svn commit: trunk/busybox/procps
vda at busybox.net
vda at busybox.net
Wed Oct 15 08:22:55 UTC 2008
Author: vda
Date: 2008-10-15 01:22:55 -0700 (Wed, 15 Oct 2008)
New Revision: 23679
Log:
sysctl: fix bug 3894 (by Kryzhanovskyy Maksym)
function old new delta
sysctl_dots_to_slashes - 47 +47
sysctl_write_setting 310 298 -12
sysctl_read_setting 296 284 -12
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 47/-24) Total: 23 bytes
Modified:
trunk/busybox/procps/sysctl.c
Changeset:
Modified: trunk/busybox/procps/sysctl.c
===================================================================
--- trunk/busybox/procps/sysctl.c 2008-10-14 16:20:55 UTC (rev 23678)
+++ trunk/busybox/procps/sysctl.c 2008-10-15 08:22:55 UTC (rev 23679)
@@ -20,6 +20,7 @@
static int sysctl_write_setting(const char *setting);
static int sysctl_display_all(const char *path);
static int sysctl_preload_file_and_exit(const char *filename);
+static void sysctl_dots_to_slashes(char *name);
static const char ETC_SYSCTL_CONF[] ALIGN1 = "/etc/sysctl.conf";
static const char PROC_SYS[] ALIGN1 = "/proc/sys/";
@@ -143,8 +144,7 @@
tmpname = xasprintf("%s%.*s", PROC_SYS, (int)(equals - name), name);
outname = xstrdup(tmpname + strlen_PROC_SYS);
- while ((cptr = strchr(tmpname, '.')) != NULL)
- *cptr = '/';
+ sysctl_dots_to_slashes(tmpname);
while ((cptr = strchr(outname, '/')) != NULL)
*cptr = '.';
@@ -198,8 +198,8 @@
tmpname = concat_path_file(PROC_SYS, name);
outname = xstrdup(tmpname + strlen_PROC_SYS);
- while ((cptr = strchr(tmpname, '.')) != NULL)
- *cptr = '/';
+ sysctl_dots_to_slashes(tmpname);
+
while ((cptr = strchr(outname, '/')) != NULL)
*cptr = '.';
@@ -266,3 +266,22 @@
return retval;
} /* end sysctl_display_all() */
+
+static void sysctl_dots_to_slashes(char *name)
+{
+ char *cptr = name;
+
+ /* Example from bug 3894:
+ * net.ipv4.conf.eth0.100.mc_forwarding ->
+ * net/ipv4/conf/eth0.100/mc_forwarding */
+ while (*cptr != '\0') {
+ if (*cptr == '.') {
+ *cptr = '\0';
+ if (access(name, F_OK) == 0)
+ *cptr = '/';
+ else
+ *cptr = '.';
+ }
+ cptr++;
+ }
+} /* end sysctl_dots_to_slashes() */
More information about the busybox-cvs
mailing list