Package: busybox / 1:1.30.1-4

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
Subject: [PATCH 19/19] swaponoff: FreeBSD support
From: Jeremie Koenig <jk@jk.fr.eu.org>
Date: Thu, 29 Jul 2010 21:59:54 +0200
Last-Update: 2017-08-17

Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>

--- a/util-linux/swaponoff.c
+++ b/util-linux/swaponoff.c
@@ -76,10 +76,8 @@
 
 #include "libbb.h"
 #include "common_bufsiz.h"
+#include "xmount.h"
 #include <mntent.h>
-#ifndef __BIONIC__
-# include <sys/swap.h>
-#endif
 
 #if ENABLE_FEATURE_SWAPONOFF_LABEL
 # include "volume_id.h"
@@ -156,7 +154,7 @@
 	resolve_mount_spec(&device);
 
 	if (do_swapoff) {
-		err = swapoff(device);
+		err = xswapoff(device);
 		/* Don't complain on OPT_ALL if not a swap device or if it doesn't exist */
 		quiet = (OPT_ALL && (errno == EINVAL || errno == ENOENT));
 	} else {
@@ -170,7 +168,7 @@
 					return 1;
 				}
 			}
-			err = swapon(device, g_flags);
+			err = xswapon(device, g_flags);
 			/* Don't complain on swapon -a if device is already in use */
 			quiet = (OPT_ALL && errno == EBUSY);
 		}
--- a/util-linux/xmount.c
+++ b/util-linux/xmount.c
@@ -67,4 +67,14 @@
 	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
@@ -59,6 +60,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
@@ -90,16 +92,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