wok-6.x view busybox/stuff/busybox-1.12.0-ionice.u @ rev 5228

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