summaryrefslogtreecommitdiff
path: root/util-linux/swaponoff.c
diff options
context:
space:
mode:
authorLauri Kasanen2010-04-29 22:20:57 +0200
committerDenys Vlasenko2010-04-29 22:20:57 +0200
commitd2844fcb6862c080177aaf314cc98d03e65b05ac (patch)
treea711e01d23ff8449ec055d07dcff4e54db5f4aaa /util-linux/swaponoff.c
parenta659b81dfa435aa19130a8c7dd1bfe8fa9a22131 (diff)
downloadbusybox-d2844fcb6862c080177aaf314cc98d03e65b05ac.zip
busybox-d2844fcb6862c080177aaf314cc98d03e65b05ac.tar.gz
swapon: skip noauto entries
Signed-off-by: Lauri Kasanen <curaga@operamail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux/swaponoff.c')
-rw-r--r--util-linux/swaponoff.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c
index f647a32..f2f52fb 100644
--- a/util-linux/swaponoff.c
+++ b/util-linux/swaponoff.c
@@ -66,11 +66,20 @@ static int do_em_all(void)
bb_perror_msg_and_die("/etc/fstab");
err = 0;
- while ((m = getmntent(f)) != NULL)
- if (strcmp(m->mnt_type, MNTTYPE_SWAP) == 0)
- err += swap_enable_disable(m->mnt_fsname);
+ while ((m = getmntent(f)) != NULL) {
+ if (strcmp(m->mnt_type, MNTTYPE_SWAP) == 0) {
+ /* swapon -a should ignore entries with noauto,
+ * but swapoff -a should process them */
+ if (applet_name[5] != 'n'
+ || hasmntopt(m, MNTOPT_NOAUTO) == NULL
+ ) {
+ err += swap_enable_disable(m->mnt_fsname);
+ }
+ }
+ }
- endmntent(f);
+ if (ENABLE_FEATURE_CLEAN_UP)
+ endmntent(f);
return err;
}