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>
This commit is contained in:
parent
d1d794fd48
commit
c439851438
@ -12,21 +12,23 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//usage:#define sysctl_trivial_usage
|
//usage:#define sysctl_trivial_usage
|
||||||
//usage: "[OPTIONS] [VALUE]..."
|
//usage: "[OPTIONS] [KEY[=VALUE]]..."
|
||||||
//usage:#define sysctl_full_usage "\n\n"
|
//usage:#define sysctl_full_usage "\n\n"
|
||||||
//usage: "Configure kernel parameters at runtime\n"
|
//usage: "Show/set kernel parameters\n"
|
||||||
//usage: "\n -n Don't print key names"
|
|
||||||
//usage: "\n -e Don't warn about unknown keys"
|
//usage: "\n -e Don't warn about unknown keys"
|
||||||
//usage: "\n -w Change sysctl setting"
|
//usage: "\n -n Don't show key names"
|
||||||
//usage: "\n -p FILE Load sysctl settings from FILE (default /etc/sysctl.conf)"
|
//usage: "\n -a Show all values"
|
||||||
//usage: "\n -a Display all values"
|
/* Same as -a, no need to show it */
|
||||||
//usage: "\n -A Display all values in table form"
|
/* //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:
|
||||||
//usage:#define sysctl_example_usage
|
//usage:#define sysctl_example_usage
|
||||||
//usage: "sysctl [-n] [-e] variable...\n"
|
//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] -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"
|
//usage: "sysctl [-n] [-e] -A\n"
|
||||||
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
@ -37,9 +39,11 @@ enum {
|
|||||||
FLAG_TABLE_FORMAT = 1 << 2, /* not implemented */
|
FLAG_TABLE_FORMAT = 1 << 2, /* not implemented */
|
||||||
FLAG_SHOW_ALL = 1 << 3,
|
FLAG_SHOW_ALL = 1 << 3,
|
||||||
FLAG_PRELOAD_FILE = 1 << 4,
|
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_WRITE = 1 << 5,
|
||||||
|
FLAG_QUIET = 1 << 6,
|
||||||
};
|
};
|
||||||
#define OPTION_STR "neAapw"
|
#define OPTION_STR "neAapwq"
|
||||||
|
|
||||||
static void sysctl_dots_to_slashes(char *name)
|
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"
|
//TODO: procps 3.2.7 writes "value\n", note trailing "\n"
|
||||||
xwrite_str(fd, value);
|
xwrite_str(fd, value);
|
||||||
close(fd);
|
close(fd);
|
||||||
if (option_mask32 & FLAG_SHOW_KEYS)
|
if (!(option_mask32 & FLAG_QUIET)) {
|
||||||
printf("%s = ", outname);
|
if (option_mask32 & FLAG_SHOW_KEYS)
|
||||||
puts(value);
|
printf("%s = ", outname);
|
||||||
|
puts(value);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user