Rev | Line | |
---|
[821] | 1 | /* vi: set sw=4 ts=4: */
|
---|
| 2 | /*
|
---|
| 3 | * setconsole.c - redirect system console output
|
---|
| 4 | *
|
---|
| 5 | * Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
|
---|
| 6 | *
|
---|
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
---|
| 8 | */
|
---|
| 9 |
|
---|
[1765] | 10 | #include <getopt.h>
|
---|
| 11 | #include "libbb.h"
|
---|
[821] | 12 |
|
---|
| 13 | #if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
|
---|
[1765] | 14 | static const char setconsole_longopts[] ALIGN1 =
|
---|
| 15 | "reset\0" No_argument "r"
|
---|
| 16 | ;
|
---|
[821] | 17 | #endif
|
---|
| 18 |
|
---|
| 19 | #define OPT_SETCONS_RESET 1
|
---|
| 20 |
|
---|
[1765] | 21 | int setconsole_main(int argc, char **argv);
|
---|
[821] | 22 | int setconsole_main(int argc, char **argv)
|
---|
| 23 | {
|
---|
| 24 | unsigned long flags;
|
---|
| 25 | const char *device = CURRENT_TTY;
|
---|
| 26 |
|
---|
| 27 | #if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
|
---|
[1765] | 28 | applet_long_options = setconsole_longopts;
|
---|
[821] | 29 | #endif
|
---|
[1765] | 30 | flags = getopt32(argv, "r");
|
---|
[821] | 31 |
|
---|
| 32 | if (argc - optind > 1)
|
---|
| 33 | bb_show_usage();
|
---|
| 34 |
|
---|
| 35 | if (argc - optind == 1) {
|
---|
| 36 | if (flags & OPT_SETCONS_RESET)
|
---|
| 37 | bb_show_usage();
|
---|
| 38 | device = argv[optind];
|
---|
| 39 | } else {
|
---|
| 40 | if (flags & OPT_SETCONS_RESET)
|
---|
[1765] | 41 | device = DEV_CONSOLE;
|
---|
[821] | 42 | }
|
---|
| 43 |
|
---|
[1765] | 44 | xioctl(xopen(device, O_RDONLY), TIOCCONS, NULL);
|
---|
[821] | 45 | return EXIT_SUCCESS;
|
---|
| 46 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.