diff options
author | Karel Zak | 2011-07-22 12:37:57 +0200 |
---|---|---|
committer | Karel Zak | 2011-07-22 12:55:01 +0200 |
commit | cbc1dc969b83d7cca64297b78d32d337c7ba3414 (patch) | |
tree | 276790e1887ebd46c57ddad6ddc0a08d9325127d /schedutils/ionice.c | |
parent | ionice: allow to use names for -c <class> (diff) | |
download | kernel-qcow2-util-linux-cbc1dc969b83d7cca64297b78d32d337c7ba3414.tar.gz kernel-qcow2-util-linux-cbc1dc969b83d7cca64297b78d32d337c7ba3414.tar.xz kernel-qcow2-util-linux-cbc1dc969b83d7cca64297b78d32d337c7ba3414.zip |
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>
Diffstat (limited to 'schedutils/ionice.c')
-rw-r--r-- | schedutils/ionice.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/schedutils/ionice.c b/schedutils/ionice.c index 26dc2d3a8..75f372e07 100644 --- a/schedutils/ionice.c +++ b/schedutils/ionice.c @@ -75,12 +75,16 @@ static void ioprio_print(int pid) err(EXIT_FAILURE, _("ioprio_get failed")); else { int ioclass = IOPRIO_PRIO_CLASS(ioprio); + const char *name = _("unknown"); + + if (ioclass < ARRAY_SIZE(to_prio)) + name = to_prio[ioclass]; if (ioclass != IOPRIO_CLASS_IDLE) - printf("%s: prio %lu\n", to_prio[ioclass], + printf("%s: prio %lu\n", name, IOPRIO_PRIO_DATA(ioprio)); else - printf("%s\n", to_prio[ioclass]); + printf("%s\n", name); } } @@ -173,7 +177,7 @@ int main(int argc, char **argv) switch (ioclass) { case IOPRIO_CLASS_NONE: - if (set & 1) + if ((set & 1) && !tolerant) warnx(_("ignoring given class data for none class")); data = 0; break; @@ -181,12 +185,14 @@ int main(int argc, char **argv) case IOPRIO_CLASS_BE: break; case IOPRIO_CLASS_IDLE: - if (set & 1) + if ((set & 1) && !tolerant) warnx(_("ignoring given class data for idle class")); data = 7; break; default: - errx(EXIT_FAILURE, _("bad prio class %d"), ioclass); + if (!tolerant) + warnx(_("unknown prio class %d"), ioclass); + break; } if (!set && !pid && optind == argc) |