1/* swapon.c - Enable region for swapping
2 *
3 * Copyright 2012 Elie De Brauwer <eliedebrauwer@gmail.com>
4
5USE_SWAPON(NEWTOY(swapon, "<1>1p#<0>32767", TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
6
7config 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
19GLOBALS(
20  long priority;
21)
22
23void 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