From patchwork Fri Jul 9 05:03:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Blanchard X-Patchwork-Id: 58328 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 48487B70A3 for ; Fri, 9 Jul 2010 15:10:42 +1000 (EST) Received: by ozlabs.org (Postfix, from userid 1010) id D060BB6F1A; Fri, 9 Jul 2010 15:10:40 +1000 (EST) Message-Id: <20100709050341.814290290@samba.org> User-Agent: quilt/0.48-1 Date: Fri, 09 Jul 2010 15:03:35 +1000 From: Anton Blanchard To: yaboot-devel@lists.ozlabs.org Subject: [patch 05/14] Add optional ino_size filesystem backend function References: <20100709050330.507659708@samba.org> Content-Disposition: inline; filename=ino_size X-BeenThere: yaboot-devel@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Technical and development discussion regarding yaboot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: yaboot-devel-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Errors-To: yaboot-devel-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Our initrd loader is very fragile and the main reason is that it doesn't know the size of the initrd. We end up claiming 1MB at a time and failing completely if the new region isn't contiguous with the previous one. Now that firmware is often at 32MB (real-base), and kernels have grown much bigger (CONFIG_FUNCTION_TRACER and CONFIG_RELOCATABLE are two big reasons), we see this failure a lot. Create a function ino_size (similar to the silo bootloader) and implement it for tftp and ext2 backends. Signed-off-by: Anton Blanchard Index: yaboot/include/fs.h =================================================================== --- yaboot.orig/include/fs.h 2010-07-09 14:36:45.000000000 +1000 +++ yaboot/include/fs.h 2010-07-09 14:43:56.000000000 +1000 @@ -44,6 +44,8 @@ struct fs_t { unsigned int newpos); int (*close)( struct boot_file_t* file); + + unsigned int (*ino_size)(struct boot_file_t *file); }; extern const struct fs_t *fs_of; Index: yaboot/second/fs_ext2.c =================================================================== --- yaboot.orig/second/fs_ext2.c 2010-07-09 14:36:45.000000000 +1000 +++ yaboot/second/fs_ext2.c 2010-07-09 14:43:56.000000000 +1000 @@ -55,6 +55,7 @@ static int ext2_read( struct boot_file_t static int ext2_seek( struct boot_file_t* file, unsigned int newpos); static int ext2_close( struct boot_file_t* file); +static unsigned int ext2_ino_size(struct boot_file_t *file); struct fs_t ext2_filesystem = { @@ -62,7 +63,8 @@ struct fs_t ext2_filesystem = ext2_open, ext2_read, ext2_seek, - ext2_close + ext2_close, + ext2_ino_size, }; /* IO manager structure for the ext2 library */ @@ -564,6 +566,16 @@ ext2_close( struct boot_file_t* file) return 0; } +static unsigned int ext2_ino_size(struct boot_file_t *file) +{ + struct ext2_inode ei; + + if (ext2fs_read_inode(fs, file->inode, &ei)) + return 0; + + return ei.i_size; +} + static errcode_t linux_open (const char *name, int flags, io_channel * channel) { io_channel io; Index: yaboot/second/fs_of.c =================================================================== --- yaboot.orig/second/fs_of.c 2010-07-09 14:36:45.000000000 +1000 +++ yaboot/second/fs_of.c 2010-07-09 14:43:57.000000000 +1000 @@ -58,6 +58,7 @@ static int of_net_open(struct boot_file_ struct partition_t* part, const char* file_name); static int of_net_read(struct boot_file_t* file, unsigned int size, void* buffer); static int of_net_seek(struct boot_file_t* file, unsigned int newpos); +static unsigned int of_net_ino_size(struct boot_file_t* file); struct fs_t of_filesystem = @@ -75,7 +76,8 @@ struct fs_t of_net_filesystem = of_net_open, of_net_read, of_net_seek, - of_close + of_close, + of_net_ino_size, }; static int @@ -243,6 +245,12 @@ of_close(struct boot_file_t* file) return 0; } +static unsigned int +of_net_ino_size(struct boot_file_t* file) +{ + return file->len; +} + /* * Local variables: * c-file-style: "k&r"