aboutsummaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorGravatar Matt Whitlock <busybox@mattwhitlock.name>2014-03-22 19:10:08 -0400
committerGravatar Denys Vlasenko <vda.linux@googlemail.com>2014-03-23 18:36:22 +0100
commitb9bbd4ddf622bc365726af4f2424210762e74b32 (patch)
tree3d602ab0abdb89400fb5d8cbaff34bd237b507eb /util-linux
parentc3a27b0bfdf758f649caab2c474e690067af3402 (diff)
downloadbusybox-b9bbd4ddf622bc365726af4f2424210762e74b32.tar.gz
busybox-b9bbd4ddf622bc365726af4f2424210762e74b32.tar.bz2
fix interaction of -a and -p options in swapon
Swap entries in /etc/fstab inherit the priority specified on the command line unless they have 'pri' in their mount options. Signed-off-by: Matt Whitlock <busybox@mattwhitlock.name> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/swaponoff.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c
index bcceff772..d5bfe1888 100644
--- a/util-linux/swaponoff.c
+++ b/util-linux/swaponoff.c
@@ -82,6 +82,9 @@ static int do_em_all(void)
struct mntent *m;
FILE *f;
int err;
+#ifdef G
+ int cl_flags = g_flags;
+#endif
f = setmntent("/etc/fstab", "r");
if (f == NULL)
@@ -97,14 +100,14 @@ static int do_em_all(void)
) {
#if ENABLE_FEATURE_SWAPON_PRI
char *p;
- g_flags = 0; /* each swap space might have different flags */
+ g_flags = cl_flags; /* each swap space might have different flags */
p = hasmntopt(m, "pri");
if (p) {
/* Max allowed 32767 (== SWAP_FLAG_PRIO_MASK) */
unsigned prio = bb_strtou(p + 4, NULL, 10);
/* We want to allow "NNNN,foo", thus errno == EINVAL is allowed too */
if (errno != ERANGE) {
- g_flags = SWAP_FLAG_PREFER |
+ g_flags = (g_flags & ~SWAP_FLAG_PRIO_MASK) | SWAP_FLAG_PREFER |
MIN(prio, SWAP_FLAG_PRIO_MASK);
}
}