Package: busybox / 1:1.17.1-8+deb6u11

swaponoff-FreeBSD-support.patch Patch series | download
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
From a5b837c34a96bdbb53151af455912b691c9aaa52 Mon Sep 17 00:00:00 2001
From: Jeremie Koenig <jk@jk.fr.eu.org>
Date: Thu, 29 Jul 2010 21:59:54 +0200
Subject: [PATCH 19/19] swaponoff: FreeBSD support


Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>
---
 util-linux/Config.src  |    3 +--
 util-linux/swaponoff.c |    6 +++---
 util-linux/xmount.c    |   10 ++++++++++
 util-linux/xmount.h    |   16 ++++++++++------
 4 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/util-linux/Config.src b/util-linux/Config.src
index 99a6fbe..cb4de95 100644
--- a/util-linux/Config.src
+++ b/util-linux/Config.src
@@ -639,7 +639,6 @@ config SETARCH
 config SWAPONOFF
 	bool "swaponoff"
 	default y
-	depends on PLATFORM_LINUX
 	help
 	  This option enables both the 'swapon' and the 'swapoff' utilities.
 	  Once you have created some swap space using 'mkswap', you also need
@@ -651,7 +650,7 @@ config SWAPONOFF
 config FEATURE_SWAPON_PRI
 	bool "Support priority option -p"
 	default y
-	depends on SWAPONOFF
+	depends on SWAPONOFF && PLATFORM_LINUX
 	help
 	  Enable support for setting swap device priority in swapon.
 
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c
index f2f52fb..d13c37e 100644
--- a/util-linux/swaponoff.c
+++ b/util-linux/swaponoff.c
@@ -8,8 +8,8 @@
  */
 
 #include "libbb.h"
+#include "xmount.h"
 #include <mntent.h>
-#include <sys/swap.h>
 
 #if ENABLE_FEATURE_MOUNT_LABEL
 # include "volume_id.h"
@@ -43,9 +43,9 @@ static int swap_enable_disable(char *device)
 #endif
 
 	if (applet_name[5] == 'n')
-		status = swapon(device, g_flags);
+		status = xswapon(device, g_flags);
 	else
-		status = swapoff(device);
+		status = xswapoff(device);
 
 	if (status != 0) {
 		bb_simple_perror_msg(device);
diff --git a/util-linux/xmount.c b/util-linux/xmount.c
index 3f322b8..16543f1 100644
--- a/util-linux/xmount.c
+++ b/util-linux/xmount.c
@@ -63,4 +63,14 @@ int FAST_FUNC xumount(const char *target, int flags)
 	return unmount(target, flags);
 }
 
+int FAST_FUNC xswapon(const char *path, int swapflags UNUSED_PARAM)
+{
+	return swapon(path);
+}
+
+int FAST_FUNC xswapoff(const char *path)
+{
+	return swapoff(path);
+}
+
 #endif
diff --git a/util-linux/xmount.h b/util-linux/xmount.h
index caef564..bcd6d18 100644
--- a/util-linux/xmount.h
+++ b/util-linux/xmount.h
@@ -5,9 +5,9 @@
  * Copyright (C) 2010 by Jeremie Koenig <jk@jk.fr.eu.org>
  * Copyright (C) 2010 by Luca Favatella <slackydeb@gmail.com>
  *
- * The Linux prototypes for mount() and umount2() are used as a reference for
- * our xmount() and xumount(), which should be implemented as a compatibility
- * wrappers for non-Linux systems (see xmount.c).
+ * The Linux prototypes for mount(), umount2(), swapon() and swapoff()  are
+ * used as a reference for our versions of them. On non-Linux system those
+ * should be implemented as compatibility wrappers (see xmount.c).
  */
 
 /*
@@ -17,6 +17,7 @@
 
 #ifdef __linux__
 # include <sys/mount.h>
+# include <sys/swap.h>
 /* Make sure we have all the new mount flags we actually try to use
  * (grab more as needed from util-linux's mount/mount_constants.h). */
 # ifndef MS_DIRSYNC
@@ -56,6 +57,7 @@
 
 #elif defined(__FreeBSD_kernel__)
 # include <sys/mount.h>
+# include <sys/swap.h>
 # define MS_NOSUID      MNT_NOSUID
 # define MS_NODEV       MNT_NODEV
 # define MS_NOEXEC      MNT_NOEXEC
@@ -82,16 +84,18 @@
 #endif
 
 /*
- * Prototypes for xmount() and xumount(): on Linux we use the system calls
- * directly, otherwise xmount() and xumount() should be implemented as
- * compatibility wrappers (see xmount.c).
+ * Prototypes for the compatibility wrappers
  */
 
 #ifdef __linux__
 # define xmount mount
 # define xumount umount2
+# define xswapon swapon
+# define xswapoff swapoff
 #else
 int xmount(const char *source, const char *target, const char *filesystemtype,
 		unsigned long mountflags, const void *data) FAST_FUNC;
 int xumount(const char *target, int flags) FAST_FUNC;
+int xswapon(const char *path, int swapflags) FAST_FUNC;
+int xswapoff(const char *path) FAST_FUNC;
 #endif
-- 
1.7.1