1 /* swapon.c - Enable region for swapping
2  *
3  * Copyright 2012 Elie De Brauwer <eliedebrauwer@gmail.com>
4 
5 USE_SWAPON(NEWTOY(swapon, "<1>1p#<0>32767", TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
6 
7 config SWAPON
8   bool "swapon"
9   default y
10   help
11     usage: swapon [-p priority] filename
12 
13     Enable swapping on a given device/file.
14 */
15 
16 #define FOR_swapon
17 #include "toys.h"
18 
GLOBALS(long priority;)19 GLOBALS(
20   long priority;
21 )
22 
23 void swapon_main(void)
24 {
25   int flags = 0;
26 
27   if (toys.optflags)
28     flags = SWAP_FLAG_PREFER | (TT.priority << SWAP_FLAG_PRIO_SHIFT);
29 
30   if (swapon(*toys.optargs, flags))
31     perror_exit("Couldn't swapon '%s'", *toys.optargs);
32 }
33