Commit 1a1e9095 authored by Alan Cox's avatar Alan Cox Committed by James Bottomley

[PATCH] report unzip errors on initrd

parent 6506be23
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment