wok rev 3613

Busybox: add ionice
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Jun 29 15:09:52 2009 +0200 (2009-06-29)
parents bd1f4334ae5d
children cf59d85c8bd5
files busybox-pam/receipt busybox/receipt busybox/stuff/busybox-1.12.0-ionice.u busybox/stuff/busybox-1.12.0.config
line diff
     1.1 --- a/busybox-pam/receipt	Mon Jun 29 13:01:11 2009 +0200
     1.2 +++ b/busybox-pam/receipt	Mon Jun 29 15:09:52 2009 +0200
     1.3 @@ -40,6 +40,7 @@
     1.4  replay.u
     1.5  ris.u
     1.6  dpkg_deb.u
     1.7 +ionice.u
     1.8  EOT
     1.9      cp $WOK/busybox/stuff/$SOURCE-$VERSION.config .config
    1.10      sed -i 's/# CONFIG_PAM is not set/CONFIG_PAM=y/' .config
     2.1 --- a/busybox/receipt	Mon Jun 29 13:01:11 2009 +0200
     2.2 +++ b/busybox/receipt	Mon Jun 29 15:09:52 2009 +0200
     2.3 @@ -38,6 +38,7 @@
     2.4  replay.u
     2.5  ris.u
     2.6  dpkg_deb.u
     2.7 +ionice.u
     2.8  EOT
     2.9      cp ../stuff/$PACKAGE-$VERSION.config .config
    2.10      make oldconfig
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/busybox/stuff/busybox-1.12.0-ionice.u	Mon Jun 29 15:09:52 2009 +0200
     3.3 @@ -0,0 +1,163 @@
     3.4 +--- busybox-1.12.0/include/applets.h	2008-12-16 22:32:03.000000000 +0100
     3.5 ++++ busybox-1.12.0/include/applets.h	2008-12-16 22:34:06.000000000 +0100
     3.6 +@@ -191,6 +191,7 @@
     3.7 + USE_INSMOD(APPLET(insmod, _BB_DIR_SBIN, _BB_SUID_NEVER))
     3.8 + USE_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, _BB_DIR_SBIN, _BB_SUID_NEVER, modprobe))
     3.9 + USE_INSTALL(APPLET(install, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
    3.10 ++USE_IONICE(APPLET(ionice, _BB_DIR_BIN, _BB_SUID_NEVER))
    3.11 + #if ENABLE_FEATURE_IP_ADDRESS \
    3.12 +  || ENABLE_FEATURE_IP_ROUTE \
    3.13 +  || ENABLE_FEATURE_IP_LINK \
    3.14 +
    3.15 +
    3.16 +--- busybox-1.12.0/miscutils/Config.in	2008-12-14 23:41:16.000000000 +0100
    3.17 ++++ busybox-1.12.0/miscutils/Config.in	2008-12-14 23:27:56.000000000 +0100
    3.18 +@@ -223,6 +223,13 @@
    3.19 + 	    "NN" (ASCII decimal number) - percentage to show on progress bar
    3.20 + 	    "exit" - well you guessed it
    3.21 + 
    3.22 ++config IONICE
    3.23 ++	bool "ionice"
    3.24 ++	default n
    3.25 ++	help
    3.26 ++	  get/set program io scheduling class and priority
    3.27 ++	  Requires kernel >= 2.6.13
    3.28 ++
    3.29 + config INOTIFYD
    3.30 + 	bool "inotifyd"
    3.31 + 	default n
    3.32 +
    3.33 +--- busybox-1.12.0/miscutils/Kbuild	2008-12-14 23:22:52.000000000 +0100
    3.34 ++++ busybox-1.12.0/miscutils/Kbuild	2008-12-14 23:22:27.000000000 +0100
    3.35 +@@ -16,4 +16,5 @@
    3.36 + lib-$(CONFIG_EJECT)       += eject.o
    3.37 + lib-$(CONFIG_FBSPLASH)    += fbsplash.o
    3.38 ++lib-$(CONFIG_IONICE)      += ionice.o
    3.39 + lib-$(CONFIG_HDPARM)      += hdparm.o
    3.40 + lib-$(CONFIG_INOTIFYD)    += inotifyd.o
    3.41 +
    3.42 +--- busybox-1.12.0/include/usage.h	2008-12-16 22:31:43.000000000 +0100
    3.43 ++++ busybox-1.12.0/include/usage.h	2008-12-16 22:32:14.000000000 +0100
    3.44 +@@ -1884,6 +1884,16 @@
    3.45 + 	USE_SELINUX( \
    3.46 +      "\n	-Z	Set security context of copy" \
    3.47 + 	)
    3.48 ++	
    3.49 ++#define ionice_trivial_usage \
    3.50 ++	"[-c 1-3] [-n 0-7] [-p PID] [COMMAND [ARG...]]"
    3.51 ++#define ionice_full_usage "\n\n" \
    3.52 ++       "change io scheduling class and priority\n" \
    3.53 ++     "\nOptions:" \
    3.54 ++     "\n	-c  scheduling class. 1=real time 2=best-effort, 3=idle" \
    3.55 ++     "\n	-n  Priority " \
    3.56 ++     "\n	-p   process pid " 
    3.57 ++
    3.58 + 
    3.59 + /* would need to make the " | " optional depending on more than one selected: */
    3.60 + #define ip_trivial_usage \
    3.61 +
    3.62 +diff --git busybox-1.12.0/miscutils/ionice.c busybox-1.12.0/miscutils/ionice.c
    3.63 +new file mode 100644
    3.64 +index 0000000..88d771c
    3.65 +--- busybox-1.12.0/dev/null
    3.66 ++++ busybox-1.12.0/miscutils/ionice.c
    3.67 +@@ -0,0 +1,99 @@
    3.68 ++/* vi: set sw=4 ts=4: */
    3.69 ++/*
    3.70 ++ * ionice implementation for busybox based on linux-utils-ng 2.14
    3.71 ++ *
    3.72 ++ * Copyright (C) 2008 by <u173034@informatik.uni-oldenburg.de>
    3.73 ++ *
    3.74 ++ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
    3.75 ++ */
    3.76 ++
    3.77 ++#include <sys/syscall.h>
    3.78 ++#include <asm/unistd.h>
    3.79 ++#include "libbb.h"
    3.80 ++
    3.81 ++static int ioprio_set(int which, int who, int ioprio)
    3.82 ++{
    3.83 ++ return syscall(SYS_ioprio_set, which, who, ioprio);
    3.84 ++}
    3.85 ++
    3.86 ++static int ioprio_get(int which, int who)
    3.87 ++{
    3.88 ++ return syscall(SYS_ioprio_get, which, who);
    3.89 ++}
    3.90 ++
    3.91 ++enum {
    3.92 ++ IOPRIO_WHO_PROCESS = 1,
    3.93 ++ IOPRIO_WHO_PGRP,
    3.94 ++ IOPRIO_WHO_USER
    3.95 ++};
    3.96 ++
    3.97 ++enum {
    3.98 ++ IOPRIO_CLASS_NONE,
    3.99 ++ IOPRIO_CLASS_RT,
   3.100 ++ IOPRIO_CLASS_BE,
   3.101 ++ IOPRIO_CLASS_IDLE
   3.102 ++};
   3.103 ++
   3.104 ++static const char to_prio[] = "none\0realtime\0best-effort\0idle";
   3.105 ++
   3.106 ++#define IOPRIO_CLASS_SHIFT 13
   3.107 ++
   3.108 ++int ionice_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
   3.109 ++int ionice_main(int argc UNUSED_PARAM, char **argv)
   3.110 ++{
   3.111 ++ /* Defaults */
   3.112 ++ int ioclass = 0;
   3.113 ++ int pri = 0;
   3.114 ++ int pid = 0; /* affect own porcess */
   3.115 ++ int opt;
   3.116 ++ enum {
   3.117 ++ OPT_n = 1,
   3.118 ++ OPT_c = 2,
   3.119 ++ OPT_p = 4,
   3.120 ++ };
   3.121 ++
   3.122 ++ /* Numeric params */
   3.123 ++ opt_complementary = "n+:c+:p+";
   3.124 ++ /* '+': stop at first non-option */
   3.125 ++ opt = getopt32(argv, "+n:c:p:", &pri, &ioclass, &pid);
   3.126 ++ argv += optind;
   3.127 ++
   3.128 ++ if (opt & OPT_c) {
   3.129 ++ if (ioclass > 3)
   3.130 ++ bb_error_msg_and_die("bad class %d", ioclass);
   3.131 ++// Do we need this (compat?)?
   3.132 ++// if (ioclass == IOPRIO_CLASS_NONE)
   3.133 ++// ioclass = IOPRIO_CLASS_BE;
   3.134 ++// if (ioclass == IOPRIO_CLASS_IDLE) {
   3.135 ++// //if (opt & OPT_n)
   3.136 ++// // bb_error_msg("ignoring priority for idle class");
   3.137 ++// pri = 7;
   3.138 ++// }
   3.139 ++ }
   3.140 ++
   3.141 ++ if (!(opt & (OPT_n|OPT_c))) {
   3.142 ++ if (!(opt & OPT_p) && *argv)
   3.143 ++ pid = xatoi_u(*argv);
   3.144 ++
   3.145 ++ pri = ioprio_get(IOPRIO_WHO_PROCESS, pid);
   3.146 ++ if (pri == -1)
   3.147 ++ bb_perror_msg_and_die("ioprio_%cet", 'g');
   3.148 ++
   3.149 ++ ioclass = (pri >> IOPRIO_CLASS_SHIFT) & 0x3;
   3.150 ++ pri &= 0xff;
   3.151 ++ printf((ioclass == IOPRIO_CLASS_IDLE) ? "%s\n" : "%s: prio %d\n",
   3.152 ++ nth_string(to_prio, ioclass), pri);
   3.153 ++ } else {
   3.154 ++//printf("pri=%d class=%d val=%x\n",
   3.155 ++//pri, ioclass, pri | (ioclass << IOPRIO_CLASS_SHIFT));
   3.156 ++ pri |= (ioclass << IOPRIO_CLASS_SHIFT);
   3.157 ++ if (ioprio_set(IOPRIO_WHO_PROCESS, pid, pri) == -1)
   3.158 ++ bb_perror_msg_and_die("ioprio_%cet", 's');
   3.159 ++ if (*argv) {
   3.160 ++ BB_EXECVP(*argv, argv);
   3.161 ++ bb_simple_perror_msg_and_die(*argv);
   3.162 ++ }
   3.163 ++ }
   3.164 ++
   3.165 ++ return EXIT_SUCCESS;
   3.166 ++}
     4.1 --- a/busybox/stuff/busybox-1.12.0.config	Mon Jun 29 13:01:11 2009 +0200
     4.2 +++ b/busybox/stuff/busybox-1.12.0.config	Mon Jun 29 15:09:52 2009 +0200
     4.3 @@ -1,7 +1,7 @@
     4.4  #
     4.5  # Automatically generated make config: don't edit
     4.6  # Busybox version: 1.12.0
     4.7 -# Thu Jun 25 17:05:48 2009
     4.8 +# Mon Jun 29 15:06:02 2009
     4.9  #
    4.10  CONFIG_HAVE_DOT_CONFIG=y
    4.11  
    4.12 @@ -569,6 +569,7 @@
    4.13  CONFIG_EJECT=y
    4.14  CONFIG_FEATURE_EJECT_SCSI=y
    4.15  # CONFIG_FBSPLASH is not set
    4.16 +CONFIG_IONICE=y
    4.17  # CONFIG_INOTIFYD is not set
    4.18  CONFIG_LAST=y
    4.19  CONFIG_FEATURE_LAST_SMALL=y