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

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/miscutils/makedevs.c

    r821 r1765  
    88 */
    99
    10 #include "busybox.h"
    11 #include <stdio.h>
    12 #include <stdlib.h>
    13 #include <string.h>
    14 #include <fcntl.h>
    15 #include <time.h>
    16 #include <ctype.h>
    17 #include <unistd.h>
    18 #include <sys/types.h>
    19 #include <sys/sysmacros.h>     /* major() and minor() */
    20 
    21 #ifdef CONFIG_FEATURE_MAKEDEVS_LEAF
     10#include "libbb.h"
     11
     12#if ENABLE_FEATURE_MAKEDEVS_LEAF
     13int makedevs_main(int argc, char **argv);
    2214int makedevs_main(int argc, char **argv)
    2315{
     
    3123    basedev = argv[1];
    3224    type = argv[2];
    33     Smajor = atoi(argv[3]);
    34     Sminor = atoi(argv[4]);
    35     S = atoi(argv[5]);
    36     E = atoi(argv[6]);
     25    Smajor = xatoi_u(argv[3]);
     26    Sminor = xatoi_u(argv[4]);
     27    S = xatoi_u(argv[5]);
     28    E = xatoi_u(argv[6]);
    3729    nodname = argc == 8 ? basedev : buf;
    3830
     
    5749
    5850        sz = snprintf(buf, sizeof(buf), "%s%d", basedev, S);
    59         if(sz<0 || sz>=sizeof(buf))  /* libc different */
     51        if (sz < 0 || sz >= sizeof(buf))  /* libc different */
    6052            bb_error_msg_and_die("%s too large", basedev);
    6153
     
    6355
    6456        if (mknod(nodname, mode, makedev(Smajor, Sminor)))
    65             bb_error_msg("Failed to create: %s", nodname);
     57            bb_error_msg("failed to create: %s", nodname);
    6658
    6759        if (nodname == basedev) /* ex. /dev/hda - to /dev/hda1 ... */
     
    7466}
    7567
    76 #elif defined CONFIG_FEATURE_MAKEDEVS_TABLE
     68#elif ENABLE_FEATURE_MAKEDEVS_TABLE
    7769
    7870/* Licensed under the GPL v2 or later, see the file LICENSE in this tarball. */
    7971
     72int makedevs_main(int argc, char **argv);
    8073int makedevs_main(int argc, char **argv)
    8174{
     
    8679    int ret = EXIT_SUCCESS;
    8780
    88     unsigned long flags;
    89     flags = bb_getopt_ulflags(argc, argv, "d:", &line);
     81    getopt32(argv, "d:", &line);
    9082    if (line)
    91         table = bb_xfopen(line, "r");
     83        table = xfopen(line, "r");
    9284
    9385    if (optind >= argc || (rootdir=argv[optind])==NULL) {
     
    9587    }
    9688
    97     bb_xchdir(rootdir);
     89    xchdir(rootdir);
    9890
    9991    umask(0);
     
    10698    }
    10799
    108     while ((line = bb_get_chomped_line_from_file(table))) {
     100    while ((line = xmalloc_getline(table))) {
    109101        char type;
    110102        unsigned int mode = 0755;
     
    130122            if (*line=='\0' || *line=='#' || isspace(*line))
    131123                continue;
    132             bb_error_msg("line %d invalid: '%s'\n", linenum, line);
     124            bb_error_msg("line %d invalid: '%s'", linenum, line);
    133125            ret = EXIT_FAILURE;
    134126            continue;
     
    138130        }
    139131
    140         gid = (*group) ? get_ug_id(group, bb_xgetgrnam) : getgid();
    141         uid = (*user) ? get_ug_id(user, bb_xgetpwnam) : getuid();
     132        gid = (*group) ? get_ug_id(group, xgroup2gid) : getgid();
     133        uid = (*user) ? get_ug_id(user, xuname2uid) : getuid();
    142134        full_name = concat_path_file(rootdir, name);
    143135
     
    171163                goto loop;
    172164            }
    173         } else
    174         {
     165        } else {
    175166            dev_t rdev;
    176167
     
    196187                for (i = start; i < count; i++) {
    197188                    sprintf(full_name_inc, "%s%d", full_name, i);
    198                     rdev = (major << 8) + minor + (i * increment - start);
     189                    rdev = makedev(major, minor + (i * increment - start));
    199190                    if (mknod(full_name_inc, mode, rdev) == -1) {
    200                         bb_perror_msg("line %d: could not create node %s", linenum, full_name_inc);
     191                        bb_perror_msg("line %d: cannot create node %s", linenum, full_name_inc);
    201192                        ret = EXIT_FAILURE;
    202193                    }
     
    212203                free(full_name_inc);
    213204            } else {
    214                 rdev = (major << 8) + minor;
     205                rdev = makedev(major, minor);
    215206                if (mknod(full_name, mode, rdev) == -1) {
    216                     bb_perror_msg("line %d: could not create node %s", linenum, full_name);
     207                    bb_perror_msg("line %d: cannot create node %s", linenum, full_name);
    217208                    ret = EXIT_FAILURE;
    218209                }
Note: See TracChangeset for help on using the changeset viewer.