source:
clfs-embedded/patches/busybox-1.15.0-branch_update-1.patch@
6d34f7d
Last change on this file since 6d34f7d was 2e856a4, checked in by , 15 years ago | |
---|---|
|
|
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 298 298 default n 299 299 depends on UNLZMA 300 300 help 301 This option reduces decompression time by about 25% at the cost of302 a 1K bigger binary.301 This option reduces decompression time by about 33% at the cost of 302 a 2K bigger binary. 303 303 304 304 config UNZIP 305 305 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 132 132 #endif 133 133 lchown(file_header->name, file_header->uid, file_header->gid); 134 134 } 135 if ( S_ISLNK(file_header->mode)) {135 if (!S_ISLNK(file_header->mode)) { 136 136 /* uclibc has no lchmod, glibc is even stranger - 137 137 * it has lchmod which seems to do nothing! 138 138 * 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 8 8 * 9 9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 10 10 */ 11 11 12 #include "libbb.h" 12 13 #include "unarchive.h" 13 14 14 15 #if ENABLE_FEATURE_LZMA_FAST 15 16 # define speed_inline ALWAYS_INLINE 16 # define size_inline17 17 #else 18 18 # define speed_inline 19 # define size_inline ALWAYS_INLINE20 19 #endif 21 20 22 21 … … 45 44 #define RC_MODEL_TOTAL_BITS 11 46 45 47 46 48 /* Called twice: once at startup (LZMA_FAST only)and once in rc_normalize() */49 static size_inlinevoid rc_read(rc_t *rc)47 /* Called twice: once at startup and once in rc_normalize() */ 48 static void rc_read(rc_t *rc) 50 49 { 51 50 int buffer_size = safe_read(rc->fd, RC_BUFFER, RC_BUFFER_SIZE); 52 51 if (buffer_size <= 0) … … 55 54 rc->buffer_end = RC_BUFFER + buffer_size; 56 55 } 57 56 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 67 57 /* Called once */ 68 static ALWAYS_INLINErc_t* rc_init(int fd) /*, int buffer_size) */58 static rc_t* rc_init(int fd) /*, int buffer_size) */ 69 59 { 70 60 int i; 71 61 rc_t *rc; … … 73 63 rc = xmalloc(sizeof(*rc) + RC_BUFFER_SIZE); 74 64 75 65 rc->fd = fd; 66 /* rc->buffer_size = buffer_size; */ 67 rc->buffer_end = RC_BUFFER + RC_BUFFER_SIZE; 76 68 rc->ptr = rc->buffer_end; 77 69 70 rc->code = 0; 71 rc->range = 0xFFFFFFFF; 78 72 for (i = 0; i < 5; i++) { 79 #if ENABLE_FEATURE_LZMA_FAST80 73 if (rc->ptr >= rc->buffer_end) 81 74 rc_read(rc); 82 75 rc->code = (rc->code << 8) | *rc->ptr++; 83 #else84 rc_do_normalize(rc);85 #endif86 76 } 87 rc->range = 0xFFFFFFFF;88 77 return rc; 89 78 } 90 79 … … 94 83 free(rc); 95 84 } 96 85 86 /* Called twice, but one callsite is in speed_inline'd rc_is_bit_0_helper() */ 87 static 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 } 97 94 static ALWAYS_INLINE void rc_normalize(rc_t *rc) 98 95 { 99 96 if (rc->range < (1 << RC_TOP_BITS)) { … … 101 98 } 102 99 } 103 100 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 */ 107 static speed_inline uint32_t rc_is_bit_0_helper(rc_t *rc, uint16_t *p) 106 108 { 107 109 rc_normalize(rc); 108 110 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 } 113 static 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 */ 120 static 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 } 125 static speed_inline void rc_update_bit_1(rc_t *rc, uint16_t *p) 126 { 114 127 rc->range -= rc->bound; 115 128 rc->code -= rc->bound; 116 129 *p -= *p >> RC_MOVE_BITS; 117 return 1;118 130 } 119 131 120 132 /* Called 4 times in unlzma loop */ 121 static speed_inlineint rc_get_bit(rc_t *rc, uint16_t *p, int *symbol)133 static int rc_get_bit(rc_t *rc, uint16_t *p, int *symbol) 122 134 { 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 } 126 144 } 127 145 128 146 /* Called once */ … … 248 266 header.dst_size = SWAP_LE64(header.dst_size); 249 267 250 268 if (header.dict_size == 0) 251 header.dict_size ++;269 header.dict_size = 1; 252 270 253 271 buffer = xmalloc(MIN(header.dst_size, header.dict_size)); 254 272 255 273 num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp)); 256 274 p = xmalloc(num_probs * sizeof(*p)); 257 num_probs += LZMA_LITERAL - LZMA_BASE_SIZE;275 num_probs = LZMA_LITERAL + (LZMA_LIT_SIZE << (lc + lp)); 258 276 for (i = 0; i < num_probs; i++) 259 277 p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1; 260 278 … … 264 282 int pos_state = (buffer_pos + global_pos) & pos_state_mask; 265 283 266 284 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)) { 268 286 mi = 1; 287 rc_update_bit_0(rc, prob); 269 288 prob = (p + LZMA_LITERAL 270 289 + (LZMA_LIT_SIZE * ((((buffer_pos + global_pos) & literal_pos_mask) << lc) 271 290 + (previous_byte >> (8 - lc)) … … 321 340 int offset; 322 341 uint16_t *prob_len; 323 342 343 rc_update_bit_1(rc, prob); 324 344 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); 326 347 rep3 = rep2; 327 348 rep2 = rep1; 328 349 rep1 = rep0; 329 350 state = state < LZMA_NUM_LIT_STATES ? 0 : 3; 330 351 prob = p + LZMA_LEN_CODER; 331 352 } 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); 334 357 prob = (p + LZMA_IS_REP_0_LONG 335 358 + (state << LZMA_NUM_POS_BITS_MAX) 336 359 + pos_state 337 360 ); 338 if (!rc_is_bit_1(rc, prob)) { 361 if (rc_is_bit_0(rc, prob)) { 362 rc_update_bit_0(rc, prob); 363 339 364 state = state < LZMA_NUM_LIT_STATES ? 9 : 11; 340 365 #if ENABLE_FEATURE_LZMA_FAST 341 366 pos = buffer_pos - rep0; … … 347 372 len = 1; 348 373 goto string; 349 374 #endif 375 } else { 376 rc_update_bit_1(rc, prob); 350 377 } 351 378 } else { 352 379 uint32_t distance; 353 380 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); 360 394 distance = rep3; 361 395 rep3 = rep2; 362 396 } … … 370 404 } 371 405 372 406 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)); 376 411 offset = 0; 377 412 num_bits = LZMA_LEN_NUM_LOW_BITS; 378 413 } 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)); 383 420 offset = 1 << LZMA_LEN_NUM_LOW_BITS; 384 421 num_bits = LZMA_LEN_NUM_MID_BITS; 385 422 } 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; 387 425 offset = ((1 << LZMA_LEN_NUM_LOW_BITS) 388 426 + (1 << LZMA_LEN_NUM_MID_BITS)); 389 427 num_bits = LZMA_LEN_NUM_HIGH_BITS; … … 400 438 ((len < LZMA_NUM_LEN_TO_POS_STATES ? len : 401 439 LZMA_NUM_LEN_TO_POS_STATES - 1) 402 440 << 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); 406 443 if (pos_slot >= LZMA_START_POS_MODEL_INDEX) { 407 444 num_bits = (pos_slot >> 1) - 1; 408 445 rep0 = 2 | (pos_slot & 1); 409 prob = p + LZMA_ALIGN;410 446 if (pos_slot < LZMA_END_POS_MODEL_INDEX) { 411 447 rep0 <<= num_bits; 412 prob += LZMA_SPEC_POS - LZMA_ALIGN - 1 + rep0 - pos_slot;448 prob = p + LZMA_SPEC_POS + rep0 - pos_slot - 1; 413 449 } else { 414 450 num_bits -= LZMA_NUM_ALIGN_BITS; 415 451 while (num_bits--) 416 452 rep0 = (rep0 << 1) | rc_direct_bit(rc); 453 prob = p + LZMA_ALIGN; 417 454 rep0 <<= LZMA_NUM_ALIGN_BITS; 418 455 num_bits = LZMA_NUM_ALIGN_BITS; 419 456 } … … 424 461 rep0 |= i; 425 462 i <<= 1; 426 463 } 427 } 464 } else 465 rep0 = pos_slot; 428 466 if (++rep0 == 0) 429 467 break; 430 468 } -
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 218 218 bksp(); /* remove last ' ' */ 219 219 appendc('\0'); 220 220 info->aliases = copy_stringbuf(); 221 replace(info->aliases, '-', '_'); 221 222 222 223 /* "dependency1 depandency2" */ 223 224 reset_stringbuf(); -
networking/inetd.c
diff -ru busybox-1.15.0-ori/networking/inetd.c busybox-1.15.0/networking/inetd.c
old new 1031 1031 continue; 1032 1032 /* One of our "wait" services */ 1033 1033 if (WIFEXITED(status) && WEXITSTATUS(status)) 1034 bb_error_msg("%s: exit status 0x%x",1034 bb_error_msg("%s: exit status %u", 1035 1035 sep->se_program, WEXITSTATUS(status)); 1036 1036 else if (WIFSIGNALED(status)) 1037 bb_error_msg("%s: exit signal 0x%x",1037 bb_error_msg("%s: exit signal %u", 1038 1038 sep->se_program, WTERMSIG(status)); 1039 1039 sep->se_wait = 1; 1040 1040 add_fd_to_set(sep->se_fd); … … 1119 1119 else 1120 1120 bb_sanitize_stdio(); 1121 1121 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); 1123 1128 logmode = LOGMODE_SYSLOG; 1124 1129 } 1125 1130 … … 1355 1360 if (rlim_ofile.rlim_cur != rlim_ofile_cur) 1356 1361 if (setrlimit(RLIMIT_NOFILE, &rlim_ofile) < 0) 1357 1362 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 */ 1359 1368 xmove_fd(ctrl, STDIN_FILENO); 1360 1369 xdup2(STDIN_FILENO, STDOUT_FILENO); 1361 1370 /* manpages of inetd I managed to find either say 1362 1371 * that stderr is also redirected to the network, 1363 1372 * 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 1366 1376 * for nowait stream children */ 1367 1377 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); 1369 1380 sigaction_set(SIGPIPE, &saved_pipe_handler); 1370 1381 restore_sigmask(&omask); 1371 1382 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 58 58 * TODOs: 59 59 * grep for "TODO" and fix (some of them are easy) 60 60 * builtins: ulimit 61 * special variables ( PWD etc)61 * special variables (done: PWD) 62 62 * follow IFS rules more precisely, including update semantics 63 63 * export builtin should be special, its arguments are assignments 64 64 * and therefore expansion of them should be "one-word" expansion: … … 1432 1432 return 0; 1433 1433 } 1434 1434 1435 /* Used at startup and after each cd */ 1436 static 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 1435 1442 static int unset_local_var_len(const char *name, int name_len) 1436 1443 { 1437 1444 struct variable *cur; … … 1604 1611 /* Set up the prompt */ 1605 1612 if (promptmode == 0) { /* PS1 */ 1606 1613 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. */ 1607 1617 G.PS1 = xasprintf("%s %c ", get_cwd(0), (geteuid() != 0) ? '$' : '#'); 1608 1618 prompt_str = G.PS1; 1609 1619 } else … … 6432 6442 } 6433 6443 e++; 6434 6444 } 6445 /* reinstate HUSH_VERSION */ 6435 6446 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 6437 6488 #if ENABLE_FEATURE_EDITING 6438 6489 G.line_input_state = new_line_input_t(FOR_SHELL); 6439 6490 #endif … … 6816 6867 bb_perror_msg("cd: %s", newdir); 6817 6868 return EXIT_FAILURE; 6818 6869 } 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); 6820 6875 return EXIT_SUCCESS; 6821 6876 } 6822 6877
Note:
See TracBrowser
for help on using the repository browser.