Changeset 1765 in MondoRescue for branches/2.2.5/mindi-busybox/console-tools


Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (16 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

Location:
branches/2.2.5/mindi-busybox/console-tools
Files:
2 added
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/console-tools/Config.in

    r821 r1765  
    66menu "Console Utilities"
    77
    8 config CONFIG_CHVT
     8config CHVT
    99    bool "chvt"
    1010    default n
     
    1313      Example: chvt 4 (change to terminal /dev/tty4)
    1414
    15 config CONFIG_CLEAR
     15config CLEAR
    1616    bool "clear"
    1717    default n
     
    1919      This program clears the terminal screen.
    2020
    21 config CONFIG_DEALLOCVT
     21config DEALLOCVT
    2222    bool "deallocvt"
    2323    default n
     
    2525      This program deallocates unused virtual consoles.
    2626
    27 config CONFIG_DUMPKMAP
     27config DUMPKMAP
    2828    bool "dumpkmap"
    2929    default n
     
    3232      stdout, in binary format. You can then use loadkmap to load it.
    3333
    34 config CONFIG_LOADFONT
     34config LOADFONT
    3535    bool "loadfont"
    3636    default n
     
    3838      This program loads a console font from standard input.
    3939
    40 config CONFIG_LOADKMAP
     40config LOADKMAP
    4141    bool "loadkmap"
    4242    default n
     
    4545      standard input.
    4646
    47 config CONFIG_OPENVT
     47config OPENVT
    4848    bool "openvt"
    4949    default n
     
    5252      virtual terminal.
    5353
    54 config CONFIG_RESET
     54config RESET
    5555    bool "reset"
    5656    default n
     
    5959      gets messed up.
    6060
    61 config CONFIG_SETCONSOLE
     61config 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
     68config 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
     78config SETCONSOLE
    6279    bool "setconsole"
    6380    default n
     
    6683      like the current tty while logged in via telnet.
    6784
    68 config CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS
     85config FEATURE_SETCONSOLE_LONG_OPTIONS
    6986    bool "Enable long options"
    7087    default n
    71     depends on CONFIG_SET_CONSOLE && CONFIG_GETOPT_LONG
     88    depends on SETCONSOLE && GETOPT_LONG
    7289    help
    7390      Support long options for the setconsole applet.
    7491
    75 config CONFIG_SETKEYCODES
     92config SETKEYCODES
    7693    bool "setkeycodes"
    7794    default n
     
    8097      map, allowing unusual keyboards to generate usable keycodes.
    8198
    82 config CONFIG_SETLOGCONS
     99config SETLOGCONS
    83100    bool "setlogcons"
    84101    default n
  • branches/2.2.5/mindi-busybox/console-tools/chvt.c

    r821 r1765  
    88 */
    99
    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"
    1611
    1712/* From <linux/vt.h> */
     
    2116};
    2217
     18int chvt_main(int argc, char **argv);
    2319int chvt_main(int argc, char **argv)
    2420{
     
    3026
    3127    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);
    3732    return EXIT_SUCCESS;
    3833}
  • branches/2.2.5/mindi-busybox/console-tools/clear.c

    r821 r1765  
    55 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
    66 *
    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.
    208 *
    219 */
     
    2311/* no options, no getopt */
    2412
    25 #include <stdio.h>
    26 #include <stdlib.h>
    27 #include "busybox.h"
     13#include "libbb.h"
    2814
    29 
     15int clear_main(int argc, char **argv);
    3016int clear_main(int argc, char **argv)
    3117{
  • branches/2.2.5/mindi-busybox/console-tools/deallocvt.c

    r821 r1765  
    66 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
    77 *
    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.
    219 */
    2210
    2311/* no options, no getopt */
    2412
    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"
    3114
    3215/* From <linux/vt.h> */
    3316enum { VT_DISALLOCATE = 0x5608 }; /* free memory associated to vt */
    3417
    35 int deallocvt_main(int argc, char *argv[])
     18int deallocvt_main(int argc, char **argv);
     19int deallocvt_main(int argc, char **argv)
    3620{
    3721    /* num = 0 deallocate all unused consoles */
     
    3923
    4024    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);
    4527        /* Fallthrough */
    46         case 1:
    47             break;
    48         default:
    49             bb_show_usage();
     28    case 1:
     29        break;
     30    default:
     31        bb_show_usage();
    5032    }
    5133
    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);
    5536    return EXIT_SUCCESS;
    5637}
  • branches/2.2.5/mindi-busybox/console-tools/dumpkmap.c

    r821 r1765  
    55 * Copyright (C) Arne Bernin <arne@matrix.loopback.org>
    66 *
    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.
    208 *
    219 */
    2210
    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"
    3112
    3213/* From <linux/kd.h> */
     
    4223#define MAX_NR_KEYMAPS 256
    4324
     25int dumpkmap_main(int argc, char **argv);
    4426int dumpkmap_main(int argc, char **argv)
    4527{
    4628    struct kbentry ke;
    4729    int i, j, fd;
    48     char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
     30    char flags[MAX_NR_KEYMAPS];
    4931
    50     if (argc >= 2 && *argv[1] == '-')
     32    if (argc >= 2 && argv[1][0] == '-')
    5133        bb_show_usage();
    5234
    53     fd = bb_xopen(CURRENT_VC, O_RDWR);
     35    fd = xopen(CURRENT_VC, O_RDWR);
    5436
    55     write(1, magic, 7);
     37    write(1, "bkeymap", 7);
    5638
    5739    /* Here we want to set everything to 0 except for indexes:
     
    6951                ke.kb_index = j;
    7052                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",
    7355                        (char *)&ke.kb_index,
    7456                        (char *)&ke.kb_table,
    75                         &ke.kb_value);
    76                 } else {
     57                        &ke.kb_value)
     58                ) {
    7759                    write(1, (void*)&ke.kb_value, 2);
    7860                }
  • branches/2.2.5/mindi-busybox/console-tools/loadfont.c

    r821 r1765  
    88 * (Adapted for busybox by Matej Vela.)
    99 */
    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"
    1911#include <sys/kd.h>
    20 #include <endian.h>
    21 #include "busybox.h"
    2212
    23 enum{
     13enum {
    2414    PSF_MAGIC1 = 0x36,
    2515    PSF_MAGIC2 = 0x04,
     
    3222
    3323struct psf_header {
    34     unsigned char magic1, magic2;   /* Magic number */
    35     unsigned char mode;         /* PSF font mode */
    36     unsigned char charsize;     /* Character size */
     24    unsigned char magic1, magic2;   /* Magic number */
     25    unsigned char mode;             /* PSF font mode */
     26    unsigned char charsize;         /* Character size */
    3727};
    3828
    3929#define PSF_MAGIC_OK(x) ((x).magic1 == PSF_MAGIC1 && (x).magic2 == PSF_MAGIC2)
    4030
    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 
    5631static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
    5732{
    58     char buf[16384];
     33    char *buf;
    5934    int i;
    6035
    61     memset(buf, 0, sizeof(buf));
     36    if (unit < 1 || unit > 32)
     37        bb_error_msg_and_die("bad character size %d", unit);
    6238
    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);*/
    6641    for (i = 0; i < fontsize; i++)
    6742        memcpy(buf + (32 * i), inbuf + (unit * i), unit);
    6843
    69 #if defined( PIO_FONTX ) && !defined( __sparc__ )
     44#if defined(PIO_FONTX) && !defined(__sparc__)
    7045    {
    7146        struct consolefontdesc cfd;
     
    7550        cfd.chardata = buf;
    7651
    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 */
    8054    }
    8155#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);
    8459}
    8560
     
    9267    int ct = 0, maxct;
    9368    int glyph;
    94     u_short unicode;
     69    uint16_t unicode;
    9570
    9671    maxct = tailsz;             /* more than enough */
    97     up = (struct unipair *) xmalloc(maxct * sizeof(struct unipair));
     72    up = xmalloc(maxct * sizeof(struct unipair));
    9873
    9974    for (glyph = 0; glyph < fontsize; glyph++) {
    10075        while (tailsz >= 2) {
    101             unicode = (((u_short) inbuf[1]) << 8) + inbuf[0];
     76            unicode = (((uint16_t) inbuf[1]) << 8) + inbuf[0];
    10277            tailsz -= 2;
    10378            inbuf += 2;
     
    11691    advice.advised_hashstep = 0;
    11792    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);
    12794    ud.entry_ct = ct;
    12895    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);
    13797}
    13898
    13999static void loadnewfont(int fd)
    140100{
     101    enum { INBUF_SIZE = 32*1024 + 1 };
     102
    141103    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);
    144107
    145108    /*
     
    148111     * just read the entire file.
    149112     */
    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");
    159118
    160119    /* test for psf first */
     
    163122        int fontsize;
    164123        int hastable;
    165         unsigned int head0, head;
     124        unsigned head0, head;
    166125
    167126        if (inputlth < sizeof(struct psf_header))
     
    174133
    175134        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");
    177136        fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
    178 #if !defined( PIO_FONTX ) || defined( __sparc__ )
     137#if !defined(PIO_FONTX) || defined(__sparc__)
    179138        if (fontsize != 256)
    180             bb_error_msg_and_die("Only fontsize 256 supported");
     139            bb_error_msg_and_die("only fontsize 256 supported");
    181140#endif
    182141        hastable = (psfhdr.mode & PSF_MODEHASTAB);
     
    186145        head = head0 + fontsize * unit;
    187146        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");
    189148        do_loadfont(fd, inbuf + head0, unit, fontsize);
    190149        if (hastable)
     
    192151        return;
    193152    }
    194   no_psf:
    195153
     154 no_psf:
    196155    /* file with three code pages? */
    197156    if (inputlth == 9780) {
     
    201160        /* bare font */
    202161        if (inputlth & 0377)
    203             bb_error_msg_and_die("Bad input file size");
     162            bb_error_msg_and_die("bad input file size");
    204163        offset = 0;
    205164        unit = inputlth / 256;
     
    207166    do_loadfont(fd, inbuf + offset, unit, 256);
    208167}
     168
     169int loadfont_main(int argc, char **argv);
     170int 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/2.2.5/mindi-busybox/console-tools/loadkmap.c

    r821 r1765  
    55 * Copyright (C) 1998 Enrique Zanardi <ezanardi@ull.es>
    66 *
    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.
    208 *
    219 */
    2210
    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"
    3112
    3213#define BINARY_KEYMAP_MAGIC "bkeymap"
     
    4526#define MAX_NR_KEYMAPS  256
    4627
     28int loadkmap_main(int argc, char **argv);
    4729int loadkmap_main(int argc, char **argv)
    4830{
    4931    struct kbentry ke;
    5032    int i, j, fd;
    51     u_short ibuff[NR_KEYS];
     33    uint16_t ibuff[NR_KEYS];
    5234    char flags[MAX_NR_KEYMAPS];
    5335    char buff[7];
     
    5638        bb_show_usage();
    5739
    58     fd = bb_xopen(CURRENT_VC, O_RDWR);
     40    fd = xopen(CURRENT_VC, O_RDWR);
    5941
    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");
    6245
    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);
    6547
    6648    for (i = 0; i < MAX_NR_KEYMAPS; i++) {
    6749        if (flags[i] == 1) {
    68             bb_full_read(0, ibuff, NR_KEYS * sizeof(u_short));
     50            xread(0, ibuff, NR_KEYS * sizeof(uint16_t));
    6951            for (j = 0; j < NR_KEYS; j++) {
    7052                ke.kb_index = j;
     
    7658    }
    7759
    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;
    8262}
  • branches/2.2.5/mindi-busybox/console-tools/openvt.c

    r821 r1765  
    1111/* getopt not needed */
    1212
    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"
    2014
    21 #include "busybox.h"
    22 
     15int openvt_main(int argc, char **argv);
    2316int openvt_main(int argc, char **argv)
    2417{
    25     int fd;
    2618    char vtname[sizeof(VC_FORMAT) + 2];
    2719
     20    if (argc < 3)
     21        bb_show_usage();
    2822
    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));
    3425
    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);
    4132
    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);
    5335}
  • branches/2.2.5/mindi-busybox/console-tools/reset.c

    r821 r1765  
    66 * Written by Erik Andersen and Kent Robotti <robotti@metconnect.com>
    77 *
    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.
    229 */
    2310
    2411/* no options, no getopt */
    2512
    26 #include <stdio.h>
    27 #include <stdlib.h>
    28 #include <unistd.h>
    29 #include "busybox.h"
     13#include "libbb.h"
    3014
     15int reset_main(int argc, char **argv);
    3116int reset_main(int argc, char **argv)
    3217{
  • branches/2.2.5/mindi-busybox/console-tools/setconsole.c

    r821 r1765  
    88 */
    99
    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"
    1812
    1913#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 };
     14static const char setconsole_longopts[] ALIGN1 =
     15    "reset\0" No_argument "r"
     16    ;
    2417#endif
    2518
    2619#define OPT_SETCONS_RESET 1
    2720
     21int setconsole_main(int argc, char **argv);
    2822int setconsole_main(int argc, char **argv)
    2923{
     
    3226
    3327#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
    34     bb_applet_long_options = setconsole_long_options;
     28    applet_long_options = setconsole_longopts;
    3529#endif
    36     flags = bb_getopt_ulflags(argc, argv, "r");
     30    flags = getopt32(argv, "r");
    3731
    3832    if (argc - optind > 1)
     
    4539    } else {
    4640        if (flags & OPT_SETCONS_RESET)
    47             device = CONSOLE_DEV;
     41            device = DEV_CONSOLE;
    4842    }
    4943
    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);
    5345    return EXIT_SUCCESS;
    5446}
  • branches/2.2.5/mindi-busybox/console-tools/setkeycodes.c

    r821 r1765  
    77 * Adjusted for BusyBox by Erik Andersen <andersen@codepoet.org>
    88 *
    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.
    2310 */
    2411
    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"
    3114
    3215/* From <linux/kd.h> */
     
    3821};
    3922
    40 extern int
    41 setkeycodes_main(int argc, char** argv)
     23int setkeycodes_main(int argc, char** argv);
     24int setkeycodes_main(int argc, char** argv)
    4225{
    43     char *ep;
    44     int fd, sc;
    45     struct kbkeycode a;
     26    int fd, sc;
     27    struct kbkeycode a;
    4628
    47     if (argc % 2 != 1 || argc < 2) {
    48       bb_show_usage();
     29    if (argc % 2 != 1 || argc < 2) {
     30        bb_show_usage();
    4931    }
    5032
    5133    fd = get_console_fd();
    5234
    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;
    5847    }
    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     }
    7348    return EXIT_SUCCESS;
    7449}
  • branches/2.2.5/mindi-busybox/console-tools/setlogcons.c

    r821 r1765  
     1/* vi: set sw=4 ts=4: */
    12/*
    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
    34 *
    45 * Copyright (C) 2006 by Jan Kiszka <jan.kiszka@web.de>
     
    910 */
    1011
    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"
    1613
    17 extern int setlogcons_main(int argc, char **argv)
     14int setlogcons_main(int argc, char **argv);
     15int setlogcons_main(int argc, char **argv)
    1816{
    1917    struct {
     
    2624
    2725    if (argc == 2)
    28         arg.subarg = atoi(argv[1]);
     26        arg.subarg = xatoul_range(argv[1], 0, 63);
    2927
    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);
    3229
    3330    return 0;
Note: See TracChangeset for help on using the changeset viewer.