File: swap.c

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; 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 (59 lines) | stat: -rw-r--r-- 1,621 bytes parent folder | download | duplicates (2)
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
/* COVERAGE: swapon swapoff */
#include <unistd.h>
#include <sys/swap.h>
#include <sys/mman.h>


int main()
{
  /* Actually creating a real swap file here is problematic. It won't
   * work if we're not root or we're on a filesystem that doesn't
   * support swap files (like tmpfs or nfs). So, we'll specify a file
   * that doesn't exist. So, all of the following calls will fail (for
   * various reasons). */

  mlockall(MCL_CURRENT);

  swapon("foobar_swap", 0);
  //staptest// swapon ("foobar_swap", 0x0) = -NNNN

  swapon("foobar_swap", ((1 << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK) | SWAP_FLAG_PREFER);
  //staptest// swapon ("foobar_swap", SWAP_FLAG_PREFER|1) = -NNNN

  swapon("foobar_swap", ((7 << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK) | SWAP_FLAG_PREFER);
  //staptest// swapon ("foobar_swap", SWAP_FLAG_PREFER|7) = -NNNN

  swapon(0, 0);
  //staptest// swapon ( *0x0, 0x0) =

#ifdef SWAP_FLAG_DISCARD
  swapon("foobar_swap", SWAP_FLAG_DISCARD);
  //staptest// swapon ("foobar_swap", SWAP_FLAG_DISCARD) = -NNNN
#endif

  swapon("foobar_swap", -1);
  //staptest// swapon ("foobar_swap", SWAP_FLAG_[^ ]+|XXXX|32767) = -NNNN

  swapon((char *)-1, SWAP_FLAG_PREFER);
#ifdef __s390__
  //staptest// swapon (0x[7]?[f]+, SWAP_FLAG_PREFER|0) = -NNNN
#else
  //staptest// swapon (0x[f]+, SWAP_FLAG_PREFER|0) = -NNNN
#endif

  swapoff("foobar_swap");
  //staptest// swapoff ("foobar_swap") = -NNNN

  swapoff(0);
  //staptest// swapoff ( *0x0) = -NNNN

  swapoff((char *)-1);
#ifdef __s390__
  //staptest// swapoff (0x[7]?[f]+) = -NNNN
#else
  //staptest// swapoff (0x[f]+) = -NNNN
#endif

  return 0;
}