]> err.no Git - util-linux/commitdiff
ionice: cleanup usage for idle class
authorMatthias Koenig <mkoenig@suse.de>
Tue, 17 Jul 2007 14:00:32 +0000 (16:00 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 25 Jul 2007 14:44:17 +0000 (16:44 +0200)
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>
schedutils/ionice.c

index ac721215b0f4262b17c03949233c51b4fedc287d..2d23dd0e77c0b3c3f5c52494ee644afacfcec74e 100644 (file)
@@ -95,11 +95,11 @@ int main(int argc, char *argv[])
                switch (c) {
                case 'n':
                        ioprio = strtol(optarg, NULL, 10);
-                       set = 1;
+                       set |= 1;
                        break;
                case 'c':
                        ioprio_class = strtol(optarg, NULL, 10);
-                       set = 1;
+                       set |= 2;
                        break;
                case 'p':
                        pid = strtol(optarg, NULL, 10);
@@ -119,6 +119,8 @@ int main(int argc, char *argv[])
                case IOPRIO_CLASS_BE:
                        break;
                case IOPRIO_CLASS_IDLE:
+                       if (set & 1)
+                               printf("Ignoring given class data for idle class\n");
                        ioprio = 7;
                        break;
                default:
@@ -136,8 +138,11 @@ int main(int argc, char *argv[])
                        perror("ioprio_get");
                else {
                        ioprio_class = ioprio >> IOPRIO_CLASS_SHIFT;
-                       ioprio = ioprio & 0xff;
-                       printf("%s: prio %d\n", to_prio[ioprio_class], ioprio);
+                       if (ioprio_class != IOPRIO_CLASS_IDLE) {
+                               ioprio = ioprio & 0xff;
+                               printf("%s: prio %d\n", to_prio[ioprio_class], ioprio);
+                       } else
+                               printf("%s\n", to_prio[ioprio_class]);
                }
        } else {
                if (ioprio_set(IOPRIO_WHO_PROCESS, pid, ioprio | ioprio_class << IOPRIO_CLASS_SHIFT) == -1) {