annotate toys/other/swapon.c @ 1775:57f2a26fa92c draft toast

To ensure that toybox can be installed alongside busybox without confusing update-alternatives, the paths of the links installed by toybox should match those installed by busybox. This is accomplished by changing the flags of a few tools within toybox.
author Paul Barker <paul@paulbarker.me.uk>
date Sat, 04 Apr 2015 11:58:06 -0500
parents 786841fdb1e0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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. Re-wordwrap 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
1775
57f2a26fa92c To ensure that toybox can be installed alongside busybox without
Paul Barker <paul@paulbarker.me.uk>
parents: 694
diff changeset
5 USE_SWAPON(NEWTOY(swapon, "<1>1p#<0>32767", TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
482
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. Re-wordwrap 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. Re-wordwrap 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. Re-wordwrap 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. Re-wordwrap 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. Re-wordwrap 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. Re-wordwrap 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. Re-wordwrap 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. Re-wordwrap 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. Re-wordwrap 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. Re-wordwrap 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. Re-wordwrap 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 }