2 #include <asm/unistd.h>
4 #if defined __NR_swapon && defined __NR_swapoff
13 static const char sample[] = "swap.sample";
16 rc = syscall(__NR_swapon, sample, 0);
17 printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
18 sample, "0", rc, errno2name());
20 rc = syscall(__NR_swapon, sample, 42);
21 printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
22 sample, "42", rc, errno2name());
24 rc = syscall(__NR_swapon, sample, SWAP_FLAG_PREFER);
25 printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
26 sample, "SWAP_FLAG_PREFER", rc, errno2name());
28 rc = syscall(__NR_swapon, sample, SWAP_FLAG_PREFER | 42);
29 printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
30 sample, "SWAP_FLAG_PREFER|42", rc, errno2name());
32 rc = syscall(__NR_swapon, sample, -1L);
33 printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
35 "SWAP_FLAG_PREFER|SWAP_FLAG_DISCARD|SWAP_FLAG_DISCARD_ONCE"
36 "|SWAP_FLAG_DISCARD_PAGES|0xfff80000|32767",
39 rc = syscall(__NR_swapoff, sample);
40 printf("swapoff(\"%s\") = %ld %s (%m)\n",
41 sample, rc, errno2name());
43 puts("+++ exited with 0 +++");
49 SKIP_MAIN_UNDEFINED("__NR_swapon && __NR_swapoff")