Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/console-tools
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- Location:
- branches/stable/mindi-busybox/console-tools
- Files:
-
- 2 deleted
- 12 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/console-tools/Config.in
r821 r1770 6 6 menu "Console Utilities" 7 7 8 config C ONFIG_CHVT8 config CHVT 9 9 bool "chvt" 10 10 default n … … 13 13 Example: chvt 4 (change to terminal /dev/tty4) 14 14 15 config C ONFIG_CLEAR15 config CLEAR 16 16 bool "clear" 17 17 default n … … 19 19 This program clears the terminal screen. 20 20 21 config CONFIG_DEALLOCVT21 config DEALLOCVT 22 22 bool "deallocvt" 23 23 default n … … 25 25 This program deallocates unused virtual consoles. 26 26 27 config CONFIG_DUMPKMAP27 config DUMPKMAP 28 28 bool "dumpkmap" 29 29 default n … … 32 32 stdout, in binary format. You can then use loadkmap to load it. 33 33 34 config CONFIG_LOADFONT34 config LOADFONT 35 35 bool "loadfont" 36 36 default n … … 38 38 This program loads a console font from standard input. 39 39 40 config CONFIG_LOADKMAP40 config LOADKMAP 41 41 bool "loadkmap" 42 42 default n … … 45 45 standard input. 46 46 47 config CONFIG_OPENVT47 config OPENVT 48 48 bool "openvt" 49 49 default n … … 52 52 virtual terminal. 53 53 54 config CONFIG_RESET54 config RESET 55 55 bool "reset" 56 56 default n … … 59 59 gets messed up. 60 60 61 config CONFIG_SETCONSOLE 61 config RESIZE 62 bool "resize" 63 default n 64 help 65 This program is used to (re)set the width and height of your current 66 terminal. 67 68 config FEATURE_RESIZE_PRINT 69 bool "print environment variables" 70 default n 71 depends on RESIZE 72 help 73 Prints the newly set size (number of columns and rows) of 74 the terminal. 75 E.g.: 76 COLUMNS=80;LINES=44;export COLUMNS LINES; 77 78 config SETCONSOLE 62 79 bool "setconsole" 63 80 default n … … 66 83 like the current tty while logged in via telnet. 67 84 68 config CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS85 config FEATURE_SETCONSOLE_LONG_OPTIONS 69 86 bool "Enable long options" 70 87 default n 71 depends on CONFIG_SET_CONSOLE && CONFIG_GETOPT_LONG88 depends on SETCONSOLE && GETOPT_LONG 72 89 help 73 90 Support long options for the setconsole applet. 74 91 75 config CONFIG_SETKEYCODES92 config SETKEYCODES 76 93 bool "setkeycodes" 77 94 default n … … 80 97 map, allowing unusual keyboards to generate usable keycodes. 81 98 82 config CONFIG_SETLOGCONS99 config SETLOGCONS 83 100 bool "setlogcons" 84 101 default n -
branches/stable/mindi-busybox/console-tools/chvt.c
r821 r1770 8 8 */ 9 9 10 #include <stdio.h> 11 #include <stdlib.h> 12 #include <fcntl.h> 13 #include <sys/types.h> 14 #include <sys/ioctl.h> 15 #include "busybox.h" 10 #include "libbb.h" 16 11 17 12 /* From <linux/vt.h> */ … … 21 16 }; 22 17 18 int chvt_main(int argc, char **argv); 23 19 int chvt_main(int argc, char **argv) 24 20 { … … 30 26 31 27 fd = get_console_fd(); 32 num = bb_xgetlarg(argv[1], 10, 0, INT_MAX); 33 if ((-1 == ioctl(fd, VT_ACTIVATE, num)) 34 || (-1 == ioctl(fd, VT_WAITACTIVE, num))) { 35 bb_perror_msg_and_die("ioctl"); 36 } 28 num = xatou_range(argv[1], 1, 63); 29 /* double cast suppresses "cast to ptr from int of different size */ 30 xioctl(fd, VT_ACTIVATE, (void *)(ptrdiff_t)num); 31 xioctl(fd, VT_WAITACTIVE, (void *)(ptrdiff_t)num); 37 32 return EXIT_SUCCESS; 38 33 } -
branches/stable/mindi-busybox/console-tools/clear.c
r821 r1770 5 5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> 6 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 GNU 15 * 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 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 20 8 * 21 9 */ … … 23 11 /* no options, no getopt */ 24 12 25 #include <stdio.h> 26 #include <stdlib.h> 27 #include "busybox.h" 13 #include "libbb.h" 28 14 29 15 int clear_main(int argc, char **argv); 30 16 int clear_main(int argc, char **argv) 31 17 { -
branches/stable/mindi-busybox/console-tools/deallocvt.c
r821 r1770 6 6 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> 7 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 21 9 */ 22 10 23 11 /* no options, no getopt */ 24 12 25 #include <stdlib.h> 26 #include <stdio.h> 27 #include <fcntl.h> 28 #include <sys/types.h> 29 #include <sys/ioctl.h> 30 #include "busybox.h" 13 #include "libbb.h" 31 14 32 15 /* From <linux/vt.h> */ 33 16 enum { VT_DISALLOCATE = 0x5608 }; /* free memory associated to vt */ 34 17 35 int deallocvt_main(int argc, char *argv[]) 18 int deallocvt_main(int argc, char **argv); 19 int deallocvt_main(int argc, char **argv) 36 20 { 37 21 /* num = 0 deallocate all unused consoles */ … … 39 23 40 24 switch (argc) { 41 case 2: 42 if ((num = bb_xgetlarg(argv[1], 10, 0, INT_MAX)) == 0) { 43 bb_error_msg_and_die("0: illegal VT number"); 44 } 25 case 2: 26 num = xatou_range(argv[1], 1, 63); 45 27 /* Fallthrough */ 46 47 48 49 28 case 1: 29 break; 30 default: 31 bb_show_usage(); 50 32 } 51 33 52 if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) { 53 bb_perror_msg_and_die("VT_DISALLOCATE"); 54 } 34 /* double cast suppresses "cast to ptr from int of different size */ 35 xioctl(get_console_fd(), VT_DISALLOCATE, (void *)(ptrdiff_t)num); 55 36 return EXIT_SUCCESS; 56 37 } -
branches/stable/mindi-busybox/console-tools/dumpkmap.c
r821 r1770 5 5 * Copyright (C) Arne Bernin <arne@matrix.loopback.org> 6 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 GNU 15 * 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 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 20 8 * 21 9 */ 22 10 23 #include <errno.h> 24 #include <fcntl.h> 25 #include <stdio.h> 26 #include <unistd.h> 27 #include <string.h> 28 #include <stdlib.h> 29 #include <sys/ioctl.h> 30 #include "busybox.h" 11 #include "libbb.h" 31 12 32 13 /* From <linux/kd.h> */ … … 42 23 #define MAX_NR_KEYMAPS 256 43 24 25 int dumpkmap_main(int argc, char **argv); 44 26 int dumpkmap_main(int argc, char **argv) 45 27 { 46 28 struct kbentry ke; 47 29 int i, j, fd; 48 char flags[MAX_NR_KEYMAPS] , magic[] = "bkeymap";30 char flags[MAX_NR_KEYMAPS]; 49 31 50 if (argc >= 2 && *argv[1] == '-')32 if (argc >= 2 && argv[1][0] == '-') 51 33 bb_show_usage(); 52 34 53 fd = bb_xopen(CURRENT_VC, O_RDWR);35 fd = xopen(CURRENT_VC, O_RDWR); 54 36 55 write(1, magic, 7);37 write(1, "bkeymap", 7); 56 38 57 39 /* Here we want to set everything to 0 except for indexes: … … 69 51 ke.kb_index = j; 70 52 ke.kb_table = i; 71 if ( ioctl(fd, KDGKBENT, &ke) < 0) {72 bb_perror_msg("ioctl failed with %s, %s, %p",53 if (!ioctl_or_perror(fd, KDGKBENT, &ke, 54 "ioctl failed with %s, %s, %p", 73 55 (char *)&ke.kb_index, 74 56 (char *)&ke.kb_table, 75 &ke.kb_value) ;76 } else{57 &ke.kb_value) 58 ) { 77 59 write(1, (void*)&ke.kb_value, 2); 78 60 } -
branches/stable/mindi-busybox/console-tools/loadfont.c
r821 r1770 8 8 * (Adapted for busybox by Matej Vela.) 9 9 */ 10 #include <stdio.h> 11 #include <string.h> 12 #include <fcntl.h> 13 #include <stdlib.h> 14 #include <unistd.h> 15 #include <sys/types.h> 16 #include <dirent.h> 17 #include <errno.h> 18 #include <sys/ioctl.h> 10 #include "libbb.h" 19 11 #include <sys/kd.h> 20 #include <endian.h>21 #include "busybox.h"22 12 23 enum {13 enum { 24 14 PSF_MAGIC1 = 0x36, 25 15 PSF_MAGIC2 = 0x04, … … 32 22 33 23 struct psf_header { 34 unsigned char magic1, magic2; 35 unsigned char mode; 36 unsigned char charsize; 24 unsigned char magic1, magic2; /* Magic number */ 25 unsigned char mode; /* PSF font mode */ 26 unsigned char charsize; /* Character size */ 37 27 }; 38 28 39 29 #define PSF_MAGIC_OK(x) ((x).magic1 == PSF_MAGIC1 && (x).magic2 == PSF_MAGIC2) 40 30 41 static void loadnewfont(int fd);42 43 int loadfont_main(int argc, char **argv)44 {45 int fd;46 47 if (argc != 1)48 bb_show_usage();49 50 fd = bb_xopen(CURRENT_VC, O_RDWR);51 loadnewfont(fd);52 53 return EXIT_SUCCESS;54 }55 56 31 static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize) 57 32 { 58 char buf[16384];33 char *buf; 59 34 int i; 60 35 61 memset(buf, 0, sizeof(buf)); 36 if (unit < 1 || unit > 32) 37 bb_error_msg_and_die("bad character size %d", unit); 62 38 63 if (unit < 1 || unit > 32) 64 bb_error_msg_and_die("Bad character size %d", unit); 65 39 buf = xzalloc(16 * 1024); 40 /*memset(buf, 0, 16 * 1024);*/ 66 41 for (i = 0; i < fontsize; i++) 67 42 memcpy(buf + (32 * i), inbuf + (unit * i), unit); 68 43 69 #if defined( PIO_FONTX ) && !defined( __sparc__)44 #if defined(PIO_FONTX) && !defined(__sparc__) 70 45 { 71 46 struct consolefontdesc cfd; … … 75 50 cfd.chardata = buf; 76 51 77 if (ioctl(fd, PIO_FONTX, &cfd) == 0) 78 return; /* success */ 79 bb_perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)"); 52 if (!ioctl_or_perror(fd, PIO_FONTX, &cfd, "PIO_FONTX ioctl failed (will try PIO_FONT)")) 53 goto ret; /* success */ 80 54 } 81 55 #endif 82 if (ioctl(fd, PIO_FONT, buf)) 83 bb_perror_msg_and_die("PIO_FONT ioctl error"); 56 xioctl(fd, PIO_FONT, buf); 57 ret: 58 free(buf); 84 59 } 85 60 … … 92 67 int ct = 0, maxct; 93 68 int glyph; 94 u _short unicode;69 uint16_t unicode; 95 70 96 71 maxct = tailsz; /* more than enough */ 97 up = (struct unipair *)xmalloc(maxct * sizeof(struct unipair));72 up = xmalloc(maxct * sizeof(struct unipair)); 98 73 99 74 for (glyph = 0; glyph < fontsize; glyph++) { 100 75 while (tailsz >= 2) { 101 unicode = (((u _short) inbuf[1]) << 8) + inbuf[0];76 unicode = (((uint16_t) inbuf[1]) << 8) + inbuf[0]; 102 77 tailsz -= 2; 103 78 inbuf += 2; … … 116 91 advice.advised_hashstep = 0; 117 92 advice.advised_hashlevel = 0; 118 if (ioctl(fd, PIO_UNIMAPCLR, &advice)) { 119 #ifdef ENOIOCTLCMD 120 if (errno == ENOIOCTLCMD) { 121 bb_error_msg("It seems this kernel is older than 1.1.92"); 122 bb_error_msg_and_die("No Unicode mapping table loaded."); 123 } else 124 #endif 125 bb_perror_msg_and_die("PIO_UNIMAPCLR"); 126 } 93 xioctl(fd, PIO_UNIMAPCLR, &advice); 127 94 ud.entry_ct = ct; 128 95 ud.entries = up; 129 if (ioctl(fd, PIO_UNIMAP, &ud)) { 130 #if 0 131 if (errno == ENOMEM) { 132 /* change advice parameters */ 133 } 134 #endif 135 bb_perror_msg_and_die("PIO_UNIMAP"); 136 } 96 xioctl(fd, PIO_UNIMAP, &ud); 137 97 } 138 98 139 99 static void loadnewfont(int fd) 140 100 { 101 enum { INBUF_SIZE = 32*1024 + 1 }; 102 141 103 int unit; 142 unsigned char inbuf[32768]; /* primitive */ 143 unsigned int inputlth, offset; 104 unsigned inputlth, offset; 105 /* Was on stack, but 32k is a bit too much: */ 106 unsigned char *inbuf = xmalloc(INBUF_SIZE); 144 107 145 108 /* … … 148 111 * just read the entire file. 149 112 */ 150 inputlth = fread(inbuf, 1, sizeof(inbuf), stdin); 151 if (ferror(stdin)) 152 bb_perror_msg_and_die("Error reading input font"); 153 /* use malloc/realloc in case of giant files; 154 maybe these do not occur: 16kB for the font, 155 and 16kB for the map leaves 32 unicode values 156 for each font position */ 157 if (!feof(stdin)) 158 bb_perror_msg_and_die("Font too large"); 113 inputlth = full_read(STDIN_FILENO, inbuf, INBUF_SIZE); 114 if (inputlth < 0) 115 bb_perror_msg_and_die("error reading input font"); 116 if (inputlth >= INBUF_SIZE) 117 bb_error_msg_and_die("font too large"); 159 118 160 119 /* test for psf first */ … … 163 122 int fontsize; 164 123 int hastable; 165 unsigned inthead0, head;124 unsigned head0, head; 166 125 167 126 if (inputlth < sizeof(struct psf_header)) … … 174 133 175 134 if (psfhdr.mode > PSF_MAXMODE) 176 bb_error_msg_and_die(" Unsupported psf file mode");135 bb_error_msg_and_die("unsupported psf file mode"); 177 136 fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256); 178 #if !defined( PIO_FONTX ) || defined( __sparc__)137 #if !defined(PIO_FONTX) || defined(__sparc__) 179 138 if (fontsize != 256) 180 bb_error_msg_and_die(" Only fontsize 256 supported");139 bb_error_msg_and_die("only fontsize 256 supported"); 181 140 #endif 182 141 hastable = (psfhdr.mode & PSF_MODEHASTAB); … … 186 145 head = head0 + fontsize * unit; 187 146 if (head > inputlth || (!hastable && head != inputlth)) 188 bb_error_msg_and_die(" Input file: bad length");147 bb_error_msg_and_die("input file: bad length"); 189 148 do_loadfont(fd, inbuf + head0, unit, fontsize); 190 149 if (hastable) … … 192 151 return; 193 152 } 194 no_psf:195 153 154 no_psf: 196 155 /* file with three code pages? */ 197 156 if (inputlth == 9780) { … … 201 160 /* bare font */ 202 161 if (inputlth & 0377) 203 bb_error_msg_and_die(" Bad input file size");162 bb_error_msg_and_die("bad input file size"); 204 163 offset = 0; 205 164 unit = inputlth / 256; … … 207 166 do_loadfont(fd, inbuf + offset, unit, 256); 208 167 } 168 169 int loadfont_main(int argc, char **argv); 170 int loadfont_main(int argc, char **argv) 171 { 172 int fd; 173 174 if (argc != 1) 175 bb_show_usage(); 176 177 fd = xopen(CURRENT_VC, O_RDWR); 178 loadnewfont(fd); 179 180 return EXIT_SUCCESS; 181 } -
branches/stable/mindi-busybox/console-tools/loadkmap.c
r821 r1770 5 5 * Copyright (C) 1998 Enrique Zanardi <ezanardi@ull.es> 6 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 GNU 15 * 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 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 20 8 * 21 9 */ 22 10 23 #include <errno.h> 24 #include <fcntl.h> 25 #include <stdio.h> 26 #include <string.h> 27 #include <stdlib.h> 28 #include <unistd.h> 29 #include <sys/ioctl.h> 30 #include "busybox.h" 11 #include "libbb.h" 31 12 32 13 #define BINARY_KEYMAP_MAGIC "bkeymap" … … 45 26 #define MAX_NR_KEYMAPS 256 46 27 28 int loadkmap_main(int argc, char **argv); 47 29 int loadkmap_main(int argc, char **argv) 48 30 { 49 31 struct kbentry ke; 50 32 int i, j, fd; 51 u _short ibuff[NR_KEYS];33 uint16_t ibuff[NR_KEYS]; 52 34 char flags[MAX_NR_KEYMAPS]; 53 35 char buff[7]; … … 56 38 bb_show_usage(); 57 39 58 fd = bb_xopen(CURRENT_VC, O_RDWR);40 fd = xopen(CURRENT_VC, O_RDWR); 59 41 60 if ((bb_full_read(0, buff, 7) != 7) || (strncmp(buff, BINARY_KEYMAP_MAGIC, 7) != 0)) 61 bb_error_msg_and_die("This is not a valid binary keymap."); 42 xread(0, buff, 7); 43 if (strncmp(buff, BINARY_KEYMAP_MAGIC, 7)) 44 bb_error_msg_and_die("this is not a valid binary keymap"); 62 45 63 if (bb_full_read(0, flags, MAX_NR_KEYMAPS) != MAX_NR_KEYMAPS) 64 bb_perror_msg_and_die("Error reading keymap flags"); 46 xread(0, flags, MAX_NR_KEYMAPS); 65 47 66 48 for (i = 0; i < MAX_NR_KEYMAPS; i++) { 67 49 if (flags[i] == 1) { 68 bb_full_read(0, ibuff, NR_KEYS * sizeof(u_short));50 xread(0, ibuff, NR_KEYS * sizeof(uint16_t)); 69 51 for (j = 0; j < NR_KEYS; j++) { 70 52 ke.kb_index = j; … … 76 58 } 77 59 78 /* Don't bother to close files. Exit does that 79 * automagically, so we can save a few bytes */ 80 /* close(fd); */ 81 return EXIT_SUCCESS; 60 if (ENABLE_FEATURE_CLEAN_UP) close(fd); 61 return 0; 82 62 } -
branches/stable/mindi-busybox/console-tools/openvt.c
r821 r1770 11 11 /* getopt not needed */ 12 12 13 #include <stdio.h> 14 #include <stdlib.h> 15 #include <unistd.h> 16 #include <fcntl.h> 17 #include <string.h> 18 #include <sys/types.h> 19 #include <ctype.h> 13 #include "libbb.h" 20 14 21 #include "busybox.h" 22 15 int openvt_main(int argc, char **argv); 23 16 int openvt_main(int argc, char **argv) 24 17 { 25 int fd;26 18 char vtname[sizeof(VC_FORMAT) + 2]; 27 19 20 if (argc < 3) 21 bb_show_usage(); 28 22 29 if (argc < 3) { 30 bb_show_usage(); 31 } 32 /* check for Illegal vt number: < 1 or > 12 */ 33 sprintf(vtname, VC_FORMAT, (int)bb_xgetlarg(argv[1], 10, 1, 12)); 23 /* check for illegal vt number: < 1 or > 63 */ 24 sprintf(vtname, VC_FORMAT, (int)xatou_range(argv[1], 1, 63)); 34 25 35 if (fork() == 0) {36 /* leave current vt*/37 if (setsid() < 0) {38 bb_perror_msg_and_die("setsid");39 }40 close(0); /* so that new vt becomes stdin */26 bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, argv); 27 /* grab new one */ 28 close(0); 29 xopen(vtname, O_RDWR); 30 dup2(0, STDOUT_FILENO); 31 dup2(0, STDERR_FILENO); 41 32 42 /* and grab new one */ 43 fd = bb_xopen(vtname, O_RDWR); 44 45 /* Reassign stdout and sterr */ 46 dup2(fd, STDOUT_FILENO); 47 dup2(fd, STDERR_FILENO); 48 49 execvp(argv[2], &argv[2]); 50 _exit(1); 51 } 52 return EXIT_SUCCESS; 33 BB_EXECVP(argv[2], &argv[2]); 34 _exit(1); 53 35 } -
branches/stable/mindi-busybox/console-tools/reset.c
r821 r1770 6 6 * Written by Erik Andersen and Kent Robotti <robotti@metconnect.com> 7 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * 8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 22 9 */ 23 10 24 11 /* no options, no getopt */ 25 12 26 #include <stdio.h> 27 #include <stdlib.h> 28 #include <unistd.h> 29 #include "busybox.h" 13 #include "libbb.h" 30 14 15 int reset_main(int argc, char **argv); 31 16 int reset_main(int argc, char **argv) 32 17 { -
branches/stable/mindi-busybox/console-tools/setconsole.c
r821 r1770 8 8 */ 9 9 10 #include <sys/ioctl.h> 11 #include <sys/stat.h> 12 #include <sys/types.h> 13 #include <fcntl.h> 14 #include <stdio.h> 15 #include <getopt.h> /* struct option */ 16 17 #include "busybox.h" 10 #include <getopt.h> 11 #include "libbb.h" 18 12 19 13 #if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS 20 static const struct option setconsole_long_options[] = { 21 { "reset", 0, NULL, 'r' }, 22 { 0, 0, 0, 0 } 23 }; 14 static const char setconsole_longopts[] ALIGN1 = 15 "reset\0" No_argument "r" 16 ; 24 17 #endif 25 18 26 19 #define OPT_SETCONS_RESET 1 27 20 21 int setconsole_main(int argc, char **argv); 28 22 int setconsole_main(int argc, char **argv) 29 23 { … … 32 26 33 27 #if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS 34 bb_applet_long_options = setconsole_long_options;28 applet_long_options = setconsole_longopts; 35 29 #endif 36 flags = bb_getopt_ulflags(argc,argv, "r");30 flags = getopt32(argv, "r"); 37 31 38 32 if (argc - optind > 1) … … 45 39 } else { 46 40 if (flags & OPT_SETCONS_RESET) 47 device = CONSOLE_DEV;41 device = DEV_CONSOLE; 48 42 } 49 43 50 if (-1 == ioctl(bb_xopen(device, O_RDONLY), TIOCCONS)) { 51 bb_perror_msg_and_die("TIOCCONS"); 52 } 44 xioctl(xopen(device, O_RDONLY), TIOCCONS, NULL); 53 45 return EXIT_SUCCESS; 54 46 } -
branches/stable/mindi-busybox/console-tools/setkeycodes.c
r821 r1770 7 7 * Adjusted for BusyBox by Erik Andersen <andersen@codepoet.org> 8 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * 9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 23 10 */ 24 11 25 #include <stdio.h> 26 #include <stdlib.h> 27 #include <fcntl.h> 28 #include <sys/ioctl.h> 29 #include "busybox.h" 30 12 //#include <sys/ioctl.h> 13 #include "libbb.h" 31 14 32 15 /* From <linux/kd.h> */ … … 38 21 }; 39 22 40 extern int 41 setkeycodes_main(int argc, char** argv)23 int setkeycodes_main(int argc, char** argv); 24 int setkeycodes_main(int argc, char** argv) 42 25 { 43 char *ep; 44 int fd, sc; 45 struct kbkeycode a; 26 int fd, sc; 27 struct kbkeycode a; 46 28 47 48 29 if (argc % 2 != 1 || argc < 2) { 30 bb_show_usage(); 49 31 } 50 32 51 33 fd = get_console_fd(); 52 34 53 while (argc > 2) { 54 a.keycode = atoi(argv[2]); 55 a.scancode = sc = strtol(argv[1], &ep, 16); 56 if (*ep) { 57 bb_error_msg_and_die("error reading SCANCODE: '%s'", argv[1]); 35 while (argc > 2) { 36 a.keycode = xatoul_range(argv[2], 0, 127); 37 a.scancode = sc = xstrtoul_range(argv[1], 16, 0, 255); 38 if (a.scancode > 127) { 39 a.scancode -= 0xe000; 40 a.scancode += 128; 41 } 42 ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a, 43 "failed to set SCANCODE %x to KEYCODE %d", 44 sc, a.keycode); 45 argc -= 2; 46 argv += 2; 58 47 } 59 if (a.scancode > 127) {60 a.scancode -= 0xe000;61 a.scancode += 128;62 }63 if (a.scancode > 255 || a.keycode > 127) {64 bb_error_msg_and_die("SCANCODE or KEYCODE outside bounds");65 }66 if (ioctl(fd,KDSETKEYCODE,&a)) {67 perror("KDSETKEYCODE");68 bb_error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);69 }70 argc -= 2;71 argv += 2;72 }73 48 return EXIT_SUCCESS; 74 49 } -
branches/stable/mindi-busybox/console-tools/setlogcons.c
r821 r1770 1 /* vi: set sw=4 ts=4: */ 1 2 /* 2 * setlogcons: Send kernel messages to the current console or to console N 3 * setlogcons: Send kernel messages to the current console or to console N 3 4 * 4 5 * Copyright (C) 2006 by Jan Kiszka <jan.kiszka@web.de> … … 9 10 */ 10 11 11 #include <stdio.h> 12 #include <stdlib.h> 13 #include <fcntl.h> 14 #include <sys/ioctl.h> 15 #include "busybox.h" 12 #include "libbb.h" 16 13 17 extern int setlogcons_main(int argc, char **argv) 14 int setlogcons_main(int argc, char **argv); 15 int setlogcons_main(int argc, char **argv) 18 16 { 19 17 struct { … … 26 24 27 25 if (argc == 2) 28 arg.subarg = atoi(argv[1]);26 arg.subarg = xatoul_range(argv[1], 0, 63); 29 27 30 if (ioctl(bb_xopen(VC_1, O_RDONLY), TIOCLINUX, &arg)) 31 bb_perror_msg_and_die("TIOCLINUX");; 28 xioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg); 32 29 33 30 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.