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.
12 #if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
13 static const struct option setconsole_long_options[] = {
14 { "reset", 0, NULL, 'r' },
19 #define OPT_SETCONS_RESET 1
21 int setconsole_main(int argc, char **argv)
24 const char *device = CURRENT_TTY;
26 #if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
27 applet_long_options = setconsole_long_options;
29 flags = getopt32(argc, argv, "r");
31 if (argc - optind > 1)
34 if (argc - optind == 1) {
35 if (flags & OPT_SETCONS_RESET)
37 device = argv[optind];
39 if (flags & OPT_SETCONS_RESET)
43 if (-1 == ioctl(xopen(device, O_RDONLY), TIOCCONS)) {
44 bb_perror_msg_and_die("TIOCCONS");