Mercurial > hg > toybox
annotate toys/other/swapon.c @ 694:786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Rewordwrap in places. Update documentation with new coding style.
The actual code should be the same afterward, this is just cosmetic refactoring.
author  Rob Landley <rob@landley.net> 

date  Tue, 13 Nov 2012 17:14:08 0600 
parents  7e846e281e38 
children  57f2a26fa92c 
rev  line source 

694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Rewordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
674
diff
changeset

1 /* swapon.c  Enable region for swapping 
482
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

2 * 
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

3 * Copyright 2012 Elie De Brauwer <eliedebrauwer@gmail.com> 
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

4 
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

5 USE_SWAPON(NEWTOY(swapon, "<1>1p#<0>32767", TOYFLAG_BINTOYFLAG_NEEDROOT)) 
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

6 
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

7 config SWAPON 
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Rewordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
674
diff
changeset

8 bool "swapon" 
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Rewordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
674
diff
changeset

9 default y 
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Rewordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
674
diff
changeset

10 help 
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Rewordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
674
diff
changeset

11 usage: swapon [p priority] filename 
482
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

12 
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Rewordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
674
diff
changeset

13 Enable swapping on a given device/file. 
482
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

14 */ 
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

15 
674
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
656
diff
changeset

16 #define FOR_swapon 
482
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

17 #include "toys.h" 
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

18 
674
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
656
diff
changeset

19 GLOBALS( 
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Rewordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
674
diff
changeset

20 long priority; 
482
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

21 ) 
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

22 
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

23 void swapon_main(void) 
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

24 { 
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Rewordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
674
diff
changeset

25 int flags = 0; 
482
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

26 
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Rewordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
674
diff
changeset

27 if (toys.optflags) 
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Rewordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
674
diff
changeset

28 flags = SWAP_FLAG_PREFER  (TT.priority << SWAP_FLAG_PRIO_SHIFT); 
482
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

29 
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Rewordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
674
diff
changeset

30 if (swapon(*toys.optargs, flags)) 
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Rewordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
674
diff
changeset

31 perror_exit("Couldn't swapon '%s'", *toys.optargs); 
482
b4a9fd8773d6
Adding swapon and swapoff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset

32 } 