diff options
| author | Thomas Gleixner <tglx@linutronix.de> | 2009-03-23 09:50:03 -0400 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2009-03-23 16:20:20 -0400 |
| commit | 80c5520811d3805adcb15c570ea5e2d489fa5d0b (patch) | |
| tree | ae797a7f4af39f80e77526533d06ac23b439f0ab /init/initramfs.c | |
| parent | b3e3b302cf6dc8d60b67f0e84d1fa5648889c038 (diff) | |
| parent | 8c083f081d0014057901c68a0a3e0f8ca7ac8d23 (diff) | |
Merge branch 'cpus4096' into irq/threaded
Conflicts:
arch/parisc/kernel/irq.c
kernel/irq/handle.c
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'init/initramfs.c')
| -rw-r--r-- | init/initramfs.c | 122 |
1 files changed, 37 insertions, 85 deletions
diff --git a/init/initramfs.c b/init/initramfs.c index d9c941c0c3ca..7dcde7ea6603 100644 --- a/init/initramfs.c +++ b/init/initramfs.c | |||
| @@ -390,11 +390,13 @@ static int __init write_buffer(char *buf, unsigned len) | |||
| 390 | return len - count; | 390 | return len - count; |
| 391 | } | 391 | } |
| 392 | 392 | ||
| 393 | static void __init flush_buffer(char *buf, unsigned len) | 393 | static int __init flush_buffer(void *bufv, unsigned len) |
| 394 | { | 394 | { |
| 395 | char *buf = (char *) bufv; | ||
| 395 | int written; | 396 | int written; |
| 397 | int origLen = len; | ||
| 396 | if (message) | 398 | if (message) |
| 397 | return; | 399 | return -1; |
| 398 | while ((written = write_buffer(buf, len)) < len && !message) { | 400 | while ((written = write_buffer(buf, len)) < len && !message) { |
| 399 | char c = buf[written]; | 401 | char c = buf[written]; |
| 400 | if (c == '0') { | 402 | if (c == '0') { |
| @@ -408,84 +410,28 @@ static void __init flush_buffer(char *buf, unsigned len) | |||
| 408 | } else | 410 | } else |
| 409 | error("junk in compressed archive"); | 411 | error("junk in compressed archive"); |
| 410 | } | 412 | } |
| 413 | return origLen; | ||
| 411 | } | 414 | } |
| 412 | 415 | ||
| 413 | /* | 416 | static unsigned my_inptr; /* index of next byte to be processed in inbuf */ |
| 414 | * gzip declarations | ||
| 415 | */ | ||
| 416 | 417 | ||
| 417 | #define OF(args) args | 418 | #include <linux/decompress/generic.h> |
| 418 | |||
| 419 | #ifndef memzero | ||
| 420 | #define memzero(s, n) memset ((s), 0, (n)) | ||
| 421 | #endif | ||
| 422 | |||
| 423 | typedef unsigned char uch; | ||
| 424 | typedef unsigned short ush; | ||
| 425 | typedef unsigned long ulg; | ||
| 426 | |||
| 427 | #define WSIZE 0x8000 /* window size--must be a power of two, and */ | ||
| 428 | /* at least 32K for zip's deflate method */ | ||
| 429 | |||
| 430 | static uch *inbuf; | ||
| 431 | static uch *window; | ||
| 432 | |||
| 433 | static unsigned insize; /* valid bytes in inbuf */ | ||
| 434 | static unsigned inptr; /* index of next byte to be processed in inbuf */ | ||
| 435 | static unsigned outcnt; /* bytes in output buffer */ | ||
| 436 | static long bytes_out; | ||
| 437 | |||
| 438 | #define get_byte() (inptr < insize ? inbuf[inptr++] : -1) | ||
| 439 | |||
| 440 | /* Diagnostic functions (stubbed out) */ | ||
| 441 | #define Assert(cond,msg) | ||
| 442 | #define Trace(x) | ||
| 443 | #define Tracev(x) | ||
| 444 | #define Tracevv(x) | ||
| 445 | #define Tracec(c,x) | ||
| 446 | #define Tracecv(c,x) | ||
| 447 | |||
| 448 | #define STATIC static | ||
| 449 | #define INIT __init | ||
| 450 | |||
| 451 | static void __init flush_window(void); | ||
| 452 | static void __init error(char *m); | ||
| 453 | |||
| 454 | #define NO_INFLATE_MALLOC | ||
| 455 | |||
| 456 | #include "../lib/inflate.c" | ||
| 457 | |||
| 458 | /* =========================================================================== | ||
| 459 | * Write the output window window[0..outcnt-1] and update crc and bytes_out. | ||
| 460 | * (Used for the decompressed data only.) | ||
| 461 | */ | ||
| 462 | static void __init flush_window(void) | ||
| 463 | { | ||
| 464 | ulg c = crc; /* temporary variable */ | ||
| 465 | unsigned n; | ||
| 466 | uch *in, ch; | ||
| 467 | |||
| 468 | flush_buffer(window, outcnt); | ||
| 469 | in = window; | ||
| 470 | for (n = 0; n < outcnt; n++) { | ||
| 471 | ch = *in++; | ||
| 472 | c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8); | ||
| 473 | } | ||
| 474 | crc = c; | ||
| 475 | bytes_out += (ulg)outcnt; | ||
| 476 | outcnt = 0; | ||
| 477 | } | ||
| 478 | 419 | ||
| 479 | static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only) | 420 | static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only) |
| 480 | { | 421 | { |
| 481 | int written; | 422 | int written; |
| 423 | decompress_fn decompress; | ||
| 424 | const char *compress_name; | ||
| 425 | static __initdata char msg_buf[64]; | ||
| 426 | |||
| 482 | dry_run = check_only; | 427 | dry_run = check_only; |
| 483 | header_buf = kmalloc(110, GFP_KERNEL); | 428 | header_buf = kmalloc(110, GFP_KERNEL); |
| 484 | symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL); | 429 | symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL); |
| 485 | name_buf = kmalloc(N_ALIGN(PATH_MAX), GFP_KERNEL); | 430 | name_buf = kmalloc(N_ALIGN(PATH_MAX), GFP_KERNEL); |
| 486 | window = kmalloc(WSIZE, GFP_KERNEL); | 431 | |
| 487 | if (!window || !header_buf || !symlink_buf || !name_buf) | 432 | if (!header_buf || !symlink_buf || !name_buf) |
| 488 | panic("can't allocate buffers"); | 433 | panic("can't allocate buffers"); |
| 434 | |||
| 489 | state = Start; | 435 | state = Start; |
| 490 | this_header = 0; | 436 | this_header = 0; |
| 491 | message = NULL; | 437 | message = NULL; |
| @@ -505,22 +451,25 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only) | |||
| 505 | continue; | 451 | continue; |
| 506 | } | 452 | } |
| 507 | this_header = 0; | 453 | this_header = 0; |
| 508 | insize = len; | 454 | decompress = decompress_method(buf, len, &compress_name); |
| 509 | inbuf = buf; | 455 | if (decompress) |
| 510 | inptr = 0; | 456 | decompress(buf, len, NULL, flush_buffer, NULL, |
| 511 | outcnt = 0; /* bytes in output buffer */ | 457 | &my_inptr, error); |
| 512 | bytes_out = 0; | 458 | else if (compress_name) { |
| 513 | crc = (ulg)0xffffffffL; /* shift register contents */ | 459 | if (!message) { |
| 514 | makecrc(); | 460 | snprintf(msg_buf, sizeof msg_buf, |
| 515 | gunzip(); | 461 | "compression method %s not configured", |
| 462 | compress_name); | ||
| 463 | message = msg_buf; | ||
| 464 | } | ||
| 465 | } | ||
| 516 | if (state != Reset) | 466 | if (state != Reset) |
| 517 | error("junk in gzipped archive"); | 467 | error("junk in compressed archive"); |
| 518 | this_header = saved_offset + inptr; | 468 | this_header = saved_offset + my_inptr; |
| 519 | buf += inptr; | 469 | buf += my_inptr; |
| 520 | len -= inptr; | 470 | len -= my_inptr; |
| 521 | } | 471 | } |
| 522 | dir_utime(); | 472 | dir_utime(); |
| 523 | kfree(window); | ||
| 524 | kfree(name_buf); | 473 | kfree(name_buf); |
| 525 | kfree(symlink_buf); | 474 | kfree(symlink_buf); |
| 526 | kfree(header_buf); | 475 | kfree(header_buf); |
| @@ -579,7 +528,7 @@ static int __init populate_rootfs(void) | |||
| 579 | char *err = unpack_to_rootfs(__initramfs_start, | 528 | char *err = unpack_to_rootfs(__initramfs_start, |
| 580 | __initramfs_end - __initramfs_start, 0); | 529 | __initramfs_end - __initramfs_start, 0); |
| 581 | if (err) | 530 | if (err) |
| 582 | panic(err); | 531 | panic(err); /* Failed to decompress INTERNAL initramfs */ |
| 583 | if (initrd_start) { | 532 | if (initrd_start) { |
| 584 | #ifdef CONFIG_BLK_DEV_RAM | 533 | #ifdef CONFIG_BLK_DEV_RAM |
| 585 | int fd; | 534 | int fd; |
| @@ -605,9 +554,12 @@ static int __init populate_rootfs(void) | |||
| 605 | printk(KERN_INFO "Unpacking initramfs..."); | 554 | printk(KERN_INFO "Unpacking initramfs..."); |
| 606 | err = unpack_to_rootfs((char *)initrd_start, | 555 | err = unpack_to_rootfs((char *)initrd_start, |
| 607 | initrd_end - initrd_start, 0); | 556 | initrd_end - initrd_start, 0); |
| 608 | if (err) | 557 | if (err) { |
| 609 | panic(err); | 558 | printk(" failed!\n"); |
| 610 | printk(" done\n"); | 559 | printk(KERN_EMERG "%s\n", err); |
| 560 | } else { | ||
| 561 | printk(" done\n"); | ||
| 562 | } | ||
| 611 | free_initrd(); | 563 | free_initrd(); |
| 612 | #endif | 564 | #endif |
| 613 | } | 565 | } |
