wok view linux/stuff/linux-freeinitrd-2.6.37.u @ rev 8623
Fix: libarchive doesn't need acl hack anymore: acl files are now installed to the right location.
author | Antoine Bodin <gokhlayeh@slitaz.org> |
---|---|
date | Mon Feb 14 20:54:26 2011 +0100 (2011-02-14) |
parents | |
children |
line source
1 --- linux-2.6.30.4/arch/x86/mm/init.c
2 +++ linux-2.6.30.4/arch/x86/mm/init.c
3 @@ -366,7 +366,7 @@
4 */
5 set_memory_rw(begin, (end - begin) >> PAGE_SHIFT);
7 - printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
8 + if (what) printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
10 for (; addr < end; addr += PAGE_SIZE) {
11 ClearPageReserved(virt_to_page(addr));
13 --- linux-2.6.30.4/init/initramfs.c
14 +++ linux-2.6.30.4/init/initramfs.c
15 @@ -374,6 +374,52 @@
16 [Reset] = do_reset,
17 };
19 +#include <linux/initrd.h>
20 +#define INITRD_PAGE ((PAGE_SIZE > 64*1024) ? PAGE_SIZE : 64*1024)
21 +#define INITRD_DOT (1024*1024)
22 +
23 +static void free_rootfs_mem(unsigned long start, unsigned long end)
24 +{
25 + free_init_pages(NULL, start, end);
26 +}
27 +
28 +static void _free_initrd(unsigned long initrd_start, unsigned long initrd_end,
29 + void (*free_initrd_mem)(unsigned long, unsigned long));
30 +
31 +static struct {
32 + int offset, last, inptr, freed;
33 + char *max;
34 +} fill;
35 +
36 +static void release_inbuf(unsigned n)
37 +{
38 + if (n >= INITRD_PAGE) {
39 + unsigned rem = n % INITRD_PAGE;
40 + unsigned end = initrd_start + n - rem;
41 + _free_initrd(initrd_start, end, free_rootfs_mem);
42 + fill.freed += n - rem;
43 + if (fill.freed >= INITRD_DOT) {
44 + fill.freed -= INITRD_DOT;
45 + printk(".");
46 + }
47 + initrd_start = end;
48 + fill.offset = rem;
49 + }
50 +}
51 +
52 +static int fill_buffer(void *buffer, unsigned size)
53 +{
54 + int max = fill.max - (char *) initrd_start - fill.offset;
55 + if (max > size) max = size;
56 + if (max > INITRD_PAGE) max = INITRD_PAGE;
57 + memcpy(buffer, (void *)(initrd_start + fill.offset), max);
58 + release_inbuf(fill.offset);
59 + fill.offset += max;
60 + fill.inptr += fill.last;
61 + fill.last = max;
62 + return max;
63 +}
64 +
65 static int __init write_buffer(char *buf, unsigned len)
66 {
67 count = len;
68 @@ -418,6 +463,7 @@
69 decompress_fn decompress;
70 const char *compress_name;
71 static __initdata char msg_buf[64];
72 + int early_free_initrd = (buf == (char *) initrd_start);
74 header_buf = kmalloc(110, GFP_KERNEL);
75 symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL);
76 @@ -431,11 +478,16 @@
77 message = NULL;
78 while (!message && len) {
79 loff_t saved_offset = this_header;
80 + fill.offset = buf - (char *) initrd_start;
81 + fill.max = buf + len;
82 + fill.inptr = fill.last = fill.freed = 0;
83 if (*buf == '0' && !(this_header & 3)) {
84 state = Start;
85 written = write_buffer(buf, len);
86 buf += written;
87 len -= written;
88 + if (early_free_initrd)
89 + release_inbuf(buf - (char *) initrd_start);
90 continue;
91 }
92 if (!*buf) {
93 @@ -447,7 +497,12 @@
94 this_header = 0;
95 decompress = decompress_method(buf, len, &compress_name);
96 if (decompress) {
97 - res = decompress(buf, len, NULL, flush_buffer, NULL,
98 + if (early_free_initrd) {
99 + res = decompress(NULL, 0, fill_buffer,
100 + flush_buffer, NULL, &my_inptr, error);
101 + my_inptr += fill.inptr;
102 + }
103 + else res = decompress(buf, len, NULL, flush_buffer, NULL,
104 &my_inptr, error);
105 if (res)
106 error("decompressor failed");
107 @@ -488,7 +546,8 @@
108 #include <linux/initrd.h>
109 #include <linux/kexec.h>
111 -static void __init free_initrd(void)
112 +static void _free_initrd(unsigned long initrd_start, unsigned long initrd_end,
113 + void (*free_initrd_mem)(unsigned long, unsigned long))
114 {
115 #ifdef CONFIG_KEXEC
116 unsigned long crashk_start = (unsigned long)__va(crashk_res.start);
117 @@ -516,6 +574,12 @@
118 #endif
119 free_initrd_mem(initrd_start, initrd_end);
120 skip:
121 + ;
122 +}
123 +
124 +static void __init free_initrd(void)
125 +{
126 + _free_initrd(initrd_start, initrd_end, free_initrd_mem);
127 initrd_start = 0;
128 initrd_end = 0;
129 }