From: Anton Blanchard Date: Thu, 8 Jul 2010 19:03:36 +0000 (+0000) Subject: Use ino_size if available X-Git-Tag: yaboot-1.3.17-rc1~11 X-Git-Url: http://git.ozlabs.org/?p=yaboot.git;a=commitdiff_plain;h=d01b3f4172d368eed8e56ab974e6028ce0710591;hp=f9631a4c18c659a6144a697e0c629fe63a44970f Use ino_size if available If ino_size is available and returns > 0, then use it to allocate the initrd. This allows us to claim it in one chunk and avoid all the issues around requiring back to back claims to be contiguous. Signed-off-by: Anton Blanchard Signed-off-by: Tony Breeds --- diff --git a/second/yaboot.c b/second/yaboot.c index b02070e..afa79ee 100644 --- a/second/yaboot.c +++ b/second/yaboot.c @@ -1106,25 +1106,33 @@ yaboot_text_ui(void) } else { #define INITRD_CHUNKSIZE 0x100000 - initrd_base = prom_claim(loadinfo.base+loadinfo.memsize, INITRD_CHUNKSIZE, 0); + unsigned int len = INITRD_CHUNKSIZE; + + /* We add a bit to the actual size so the loop below doesn't think + * there is more to load. + */ + if (file.fs->ino_size && file.fs->ino_size(&file) > 0) + len = file.fs->ino_size(&file) + 0x1000; + + initrd_base = prom_claim_chunk(loadinfo.base+loadinfo.memsize, len, 0); if (initrd_base == (void *)-1) { prom_printf("Claim failed for initrd memory\n"); initrd_base = 0; } else { - initrd_size = file.fs->read(&file, INITRD_CHUNKSIZE, initrd_base); + initrd_size = file.fs->read(&file, len, initrd_base); if (initrd_size == 0) initrd_base = 0; initrd_read = initrd_size; initrd_more = initrd_base; - while (initrd_read == INITRD_CHUNKSIZE ) { /* need to read more? */ - initrd_want = (void *)((unsigned long)initrd_more+INITRD_CHUNKSIZE); - initrd_more = prom_claim(initrd_want, INITRD_CHUNKSIZE, 0); + while (initrd_read == len ) { /* need to read more? */ + initrd_want = (void *)((unsigned long)initrd_more+len); + initrd_more = prom_claim(initrd_want, len, 0); if (initrd_more != initrd_want) { prom_printf("Claim failed for initrd memory at %p rc=%p\n",initrd_want,initrd_more); prom_pause(); break; } - initrd_read = file.fs->read(&file, INITRD_CHUNKSIZE, initrd_more); + initrd_read = file.fs->read(&file, len, initrd_more); DEBUG_F(" block at %p rc=%lu\n",initrd_more,initrd_read); initrd_size += initrd_read; }