Contents of /trunk/mkinitrd-magellan/busybox/console-tools/setconsole.c
Parent Directory | Revision Log
Revision 532 -
(show annotations)
(download)
Sat Sep 1 22:45:15 2007 UTC (17 years ago) by niro
File MIME type: text/plain
File size: 1020 byte(s)
Sat Sep 1 22:45:15 2007 UTC (17 years ago) by niro
File MIME type: text/plain
File size: 1020 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 | * 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 | |
10 | #include "busybox.h" |
11 | |
12 | #if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS |
13 | static const struct option setconsole_long_options[] = { |
14 | { "reset", 0, NULL, 'r' }, |
15 | { 0, 0, 0, 0 } |
16 | }; |
17 | #endif |
18 | |
19 | #define OPT_SETCONS_RESET 1 |
20 | |
21 | int setconsole_main(int argc, char **argv) |
22 | { |
23 | unsigned long flags; |
24 | const char *device = CURRENT_TTY; |
25 | |
26 | #if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS |
27 | applet_long_options = setconsole_long_options; |
28 | #endif |
29 | flags = getopt32(argc, argv, "r"); |
30 | |
31 | if (argc - optind > 1) |
32 | bb_show_usage(); |
33 | |
34 | if (argc - optind == 1) { |
35 | if (flags & OPT_SETCONS_RESET) |
36 | bb_show_usage(); |
37 | device = argv[optind]; |
38 | } else { |
39 | if (flags & OPT_SETCONS_RESET) |
40 | device = CONSOLE_DEV; |
41 | } |
42 | |
43 | if (-1 == ioctl(xopen(device, O_RDONLY), TIOCCONS)) { |
44 | bb_perror_msg_and_die("TIOCCONS"); |
45 | } |
46 | return EXIT_SUCCESS; |
47 | } |