diff options
author | Joshua Kahlenberg <jbkberg@gmail.com> | 2012-09-05 18:15:12 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-09-05 18:15:12 +0200 |
commit | c4398514385f806e1725685d0fee62dc0eb69b9f (patch) | |
tree | 12812f00c4d76c1ec96803c80e3c1047e6aba0d5 /procps | |
parent | d1d794fd4878834324602ae12ad7af73064683a9 (diff) | |
download | busybox-c4398514385f806e1725685d0fee62dc0eb69b9f.tar.gz |
sysctl: implement -q
function old new delta
packed_usage 29208 29223 +15
sysctl_act_recursive 605 598 -7
sysctl_main 233 222 -11
Signed-off-by: Joshua Kahlenberg <jbkberg@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'procps')
-rw-r--r-- | procps/sysctl.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/procps/sysctl.c b/procps/sysctl.c index 5296d0f58..878656862 100644 --- a/procps/sysctl.c +++ b/procps/sysctl.c @@ -12,21 +12,23 @@ */ //usage:#define sysctl_trivial_usage -//usage: "[OPTIONS] [VALUE]..." +//usage: "[OPTIONS] [KEY[=VALUE]]..." //usage:#define sysctl_full_usage "\n\n" -//usage: "Configure kernel parameters at runtime\n" -//usage: "\n -n Don't print key names" +//usage: "Show/set kernel parameters\n" //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: "\n -n Don't show key names" +//usage: "\n -a Show all values" +/* Same as -a, no need to show it */ +/* //usage: "\n -A Show all values in table form" */ +//usage: "\n -w Set values" +//usage: "\n -p FILE Set values from FILE (default /etc/sysctl.conf)" +//usage: "\n -q Set values silently" //usage: //usage:#define sysctl_example_usage //usage: "sysctl [-n] [-e] variable...\n" -//usage: "sysctl [-n] [-e] -w variable=value...\n" +//usage: "sysctl [-n] [-e] [-q] -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] [-q] -p file (default /etc/sysctl.conf)\n" //usage: "sysctl [-n] [-e] -A\n" #include "libbb.h" @@ -37,9 +39,11 @@ enum { FLAG_TABLE_FORMAT = 1 << 2, /* not implemented */ FLAG_SHOW_ALL = 1 << 3, FLAG_PRELOAD_FILE = 1 << 4, +/* TODO: procps 3.2.8 seems to not require -w for KEY=VAL to work: */ FLAG_WRITE = 1 << 5, + FLAG_QUIET = 1 << 6, }; -#define OPTION_STR "neAapw" +#define OPTION_STR "neAapwq" static void sysctl_dots_to_slashes(char *name) { @@ -144,9 +148,11 @@ static int sysctl_act_on_setting(char *setting) //TODO: procps 3.2.7 writes "value\n", note trailing "\n" xwrite_str(fd, value); close(fd); - if (option_mask32 & FLAG_SHOW_KEYS) - printf("%s = ", outname); - puts(value); + if (!(option_mask32 & FLAG_QUIET)) { + if (option_mask32 & FLAG_SHOW_KEYS) + printf("%s = ", outname); + puts(value); + } } else { char c; |