Magellan Linux

Contents of /trunk/mkinitrd-magellan/busybox/miscutils/runlevel.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 984 - (show annotations) (download)
Sun May 30 11:32:42 2010 UTC (13 years, 11 months ago) by niro
File MIME type: text/plain
File size: 935 byte(s)
-updated to busybox-1.16.1 and enabled blkid/uuid support in default config
1 /* 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 * initially busyboxified by Bernhard Reutner-Fischer
13 */
14 #include "libbb.h"
15 #include <utmp.h>
16
17 int runlevel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
18 int runlevel_main(int argc UNUSED_PARAM, char **argv)
19 {
20 struct utmp *ut;
21 char prev;
22
23 if (argv[1]) utmpname(argv[1]);
24
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 if (ENABLE_FEATURE_CLEAN_UP)
32 endutent();
33 return 0;
34 }
35 }
36
37 puts("unknown");
38
39 if (ENABLE_FEATURE_CLEAN_UP)
40 endutent();
41 return 1;
42 }