===================================================================
@@ -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;
===================================================================
@@ -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;
===================================================================
@@ -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"
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> ---