X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=util-linux%2Fswaponoff.c;h=f2f52fb88ebc144a22b2df224c1073ad67d2f647;hb=765b0eed3ef29a80115708c3249d3a541509cd24;hp=f647a32bccee762d92f7a611153298414a632f3b;hpb=98a4c7cf3d799ab953cb77e8b34597c73e3e7335;p=oweals%2Fbusybox.git 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; }