]>
Commit | Line | Data |
---|---|---|
1 | diff --git a/mount/swapon.c b/mount/swapon.c | |
2 | index a8e5cc1..e5f945e 100644 | |
3 | --- a/mount/swapon.c | |
4 | +++ b/mount/swapon.c | |
5 | @@ -11,24 +11,29 @@ | |
6 | #include <mntent.h> | |
7 | #include <errno.h> | |
8 | #include <sys/stat.h> | |
9 | +#include <unistd.h> | |
10 | #include "xmalloc.h" | |
11 | #include "swap_constants.h" | |
12 | #include "nls.h" | |
13 | #include "fsprobe.h" | |
14 | #include "realpath.h" | |
15 | ||
16 | +#ifdef HAVE_SYS_SWAP_H | |
17 | +# include <sys/swap.h> | |
18 | +#endif | |
19 | + | |
20 | +#ifndef SWAPON_HAS_TWO_ARGS | |
21 | +/* libc is insane, let's call the kernel */ | |
22 | +# include <sys/syscall.h> | |
23 | +# define swapon(path, flags) syscall(SYS_swapon, path, flags) | |
24 | +# define swapoff(path) syscall(SYS_swapoff, path) | |
25 | +#endif | |
26 | + | |
27 | #define streq(s, t) (strcmp ((s), (t)) == 0) | |
28 | ||
29 | #define _PATH_FSTAB "/etc/fstab" | |
30 | #define PROC_SWAPS "/proc/swaps" | |
31 | ||
32 | -#ifdef SWAPON_HAS_TWO_ARGS | |
33 | -# include <asm/page.h> | |
34 | -# include <sys/swap.h> | |
35 | -#endif | |
36 | - | |
37 | -#define SWAPON_NEEDS_TWO_ARGS | |
38 | - | |
39 | #define QUIET 1 | |
40 | ||
41 | int all = 0; | |
42 | @@ -75,24 +80,6 @@ swapoff_usage(FILE *fp, int n) { | |
43 | exit(n); | |
44 | } | |
45 | ||
46 | -#ifdef SWAPON_HAS_TWO_ARGS | |
47 | -#define SWAPON_NEEDS_TWO_ARGS | |
48 | -#endif | |
49 | - | |
50 | -#if defined(SWAPON_NEEDS_TWO_ARGS) && !defined(SWAPON_HAS_TWO_ARGS) | |
51 | -/* We want a swapon with two args, but have an old libc. | |
52 | - Build the kernel call by hand. */ | |
53 | -#include <linux/unistd.h> | |
54 | -static | |
55 | -_syscall2(int, swapon, const char *, path, int, flags); | |
56 | -static | |
57 | -_syscall1(int, swapoff, const char *, path); | |
58 | -#else | |
59 | -/* just do as libc says */ | |
60 | -#include <unistd.h> | |
61 | -#endif | |
62 | - | |
63 | - | |
64 | /* | |
65 | * contents of /proc/swaps | |
66 | */ | |
67 | @@ -219,7 +206,6 @@ do_swapon(const char *orig_special, int prio) { | |
68 | } | |
69 | } | |
70 | ||
71 | -#ifdef SWAPON_NEEDS_TWO_ARGS | |
72 | { | |
73 | int flags = 0; | |
74 | ||
75 | @@ -234,9 +220,7 @@ do_swapon(const char *orig_special, int prio) { | |
76 | #endif | |
77 | status = swapon(special, flags); | |
78 | } | |
79 | -#else | |
80 | - status = swapon(special); | |
81 | -#endif | |
82 | + | |
83 | if (status < 0) { | |
84 | int errsv = errno; | |
85 | fprintf(stderr, "%s: %s: %s\n", |