X-Git-Url: http://git.ozlabs.org/?p=yaboot.git;a=blobdiff_plain;f=second%2Ffs_ext2.c;h=41a3c79cce2096ac513e9135ccb677b072a67f4f;hp=67571f28fadda668e967cde6e263a2ce37dda0a8;hb=0298b541149eca4c30749085694526a0040d0982;hpb=082b8310e3f92ea8da0b7011549bd86c9fd4ce95 diff --git a/second/fs_ext2.c b/second/fs_ext2.c index 67571f2..41a3c79 100644 --- a/second/fs_ext2.c +++ b/second/fs_ext2.c @@ -46,15 +46,15 @@ typedef int FILE; #include "ext2fs/ext2fs.h" static int ext2_open( struct boot_file_t* file, - const char* dev_name, struct partition_t* part, - const char* file_name); + struct boot_fspec_t* fspec); static int ext2_read( struct boot_file_t* file, unsigned int size, void* buffer); static int ext2_seek( struct boot_file_t* file, unsigned int newpos); static int ext2_close( struct boot_file_t* file); +static int ext2_ino_size(struct boot_file_t *file, unsigned int *size); struct fs_t ext2_filesystem = { @@ -62,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 */ @@ -108,7 +109,7 @@ static unsigned long read_total; static unsigned long read_max; static struct boot_file_t* read_cur_file; static errcode_t read_result; -static char* read_buffer; +static unsigned char* read_buffer; static int read_dump_range(void); static int read_iterator(ext2_filsys fs, blk_t *blocknr, int lg_block, void *private); @@ -123,14 +124,15 @@ void com_err (const char *a, long i, const char *fmt,...) static int ext2_open( struct boot_file_t* file, - const char* dev_name, struct partition_t* part, - const char* file_name) + struct boot_fspec_t* fspec) { int result = 0; int error = FILE_ERR_NOTFOUND; static char buffer[1024]; int ofopened = 0; + char *dev_name = fspec->dev; + char *file_name = fspec->file; DEBUG_ENTER; DEBUG_OPEN; @@ -139,7 +141,8 @@ ext2_open( struct boot_file_t* file, DEBUG_LEAVE(FILE_ERR_FSBUSY); return FILE_ERR_FSBUSY; } - if (file->device_kind != FILE_DEVICE_BLOCK) { + if (file->device_kind != FILE_DEVICE_BLOCK + && file->device_kind != FILE_DEVICE_ISCSI) { DEBUG_LEAVE(FILE_ERR_BADDEV); return FILE_ERR_BADDEV; } @@ -564,6 +567,17 @@ ext2_close( struct boot_file_t* file) return 0; } +static int ext2_ino_size(struct boot_file_t *file, unsigned int *size) +{ + struct ext2_inode ei; + + if (ext2fs_read_inode(fs, file->inode, &ei)) + return FILE_IOERR; + + *size = ei.i_size; + return FILE_ERR_OK; +} + static errcode_t linux_open (const char *name, int flags, io_channel * channel) { io_channel io;