diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2005-10-28 20:37:03 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2005-10-28 20:37:03 +0000 |
commit | 62d7acc97efe6a4c3307918c51efee7acb0e9c30 (patch) | |
tree | b0a5ae0270677ce2bbe0a62dbd514b3245fb88da /miscutils/runlevel.c | |
parent | 4922f2a06f7e3212f4b5d1bb9329fdc1b1c18252 (diff) | |
download | busybox-w32-62d7acc97efe6a4c3307918c51efee7acb0e9c30.tar.gz busybox-w32-62d7acc97efe6a4c3307918c51efee7acb0e9c30.tar.bz2 busybox-w32-62d7acc97efe6a4c3307918c51efee7acb0e9c30.zip |
- add BB_APPLET_RUNLEVEL used by emdebian via /etc/init.d/rc.
Note that we leave the buggy CONFIG_* namespace now, so please fix any applet you thouch.
Diffstat (limited to 'miscutils/runlevel.c')
-rw-r--r-- | miscutils/runlevel.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/miscutils/runlevel.c b/miscutils/runlevel.c new file mode 100644 index 000000000..dfa846f81 --- /dev/null +++ b/miscutils/runlevel.c | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * runlevel Prints out the previous and the current runlevel. | ||
3 | * | ||
4 | * Version: @(#)runlevel 1.20 16-Apr-1997 MvS | ||
5 | * | ||
6 | * This file is part of the sysvinit suite, | ||
7 | * Copyright 1991-1997 Miquel van Smoorenburg. | ||
8 | * | ||
9 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. | ||
10 | * | ||
11 | * initially busyboxified by Bernhard Fischer | ||
12 | */ | ||
13 | |||
14 | #include <stdio.h> | ||
15 | #include <utmp.h> | ||
16 | #include <time.h> | ||
17 | #include <stdlib.h> | ||
18 | |||
19 | #include "busybox.h" | ||
20 | |||
21 | int runlevel_main(int argc, char *argv[]) | ||
22 | { | ||
23 | struct utmp *ut; | ||
24 | char prev; | ||
25 | |||
26 | if (argc > 1) utmpname(argv[1]); | ||
27 | |||
28 | setutent(); | ||
29 | while ((ut = getutent()) != NULL) { | ||
30 | if (ut->ut_type == RUN_LVL) { | ||
31 | prev = ut->ut_pid / 256; | ||
32 | if (prev == 0) prev = 'N'; | ||
33 | printf("%c %c\n", prev, ut->ut_pid % 256); | ||
34 | endutent(); | ||
35 | return (0); | ||
36 | } | ||
37 | } | ||
38 | |||
39 | printf("unknown\n"); | ||
40 | endutent(); | ||
41 | return (1); | ||
42 | } | ||
43 | |||