2 * ioprio-glue.c - I/O priority wrappers for the big dog
4 * Robert Love <rml@novell.com>
6 * Copyright (C) 2005 Novell, Inc.
9 #include <sys/syscall.h>
13 #define __NR_ioprio_set 289
14 #define __NR_ioprio_get 290
15 #elif defined(__powerpc__) || defined(__powerpc64__)
16 #define __NR_ioprio_set 273
17 #define __NR_ioprio_get 274
18 #elif defined(__x86_64__)
19 #define __NR_ioprio_set 251
20 #define __NR_ioprio_get 252
21 #elif defined(__ia64__)
22 #define __NR_ioprio_set 1274
23 #define __NR_ioprio_get 1275
24 #elif defined(__alpha__)
25 #define __NR_ioprio_set 442
26 #define __NR_ioprio_get 443
27 #elif defined(__s390x__) || defined(__s390__)
28 #define __NR_ioprio_set 282
29 #define __NR_ioprio_get 283
30 #elif defined(__SH4__)
31 #define __NR_ioprio_set 288
32 #define __NR_ioprio_get 289
33 #elif defined(__SH5__)
34 #define __NR_ioprio_set 316
35 #define __NR_ioprio_get 317
36 #elif defined(__sparc__) || defined(__sparc64__)
37 #define __NR_ioprio_set 196
38 #define __NR_ioprio_get 218
39 #elif defined(__arm__)
40 #define __NR_ioprio_set 314
41 #define __NR_ioprio_get 315
43 #error "Unsupported architecture!"
46 static inline int ioprio_set (int which
, int who
, int ioprio
)
48 return syscall (__NR_ioprio_set
, which
, who
, ioprio
);
51 static inline int ioprio_get (int which
, int who
)
53 return syscall (__NR_ioprio_get
, which
, who
);
64 IOPRIO_WHO_PROCESS
= 1,
69 #define IOPRIO_CLASS_SHIFT 13
70 #define IOPRIO_PRIO_MASK 0xff
72 int set_io_priority_idle (void)
76 ioprio
= 7; /* priority is ignored with idle class */
77 ioclass
= IOPRIO_CLASS_IDLE
<< IOPRIO_CLASS_SHIFT
;
79 return ioprio_set (IOPRIO_WHO_PROCESS
, 0, ioprio
| ioclass
);
82 int set_io_priority_best_effort (int ioprio
)
86 ioclass
= IOPRIO_CLASS_BE
<< IOPRIO_CLASS_SHIFT
;
88 return ioprio_set (IOPRIO_WHO_PROCESS
, 0, ioprio
| ioclass
);