Mercurial > hg > toybox
annotate toys/other/reboot.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 | 5fac2769a159 |
children |
rev | line source |
---|---|
1092
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
1 /* reboot.c - Restart, halt or powerdown the system. |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
2 * |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
3 * Copyright 2013 Elie De Brauwer <eliedebrauwer@gmail.com> |
1a5c7092afbf
New toy: reboot/halt/poweroff
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:
1634
diff
changeset
|
5 USE_REBOOT(NEWTOY(reboot, "n", TOYFLAG_SBIN|TOYFLAG_NEEDROOT)) |
57f2a26fa92c
To ensure that toybox can be installed alongside busybox without
Paul Barker <paul@paulbarker.me.uk>
parents:
1634
diff
changeset
|
6 USE_REBOOT(OLDTOY(halt, reboot, TOYFLAG_SBIN|TOYFLAG_NEEDROOT)) |
57f2a26fa92c
To ensure that toybox can be installed alongside busybox without
Paul Barker <paul@paulbarker.me.uk>
parents:
1634
diff
changeset
|
7 USE_REBOOT(OLDTOY(poweroff, reboot, TOYFLAG_SBIN|TOYFLAG_NEEDROOT)) |
1092
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
8 |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
9 config REBOOT |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
10 bool "reboot" |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
11 default y |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
12 help |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
13 usage: reboot/halt/poweroff [-n] |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
14 |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
15 Restart, halt or powerdown the system. |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
16 |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
17 -n Don't sync before stopping the system. |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
18 */ |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
19 |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
20 #define FOR_reboot |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
21 #include "toys.h" |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
22 #include <sys/reboot.h> |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
23 |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
24 void reboot_main(void) |
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
25 { |
1093 | 26 int types[] = {RB_AUTOBOOT, RB_HALT_SYSTEM, RB_POWER_OFF}; |
1092
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
27 |
1093 | 28 if (!(toys.optflags & FLAG_n)) sync(); |
29 | |
30 toys.exitval = reboot(types[stridx("hp", *toys.which->name)+1]); | |
1092
1a5c7092afbf
New toy: reboot/halt/poweroff
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff
changeset
|
31 } |