#include <mntent.h>
#include <sys/swap.h>
+#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
int status;
struct stat st;
+ resolve_mount_spec(&device);
xstat(device, &st);
#if ENABLE_DESKTOP
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;