diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2002-12-01 02:27:22 -0800 |
---|---|---|
committer | James Bottomley <jejb@raven.il.steeleye.com> | 2002-12-01 02:27:22 -0800 |
commit | 1a1e90953c21e84956018c4abcf2b33f1cad5308 (patch) | |
tree | 75902ef47c6eee467aa58b252ca96f3b7c68405a /init | |
parent | 6506be2380c13734979cab5c06bf74068dbf0b96 (diff) | |
download | history-1a1e90953c21e84956018c4abcf2b33f1cad5308.tar.gz |
[PATCH] report unzip errors on initrd
Diffstat (limited to 'init')
-rw-r--r-- | init/do_mounts.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/init/do_mounts.c b/init/do_mounts.c index c5dfb8c691bb77..be86a550b98440 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c @@ -920,6 +920,7 @@ static unsigned insize; /* valid bytes in inbuf */ static unsigned inptr; /* index of next byte to be processed in inbuf */ static unsigned outcnt; /* bytes in output buffer */ static int exit_code; +static int unzip_error; static long bytes_out; static int crd_infd, crd_outfd; @@ -967,13 +968,17 @@ static void __init gzip_release(void **ptr) /* =========================================================================== * Fill the input buffer. This is called only when the buffer is empty * and at least one byte is really needed. + * Returning -1 does not guarantee that gunzip() will ever return. */ static int __init fill_inbuf(void) { if (exit_code) return -1; insize = read(crd_infd, inbuf, INBUFSIZ); - if (insize == 0) return -1; + if (insize == 0) { + error("RAMDISK: ran out of compressed data\n"); + return -1; + } inptr = 1; @@ -987,10 +992,15 @@ static int __init fill_inbuf(void) static void __init flush_window(void) { ulg c = crc; /* temporary variable */ - unsigned n; + unsigned n, written; uch *in, ch; - write(crd_outfd, window, outcnt); + written = write(crd_outfd, window, outcnt); + if (written != outcnt && unzip_error == 0) { + printk(KERN_ERR "RAMDISK: incomplete write (%d != %d) %d\n", + written, outcnt, bytes_out); + unzip_error = 1; + } in = window; for (n = 0; n < outcnt; n++) { ch = *in++; @@ -1005,6 +1015,7 @@ static void __init error(char *x) { printk(KERN_ERR "%s", x); exit_code = 1; + unzip_error = 1; } static int __init crd_load(int in_fd, int out_fd) @@ -1033,6 +1044,8 @@ static int __init crd_load(int in_fd, int out_fd) } makecrc(); result = gunzip(); + if (unzip_error) + result = 1; kfree(inbuf); kfree(window); return result; |