File: ioperm.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 (76 lines) | stat: -rw-r--r-- 1,772 bytes parent folder | download | duplicates (4)
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
69
70
71
72
73
74
75
76
/* COVERAGE: ioperm iopl */

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

#ifdef __NR_ioperm
static inline int __ioperm(unsigned long from, unsigned long num, int turn_on)
{
    return syscall(__NR_ioperm, from, num, turn_on);
}
#endif

#ifdef __NR_iopl
static inline int __iopl(int level)
{
    return syscall(__NR_iopl, level);
}
#endif

// ENOSYS expected on s390 (31-on-64) and on powerpc

int main() {

#ifdef __NR_ioperm
    __ioperm(1060, 1, 1);
#if defined(__powerpc__) || defined(__s390__)
    //staptest// ni_syscall () = -38 (ENOSYS)
#else
    //staptest// ioperm (0x424, 0x1, 0x1) = NNNN
#endif

    __ioperm((unsigned long)-1, 1, 1);
#if defined(__powerpc__) || defined(__s390__)
    //staptest// ni_syscall () = -38 (ENOSYS)
#else
#if __WORDSIZE == 64
    //staptest// ioperm (0xffffffffffffffff, 0x1, 0x1) = NNNN
#else
    //staptest// ioperm (0xffffffff, 0x1, 0x1) = NNNN
#endif
#endif

    __ioperm(1060, (unsigned long)-1, 1);
#if defined(__powerpc__) || defined(__s390__)
    //staptest// ni_syscall () = -38 (ENOSYS)
#else
#if __WORDSIZE == 64
    //staptest// ioperm (0x424, 0xffffffffffffffff, 0x1) = NNNN
#else
    //staptest// ioperm (0x424, 0xffffffff, 0x1) = NNNN
#endif
#endif

    __ioperm(1060, 1, -1);
#if defined(__powerpc__) || defined(__s390__)
    //staptest// ni_syscall () = -38 (ENOSYS)
#else
    //staptest// ioperm (0x424, 0x1, 0xffffffff) = NNNN
#endif
#endif /* __NR_ioperm */

#if defined(__i386__) || defined(__x86_64__)
    // NOTE. This function is only in i386 and x86_64 and 
    // its args vary between those two archs. Not all are
    // being addressed in the tapset.

    __iopl(3);
    //staptest// iopl (3) = NNNN

    __iopl(-1);
    //staptest// iopl (4294967295) = NNNN
#endif

    return 0;
}