[U-Boot] [PATCH V4 3/3] fs: add filesystem switch libary, implement ls and fsload commands

Andreas Bießmann
2012-10-30T11:05:37Z

Dear all,

On 22.10.2012 18:43, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
>
> Implement "ls" and "fsload" commands that act like {fat,ext2}{ls,load},
> and transparently handle either file-system. This scheme could easily be
> extended to other filesystem types; I only didn't do it for zfs because
> I don't have any filesystems of that type to test with.
>
> Replace the implementation of {fat,ext[24]}{ls,load} with this new code
> too.
>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>

this patch (namely 045fa1e1142552799ad3203e9e0bc22a11e866ea) seems to
break avr32 on runtime. It seems there is a new array introduced (the
fstypes array in fs/fs.c) which do not provide a relocation method
(CONFIG_NEEDS_MANUAL_RELOC). This is currently only a weak assumption,
but has any other requiring manual relocation m86k, mips, nds32m sparc)
also encountered this problem?

> ---

<snip>

> diff --git a/fs/fs.c b/fs/fs.c
> new file mode 100644
> index 0000000..23ffa25
> --- /dev/null
> +++ b/fs/fs.c
> @@ -0,0 +1,308 @@

<snip>

> +
> +static const struct {
> + int fstype;
> + int (*probe)(void);
> +} fstypes[] = {
> + {
> + .fstype = FS_TYPE_FAT,
> + .probe = fs_probe_fat,
> + },
> + {
> + .fstype = FS_TYPE_EXT,
> + .probe = fs_probe_ext,
> + },
> +};

I currently think this should be manually relocated for those arches
which need the manual relocation.

> +
> +int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype)
> +{
> + int part, i;
> +
> + part = get_device_and_partition(ifname, dev_part_str, &fs_dev_desc,
> + &fs_partition, 1);
> + if (part < 0)
> + return -1;
> +
> + for (i = 0; i < ARRAY_SIZE(fstypes); i++) {
> + if ((fstype != FS_TYPE_ANY) && (fstype != fstypes[i].fstype))
> + continue;
> +
> + if (!fstypes[i].probe()) {
> + fs_type = fstypes[i].fstype;
> + return 0;
> + }
> + }
> +
> + printf("** Unrecognized filesystem type **\n");
> + return -1;
> +}

Best regards

Andreas Bie?mann