diff options
| author | Paul Fox <pgf@brightstareng.com> | 2005-08-01 18:12:30 +0000 |
|---|---|---|
| committer | Paul Fox <pgf@brightstareng.com> | 2005-08-01 18:12:30 +0000 |
| commit | fc2256a6ca7f943d671edaceac1ed1dfe3d1751c (patch) | |
| tree | bd9d3d8d3ac6ad21dbf31c7a40387d1a13f084a8 | |
| parent | 41a72ecd1936bc0b4ae75c723c88129bb01928ff (diff) | |
| download | busybox-w32-fc2256a6ca7f943d671edaceac1ed1dfe3d1751c.tar.gz busybox-w32-fc2256a6ca7f943d671edaceac1ed1dfe3d1751c.tar.bz2 busybox-w32-fc2256a6ca7f943d671edaceac1ed1dfe3d1751c.zip | |
applying patch for bug 72:
0000072: Add applet to redirect console output via ioctl(..., TIOCCONS)
applet name changed to setconsole, since suse has a very similar
utility. better to treat differences as bugs than invent a new command.
| -rw-r--r-- | AUTHORS | 3 | ||||
| -rw-r--r-- | console-tools/Config.in | 7 | ||||
| -rw-r--r-- | console-tools/Makefile.in | 1 | ||||
| -rw-r--r-- | console-tools/setconsole.c | 74 | ||||
| -rw-r--r-- | include/applets.h | 3 | ||||
| -rw-r--r-- | include/usage.h | 7 |
6 files changed, 95 insertions, 0 deletions
| @@ -26,6 +26,9 @@ Laurence Anderson <l.d.anderson@warwick.ac.uk> | |||
| 26 | Jeff Angielski <jeff@theptrgroup.com> | 26 | Jeff Angielski <jeff@theptrgroup.com> |
| 27 | ftpput, ftpget | 27 | ftpput, ftpget |
| 28 | 28 | ||
| 29 | Enrik Berkhan <Enrik.Berkhan@inka.de> | ||
| 30 | setconsole | ||
| 31 | |||
| 29 | Edward Betts <edward@debian.org> | 32 | Edward Betts <edward@debian.org> |
| 30 | expr, hostid, logname, whoami | 33 | expr, hostid, logname, whoami |
| 31 | 34 | ||
diff --git a/console-tools/Config.in b/console-tools/Config.in index e261794ab..aa5111ac8 100644 --- a/console-tools/Config.in +++ b/console-tools/Config.in | |||
| @@ -31,6 +31,13 @@ config CONFIG_DUMPKMAP | |||
| 31 | This program dumps the kernel's keyboard translation table to | 31 | This program dumps the kernel's keyboard translation table to |
| 32 | stdout, in binary format. You can then use loadkmap to load it. | 32 | stdout, in binary format. You can then use loadkmap to load it. |
| 33 | 33 | ||
| 34 | config CONFIG_SETCONSOLE | ||
| 35 | bool "setconsole" | ||
| 36 | default n | ||
| 37 | help | ||
| 38 | This program redirects the system console to another device, | ||
| 39 | like the current tty while logged in via telnet. | ||
| 40 | |||
| 34 | config CONFIG_LOADFONT | 41 | config CONFIG_LOADFONT |
| 35 | bool "loadfont" | 42 | bool "loadfont" |
| 36 | default n | 43 | default n |
diff --git a/console-tools/Makefile.in b/console-tools/Makefile.in index 23ce37397..5474b1974 100644 --- a/console-tools/Makefile.in +++ b/console-tools/Makefile.in | |||
| @@ -28,6 +28,7 @@ CONSOLETOOLS_DIR-$(CONFIG_CHVT) += chvt.o | |||
| 28 | CONSOLETOOLS_DIR-$(CONFIG_CLEAR) += clear.o | 28 | CONSOLETOOLS_DIR-$(CONFIG_CLEAR) += clear.o |
| 29 | CONSOLETOOLS_DIR-$(CONFIG_DEALLOCVT) += deallocvt.o | 29 | CONSOLETOOLS_DIR-$(CONFIG_DEALLOCVT) += deallocvt.o |
| 30 | CONSOLETOOLS_DIR-$(CONFIG_DUMPKMAP) += dumpkmap.o | 30 | CONSOLETOOLS_DIR-$(CONFIG_DUMPKMAP) += dumpkmap.o |
| 31 | CONSOLETOOLS_DIR-$(CONFIG_SETCONSOLE) += setconsole.o | ||
| 31 | CONSOLETOOLS_DIR-$(CONFIG_LOADFONT) += loadfont.o | 32 | CONSOLETOOLS_DIR-$(CONFIG_LOADFONT) += loadfont.o |
| 32 | CONSOLETOOLS_DIR-$(CONFIG_LOADKMAP) += loadkmap.o | 33 | CONSOLETOOLS_DIR-$(CONFIG_LOADKMAP) += loadkmap.o |
| 33 | CONSOLETOOLS_DIR-$(CONFIG_OPENVT) += openvt.o | 34 | CONSOLETOOLS_DIR-$(CONFIG_OPENVT) += openvt.o |
diff --git a/console-tools/setconsole.c b/console-tools/setconsole.c new file mode 100644 index 000000000..53ff1ad1e --- /dev/null +++ b/console-tools/setconsole.c | |||
| @@ -0,0 +1,74 @@ | |||
| 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 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2 of the License, or | ||
| 10 | * (at your option) any later version. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <sys/ioctl.h> | ||
| 23 | #include <sys/stat.h> | ||
| 24 | #include <sys/types.h> | ||
| 25 | #include <fcntl.h> | ||
| 26 | #include <stdio.h> | ||
| 27 | #include <getopt.h> | ||
| 28 | |||
| 29 | #include "busybox.h" | ||
| 30 | |||
| 31 | static const struct option setconsole_long_options[] = { | ||
| 32 | { "reset", 0, NULL, 'r' }, | ||
| 33 | { 0, 0, 0, 0 } | ||
| 34 | }; | ||
| 35 | |||
| 36 | #define OPT_SETCONS_RESET 1 | ||
| 37 | |||
| 38 | int setconsole_main(int argc, char **argv) | ||
| 39 | { | ||
| 40 | int con; | ||
| 41 | unsigned long flags; | ||
| 42 | const char *device = "/dev/tty"; | ||
| 43 | |||
| 44 | bb_applet_long_options = setconsole_long_options; | ||
| 45 | flags = bb_getopt_ulflags(argc, argv, "r"); | ||
| 46 | |||
| 47 | if (argc - optind > 1) | ||
| 48 | bb_show_usage(); | ||
| 49 | |||
| 50 | if (argc - optind == 1) { | ||
| 51 | if (flags & OPT_SETCONS_RESET) | ||
| 52 | bb_show_usage(); | ||
| 53 | device = argv[optind]; | ||
| 54 | } else { | ||
| 55 | if (flags & OPT_SETCONS_RESET) | ||
| 56 | device = "/dev/console"; | ||
| 57 | } | ||
| 58 | |||
| 59 | if (-1 == (con = open(device, O_RDONLY))) { | ||
| 60 | bb_perror_msg_and_die("open %s", device); | ||
| 61 | } | ||
| 62 | if (-1 == ioctl(con, TIOCCONS)) { | ||
| 63 | bb_perror_msg_and_die("ioctl TIOCCONS"); | ||
| 64 | } | ||
| 65 | return EXIT_SUCCESS; | ||
| 66 | } | ||
| 67 | |||
| 68 | /* | ||
| 69 | Local Variables: | ||
| 70 | c-file-style: "linux" | ||
| 71 | c-basic-offset: 4 | ||
| 72 | tab-width: 4 | ||
| 73 | End: | ||
| 74 | */ | ||
diff --git a/include/applets.h b/include/applets.h index 8ef5f460f..d6aee5599 100644 --- a/include/applets.h +++ b/include/applets.h | |||
| @@ -552,6 +552,9 @@ | |||
| 552 | #ifdef CONFIG_SEQ | 552 | #ifdef CONFIG_SEQ |
| 553 | APPLET(seq, seq_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) | 553 | APPLET(seq, seq_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) |
| 554 | #endif | 554 | #endif |
| 555 | #ifdef CONFIG_SETCONSOLE | ||
| 556 | APPLET(setconsole, setconsole_main, _BB_DIR_SBIN, _BB_SUID_NEVER) | ||
| 557 | #endif | ||
| 555 | #ifdef CONFIG_SETKEYCODES | 558 | #ifdef CONFIG_SETKEYCODES |
| 556 | APPLET(setkeycodes, setkeycodes_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) | 559 | APPLET(setkeycodes, setkeycodes_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) |
| 557 | #endif | 560 | #endif |
diff --git a/include/usage.h b/include/usage.h index 291ccb91a..967ab3f19 100644 --- a/include/usage.h +++ b/include/usage.h | |||
| @@ -2351,6 +2351,13 @@ | |||
| 2351 | "\tFIRST\tLAST\n" \ | 2351 | "\tFIRST\tLAST\n" \ |
| 2352 | "\tFIRST\tINCREMENT\tLAST" | 2352 | "\tFIRST\tINCREMENT\tLAST" |
| 2353 | 2353 | ||
| 2354 | #define setconsole_trivial_usage \ | ||
| 2355 | "[-r|--reset] [DEVICE]" | ||
| 2356 | #define setconsole_full_usage \ | ||
| 2357 | "Redirects system console output to DEVICE (default: /dev/tty).\n\n" \ | ||
| 2358 | "Options:\n" \ | ||
| 2359 | "\t-r\tReset output to /dev/console." | ||
| 2360 | |||
| 2354 | #define setkeycodes_trivial_usage \ | 2361 | #define setkeycodes_trivial_usage \ |
| 2355 | "SCANCODE KEYCODE ..." | 2362 | "SCANCODE KEYCODE ..." |
| 2356 | #define setkeycodes_full_usage \ | 2363 | #define setkeycodes_full_usage \ |
