rev |
line source |
pascal@3613
|
1 --- busybox-1.12.0/include/applets.h 2008-12-16 22:32:03.000000000 +0100
|
pascal@3613
|
2 +++ busybox-1.12.0/include/applets.h 2008-12-16 22:34:06.000000000 +0100
|
pascal@3613
|
3 @@ -191,6 +191,7 @@
|
pascal@3613
|
4 USE_INSMOD(APPLET(insmod, _BB_DIR_SBIN, _BB_SUID_NEVER))
|
pascal@3613
|
5 USE_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, _BB_DIR_SBIN, _BB_SUID_NEVER, modprobe))
|
pascal@3613
|
6 USE_INSTALL(APPLET(install, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
|
pascal@3613
|
7 +USE_IONICE(APPLET(ionice, _BB_DIR_BIN, _BB_SUID_NEVER))
|
pascal@3613
|
8 #if ENABLE_FEATURE_IP_ADDRESS \
|
pascal@3613
|
9 || ENABLE_FEATURE_IP_ROUTE \
|
pascal@3613
|
10 || ENABLE_FEATURE_IP_LINK \
|
pascal@3613
|
11
|
pascal@3613
|
12
|
pascal@3613
|
13 --- busybox-1.12.0/miscutils/Config.in 2008-12-14 23:41:16.000000000 +0100
|
pascal@3613
|
14 +++ busybox-1.12.0/miscutils/Config.in 2008-12-14 23:27:56.000000000 +0100
|
pascal@3613
|
15 @@ -223,6 +223,13 @@
|
pascal@3613
|
16 "NN" (ASCII decimal number) - percentage to show on progress bar
|
pascal@3613
|
17 "exit" - well you guessed it
|
pascal@3613
|
18
|
pascal@3613
|
19 +config IONICE
|
pascal@3613
|
20 + bool "ionice"
|
pascal@3613
|
21 + default n
|
pascal@3613
|
22 + help
|
pascal@3613
|
23 + get/set program io scheduling class and priority
|
pascal@3613
|
24 + Requires kernel >= 2.6.13
|
pascal@3613
|
25 +
|
pascal@3613
|
26 config INOTIFYD
|
pascal@3613
|
27 bool "inotifyd"
|
pascal@3613
|
28 default n
|
pascal@3613
|
29
|
pascal@3613
|
30 --- busybox-1.12.0/miscutils/Kbuild 2008-12-14 23:22:52.000000000 +0100
|
pascal@3613
|
31 +++ busybox-1.12.0/miscutils/Kbuild 2008-12-14 23:22:27.000000000 +0100
|
pascal@3613
|
32 @@ -16,4 +16,5 @@
|
pascal@3613
|
33 lib-$(CONFIG_EJECT) += eject.o
|
pascal@3613
|
34 lib-$(CONFIG_FBSPLASH) += fbsplash.o
|
pascal@3613
|
35 +lib-$(CONFIG_IONICE) += ionice.o
|
pascal@3613
|
36 lib-$(CONFIG_HDPARM) += hdparm.o
|
pascal@3613
|
37 lib-$(CONFIG_INOTIFYD) += inotifyd.o
|
pascal@3613
|
38
|
pascal@3613
|
39 --- busybox-1.12.0/include/usage.h 2008-12-16 22:31:43.000000000 +0100
|
pascal@3613
|
40 +++ busybox-1.12.0/include/usage.h 2008-12-16 22:32:14.000000000 +0100
|
pascal@3613
|
41 @@ -1884,6 +1884,16 @@
|
pascal@3613
|
42 USE_SELINUX( \
|
pascal@3613
|
43 "\n -Z Set security context of copy" \
|
pascal@3613
|
44 )
|
pascal@3613
|
45 +
|
pascal@3613
|
46 +#define ionice_trivial_usage \
|
pascal@3613
|
47 + "[-c 1-3] [-n 0-7] [-p PID] [COMMAND [ARG...]]"
|
pascal@3613
|
48 +#define ionice_full_usage "\n\n" \
|
pascal@3613
|
49 + "change io scheduling class and priority\n" \
|
pascal@3613
|
50 + "\nOptions:" \
|
pascal@3613
|
51 + "\n -c scheduling class. 1=real time 2=best-effort, 3=idle" \
|
pascal@3613
|
52 + "\n -n Priority " \
|
pascal@3613
|
53 + "\n -p process pid "
|
pascal@3613
|
54 +
|
pascal@3613
|
55
|
pascal@3613
|
56 /* would need to make the " | " optional depending on more than one selected: */
|
pascal@3613
|
57 #define ip_trivial_usage \
|
pascal@3613
|
58
|
pascal@3613
|
59 diff --git busybox-1.12.0/miscutils/ionice.c busybox-1.12.0/miscutils/ionice.c
|
pascal@3613
|
60 new file mode 100644
|
pascal@3613
|
61 index 0000000..88d771c
|
pascal@3613
|
62 --- busybox-1.12.0/dev/null
|
pascal@3613
|
63 +++ busybox-1.12.0/miscutils/ionice.c
|
pascal@3613
|
64 @@ -0,0 +1,99 @@
|
pascal@3613
|
65 +/* vi: set sw=4 ts=4: */
|
pascal@3613
|
66 +/*
|
pascal@3613
|
67 + * ionice implementation for busybox based on linux-utils-ng 2.14
|
pascal@3613
|
68 + *
|
pascal@3613
|
69 + * Copyright (C) 2008 by <u173034@informatik.uni-oldenburg.de>
|
pascal@3613
|
70 + *
|
pascal@3613
|
71 + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
pascal@3613
|
72 + */
|
pascal@3613
|
73 +
|
pascal@3613
|
74 +#include <sys/syscall.h>
|
pascal@3613
|
75 +#include <asm/unistd.h>
|
pascal@3613
|
76 +#include "libbb.h"
|
pascal@3613
|
77 +
|
pascal@3613
|
78 +static int ioprio_set(int which, int who, int ioprio)
|
pascal@3613
|
79 +{
|
pascal@3613
|
80 + return syscall(SYS_ioprio_set, which, who, ioprio);
|
pascal@3613
|
81 +}
|
pascal@3613
|
82 +
|
pascal@3613
|
83 +static int ioprio_get(int which, int who)
|
pascal@3613
|
84 +{
|
pascal@3613
|
85 + return syscall(SYS_ioprio_get, which, who);
|
pascal@3613
|
86 +}
|
pascal@3613
|
87 +
|
pascal@3613
|
88 +enum {
|
pascal@3613
|
89 + IOPRIO_WHO_PROCESS = 1,
|
pascal@3613
|
90 + IOPRIO_WHO_PGRP,
|
pascal@3613
|
91 + IOPRIO_WHO_USER
|
pascal@3613
|
92 +};
|
pascal@3613
|
93 +
|
pascal@3613
|
94 +enum {
|
pascal@3613
|
95 + IOPRIO_CLASS_NONE,
|
pascal@3613
|
96 + IOPRIO_CLASS_RT,
|
pascal@3613
|
97 + IOPRIO_CLASS_BE,
|
pascal@3613
|
98 + IOPRIO_CLASS_IDLE
|
pascal@3613
|
99 +};
|
pascal@3613
|
100 +
|
pascal@3613
|
101 +static const char to_prio[] = "none\0realtime\0best-effort\0idle";
|
pascal@3613
|
102 +
|
pascal@3613
|
103 +#define IOPRIO_CLASS_SHIFT 13
|
pascal@3613
|
104 +
|
pascal@3613
|
105 +int ionice_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
pascal@3613
|
106 +int ionice_main(int argc UNUSED_PARAM, char **argv)
|
pascal@3613
|
107 +{
|
pascal@3613
|
108 + /* Defaults */
|
pascal@3613
|
109 + int ioclass = 0;
|
pascal@3613
|
110 + int pri = 0;
|
pascal@3613
|
111 + int pid = 0; /* affect own porcess */
|
pascal@3613
|
112 + int opt;
|
pascal@3613
|
113 + enum {
|
pascal@3613
|
114 + OPT_n = 1,
|
pascal@3613
|
115 + OPT_c = 2,
|
pascal@3613
|
116 + OPT_p = 4,
|
pascal@3613
|
117 + };
|
pascal@3613
|
118 +
|
pascal@3613
|
119 + /* Numeric params */
|
pascal@3613
|
120 + opt_complementary = "n+:c+:p+";
|
pascal@3613
|
121 + /* '+': stop at first non-option */
|
pascal@3613
|
122 + opt = getopt32(argv, "+n:c:p:", &pri, &ioclass, &pid);
|
pascal@3613
|
123 + argv += optind;
|
pascal@3613
|
124 +
|
pascal@3613
|
125 + if (opt & OPT_c) {
|
pascal@3613
|
126 + if (ioclass > 3)
|
pascal@3613
|
127 + bb_error_msg_and_die("bad class %d", ioclass);
|
pascal@3613
|
128 +// Do we need this (compat?)?
|
pascal@3613
|
129 +// if (ioclass == IOPRIO_CLASS_NONE)
|
pascal@3613
|
130 +// ioclass = IOPRIO_CLASS_BE;
|
pascal@3613
|
131 +// if (ioclass == IOPRIO_CLASS_IDLE) {
|
pascal@3613
|
132 +// //if (opt & OPT_n)
|
pascal@3613
|
133 +// // bb_error_msg("ignoring priority for idle class");
|
pascal@3613
|
134 +// pri = 7;
|
pascal@3613
|
135 +// }
|
pascal@3613
|
136 + }
|
pascal@3613
|
137 +
|
pascal@3613
|
138 + if (!(opt & (OPT_n|OPT_c))) {
|
pascal@3613
|
139 + if (!(opt & OPT_p) && *argv)
|
pascal@3613
|
140 + pid = xatoi_u(*argv);
|
pascal@3613
|
141 +
|
pascal@3613
|
142 + pri = ioprio_get(IOPRIO_WHO_PROCESS, pid);
|
pascal@3613
|
143 + if (pri == -1)
|
pascal@3613
|
144 + bb_perror_msg_and_die("ioprio_%cet", 'g');
|
pascal@3613
|
145 +
|
pascal@3613
|
146 + ioclass = (pri >> IOPRIO_CLASS_SHIFT) & 0x3;
|
pascal@3613
|
147 + pri &= 0xff;
|
pascal@3613
|
148 + printf((ioclass == IOPRIO_CLASS_IDLE) ? "%s\n" : "%s: prio %d\n",
|
pascal@3613
|
149 + nth_string(to_prio, ioclass), pri);
|
pascal@3613
|
150 + } else {
|
pascal@3613
|
151 +//printf("pri=%d class=%d val=%x\n",
|
pascal@3613
|
152 +//pri, ioclass, pri | (ioclass << IOPRIO_CLASS_SHIFT));
|
pascal@3613
|
153 + pri |= (ioclass << IOPRIO_CLASS_SHIFT);
|
pascal@3613
|
154 + if (ioprio_set(IOPRIO_WHO_PROCESS, pid, pri) == -1)
|
pascal@3613
|
155 + bb_perror_msg_and_die("ioprio_%cet", 's');
|
pascal@3613
|
156 + if (*argv) {
|
pascal@3613
|
157 + BB_EXECVP(*argv, argv);
|
pascal@3613
|
158 + bb_simple_perror_msg_and_die(*argv);
|
pascal@3613
|
159 + }
|
pascal@3613
|
160 + }
|
pascal@3613
|
161 +
|
pascal@3613
|
162 + return EXIT_SUCCESS;
|
pascal@3613
|
163 +}
|