Patchwork [05/14] Add optional ino_size filesystem backend function

login
register
mail settings
Submitter Anton Blanchard
Date July 9, 2010, 5:03 a.m.
Message ID <20100709050341.814290290@samba.org>
Download mbox | patch
Permalink /patch/58328/
State Changes Requested
Headers show

Comments

Anton Blanchard - July 9, 2010, 5:03 a.m.
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>
---

Patch

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"