summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2021-06-17 13:45:13 +0200
committerDenys Vlasenko2021-06-17 13:45:13 +0200
commitf02b64de864b03ac29b64efb7eb26658da05b1a2 (patch)
tree4b61f0777fdcacbbf8b9c535abbbccded9cfa3a1
parentc113796884c972244595040466975c74667d4359 (diff)
downloadbusybox-f02b64de864b03ac29b64efb7eb26658da05b1a2.zip
busybox-f02b64de864b03ac29b64efb7eb26658da05b1a2.tar.gz
ionice: implement -t
function old new delta packed_usage 33618 33629 +11 ionice_main 272 282 +10 .rodata 103250 103251 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 22/0) Total: 22 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--util-linux/ionice.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/util-linux/ionice.c b/util-linux/ionice.c
index ff5177a..82bd309 100644
--- a/util-linux/ionice.c
+++ b/util-linux/ionice.c
@@ -18,12 +18,13 @@
//kbuild:lib-$(CONFIG_IONICE) += ionice.o
//usage:#define ionice_trivial_usage
-//usage: "[-c 1-3] [-n 0-7] { -p PID | PROG ARGS }"
+//usage: "[-c 1-3] [-n 0-7] [-t] { -p PID | PROG ARGS }"
//TODO: | -P PGID | -u UID; also -pPu can take _list of_ IDs
//usage:#define ionice_full_usage "\n\n"
//usage: "Change I/O priority and class\n"
//usage: "\n -c N Class. 1:realtime 2:best-effort 3:idle"
//usage: "\n -n N Priority"
+//usage: "\n -t Ignore errors"
#include <sys/syscall.h>
#include <asm/unistd.h>
@@ -65,14 +66,15 @@ int ionice_main(int argc UNUSED_PARAM, char **argv)
int pid = 0; /* affect own process */
int opt;
enum {
- OPT_n = 1,
- OPT_c = 2,
- OPT_p = 4,
+ OPT_n = 1 << 0,
+ OPT_c = 1 << 1,
+ OPT_p = 1 << 2,
+ OPT_t = 1 << 3,
};
- /* Numeric params */
/* '+': stop at first non-option */
- opt = getopt32(argv, "+n:+c:+p:+", &pri, &ioclass, &pid);
+ /* numeric params for -n -c -p */
+ opt = getopt32(argv, "+""n:+c:+p:+t", &pri, &ioclass, &pid);
argv += optind;
if (opt & OPT_c) {
@@ -105,7 +107,8 @@ int ionice_main(int argc UNUSED_PARAM, char **argv)
//pri, ioclass, pri | (ioclass << IOPRIO_CLASS_SHIFT));
pri |= (ioclass << IOPRIO_CLASS_SHIFT);
if (ioprio_set(IOPRIO_WHO_PROCESS, pid, pri) == -1)
- bb_perror_msg_and_die("ioprio_%cet", 's');
+ if (!(opt & OPT_t))
+ bb_perror_msg_and_die("ioprio_%cet", 's');
if (argv[0]) {
BB_EXECVP_or_die(argv);
}