From: Lauri Kasanen Date: Thu, 29 Apr 2010 20:20:57 +0000 (+0200) Subject: swapon: skip noauto entries X-Git-Tag: 1_17_0~265 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d2844fcb6862c080177aaf314cc98d03e65b05ac;p=oweals%2Fbusybox.git swapon: skip noauto entries Signed-off-by: Lauri Kasanen Signed-off-by: Denys Vlasenko --- diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c index f647a32bc..f2f52fb88 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; }