aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 ff5177abb..82bd309d1 100644
--- a/util-linux/ionice.c
+++ b/util-linux/ionice.c
@@ -18,12 +18,13 @@
18//kbuild:lib-$(CONFIG_IONICE) += ionice.o 18//kbuild:lib-$(CONFIG_IONICE) += ionice.o
19 19
20//usage:#define ionice_trivial_usage 20//usage:#define ionice_trivial_usage
21//usage: "[-c 1-3] [-n 0-7] { -p PID | PROG ARGS }" 21//usage: "[-c 1-3] [-n 0-7] [-t] { -p PID | PROG ARGS }"
22//TODO: | -P PGID | -u UID; also -pPu can take _list of_ IDs 22//TODO: | -P PGID | -u UID; also -pPu can take _list of_ IDs
23//usage:#define ionice_full_usage "\n\n" 23//usage:#define ionice_full_usage "\n\n"
24//usage: "Change I/O priority and class\n" 24//usage: "Change I/O priority and class\n"
25//usage: "\n -c N Class. 1:realtime 2:best-effort 3:idle" 25//usage: "\n -c N Class. 1:realtime 2:best-effort 3:idle"
26//usage: "\n -n N Priority" 26//usage: "\n -n N Priority"
27//usage: "\n -t Ignore errors"
27 28
28#include <sys/syscall.h> 29#include <sys/syscall.h>
29#include <asm/unistd.h> 30#include <asm/unistd.h>
@@ -65,14 +66,15 @@ int ionice_main(int argc UNUSED_PARAM, char **argv)
65 int pid = 0; /* affect own process */ 66 int pid = 0; /* affect own process */
66 int opt; 67 int opt;
67 enum { 68 enum {
68 OPT_n = 1, 69 OPT_n = 1 << 0,
69 OPT_c = 2, 70 OPT_c = 1 << 1,
70 OPT_p = 4, 71 OPT_p = 1 << 2,
72 OPT_t = 1 << 3,
71 }; 73 };
72 74
73 /* Numeric params */
74 /* '+': stop at first non-option */ 75 /* '+': stop at first non-option */
75 opt = getopt32(argv, "+n:+c:+p:+", &pri, &ioclass, &pid); 76 /* numeric params for -n -c -p */
77 opt = getopt32(argv, "+""n:+c:+p:+t", &pri, &ioclass, &pid);
76 argv += optind; 78 argv += optind;
77 79
78 if (opt & OPT_c) { 80 if (opt & OPT_c) {
@@ -105,7 +107,8 @@ int ionice_main(int argc UNUSED_PARAM, char **argv)
105//pri, ioclass, pri | (ioclass << IOPRIO_CLASS_SHIFT)); 107//pri, ioclass, pri | (ioclass << IOPRIO_CLASS_SHIFT));
106 pri |= (ioclass << IOPRIO_CLASS_SHIFT); 108 pri |= (ioclass << IOPRIO_CLASS_SHIFT);
107 if (ioprio_set(IOPRIO_WHO_PROCESS, pid, pri) == -1) 109 if (ioprio_set(IOPRIO_WHO_PROCESS, pid, pri) == -1)
108 bb_perror_msg_and_die("ioprio_%cet", 's'); 110 if (!(opt & OPT_t))
111 bb_perror_msg_and_die("ioprio_%cet", 's');
109 if (argv[0]) { 112 if (argv[0]) {
110 BB_EXECVP_or_die(argv); 113 BB_EXECVP_or_die(argv);
111 } 114 }