Package: busybox / 1:1.22.0-19

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
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/swaponoff.c |    9 +++------
 util-linux/xmount.c    |   10 ++++++++++
 util-linux/xmount.h    |   16 ++++++++++------
 3 files changed, 23 insertions(+), 12 deletions(-)

--- a/util-linux/swaponoff.c
+++ b/util-linux/swaponoff.c
@@ -23,10 +23,8 @@
 //usage:     "\n	-a	Stop swapping on all swap devices"
 
 #include "libbb.h"
+#include "xmount.h"
 #include <mntent.h>
-#ifndef __BIONIC__
-# include <sys/swap.h>
-#endif
 
 #if ENABLE_FEATURE_MOUNT_LABEL
 # include "volume_id.h"
@@ -65,9 +63,9 @@ static int swap_enable_disable(char *dev
 #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);
--- a/util-linux/xmount.c
+++ b/util-linux/xmount.c
@@ -67,4 +67,14 @@ int FAST_FUNC xumount(const char *target
 	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
--- 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
 # ifdef MNT_NODEV
 #  define MS_NODEV	MNT_NODEV
@@ -86,16 +88,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