Dmitry V. Levin | fc4727d | 2014-02-05 17:27:43 +0000 | [diff] [blame] | 1 | #include "defs.h" |
| 2 | |
| 3 | enum { |
| 4 | IOPRIO_WHO_PROCESS = 1, |
| 5 | IOPRIO_WHO_PGRP, |
| 6 | IOPRIO_WHO_USER |
| 7 | }; |
| 8 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 9 | #include "xlat/ioprio_who.h" |
Dmitry V. Levin | fc4727d | 2014-02-05 17:27:43 +0000 | [diff] [blame] | 10 | |
| 11 | enum { |
| 12 | IOPRIO_CLASS_NONE, |
| 13 | IOPRIO_CLASS_RT, |
| 14 | IOPRIO_CLASS_BE, |
| 15 | IOPRIO_CLASS_IDLE |
| 16 | }; |
| 17 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 18 | #include "xlat/ioprio_class.h" |
Dmitry V. Levin | fc4727d | 2014-02-05 17:27:43 +0000 | [diff] [blame] | 19 | |
| 20 | #define IOPRIO_CLASS_SHIFT (13) |
| 21 | #define IOPRIO_PRIO_MASK ((1ul << IOPRIO_CLASS_SHIFT) - 1) |
| 22 | |
| 23 | #define IOPRIO_PRIO_CLASS(mask) ((mask) >> IOPRIO_CLASS_SHIFT) |
| 24 | #define IOPRIO_PRIO_DATA(mask) ((mask) & IOPRIO_PRIO_MASK) |
| 25 | |
| 26 | static const char * |
| 27 | sprint_ioprio(int ioprio) |
| 28 | { |
| 29 | static char outstr[256]; |
| 30 | const char *str; |
| 31 | int class, data; |
| 32 | |
| 33 | class = IOPRIO_PRIO_CLASS(ioprio); |
| 34 | data = IOPRIO_PRIO_DATA(ioprio); |
| 35 | str = xlookup(ioprio_class, class); |
| 36 | if (str) |
| 37 | sprintf(outstr, "IOPRIO_PRIO_VALUE(%s,%d)", str, data); |
| 38 | else |
| 39 | sprintf(outstr, "IOPRIO_PRIO_VALUE(%#x /* %s */,%d)", |
| 40 | class, "IOPRIO_CLASS_???", data); |
| 41 | |
| 42 | return outstr; |
| 43 | } |
| 44 | |
| 45 | int |
| 46 | sys_ioprio_get(struct tcb *tcp) |
| 47 | { |
| 48 | if (entering(tcp)) { |
| 49 | /* int which */ |
| 50 | printxval(ioprio_who, tcp->u_arg[0], "IOPRIO_WHO_???"); |
| 51 | /* int who */ |
| 52 | tprintf(", %d", (int) tcp->u_arg[1]); |
| 53 | return 0; |
| 54 | } else { |
| 55 | if (syserror(tcp)) |
| 56 | return 0; |
| 57 | |
| 58 | tcp->auxstr = sprint_ioprio(tcp->u_rval); |
| 59 | return RVAL_STR; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | int |
| 64 | sys_ioprio_set(struct tcb *tcp) |
| 65 | { |
| 66 | if (entering(tcp)) { |
| 67 | /* int which */ |
| 68 | printxval(ioprio_who, tcp->u_arg[0], "IOPRIO_WHO_???"); |
| 69 | /* int who */ |
| 70 | tprintf(", %d, ", (int) tcp->u_arg[1]); |
| 71 | /* int ioprio */ |
| 72 | tprints(sprint_ioprio(tcp->u_arg[2])); |
| 73 | } |
| 74 | return 0; |
| 75 | } |