File: ioprio.c

package info (click to toggle)
systemtap 5.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 47,964 kB
  • sloc: cpp: 80,838; ansic: 54,757; xml: 49,725; exp: 43,665; sh: 11,527; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (68 lines) | stat: -rw-r--r-- 1,791 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* COVERAGE: ioprio_set ioprio_get */

#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>

#if !defined(__NR_ioprio_set) || !defined(__NR_ioprio_get)
#error "ioprio_[gs]et syscall numbers not defined"
#endif

// There aren't any glibc wrappers for these syscalls, so create our
// own.

static inline int __ioprio_set(int which, int who, int ioprio)
{
    return syscall(__NR_ioprio_set, which, who, ioprio);
}

static inline int __ioprio_get(int which, int who)
{
    return syscall(__NR_ioprio_get, which, who);
}

// These enums/defines were copied from the kernel's
// include/linux/ioprio.h file.
enum {
    IOPRIO_CLASS_NONE,
    IOPRIO_CLASS_RT,
    IOPRIO_CLASS_BE,
    IOPRIO_CLASS_IDLE,
};

enum {
    IOPRIO_WHO_PROCESS = 1,
    IOPRIO_WHO_PGRP,
    IOPRIO_WHO_USER,
};

#define IOPRIO_CLASS_SHIFT	(13)
#define IOPRIO_PRIO_VALUE(class, data)	(((class) << IOPRIO_CLASS_SHIFT) | data)

int main()
{
    __ioprio_get(IOPRIO_WHO_USER, 0);
    //staptest// ioprio_get (IOPRIO_WHO_USER, 0) = NNNN

    __ioprio_set(IOPRIO_WHO_PROCESS, 0, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 7));
    //staptest// ioprio_set (IOPRIO_WHO_PROCESS, 0, IOPRIO_CLASS_BE|7) = NNNN

    /* Limits testing */

    __ioprio_get(-1, 0);
    //staptest// ioprio_get (-1, 0) = NNNN

    __ioprio_get(IOPRIO_WHO_PGRP, -1);
    //staptest// ioprio_get (IOPRIO_WHO_PGRP, -1) = NNNN

    __ioprio_set(-1, 0, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 7));
    //staptest// ioprio_set (-1, 0, IOPRIO_CLASS_BE|7) = NNNN

    __ioprio_set(IOPRIO_WHO_PROCESS, -1, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 7));
    //staptest// ioprio_set (IOPRIO_WHO_PROCESS, -1, IOPRIO_CLASS_BE|7) = NNNN

    __ioprio_set(IOPRIO_WHO_PROCESS, 0, -1);
    //staptest// ioprio_set (IOPRIO_WHO_PROCESS, 0, 0x7ffff|NNNN) = NNNN

    return 0;
}