Skip to contentSkip to conversation

File system API: Read file size without reading file contents

U-Boot Frank Bormann 2 participants 2 messages Jan 22, 2014 – Jan 23, 2014

lore
Share & tools
lore
#0 lore raw

Hi All,

I would like to read a configuration file from an ext4 disk partition in u-boot and parse its contents. In order to malloc a buffer of sufficient size to read the entire file contents, I would need to know the file size before actually reading it.

As far as I understand, the current struct fstype_info API does not allow me to do that (other than parsing the ls output). While the read function does in fact return the file size, it does so only after the file was already read into memory. Lower level functions for ext4 such as ext4fs_open() do however provide this information before reading the file contents. Unless there is something that I have missed, how would you feel about me adding a .size function to the struct fstype_info API to expose this information on the top-level API?

Thanks,
Frank

#1 lore raw

+Stephen

Hi Frank,

Quoted 7 lines · Frank Bormann

Hi All,

I would like to read a configuration file from an ext4 disk partition in u-boot and parse its contents. In order to malloc a buffer of sufficient size to read the entire file contents, I would need to know the file size before actually reading it.

Quoted 9 lines

As far as I understand, the current struct fstype_info API does not allow me to do that (other than parsing the ls output). While the read function does in fact return the file size, it does so only after the file was already read into memory. Lower level functions for ext4 such as ext4fs_open() do however provide this information before reading the file contents. Unless there is something that I have missed, how would you feel about me adding a .size function to the struct fstype_info API to expose this information on the top-level API?

Perhaps .filesize, but this sounds reasonable to me.

Regards,
Simon

Quoted 9 lines

Thanks,
Frank

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot