Annotation of /tags/mkinitrd-6_2_0/miscutils/runlevel.c
Parent Directory | Revision Log
Revision 994 -
(hide annotations)
(download)
Sun May 30 11:53:18 2010 UTC (14 years ago) by niro
File MIME type: text/plain
File size: 935 byte(s)
Sun May 30 11:53:18 2010 UTC (14 years ago) by niro
File MIME type: text/plain
File size: 935 byte(s)
tagged 'mkinitrd-6_2_0'
1 | niro | 532 | /* vi: set sw=4 ts=4: */ |
2 | /* | ||
3 | * runlevel Prints out the previous and the current runlevel. | ||
4 | * | ||
5 | * Version: @(#)runlevel 1.20 16-Apr-1997 MvS | ||
6 | * | ||
7 | * This file is part of the sysvinit suite, | ||
8 | * Copyright 1991-1997 Miquel van Smoorenburg. | ||
9 | * | ||
10 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. | ||
11 | * | ||
12 | niro | 816 | * initially busyboxified by Bernhard Reutner-Fischer |
13 | niro | 532 | */ |
14 | niro | 984 | #include "libbb.h" |
15 | niro | 532 | #include <utmp.h> |
16 | |||
17 | niro | 816 | int runlevel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
18 | niro | 984 | int runlevel_main(int argc UNUSED_PARAM, char **argv) |
19 | niro | 532 | { |
20 | struct utmp *ut; | ||
21 | char prev; | ||
22 | |||
23 | niro | 984 | if (argv[1]) utmpname(argv[1]); |
24 | niro | 532 | |
25 | setutent(); | ||
26 | while ((ut = getutent()) != NULL) { | ||
27 | if (ut->ut_type == RUN_LVL) { | ||
28 | prev = ut->ut_pid / 256; | ||
29 | if (prev == 0) prev = 'N'; | ||
30 | printf("%c %c\n", prev, ut->ut_pid % 256); | ||
31 | niro | 816 | if (ENABLE_FEATURE_CLEAN_UP) |
32 | endutent(); | ||
33 | niro | 532 | return 0; |
34 | } | ||
35 | } | ||
36 | |||
37 | puts("unknown"); | ||
38 | niro | 816 | |
39 | if (ENABLE_FEATURE_CLEAN_UP) | ||
40 | endutent(); | ||
41 | niro | 532 | return 1; |
42 | } |