Commit Graph

45 Commits

Author SHA1 Message Date
Karel Zak 2c308875a7 misc: consolidate version printing and close_stdout()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 15:14:13 +02:00
Karel Zak 61b6222269 schedutils: use errexec()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-01 15:40:59 +01:00
Ruediger Meier f45f3ec34a misc: consolidate macro style USAGE_HELP_OPTIONS
changed in include/c.h and applied via sed:

  sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
  sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-29 16:54:33 +02:00
Ruediger Meier b1a294c448 misc: introduce print_usage_help_options()
Consolidate --help and --version descriptions. We are
now able to align them to the other options.

We changed include/c.h. The rest of this patch was
generated by sed, plus manually setting the right
alignment numbers. We do not change anything but
white spaces in the --help output.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-27 12:26:19 +02:00
Ruediger Meier 6e1eda6f22 misc: never use usage(stderr)
Here we fix all cases where we have usage(FILE*)
functions.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Sami Kerola 2ba641e5f3 misc: add static keyword to where needed [smatch scan]
text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be
static?

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:49 +01:00
Karel Zak 677ec86cef Use --help suggestion on invalid option
The current default is to print all usage() output. This is overkill
in many case.

Addresses: https://github.com/karelzak/util-linux/issues/338
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 13:13:34 +01:00
Benno Schulenberg 6b93474df7 ionice: drop the duplicate docstring
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-26 11:22:12 +01:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:27:38 +01:00
Benno Schulenberg 2d745ee6e6 textual: slice up and standardize the usage text of ionice
Done for ease of translation and maintenance.  Also improve the
clarity of some of the descriptions, and of one error message.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-05-06 11:09:33 +02:00
Benno Schulenberg b6973e5d23 ionice: add a missing error message
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-05-06 11:09:30 +02:00
Masatake YAMATO bd2ff3d2d9 ionice: add the way to specify the target processes with pgid and uid
ioprio_get and ioprio_set system call accept not only process ID but
also process group ID(pgid) and user ID(uid) to specify the target
process(es).  However, ionice command accepts only process ID.  With
this patch a user can specify the target processes with pgid(-P
option) and uid(-u option).

[kzak@redhat.com: - tiny cleanup in usage()]

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-02-17 11:44:12 +01:00
Michael Bunk b422f5fe87 ionice: Fix output for case ioclass==0
output "none" instead of "unknown"
2014-01-15 17:38:37 +01:00
Karel Zak 65f25186d5 ionice: keep output backwardly compatible
...bug introduced by 8c219bf463

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-04 12:58:12 +01:00
Sami Kerola 07ff972eb6 translation: unify exec error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-02-06 11:51:17 +01:00
Benno Schulenberg 8c219bf463 textual: gettextize several overlooked messages
Also improve the clarity of some of them.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-01-25 11:47:29 +01:00
Karel Zak 630ed89d5a schedutils: cleanup strtoxx_or_err()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-15 17:45:05 +02:00
Sami Kerola ed8ec2a65d schedutils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:51:32 +02:00
Karel Zak cee12fc60c ionice: fix compiler warnings [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01 13:17:54 +02:00
Karel Zak cbc1dc969b ionice: make -t more tolerant
* replace errx() with warnx() for unknown -c class

  The right place to check I/O scheduler features is in kernel. We should
  not try to be more smart than kernel.

* make the code ready (robust) for unknown sched.classes

* fix -t behavior

	old version:
	  $ ionice -c 4 -t bash
	  ionice: bad prio class 4

	new version:
	  $ ionice -c 4 -t bash

Reported-by: Voelker, Bernhard" <bernhard.voelker@siemens-enterprise.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-22 12:55:01 +02:00
Karel Zak fe040397f9 ionice: allow to use names for -c <class>
for example:

   $ ionice -c best-effort bash

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-22 11:39:06 +02:00
Karel Zak fcc2b2da4c ionice: improve command line interpretation
ionice                       : print the current I/O prio.
 ionice COMMAND               : exec command with default (best-effort) class
 ionice -p PID [...]          : return info about the PID(s)
 ionice -c CLASS COMMAND      : exec command with the class
 ionice -c CLASS -p PID [...] : modify PID(s) class

This should be backwardly compatible and also compatible with nice(1)
from coreutils.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-22 11:24:05 +02:00
Sami Kerola a5e9b75fac ionice: coding style fixes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-21 17:09:28 +02:00
Sami Kerola abd57eb3e3 ionice: fix -V output
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-21 17:04:36 +02:00
Karel Zak 7ab08ba3e5 ionice: fix -p
$ ionice 123
 none: prio 4
 none: prio 4

It calls ioprio_get(0x1, 0) and ioprio_get(0x1, 123), because the
code does not check it the "-p" options was specified.

The proper command line syntax is:

  $ ionice -p 123

and the ioprio_get() should be called only once.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-21 17:02:52 +02:00
Karel Zak 560cdabbfa ionice: IOPRIO_PRIO_* macros
* make the code more robust
 * follow kernel conventions for variable names
   (data = classdata, ioprio = classdata | class)

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-21 16:33:20 +02:00
Sami Kerola 976b7580e0 ionice: add long options
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-21 16:03:35 +02:00
Fabian Groffen eb76ca98b0 build-sys: provide alternatives for err, errx, warn and warnx
Solaris lacks err, errx, warn and warnx.  This also means the err.h header
doesn't exist.  Removed err.h include from all files, and included err.h from
c.h instead if it exists, otherwise alternatives are provided.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-02-14 17:45:24 +01:00
Davidlohr Bueso f2f0dcaf11 schedutils: remove unneeded header files
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-02-08 16:23:28 +01:00
Davidlohr Bueso 8abcf29002 lib: [strutils] general purpose string handling functions
This patch replaces a few functions used throughout the source:
* Renames getnum (from schedutils) to strtol_or_err
* Moves strtosize (from lib/strtosize.c)
* Moves xstrncpy (from include/xstrncpy.h)
* Adds strnlen, strnchr and strndup if not available (remove it from libmount utils)

A few Makefile.am files were modified to compile accordingly along with trivial renaming
in schedutils source code.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2010-11-23 21:06:49 +01:00
Karel Zak 2429509658 taskset: proper numbers parsing
Reported-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-09-30 23:29:14 +02:00
Ævar Arnfjörð Bjarmason 048b81c9ff ionice: non-cryptic error message when ionice can't execvp
Previously ionice would reply like this when it couldn't find the
command to execute:

    $ ionice -c 3 does-not-exist
    ionice: execvp failed: No such file or directory

Getting that message from cron because you haven't set the right $PATH
makes it hard to track down the problem. Now it says:

    $ ionice -c 3 does-not-exist
    ionice: executing does-not-exist failed: No such file or directory

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
2010-05-06 09:18:20 +02:00
Pierre Hauweele 4880a6f1ed ionice: fix typo
Signed-off-by: Pierre Hauweele <antegallya@gmail.com>
2010-03-14 22:58:56 +01:00
Jakob Unterwurzacher 5dc9371ce6 ionice: Allow setting the none class
Allow users to set the "none" class on processes. Using the
none class has the distict advantage that the io priority
is inherited from the cpu nice level. Update the man page
to reflect the change.

Signed-off-by: Jakob Unterwurzacher <jakobunt@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-05-27 23:43:18 +02:00
Karel Zak 357e7c3b2d ionice: change Jens Axboe's email
Based on
   util-linux-2.14.2-schedutils_fix_email.patch
from SUSE src.rpm package.

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-04-23 13:22:27 +02:00
Karel Zak 030d18fd2a ionice: add strtol() checks, cleanup usage text and man page
* cleanup usage() output

 * check strtol(); don't ignore wrong command line options

The original ionice design was a little broken, because it was
possible to specify a PID and also a COMMAND:

	ionice -c2 -p 123 /bin/foo

but the command /bin/foo was executed without requested scheduling
class. That's stupid behaviour.

Now you have to use "-p PID" **or** COMMAND, but not both. Nothing is
ignored and all options are checked.

Signed-off-by: Karel Zak <kzak@redhat.com>
2008-09-06 14:54:01 +02:00
Stephan Maka ef0fe2e8aa ionice: let -p handle multiple PIDs
Makes ionice -p usable like renice, this time backwards compatible

[kzak@redhat.com: - fix coding style
                  - add ioprio_setpid()]

Signed-off-by: Stephan Maka <stephan@spaceboyz.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-09-05 16:18:14 +02:00
Karel Zak 5bd11d0d11 ionice: cleanup error messages, add NLS support
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-08-14 11:40:08 +02:00
Lubomir Kundrak 4d125dfc41 ionice: add -t option
This patch allows "tolerant" behavior, i.e. proceeding even if
priority could not be set. This might be of use in case something
(selinux, old kernel, etc.) does not allow the requested scheduling
priority to be set.

This could be to some extend done as follows:

	ionice -c3 command || command

but the downside is that one could not really tell if what failed was
setting priority or command itself, which could result in duplicate
command run.

This patch solves the situation, so that user can do

	ionice -t -c3 command

Addresses-Red-Hat-Bugzilla: #443842
Signed-off-by: Lubomir Kundrak <lkundrak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-06-16 13:08:51 +02:00
Mike Frysinger 72065909cc build-sys: unify method for checking system calls and fallback handling
Co-Author: Stepan Kasal <skasal@redhat.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Stepan Kasal <skasal@redhat.com>
2007-09-20 00:22:22 +02:00
Matthias Koenig 2b25841371 ionice: clean up error handling
Print error in case execvp fails and use exit macros.

Based on patch by Bernhard Voelker <mail@bernhard-voelker.de>

Signed-off-by: Matthias Koenig <mkoenig@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-08-27 23:58:05 +02:00
Matthias Koenig 8dbfe5a1fe ionice: cleanup usage for idle class
The idle class has no class data. It will print a warning if
a prio argument is given for it, since this will be ignored.
Output for idle class will not contain prio data.

Signed-off-by: Matthias Koenig <mkoenig@suse.de>
2007-07-25 16:44:17 +02:00
Karel Zak 4dfadf9c3a ionice: prefer SYS_ioprio_{set,get} from glibc to hardcoded version
It's better to use glibc SYS_ioprio_{set,get} definitions rather than an
incomplete (not all archs) and hardcoded version from ionice.c.

Signed-off-by: Karel Zak <kzak@redhat.com>
2007-07-16 12:22:54 +02:00
David Miller eba338783e ionice: fix ionice build on sparc
Provide the proper syscall numbers for this architecture.

Signed-off-by: David S. Miller <davem@davemloft.net>
2007-07-02 13:52:41 +02:00
Karel Zak 48d7b13a1e Imported from util-linux-2.13-pre1 tarball. 2006-12-07 00:26:54 +01:00