blob: 6826e56d62030c3d6feaa840c92c23f768e5ed4b [file] [log] [blame]
Dmitry V. Levinfc4727d2014-02-05 17:27:43 +00001#include "defs.h"
2
3enum {
4 IOPRIO_WHO_PROCESS = 1,
5 IOPRIO_WHO_PGRP,
6 IOPRIO_WHO_USER
7};
8
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +00009#include "xlat/ioprio_who.h"
Dmitry V. Levinfc4727d2014-02-05 17:27:43 +000010
11enum {
12 IOPRIO_CLASS_NONE,
13 IOPRIO_CLASS_RT,
14 IOPRIO_CLASS_BE,
15 IOPRIO_CLASS_IDLE
16};
17
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000018#include "xlat/ioprio_class.h"
Dmitry V. Levinfc4727d2014-02-05 17:27:43 +000019
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
26static const char *
27sprint_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
45int
46sys_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
63int
64sys_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}