summaryrefslogtreecommitdiffstats
path: root/mount/swapon.c
diff options
context:
space:
mode:
authorMike Frysinger2007-06-13 11:52:55 +0200
committerKarel Zak2007-06-13 14:35:34 +0200
commitffa63a3dbbf8c4724e76cff104626a8cf5686223 (patch)
tree553cdcb12bed6064381f8e1f1a59677a0d33f1ae /mount/swapon.c
parentcal: widechar code cleanup (diff)
downloadkernel-qcow2-util-linux-ffa63a3dbbf8c4724e76cff104626a8cf5686223.tar.gz
kernel-qcow2-util-linux-ffa63a3dbbf8c4724e76cff104626a8cf5686223.tar.xz
kernel-qcow2-util-linux-ffa63a3dbbf8c4724e76cff104626a8cf5686223.zip
swapon: fix swapon headers and syscalls
This patch scrubs anything related to SWAPON_NEEDS_TWO_ARGS as this is only relevant for < linux-1.3.2 and i say it's about time we let it go. I also cleaned up the system call fallback logic as the _syscall#() macros are the deprecated interface in favor of the real syscall() function. The asm/page.h gets the boot as nothing in swapon.c utilizes defines from it while unistd.h gets always included as defines/functions are used from it other than just swapon(). Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'mount/swapon.c')
-rw-r--r--mount/swapon.c42
1 files changed, 13 insertions, 29 deletions
diff --git a/mount/swapon.c b/mount/swapon.c
index a8e5cc10e..e5f945ed3 100644
--- a/mount/swapon.c
+++ b/mount/swapon.c
@@ -11,24 +11,29 @@
#include <mntent.h>
#include <errno.h>
#include <sys/stat.h>
+#include <unistd.h>
#include "xmalloc.h"
#include "swap_constants.h"
#include "nls.h"
#include "fsprobe.h"
#include "realpath.h"
+#ifdef HAVE_SYS_SWAP_H
+# include <sys/swap.h>
+#endif
+
+#ifndef SWAPON_HAS_TWO_ARGS
+/* libc is insane, let's call the kernel */
+# include <sys/syscall.h>
+# define swapon(path, flags) syscall(SYS_swapon, path, flags)
+# define swapoff(path) syscall(SYS_swapoff, path)
+#endif
+
#define streq(s, t) (strcmp ((s), (t)) == 0)
#define _PATH_FSTAB "/etc/fstab"
#define PROC_SWAPS "/proc/swaps"
-#ifdef SWAPON_HAS_TWO_ARGS
-# include <asm/page.h>
-# include <sys/swap.h>
-#endif
-
-#define SWAPON_NEEDS_TWO_ARGS
-
#define QUIET 1
int all = 0;
@@ -75,24 +80,6 @@ swapoff_usage(FILE *fp, int n) {
exit(n);
}
-#ifdef SWAPON_HAS_TWO_ARGS
-#define SWAPON_NEEDS_TWO_ARGS
-#endif
-
-#if defined(SWAPON_NEEDS_TWO_ARGS) && !defined(SWAPON_HAS_TWO_ARGS)
-/* We want a swapon with two args, but have an old libc.
- Build the kernel call by hand. */
-#include <linux/unistd.h>
-static
-_syscall2(int, swapon, const char *, path, int, flags);
-static
-_syscall1(int, swapoff, const char *, path);
-#else
-/* just do as libc says */
-#include <unistd.h>
-#endif
-
-
/*
* contents of /proc/swaps
*/
@@ -219,7 +206,6 @@ do_swapon(const char *orig_special, int prio) {
}
}
-#ifdef SWAPON_NEEDS_TWO_ARGS
{
int flags = 0;
@@ -234,9 +220,7 @@ do_swapon(const char *orig_special, int prio) {
#endif
status = swapon(special, flags);
}
-#else
- status = swapon(special);
-#endif
+
if (status < 0) {
int errsv = errno;
fprintf(stderr, "%s: %s: %s\n",