X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=util-linux%2Fswaponoff.c;h=f2f52fb88ebc144a22b2df224c1073ad67d2f647;hb=dc1fd2e52aa7d24fd609399e94b78c8c4dd79229;hp=6eafa3e2116e638e6ad9c79dc02b3141dddd1635;hpb=ee56e013cfb6304f66129afee7978b0864699419;p=oweals%2Fbusybox.git diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c index 6eafa3e21..f2f52fb88 100644 --- a/util-linux/swaponoff.c +++ b/util-linux/swaponoff.c @@ -11,10 +11,16 @@ #include #include +#if ENABLE_FEATURE_MOUNT_LABEL +# include "volume_id.h" +#else +# define resolve_mount_spec(fsname) ((void)0) +#endif + #if ENABLE_FEATURE_SWAPON_PRI struct globals { int flags; -}; +} FIX_ALIASING; #define G (*(struct globals*)&bb_common_bufsiz1) #define g_flags (G.flags) #else @@ -26,6 +32,7 @@ static int swap_enable_disable(char *device) int status; struct stat st; + resolve_mount_spec(&device); xstat(device, &st); #if ENABLE_DESKTOP @@ -59,17 +66,26 @@ 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; } int swap_on_off_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; -int swap_on_off_main(int argc ATTRIBUTE_UNUSED, char **argv) +int swap_on_off_main(int argc UNUSED_PARAM, char **argv) { int ret;