Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 532 - (show annotations) (download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 845 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd

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 Fischer
13 */
14
15 #include "busybox.h"
16 #include <stdio.h>
17 #include <utmp.h>
18 #include <time.h>
19 #include <stdlib.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 puts("unknown");
40 endutent();
41 return 1;
42 }