2 * Copyright (c) 2016-2019 The strace developers.
5 * SPDX-License-Identifier: GPL-2.0-or-later
11 #if defined __NR_swapon && defined __NR_swapoff
14 # include <sys/swap.h>
20 static const char sample[] = "swap.sample";
23 rc = syscall(__NR_swapon, sample, 0);
24 printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
25 sample, "0", rc, errno2name());
27 rc = syscall(__NR_swapon, sample, 42);
28 printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
29 sample, "42", rc, errno2name());
31 rc = syscall(__NR_swapon, sample, SWAP_FLAG_PREFER);
32 printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
33 sample, "SWAP_FLAG_PREFER|0", rc, errno2name());
35 rc = syscall(__NR_swapon, sample, SWAP_FLAG_PREFER | 42);
36 printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
37 sample, "SWAP_FLAG_PREFER|42", rc, errno2name());
39 rc = syscall(__NR_swapon, sample, -1L);
40 printf("swapon(\"%s\", %s) = %ld %s (%m)\n",
42 "SWAP_FLAG_PREFER|SWAP_FLAG_DISCARD|SWAP_FLAG_DISCARD_ONCE"
43 "|SWAP_FLAG_DISCARD_PAGES|0xfff80000|32767",
46 rc = syscall(__NR_swapoff, sample);
47 printf("swapoff(\"%s\") = %ld %s (%m)\n",
48 sample, rc, errno2name());
50 puts("+++ exited with 0 +++");
56 SKIP_MAIN_UNDEFINED("__NR_swapon && __NR_swapoff")