wok-6.x rev 5163

linux: limit uncompress initramfs dots.
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Mar 25 17:01:27 2010 +0100 (2010-03-25)
parents 252a378d28c1
children 6d0d35352519
files linux/stuff/linux-freeinitrd-2.6.30.6.u
line diff
     1.1 --- a/linux/stuff/linux-freeinitrd-2.6.30.6.u	Thu Mar 25 09:27:06 2010 +0100
     1.2 +++ b/linux/stuff/linux-freeinitrd-2.6.30.6.u	Thu Mar 25 17:01:27 2010 +0100
     1.3 @@ -33,13 +33,13 @@
     1.4  +	char *max;
     1.5  +} fill;
     1.6  +
     1.7 -+static void release_inbuf(void)
     1.8 ++static void release_inbuf(unsigned n)
     1.9  +{
    1.10 -+	if (fill.offset >= INITRD_PAGE) {
    1.11 -+		unsigned rem = fill.offset % INITRD_PAGE;
    1.12 -+		unsigned end = initrd_start + fill.offset - rem;
    1.13 ++	if (n >= INITRD_PAGE) {
    1.14 ++		unsigned rem = n % INITRD_PAGE;
    1.15 ++		unsigned end = initrd_start + n - rem;
    1.16  +		_free_initrd(initrd_start, end, free_rootfs_mem);
    1.17 -+		fill.freed += fill.offset - rem;
    1.18 ++		fill.freed += n - rem;
    1.19  +		if (fill.freed >= INITRD_DOT) {
    1.20  +			fill.freed -= INITRD_DOT;
    1.21  +			printk(".");
    1.22 @@ -55,7 +55,7 @@
    1.23  +	if (max > size) max = size;
    1.24  +	if (max > INITRD_PAGE) max = INITRD_PAGE;
    1.25  +	memcpy(buffer, (void *)(initrd_start + fill.offset), max);
    1.26 -+	release_inbuf();
    1.27 ++	release_inbuf(fill.offset);
    1.28  +	fill.offset += max;
    1.29  +	fill.inptr += fill.last;
    1.30  +	fill.last = max;
    1.31 @@ -65,7 +65,7 @@
    1.32   static int __init write_buffer(char *buf, unsigned len)
    1.33   {
    1.34   	count = len;
    1.35 -@@ -418,6 +464,7 @@
    1.36 +@@ -418,6 +463,7 @@
    1.37   	decompress_fn decompress;
    1.38   	const char *compress_name;
    1.39   	static __initdata char msg_buf[64];
    1.40 @@ -73,7 +73,7 @@
    1.41   
    1.42   	header_buf = kmalloc(110, GFP_KERNEL);
    1.43   	symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL);
    1.44 -@@ -431,8 +478,31 @@
    1.45 +@@ -431,11 +478,16 @@
    1.46   	message = NULL;
    1.47   	while (!message && len) {
    1.48   		loff_t saved_offset = this_header;
    1.49 @@ -82,30 +82,15 @@
    1.50  +		fill.inptr = fill.last = fill.freed = 0;
    1.51   		if (*buf == '0' && !(this_header & 3)) {
    1.52   			state = Start;
    1.53 -+			if (early_free_initrd) {
    1.54 -+				while (len) {
    1.55 -+					unsigned n = len, tofree;
    1.56 -+					if (n > INITRD_PAGE)
    1.57 -+						n = INITRD_PAGE;
    1.58 -+					flush_buffer(buf, n);
    1.59 -+					buf += n;
    1.60 -+					len -= n;
    1.61 -+					n = buf - (char *) initrd_start;
    1.62 -+					tofree = n - (n % INITRD_PAGE);
    1.63 -+					if (!tofree)
    1.64 -+						continue;
    1.65 -+					_free_initrd(initrd_start,
    1.66 -+						     initrd_start + tofree,
    1.67 -+						     free_rootfs_mem);
    1.68 -+					initrd_start += tofree;
    1.69 -+					printk(".");
    1.70 -+				}
    1.71 -+				continue;
    1.72 -+			}
    1.73   			written = write_buffer(buf, len);
    1.74   			buf += written;
    1.75   			len -= written;
    1.76 -@@ -446,9 +516,15 @@
    1.77 ++			if (early_free_initrd)
    1.78 ++				release_inbuf(buf - (char *) initrd_start);
    1.79 + 			continue;
    1.80 + 		}
    1.81 + 		if (!*buf) {
    1.82 +@@ -446,9 +497,15 @@
    1.83   		}
    1.84   		this_header = 0;
    1.85   		decompress = decompress_method(buf, len, &compress_name);
    1.86 @@ -123,7 +108,7 @@
    1.87   		else if (compress_name) {
    1.88   			if (!message) {
    1.89   				snprintf(msg_buf, sizeof msg_buf,
    1.90 -@@ -485,7 +561,8 @@
    1.91 +@@ -485,7 +543,8 @@
    1.92   #include <linux/initrd.h>
    1.93   #include <linux/kexec.h>
    1.94   
    1.95 @@ -133,7 +118,7 @@
    1.96   {
    1.97   #ifdef CONFIG_KEXEC
    1.98   	unsigned long crashk_start = (unsigned long)__va(crashk_res.start);
    1.99 -@@ -513,6 +590,12 @@
   1.100 +@@ -513,6 +571,12 @@
   1.101   #endif
   1.102   		free_initrd_mem(initrd_start, initrd_end);
   1.103   skip: