]> git.ozlabs.org Git - yaboot.git/commitdiff
Add optional ino_size filesystem backend function
authorAnton Blanchard <anton@samba.org>
Thu, 8 Jul 2010 19:03:35 +0000 (19:03 +0000)
committerTony Breeds <tony@bakeyournoodle.com>
Fri, 16 Jul 2010 05:51:57 +0000 (15:51 +1000)
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 <anton@samba.org>
Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
include/fs.h
second/fs_ext2.c
second/fs_of.c

index 1ff7986af5c9343d8dadb7de55005c2704d06511..7f7847cde4ac91be3c2252c92d3edb625551e182 100644 (file)
@@ -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 d24450d5c92b5b0105a7597907b54ef2ee2f2fc5..c86907ebb89464681194da73c951bc56ad0981eb 100644 (file)
@@ -54,6 +54,7 @@ static int ext2_read( struct boot_file_t*     file,
 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 =
 {
@@ -61,7 +62,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 2e5feb92c57b3e89b364ad162cc69ea47b6d7467..5961cfecd57a09b45702444f7628382541427aed 100644 (file)
@@ -58,6 +58,7 @@ static int of_net_open(struct boot_file_t* file,
                       struct partition_t* part, struct boot_fspec_t* fspec);
 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
@@ -283,6 +285,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"