source: clfs-embedded/patches/busybox-1.15.0-branch_update-1.patch @ 2e856a4

Last change on this file since 2e856a4 was 2e856a4, checked in by Maarten Lankhorst <mlankhorst@…>, 15 years ago

bump busybox to 1.15

  • Property mode set to 100644
File size: 15.5 KB
  • archival/Config.in

    diff -ru busybox-1.15.0-ori/archival/Config.in busybox-1.15.0/archival/Config.in
    old new  
    298298        default n
    299299        depends on UNLZMA
    300300        help
    301           This option reduces decompression time by about 25% at the cost of
    302           a 1K bigger binary.
     301          This option reduces decompression time by about 33% at the cost of
     302          a 2K bigger binary.
    303303
    304304config UNZIP
    305305        bool "unzip"
  • archival/libunarchive/data_extract_all.c

    diff -ru busybox-1.15.0-ori/archival/libunarchive/data_extract_all.c busybox-1.15.0/archival/libunarchive/data_extract_all.c
    old new  
    132132#endif
    133133                        lchown(file_header->name, file_header->uid, file_header->gid);
    134134        }
    135         if (S_ISLNK(file_header->mode)) {
     135        if (!S_ISLNK(file_header->mode)) {
    136136                /* uclibc has no lchmod, glibc is even stranger -
    137137                 * it has lchmod which seems to do nothing!
    138138                 * so we use chmod... */
  • archival/libunarchive/decompress_unlzma.c

    diff -ru busybox-1.15.0-ori/archival/libunarchive/decompress_unlzma.c busybox-1.15.0/archival/libunarchive/decompress_unlzma.c
    old new  
    88 *
    99 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
    1010 */
     11
    1112#include "libbb.h"
    1213#include "unarchive.h"
    1314
    1415#if ENABLE_FEATURE_LZMA_FAST
    1516#  define speed_inline ALWAYS_INLINE
    16 #  define size_inline
    1717#else
    1818#  define speed_inline
    19 #  define size_inline ALWAYS_INLINE
    2019#endif
    2120
    2221
     
    4544#define RC_MODEL_TOTAL_BITS 11
    4645
    4746
    48 /* Called twice: once at startup (LZMA_FAST only) and once in rc_normalize() */
    49 static size_inline void rc_read(rc_t *rc)
     47/* Called twice: once at startup and once in rc_normalize() */
     48static void rc_read(rc_t *rc)
    5049{
    5150        int buffer_size = safe_read(rc->fd, RC_BUFFER, RC_BUFFER_SIZE);
    5251        if (buffer_size <= 0)
     
    5554        rc->buffer_end = RC_BUFFER + buffer_size;
    5655}
    5756
    58 /* Called twice, but one callsite is in speed_inline'd rc_is_bit_1() */
    59 static void rc_do_normalize(rc_t *rc)
    60 {
    61         if (rc->ptr >= rc->buffer_end)
    62                 rc_read(rc);
    63         rc->range <<= 8;
    64         rc->code = (rc->code << 8) | *rc->ptr++;
    65 }
    66 
    6757/* Called once */
    68 static ALWAYS_INLINE rc_t* rc_init(int fd) /*, int buffer_size) */
     58static rc_t* rc_init(int fd) /*, int buffer_size) */
    6959{
    7060        int i;
    7161        rc_t *rc;
     
    7363        rc = xmalloc(sizeof(*rc) + RC_BUFFER_SIZE);
    7464
    7565        rc->fd = fd;
     66        /* rc->buffer_size = buffer_size; */
     67        rc->buffer_end = RC_BUFFER + RC_BUFFER_SIZE;
    7668        rc->ptr = rc->buffer_end;
    7769
     70        rc->code = 0;
     71        rc->range = 0xFFFFFFFF;
    7872        for (i = 0; i < 5; i++) {
    79 #if ENABLE_FEATURE_LZMA_FAST
    8073                if (rc->ptr >= rc->buffer_end)
    8174                        rc_read(rc);
    8275                rc->code = (rc->code << 8) | *rc->ptr++;
    83 #else
    84                 rc_do_normalize(rc);
    85 #endif
    8676        }
    87         rc->range = 0xFFFFFFFF;
    8877        return rc;
    8978}
    9079
     
    9483        free(rc);
    9584}
    9685
     86/* Called twice, but one callsite is in speed_inline'd rc_is_bit_0_helper() */
     87static void rc_do_normalize(rc_t *rc)
     88{
     89        if (rc->ptr >= rc->buffer_end)
     90                rc_read(rc);
     91        rc->range <<= 8;
     92        rc->code = (rc->code << 8) | *rc->ptr++;
     93}
    9794static ALWAYS_INLINE void rc_normalize(rc_t *rc)
    9895{
    9996        if (rc->range < (1 << RC_TOP_BITS)) {
     
    10198        }
    10299}
    103100
    104 /* rc_is_bit_1 is called 9 times */
    105 static speed_inline int rc_is_bit_1(rc_t *rc, uint16_t *p)
     101/* rc_is_bit_0 is called 9 times */
     102/* Why rc_is_bit_0_helper exists?
     103 * Because we want to always expose (rc->code < rc->bound) to optimizer.
     104 * Thus rc_is_bit_0 is always inlined, and rc_is_bit_0_helper is inlined
     105 * only if we compile for speed.
     106 */
     107static speed_inline uint32_t rc_is_bit_0_helper(rc_t *rc, uint16_t *p)
    106108{
    107109        rc_normalize(rc);
    108110        rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
    109         if (rc->code < rc->bound) {
    110                 rc->range = rc->bound;
    111                 *p += ((1 << RC_MODEL_TOTAL_BITS) - *p) >> RC_MOVE_BITS;
    112                 return 0;
    113         }
     111        return rc->bound;
     112}
     113static ALWAYS_INLINE int rc_is_bit_0(rc_t *rc, uint16_t *p)
     114{
     115        uint32_t t = rc_is_bit_0_helper(rc, p);
     116        return rc->code < t;
     117}
     118
     119/* Called ~10 times, but very small, thus inlined */
     120static speed_inline void rc_update_bit_0(rc_t *rc, uint16_t *p)
     121{
     122        rc->range = rc->bound;
     123        *p += ((1 << RC_MODEL_TOTAL_BITS) - *p) >> RC_MOVE_BITS;
     124}
     125static speed_inline void rc_update_bit_1(rc_t *rc, uint16_t *p)
     126{
    114127        rc->range -= rc->bound;
    115128        rc->code -= rc->bound;
    116129        *p -= *p >> RC_MOVE_BITS;
    117         return 1;
    118130}
    119131
    120132/* Called 4 times in unlzma loop */
    121 static speed_inline int rc_get_bit(rc_t *rc, uint16_t *p, int *symbol)
     133static int rc_get_bit(rc_t *rc, uint16_t *p, int *symbol)
    122134{
    123         int ret = rc_is_bit_1(rc, p);
    124         *symbol = *symbol * 2 + ret;
    125         return ret;
     135        if (rc_is_bit_0(rc, p)) {
     136                rc_update_bit_0(rc, p);
     137                *symbol *= 2;
     138                return 0;
     139        } else {
     140                rc_update_bit_1(rc, p);
     141                *symbol = *symbol * 2 + 1;
     142                return 1;
     143        }
    126144}
    127145
    128146/* Called once */
     
    248266        header.dst_size = SWAP_LE64(header.dst_size);
    249267
    250268        if (header.dict_size == 0)
    251                 header.dict_size++;
     269                header.dict_size = 1;
    252270
    253271        buffer = xmalloc(MIN(header.dst_size, header.dict_size));
    254272
    255273        num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp));
    256274        p = xmalloc(num_probs * sizeof(*p));
    257         num_probs += LZMA_LITERAL - LZMA_BASE_SIZE;
     275        num_probs = LZMA_LITERAL + (LZMA_LIT_SIZE << (lc + lp));
    258276        for (i = 0; i < num_probs; i++)
    259277                p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1;
    260278
     
    264282                int pos_state = (buffer_pos + global_pos) & pos_state_mask;
    265283
    266284                prob = p + LZMA_IS_MATCH + (state << LZMA_NUM_POS_BITS_MAX) + pos_state;
    267                 if (!rc_is_bit_1(rc, prob)) {
     285                if (rc_is_bit_0(rc, prob)) {
    268286                        mi = 1;
     287                        rc_update_bit_0(rc, prob);
    269288                        prob = (p + LZMA_LITERAL
    270289                                + (LZMA_LIT_SIZE * ((((buffer_pos + global_pos) & literal_pos_mask) << lc)
    271290                                                    + (previous_byte >> (8 - lc))
     
    321340                        int offset;
    322341                        uint16_t *prob_len;
    323342
     343                        rc_update_bit_1(rc, prob);
    324344                        prob = p + LZMA_IS_REP + state;
    325                         if (!rc_is_bit_1(rc, prob)) {
     345                        if (rc_is_bit_0(rc, prob)) {
     346                                rc_update_bit_0(rc, prob);
    326347                                rep3 = rep2;
    327348                                rep2 = rep1;
    328349                                rep1 = rep0;
    329350                                state = state < LZMA_NUM_LIT_STATES ? 0 : 3;
    330351                                prob = p + LZMA_LEN_CODER;
    331352                        } else {
    332                                 prob += LZMA_IS_REP_G0 - LZMA_IS_REP;
    333                                 if (!rc_is_bit_1(rc, prob)) {
     353                                rc_update_bit_1(rc, prob);
     354                                prob = p + LZMA_IS_REP_G0 + state;
     355                                if (rc_is_bit_0(rc, prob)) {
     356                                        rc_update_bit_0(rc, prob);
    334357                                        prob = (p + LZMA_IS_REP_0_LONG
    335358                                                + (state << LZMA_NUM_POS_BITS_MAX)
    336359                                                + pos_state
    337360                                        );
    338                                         if (!rc_is_bit_1(rc, prob)) {
     361                                        if (rc_is_bit_0(rc, prob)) {
     362                                                rc_update_bit_0(rc, prob);
     363
    339364                                                state = state < LZMA_NUM_LIT_STATES ? 9 : 11;
    340365#if ENABLE_FEATURE_LZMA_FAST
    341366                                                pos = buffer_pos - rep0;
     
    347372                                                len = 1;
    348373                                                goto string;
    349374#endif
     375                                        } else {
     376                                                rc_update_bit_1(rc, prob);
    350377                                        }
    351378                                } else {
    352379                                        uint32_t distance;
    353380
    354                                         prob += LZMA_IS_REP_G1 - LZMA_IS_REP_G0;
    355                                         distance = rep1;
    356                                         if (rc_is_bit_1(rc, prob)) {
    357                                                 prob += LZMA_IS_REP_G2 - LZMA_IS_REP_G1;
    358                                                 distance = rep2;
    359                                                 if (rc_is_bit_1(rc, prob)) {
     381                                        rc_update_bit_1(rc, prob);
     382                                        prob = p + LZMA_IS_REP_G1 + state;
     383                                        if (rc_is_bit_0(rc, prob)) {
     384                                                rc_update_bit_0(rc, prob);
     385                                                distance = rep1;
     386                                        } else {
     387                                                rc_update_bit_1(rc, prob);
     388                                                prob = p + LZMA_IS_REP_G2 + state;
     389                                                if (rc_is_bit_0(rc, prob)) {
     390                                                        rc_update_bit_0(rc, prob);
     391                                                        distance = rep2;
     392                                                } else {
     393                                                        rc_update_bit_1(rc, prob);
    360394                                                        distance = rep3;
    361395                                                        rep3 = rep2;
    362396                                                }
     
    370404                        }
    371405
    372406                        prob_len = prob + LZMA_LEN_CHOICE;
    373                         if (!rc_is_bit_1(rc, prob_len)) {
    374                                 prob_len += LZMA_LEN_LOW - LZMA_LEN_CHOICE
    375                                             + (pos_state << LZMA_LEN_NUM_LOW_BITS);
     407                        if (rc_is_bit_0(rc, prob_len)) {
     408                                rc_update_bit_0(rc, prob_len);
     409                                prob_len = (prob + LZMA_LEN_LOW
     410                                            + (pos_state << LZMA_LEN_NUM_LOW_BITS));
    376411                                offset = 0;
    377412                                num_bits = LZMA_LEN_NUM_LOW_BITS;
    378413                        } else {
    379                                 prob_len += LZMA_LEN_CHOICE_2 - LZMA_LEN_CHOICE;
    380                                 if (!rc_is_bit_1(rc, prob_len)) {
    381                                         prob_len += LZMA_LEN_MID - LZMA_LEN_CHOICE_2
    382                                                     + (pos_state << LZMA_LEN_NUM_MID_BITS);
     414                                rc_update_bit_1(rc, prob_len);
     415                                prob_len = prob + LZMA_LEN_CHOICE_2;
     416                                if (rc_is_bit_0(rc, prob_len)) {
     417                                        rc_update_bit_0(rc, prob_len);
     418                                        prob_len = (prob + LZMA_LEN_MID
     419                                                    + (pos_state << LZMA_LEN_NUM_MID_BITS));
    383420                                        offset = 1 << LZMA_LEN_NUM_LOW_BITS;
    384421                                        num_bits = LZMA_LEN_NUM_MID_BITS;
    385422                                } else {
    386                                         prob_len += LZMA_LEN_HIGH - LZMA_LEN_CHOICE_2;
     423                                        rc_update_bit_1(rc, prob_len);
     424                                        prob_len = prob + LZMA_LEN_HIGH;
    387425                                        offset = ((1 << LZMA_LEN_NUM_LOW_BITS)
    388426                                                  + (1 << LZMA_LEN_NUM_MID_BITS));
    389427                                        num_bits = LZMA_LEN_NUM_HIGH_BITS;
     
    400438                                       ((len < LZMA_NUM_LEN_TO_POS_STATES ? len :
    401439                                         LZMA_NUM_LEN_TO_POS_STATES - 1)
    402440                                         << LZMA_NUM_POS_SLOT_BITS);
    403                                 rc_bit_tree_decode(rc, prob,
    404                                         LZMA_NUM_POS_SLOT_BITS, &pos_slot);
    405                                 rep0 = pos_slot;
     441                                rc_bit_tree_decode(rc, prob, LZMA_NUM_POS_SLOT_BITS,
     442                                                                   &pos_slot);
    406443                                if (pos_slot >= LZMA_START_POS_MODEL_INDEX) {
    407444                                        num_bits = (pos_slot >> 1) - 1;
    408445                                        rep0 = 2 | (pos_slot & 1);
    409                                         prob = p + LZMA_ALIGN;
    410446                                        if (pos_slot < LZMA_END_POS_MODEL_INDEX) {
    411447                                                rep0 <<= num_bits;
    412                                                 prob += LZMA_SPEC_POS - LZMA_ALIGN - 1 + rep0 - pos_slot;
     448                                                prob = p + LZMA_SPEC_POS + rep0 - pos_slot - 1;
    413449                                        } else {
    414450                                                num_bits -= LZMA_NUM_ALIGN_BITS;
    415451                                                while (num_bits--)
    416452                                                        rep0 = (rep0 << 1) | rc_direct_bit(rc);
     453                                                prob = p + LZMA_ALIGN;
    417454                                                rep0 <<= LZMA_NUM_ALIGN_BITS;
    418455                                                num_bits = LZMA_NUM_ALIGN_BITS;
    419456                                        }
     
    424461                                                        rep0 |= i;
    425462                                                i <<= 1;
    426463                                        }
    427                                 }
     464                                } else
     465                                        rep0 = pos_slot;
    428466                                if (++rep0 == 0)
    429467                                        break;
    430468                        }
  • modutils/modprobe-small.c

    diff -ru busybox-1.15.0-ori/modutils/modprobe-small.c busybox-1.15.0/modutils/modprobe-small.c
    old new  
    218218        bksp(); /* remove last ' ' */
    219219        appendc('\0');
    220220        info->aliases = copy_stringbuf();
     221        replace(info->aliases, '-', '_');
    221222
    222223        /* "dependency1 depandency2" */
    223224        reset_stringbuf();
  • networking/inetd.c

    diff -ru busybox-1.15.0-ori/networking/inetd.c busybox-1.15.0/networking/inetd.c
    old new  
    10311031                                continue;
    10321032                        /* One of our "wait" services */
    10331033                        if (WIFEXITED(status) && WEXITSTATUS(status))
    1034                                 bb_error_msg("%s: exit status 0x%x",
     1034                                bb_error_msg("%s: exit status %u",
    10351035                                                sep->se_program, WEXITSTATUS(status));
    10361036                        else if (WIFSIGNALED(status))
    1037                                 bb_error_msg("%s: exit signal 0x%x",
     1037                                bb_error_msg("%s: exit signal %u",
    10381038                                                sep->se_program, WTERMSIG(status));
    10391039                        sep->se_wait = 1;
    10401040                        add_fd_to_set(sep->se_fd);
     
    11191119        else
    11201120                bb_sanitize_stdio();
    11211121        if (!(opt & 4)) {
    1122                 openlog(applet_name, LOG_PID, LOG_DAEMON);
     1122                /* LOG_NDELAY: connect to syslog daemon NOW.
     1123                 * Otherwise, we may open syslog socket
     1124                 * in vforked child, making opened fds and syslog()
     1125                 * internal state inconsistent.
     1126                 * This was observed to leak file descriptors. */
     1127                openlog(applet_name, LOG_PID | LOG_NDELAY, LOG_DAEMON);
    11231128                logmode = LOGMODE_SYSLOG;
    11241129        }
    11251130
     
    13551360                        if (rlim_ofile.rlim_cur != rlim_ofile_cur)
    13561361                                if (setrlimit(RLIMIT_NOFILE, &rlim_ofile) < 0)
    13571362                                        bb_perror_msg("setrlimit");
    1358                         closelog();
     1363
     1364                        /* closelog(); - WRONG. we are after vfork,
     1365                         * this may confuse syslog() internal state.
     1366                         * Let's hope libc sets syslog fd to CLOEXEC...
     1367                         */
    13591368                        xmove_fd(ctrl, STDIN_FILENO);
    13601369                        xdup2(STDIN_FILENO, STDOUT_FILENO);
    13611370                        /* manpages of inetd I managed to find either say
    13621371                         * that stderr is also redirected to the network,
    13631372                         * or do not talk about redirection at all (!) */
    1364                         xdup2(STDIN_FILENO, STDERR_FILENO);
    1365                         /* NB: among others, this loop closes listening socket
     1373                        if (!sep->se_wait) /* only for usual "tcp nowait" */
     1374                                xdup2(STDIN_FILENO, STDERR_FILENO);
     1375                        /* NB: among others, this loop closes listening sockets
    13661376                         * for nowait stream children */
    13671377                        for (sep2 = serv_list; sep2; sep2 = sep2->se_next)
    1368                                 maybe_close(sep2->se_fd);
     1378                                if (sep2->se_fd != ctrl)
     1379                                        maybe_close(sep2->se_fd);
    13691380                        sigaction_set(SIGPIPE, &saved_pipe_handler);
    13701381                        restore_sigmask(&omask);
    13711382                        BB_EXECVP(sep->se_program, sep->se_argv);
  • shell/hush.c

    diff -ru busybox-1.15.0-ori/shell/hush.c busybox-1.15.0/shell/hush.c
    old new  
    5858 * TODOs:
    5959 *      grep for "TODO" and fix (some of them are easy)
    6060 *      builtins: ulimit
    61  *      special variables (PWD etc)
     61 *      special variables (done: PWD)
    6262 *      follow IFS rules more precisely, including update semantics
    6363 *      export builtin should be special, its arguments are assignments
    6464 *          and therefore expansion of them should be "one-word" expansion:
     
    14321432        return 0;
    14331433}
    14341434
     1435/* Used at startup and after each cd */
     1436static void set_pwd_var(int exp)
     1437{
     1438        set_local_var(xasprintf("PWD=%s", get_cwd(/*force:*/ 1)),
     1439                /*exp:*/ exp, /*lvl:*/ 0, /*ro:*/ 0);
     1440}
     1441
    14351442static int unset_local_var_len(const char *name, int name_len)
    14361443{
    14371444        struct variable *cur;
     
    16041611                /* Set up the prompt */
    16051612                if (promptmode == 0) { /* PS1 */
    16061613                        free((char*)G.PS1);
     1614                        /* bash uses $PWD value, even if it is set by user.
     1615                         * It uses current dir only if PWD is unset.
     1616                         * We always use current dir. */
    16071617                        G.PS1 = xasprintf("%s %c ", get_cwd(0), (geteuid() != 0) ? '$' : '#');
    16081618                        prompt_str = G.PS1;
    16091619                } else
     
    64326442                }
    64336443                e++;
    64346444        }
     6445        /* reinstate HUSH_VERSION */
    64356446        debug_printf_env("putenv '%s'\n", hush_version_str);
    6436         putenv((char *)hush_version_str); /* reinstate HUSH_VERSION */
     6447        putenv((char *)hush_version_str);
     6448
     6449        /* Export PWD */
     6450        set_pwd_var(/*exp:*/ 1);
     6451        /* bash also exports SHLVL and _,
     6452         * and sets (but doesn't export) the following variables:
     6453         * BASH=/bin/bash
     6454         * BASH_VERSINFO=([0]="3" [1]="2" [2]="0" [3]="1" [4]="release" [5]="i386-pc-linux-gnu")
     6455         * BASH_VERSION='3.2.0(1)-release'
     6456         * HOSTTYPE=i386
     6457         * MACHTYPE=i386-pc-linux-gnu
     6458         * OSTYPE=linux-gnu
     6459         * HOSTNAME=<xxxxxxxxxx>
     6460         * PPID=<NNNNN>
     6461         * EUID=<NNNNN>
     6462         * UID=<NNNNN>
     6463         * GROUPS=()
     6464         * LINES=<NNN>
     6465         * COLUMNS=<NNN>
     6466         * BASH_ARGC=()
     6467         * BASH_ARGV=()
     6468         * BASH_LINENO=()
     6469         * BASH_SOURCE=()
     6470         * DIRSTACK=()
     6471         * PIPESTATUS=([0]="0")
     6472         * HISTFILE=/<xxx>/.bash_history
     6473         * HISTFILESIZE=500
     6474         * HISTSIZE=500
     6475         * MAILCHECK=60
     6476         * PATH=/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.
     6477         * SHELL=/bin/bash
     6478         * SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
     6479         * TERM=dumb
     6480         * OPTERR=1
     6481         * OPTIND=1
     6482         * IFS=$' \t\n'
     6483         * PS1='\s-\v\$ '
     6484         * PS2='> '
     6485         * PS4='+ '
     6486         */
     6487
    64376488#if ENABLE_FEATURE_EDITING
    64386489        G.line_input_state = new_line_input_t(FOR_SHELL);
    64396490#endif
     
    68166867                bb_perror_msg("cd: %s", newdir);
    68176868                return EXIT_FAILURE;
    68186869        }
    6819         get_cwd(1);
     6870        /* Read current dir (get_cwd(1) is inside) and set PWD.
     6871         * Note: do not enforce exporting. If PWD was unset or unexported,
     6872         * set it again, but do not export. bash does the same.
     6873         */
     6874        set_pwd_var(/*exp:*/ 0);
    68206875        return EXIT_SUCCESS;
    68216876}
    68226877
Note: See TracBrowser for help on using the repository browser.