source: MondoRescue/branches/2.2.5/mindi-busybox/console-tools/setconsole.c@ 1765

Last change on this file since 1765 was 1765, checked in by Bruno Cornec, 16 years ago

Update to busybox 1.7.2

File size: 1002 bytes
Line 
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 <getopt.h>
11#include "libbb.h"
12
13#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
14static const char setconsole_longopts[] ALIGN1 =
15 "reset\0" No_argument "r"
16 ;
17#endif
18
19#define OPT_SETCONS_RESET 1
20
21int setconsole_main(int argc, char **argv);
22int 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
28 applet_long_options = setconsole_longopts;
29#endif
30 flags = getopt32(argv, "r");
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)
41 device = DEV_CONSOLE;
42 }
43
44 xioctl(xopen(device, O_RDONLY), TIOCCONS, NULL);
45 return EXIT_SUCCESS;
46}
Note: See TracBrowser for help on using the repository browser.