# HG changeset patch # User Pascal Bellard # Date 1246280992 -7200 # Node ID 9f07b09ba8955506be234104918cb5312151e7a6 # Parent bd1f4334ae5d400629f0e07fbbd1dea9d7fb1cb9 Busybox: add ionice diff -r bd1f4334ae5d -r 9f07b09ba895 busybox-pam/receipt --- a/busybox-pam/receipt Mon Jun 29 13:01:11 2009 +0200 +++ b/busybox-pam/receipt Mon Jun 29 15:09:52 2009 +0200 @@ -40,6 +40,7 @@ replay.u ris.u dpkg_deb.u +ionice.u EOT cp $WOK/busybox/stuff/$SOURCE-$VERSION.config .config sed -i 's/# CONFIG_PAM is not set/CONFIG_PAM=y/' .config diff -r bd1f4334ae5d -r 9f07b09ba895 busybox/receipt --- a/busybox/receipt Mon Jun 29 13:01:11 2009 +0200 +++ b/busybox/receipt Mon Jun 29 15:09:52 2009 +0200 @@ -38,6 +38,7 @@ replay.u ris.u dpkg_deb.u +ionice.u EOT cp ../stuff/$PACKAGE-$VERSION.config .config make oldconfig diff -r bd1f4334ae5d -r 9f07b09ba895 busybox/stuff/busybox-1.12.0-ionice.u --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/busybox/stuff/busybox-1.12.0-ionice.u Mon Jun 29 15:09:52 2009 +0200 @@ -0,0 +1,163 @@ +--- busybox-1.12.0/include/applets.h 2008-12-16 22:32:03.000000000 +0100 ++++ busybox-1.12.0/include/applets.h 2008-12-16 22:34:06.000000000 +0100 +@@ -191,6 +191,7 @@ + USE_INSMOD(APPLET(insmod, _BB_DIR_SBIN, _BB_SUID_NEVER)) + USE_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, _BB_DIR_SBIN, _BB_SUID_NEVER, modprobe)) + USE_INSTALL(APPLET(install, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) ++USE_IONICE(APPLET(ionice, _BB_DIR_BIN, _BB_SUID_NEVER)) + #if ENABLE_FEATURE_IP_ADDRESS \ + || ENABLE_FEATURE_IP_ROUTE \ + || ENABLE_FEATURE_IP_LINK \ + + +--- busybox-1.12.0/miscutils/Config.in 2008-12-14 23:41:16.000000000 +0100 ++++ busybox-1.12.0/miscutils/Config.in 2008-12-14 23:27:56.000000000 +0100 +@@ -223,6 +223,13 @@ + "NN" (ASCII decimal number) - percentage to show on progress bar + "exit" - well you guessed it + ++config IONICE ++ bool "ionice" ++ default n ++ help ++ get/set program io scheduling class and priority ++ Requires kernel >= 2.6.13 ++ + config INOTIFYD + bool "inotifyd" + default n + +--- busybox-1.12.0/miscutils/Kbuild 2008-12-14 23:22:52.000000000 +0100 ++++ busybox-1.12.0/miscutils/Kbuild 2008-12-14 23:22:27.000000000 +0100 +@@ -16,4 +16,5 @@ + lib-$(CONFIG_EJECT) += eject.o + lib-$(CONFIG_FBSPLASH) += fbsplash.o ++lib-$(CONFIG_IONICE) += ionice.o + lib-$(CONFIG_HDPARM) += hdparm.o + lib-$(CONFIG_INOTIFYD) += inotifyd.o + +--- busybox-1.12.0/include/usage.h 2008-12-16 22:31:43.000000000 +0100 ++++ busybox-1.12.0/include/usage.h 2008-12-16 22:32:14.000000000 +0100 +@@ -1884,6 +1884,16 @@ + USE_SELINUX( \ + "\n -Z Set security context of copy" \ + ) ++ ++#define ionice_trivial_usage \ ++ "[-c 1-3] [-n 0-7] [-p PID] [COMMAND [ARG...]]" ++#define ionice_full_usage "\n\n" \ ++ "change io scheduling class and priority\n" \ ++ "\nOptions:" \ ++ "\n -c scheduling class. 1=real time 2=best-effort, 3=idle" \ ++ "\n -n Priority " \ ++ "\n -p process pid " ++ + + /* would need to make the " | " optional depending on more than one selected: */ + #define ip_trivial_usage \ + +diff --git busybox-1.12.0/miscutils/ionice.c busybox-1.12.0/miscutils/ionice.c +new file mode 100644 +index 0000000..88d771c +--- busybox-1.12.0/dev/null ++++ busybox-1.12.0/miscutils/ionice.c +@@ -0,0 +1,99 @@ ++/* vi: set sw=4 ts=4: */ ++/* ++ * ionice implementation for busybox based on linux-utils-ng 2.14 ++ * ++ * Copyright (C) 2008 by ++ * ++ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. ++ */ ++ ++#include ++#include ++#include "libbb.h" ++ ++static int ioprio_set(int which, int who, int ioprio) ++{ ++ return syscall(SYS_ioprio_set, which, who, ioprio); ++} ++ ++static int ioprio_get(int which, int who) ++{ ++ return syscall(SYS_ioprio_get, which, who); ++} ++ ++enum { ++ IOPRIO_WHO_PROCESS = 1, ++ IOPRIO_WHO_PGRP, ++ IOPRIO_WHO_USER ++}; ++ ++enum { ++ IOPRIO_CLASS_NONE, ++ IOPRIO_CLASS_RT, ++ IOPRIO_CLASS_BE, ++ IOPRIO_CLASS_IDLE ++}; ++ ++static const char to_prio[] = "none\0realtime\0best-effort\0idle"; ++ ++#define IOPRIO_CLASS_SHIFT 13 ++ ++int ionice_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; ++int ionice_main(int argc UNUSED_PARAM, char **argv) ++{ ++ /* Defaults */ ++ int ioclass = 0; ++ int pri = 0; ++ int pid = 0; /* affect own porcess */ ++ int opt; ++ enum { ++ OPT_n = 1, ++ OPT_c = 2, ++ OPT_p = 4, ++ }; ++ ++ /* Numeric params */ ++ opt_complementary = "n+:c+:p+"; ++ /* '+': stop at first non-option */ ++ opt = getopt32(argv, "+n:c:p:", &pri, &ioclass, &pid); ++ argv += optind; ++ ++ if (opt & OPT_c) { ++ if (ioclass > 3) ++ bb_error_msg_and_die("bad class %d", ioclass); ++// Do we need this (compat?)? ++// if (ioclass == IOPRIO_CLASS_NONE) ++// ioclass = IOPRIO_CLASS_BE; ++// if (ioclass == IOPRIO_CLASS_IDLE) { ++// //if (opt & OPT_n) ++// // bb_error_msg("ignoring priority for idle class"); ++// pri = 7; ++// } ++ } ++ ++ if (!(opt & (OPT_n|OPT_c))) { ++ if (!(opt & OPT_p) && *argv) ++ pid = xatoi_u(*argv); ++ ++ pri = ioprio_get(IOPRIO_WHO_PROCESS, pid); ++ if (pri == -1) ++ bb_perror_msg_and_die("ioprio_%cet", 'g'); ++ ++ ioclass = (pri >> IOPRIO_CLASS_SHIFT) & 0x3; ++ pri &= 0xff; ++ printf((ioclass == IOPRIO_CLASS_IDLE) ? "%s\n" : "%s: prio %d\n", ++ nth_string(to_prio, ioclass), pri); ++ } else { ++//printf("pri=%d class=%d val=%x\n", ++//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 (*argv) { ++ BB_EXECVP(*argv, argv); ++ bb_simple_perror_msg_and_die(*argv); ++ } ++ } ++ ++ return EXIT_SUCCESS; ++} diff -r bd1f4334ae5d -r 9f07b09ba895 busybox/stuff/busybox-1.12.0.config --- a/busybox/stuff/busybox-1.12.0.config Mon Jun 29 13:01:11 2009 +0200 +++ b/busybox/stuff/busybox-1.12.0.config Mon Jun 29 15:09:52 2009 +0200 @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Busybox version: 1.12.0 -# Thu Jun 25 17:05:48 2009 +# Mon Jun 29 15:06:02 2009 # CONFIG_HAVE_DOT_CONFIG=y @@ -569,6 +569,7 @@ CONFIG_EJECT=y CONFIG_FEATURE_EJECT_SCSI=y # CONFIG_FBSPLASH is not set +CONFIG_IONICE=y # CONFIG_INOTIFYD is not set CONFIG_LAST=y CONFIG_FEATURE_LAST_SMALL=y