Fix find -follow support
[oweals/busybox.git] / procps / sysctl.c
index c9063bf07310041fe42039835023e62336778a10..cb3b6a25a2fde51250bd314bea3eb4c324e5e405 100644 (file)
@@ -4,13 +4,31 @@
  *
  * Copyright 1999 George Staikos
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  *
  * Changelog:
  * v1.01   - added -p <preload> to preload values from a file
  * v1.01.1 - busybox applet aware by <solar@gentoo.org>
  */
 
+//usage:#define sysctl_trivial_usage
+//usage:       "[OPTIONS] [VALUE]..."
+//usage:#define sysctl_full_usage "\n\n"
+//usage:       "Configure kernel parameters at runtime\n"
+//usage:     "\n       -n      Don't print key names"
+//usage:     "\n       -e      Don't warn about unknown keys"
+//usage:     "\n       -w      Change sysctl setting"
+//usage:     "\n       -p FILE Load sysctl settings from FILE (default /etc/sysctl.conf)"
+//usage:     "\n       -a      Display all values"
+//usage:     "\n       -A      Display all values in table form"
+//usage:
+//usage:#define sysctl_example_usage
+//usage:       "sysctl [-n] [-e] variable...\n"
+//usage:       "sysctl [-n] [-e] -w variable=value...\n"
+//usage:       "sysctl [-n] [-e] -a\n"
+//usage:       "sysctl [-n] [-e] -p file       (default /etc/sysctl.conf)\n"
+//usage:       "sysctl [-n] [-e] -A\n"
+
 #include "libbb.h"
 
 enum {
@@ -56,8 +74,7 @@ static void sysctl_dots_to_slashes(char *name)
                        *cptr = '\0';
                        //bb_error_msg("trying:'%s'", name);
                        if (access(name, F_OK) == 0) {
-                               if (cptr != end) /* prevent trailing '/' */
-                                       *cptr = '/';
+                               *cptr = '/';
                                //bb_error_msg("replaced:'%s'", name);
                                last_good = cptr;
                                goto again;
@@ -92,7 +109,7 @@ static int sysctl_act_on_setting(char *setting)
                        retval = EXIT_FAILURE;
                        goto end;
                }
-               value = cptr + 1;       /* point to the value in name=value */
+               value = cptr + 1;  /* point to the value in name=value */
                if (setting == cptr || !*value) {
                        bb_error_msg("error: malformed setting '%s'", outname);
                        retval = EXIT_FAILURE;
@@ -213,6 +230,7 @@ static int sysctl_handle_preload_file(const char *filename)
 //TODO: comment may be only at line start. "var=1 #abc" - "1 #abc" is the value
 // (but _whitespace_ from ends should be trimmed first (and we do it right))
 //TODO: "var==1" is mishandled (must use "=1" as a value, but uses "1")
+// can it be fixed by removing PARSE_COLLAPSE bit?
        while (config_read(parser, token, 2, 2, "# \t=", PARSE_NORMAL)) {
                char *tp;
                sysctl_dots_to_slashes(token[0]);