comparison toys/swapon.c @ 482:b4a9fd8773d6

Adding swapon and swapoff
author Elie De Brauwer <eliedebrauwer@gmail.com>
date Sat, 18 Feb 2012 15:33:27 +0100
parents
children 26db0cd433f3
comparison
equal deleted inserted replaced
481:e1b9a8579ddb 482:b4a9fd8773d6
1 /* vi: set sw=4 ts=4:
2 *
3 * swapon.c - Enable region for swapping
4 *
5 * Copyright 2012 Elie De Brauwer <eliedebrauwer@gmail.com>
6 *
7 * Not in SUSv4.
8
9 USE_SWAPON(NEWTOY(swapon, "<1>1p#<0>32767", TOYFLAG_BIN|TOYFLAG_NEEDROOT))
10
11 config SWAPON
12 bool "swapon"
13 default y
14 help
15 usage: swapon swapregion
16
17 Enable swapping on a given swapregion.
18 */
19
20 #include "toys.h"
21
22 DEFINE_GLOBALS(
23 long priority;
24 )
25
26 #define TT this.swapon
27
28 void swapon_main(void)
29 {
30 int flags = 0;
31
32 if (toys.optflags & 1)
33 flags = SWAP_FLAG_PREFER |
34 ((TT.priority & SWAP_FLAG_PRIO_MASK) << SWAP_FLAG_PRIO_SHIFT);
35
36 if (swapon(toys.optargs[0], flags))
37 perror_exit("failed to enable swaparea");
38 }