Last change
on this file since 3853 was 3621, checked in by Bruno Cornec, 8 years ago |
New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.
|
File size:
1.3 KB
|
Rev | Line | |
---|
[821] | 1 | /* vi: set sw=4 ts=4: */
|
---|
| 2 | /*
|
---|
[2725] | 3 | * Prints out the previous and the current runlevel.
|
---|
[821] | 4 | *
|
---|
[2725] | 5 | * Version: @(#)runlevel 1.20 16-Apr-1997 MvS
|
---|
[821] | 6 | *
|
---|
[2725] | 7 | * This file is part of the sysvinit suite,
|
---|
| 8 | * Copyright 1991-1997 Miquel van Smoorenburg.
|
---|
[821] | 9 | *
|
---|
[2725] | 10 | * Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
---|
[821] | 11 | *
|
---|
[2725] | 12 | * initially busyboxified by Bernhard Reutner-Fischer
|
---|
[821] | 13 | */
|
---|
[3232] | 14 |
|
---|
| 15 | //usage:#define runlevel_trivial_usage
|
---|
| 16 | //usage: "[FILE]"
|
---|
| 17 | //usage:#define runlevel_full_usage "\n\n"
|
---|
| 18 | //usage: "Find the current and previous system runlevel\n"
|
---|
| 19 | //usage: "\n"
|
---|
| 20 | //usage: "If no utmp FILE exists or if no runlevel record can be found,\n"
|
---|
| 21 | //usage: "print \"unknown\""
|
---|
| 22 | //usage:
|
---|
| 23 | //usage:#define runlevel_example_usage
|
---|
| 24 | //usage: "$ runlevel /var/run/utmp\n"
|
---|
| 25 | //usage: "N 2"
|
---|
| 26 |
|
---|
[2725] | 27 | #include "libbb.h"
|
---|
[821] | 28 |
|
---|
[2725] | 29 | int runlevel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
---|
| 30 | int runlevel_main(int argc UNUSED_PARAM, char **argv)
|
---|
[821] | 31 | {
|
---|
[3621] | 32 | struct utmpx *ut;
|
---|
[1765] | 33 | char prev;
|
---|
[821] | 34 |
|
---|
[3621] | 35 | if (argv[1]) utmpxname(argv[1]);
|
---|
[821] | 36 |
|
---|
[3621] | 37 | setutxent();
|
---|
| 38 | while ((ut = getutxent()) != NULL) {
|
---|
[1765] | 39 | if (ut->ut_type == RUN_LVL) {
|
---|
| 40 | prev = ut->ut_pid / 256;
|
---|
| 41 | if (prev == 0) prev = 'N';
|
---|
| 42 | printf("%c %c\n", prev, ut->ut_pid % 256);
|
---|
| 43 | if (ENABLE_FEATURE_CLEAN_UP)
|
---|
[3621] | 44 | endutxent();
|
---|
[1765] | 45 | return 0;
|
---|
| 46 | }
|
---|
[821] | 47 | }
|
---|
| 48 |
|
---|
[1765] | 49 | puts("unknown");
|
---|
| 50 |
|
---|
| 51 | if (ENABLE_FEATURE_CLEAN_UP)
|
---|
[3621] | 52 | endutxent();
|
---|
[1765] | 53 | return 1;
|
---|
[821] | 54 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.