1 From a5b837c34a96bdbb53151af455912b691c9aaa52 Mon Sep 17 00:00:00 2001
2 From: Jeremie Koenig <jk@jk.fr.eu.org>
3 Date: Thu, 29 Jul 2010 21:59:54 +0200
4 Subject: [PATCH 19/19] swaponoff: FreeBSD support
7 Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>
9 util-linux/Config.src | 3 +--
10 util-linux/swaponoff.c | 6 +++---
11 util-linux/xmount.c | 10 ++++++++++
12 util-linux/xmount.h | 16 ++++++++++------
13 4 files changed, 24 insertions(+), 11 deletions(-)
15 diff --git a/util-linux/Config.src b/util-linux/Config.src
16 index 99a6fbe..cb4de95 100644
17 --- a/util-linux/Config.src
18 +++ b/util-linux/Config.src
19 @@ -639,7 +639,6 @@ config SETARCH
23 - depends on PLATFORM_LINUX
25 This option enables both the 'swapon' and the 'swapoff' utilities.
26 Once you have created some swap space using 'mkswap', you also need
27 @@ -651,7 +650,7 @@ config SWAPONOFF
28 config FEATURE_SWAPON_PRI
29 bool "Support priority option -p"
31 - depends on SWAPONOFF
32 + depends on SWAPONOFF && PLATFORM_LINUX
34 Enable support for setting swap device priority in swapon.
36 diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c
37 index f2f52fb..d13c37e 100644
38 --- a/util-linux/swaponoff.c
39 +++ b/util-linux/swaponoff.c
46 -#include <sys/swap.h>
48 #if ENABLE_FEATURE_MOUNT_LABEL
49 # include "volume_id.h"
50 @@ -43,9 +43,9 @@ static int swap_enable_disable(char *device)
53 if (applet_name[5] == 'n')
54 - status = swapon(device, g_flags);
55 + status = xswapon(device, g_flags);
57 - status = swapoff(device);
58 + status = xswapoff(device);
61 bb_simple_perror_msg(device);
62 diff --git a/util-linux/xmount.c b/util-linux/xmount.c
63 index 3f322b8..16543f1 100644
64 --- a/util-linux/xmount.c
65 +++ b/util-linux/xmount.c
66 @@ -63,4 +63,14 @@ int FAST_FUNC xumount(const char *target, int flags)
67 return unmount(target, flags);
70 +int FAST_FUNC xswapon(const char *path, int swapflags UNUSED_PARAM)
72 + return swapon(path);
75 +int FAST_FUNC xswapoff(const char *path)
77 + return swapoff(path);
81 diff --git a/util-linux/xmount.h b/util-linux/xmount.h
82 index caef564..bcd6d18 100644
83 --- a/util-linux/xmount.h
84 +++ b/util-linux/xmount.h
86 * Copyright (C) 2010 by Jeremie Koenig <jk@jk.fr.eu.org>
87 * Copyright (C) 2010 by Luca Favatella <slackydeb@gmail.com>
89 - * The Linux prototypes for mount() and umount2() are used as a reference for
90 - * our xmount() and xumount(), which should be implemented as a compatibility
91 - * wrappers for non-Linux systems (see xmount.c).
92 + * The Linux prototypes for mount(), umount2(), swapon() and swapoff() are
93 + * used as a reference for our versions of them. On non-Linux system those
94 + * should be implemented as compatibility wrappers (see xmount.c).
101 # include <sys/mount.h>
102 +# include <sys/swap.h>
103 /* Make sure we have all the new mount flags we actually try to use
104 * (grab more as needed from util-linux's mount/mount_constants.h). */
108 #elif defined(__FreeBSD_kernel__)
109 # include <sys/mount.h>
110 +# include <sys/swap.h>
111 # define MS_NOSUID MNT_NOSUID
112 # define MS_NODEV MNT_NODEV
113 # define MS_NOEXEC MNT_NOEXEC
118 - * Prototypes for xmount() and xumount(): on Linux we use the system calls
119 - * directly, otherwise xmount() and xumount() should be implemented as
120 - * compatibility wrappers (see xmount.c).
121 + * Prototypes for the compatibility wrappers
125 # define xmount mount
126 # define xumount umount2
127 +# define xswapon swapon
128 +# define xswapoff swapoff
130 int xmount(const char *source, const char *target, const char *filesystemtype,
131 unsigned long mountflags, const void *data) FAST_FUNC;
132 int xumount(const char *target, int flags) FAST_FUNC;
133 +int xswapon(const char *path, int swapflags) FAST_FUNC;
134 +int xswapoff(const char *path) FAST_FUNC;