1 /* vi: set sw=4 ts=4: */
3 * setconsole.c - redirect system console output
5 * Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
10 #include <sys/ioctl.h>
12 #include <sys/types.h>
15 #include <getopt.h> /* struct option */
19 #if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
20 static const struct option setconsole_long_options[] = {
21 { "reset", 0, NULL, 'r' },
26 #define OPT_SETCONS_RESET 1
28 int setconsole_main(int argc, char **argv)
31 const char *device = CURRENT_TTY;
33 #if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
34 bb_applet_long_options = setconsole_long_options;
36 flags = bb_getopt_ulflags(argc, argv, "r");
38 if (argc - optind > 1)
41 if (argc - optind == 1) {
42 if (flags & OPT_SETCONS_RESET)
44 device = argv[optind];
46 if (flags & OPT_SETCONS_RESET)
50 if (-1 == ioctl(bb_xopen(device, O_RDONLY), TIOCCONS)) {
51 bb_perror_msg_and_die("TIOCCONS");