X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=fs%2Ffs.c;h=595ff1fe69b5bc446ebd32c3d7badd7726348d63;hb=c9607c932585e6757ad1c378751030c2a4234227;hp=ddd751c9cccc1d4c30ed6d29bf1d55581e208ab7;hpb=97cdf64026c7d749dd7a5c0dbaba7a60a7292ac9;p=u-boot diff --git a/fs/fs.c b/fs/fs.c index ddd751c9cc..595ff1fe69 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -1,38 +1,30 @@ /* * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * SPDX-License-Identifier: GPL-2.0 */ #include #include #include +#include #include #include #include #include #include +#include #include #include #include DECLARE_GLOBAL_DATA_PTR; -static block_dev_desc_t *fs_dev_desc; +static struct blk_desc *fs_dev_desc; static disk_partition_t fs_partition; static int fs_type = FS_TYPE_ANY; -static inline int fs_probe_unsupported(block_dev_desc_t *fs_dev_desc, +static inline int fs_probe_unsupported(struct blk_desc *fs_dev_desc, disk_partition_t *fs_partition) { printf("** Unrecognized filesystem type **\n"); @@ -79,6 +71,7 @@ static inline int fs_uuid_unsupported(char *uuid_str) struct fstype_info { int fstype; + char *name; /* * Is it legal to pass NULL as .probe()'s fs_dev_desc parameter? This * should be false in most cases. For "virtual" filesystems which @@ -88,7 +81,7 @@ struct fstype_info { * filesystem. */ bool null_dev_desc_ok; - int (*probe)(block_dev_desc_t *fs_dev_desc, + int (*probe)(struct blk_desc *fs_dev_desc, disk_partition_t *fs_partition); int (*ls)(const char *dirname); int (*exists)(const char *filename); @@ -105,6 +98,7 @@ static struct fstype_info fstypes[] = { #ifdef CONFIG_FS_FAT { .fstype = FS_TYPE_FAT, + .name = "fat", .null_dev_desc_ok = false, .probe = fat_set_blk_dev, .close = fat_close, @@ -123,6 +117,7 @@ static struct fstype_info fstypes[] = { #ifdef CONFIG_FS_EXT4 { .fstype = FS_TYPE_EXT, + .name = "ext4", .null_dev_desc_ok = false, .probe = ext4fs_probe, .close = ext4fs_close, @@ -141,6 +136,7 @@ static struct fstype_info fstypes[] = { #ifdef CONFIG_SANDBOX { .fstype = FS_TYPE_SANDBOX, + .name = "sandbox", .null_dev_desc_ok = true, .probe = sandbox_fs_set_blk_dev, .close = sandbox_fs_close, @@ -151,9 +147,25 @@ static struct fstype_info fstypes[] = { .write = fs_write_sandbox, .uuid = fs_uuid_unsupported, }, +#endif +#ifdef CONFIG_CMD_UBIFS + { + .fstype = FS_TYPE_UBIFS, + .name = "ubifs", + .null_dev_desc_ok = true, + .probe = ubifs_set_blk_dev, + .close = ubifs_close, + .ls = ubifs_ls, + .exists = ubifs_exists, + .size = ubifs_size, + .read = ubifs_read, + .write = fs_write_unsupported, + .uuid = fs_uuid_unsupported, + }, #endif { .fstype = FS_TYPE_ANY, + .name = "unsupported", .null_dev_desc_ok = true, .probe = fs_probe_unsupported, .close = fs_close_unsupported, @@ -190,6 +202,7 @@ int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype) if (!relocated) { for (i = 0, info = fstypes; i < ARRAY_SIZE(fstypes); i++, info++) { + info->name += gd->reloc_off; info->probe += gd->reloc_off; info->close += gd->reloc_off; info->ls += gd->reloc_off; @@ -200,7 +213,7 @@ int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype) } #endif - part = get_device_and_partition(ifname, dev_part_str, &fs_dev_desc, + part = blk_get_device_part_str(ifname, dev_part_str, &fs_dev_desc, &fs_partition, 1); if (part < 0) return -1; @@ -294,10 +307,8 @@ int fs_read(const char *filename, ulong addr, loff_t offset, loff_t len, unmap_sysmem(buf); /* If we requested a specific number of bytes, check we got it */ - if (ret == 0 && len && *actread != len) { - printf("** Unable to read file %s **\n", filename); - ret = -1; - } + if (ret == 0 && len && *actread != len) + printf("** %s shorter than offset + len **\n", filename); fs_close(); return ret; @@ -406,6 +417,7 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], } puts("\n"); + setenv_hex("fileaddr", addr); setenv_hex("filesize", len_read); return 0; @@ -503,3 +515,24 @@ int do_fs_uuid(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], return CMD_RET_SUCCESS; } + +int do_fs_type(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + struct fstype_info *info; + + if (argc < 3 || argc > 4) + return CMD_RET_USAGE; + + if (fs_set_blk_dev(argv[1], argv[2], FS_TYPE_ANY)) + return 1; + + info = fs_get_info(fs_type); + + if (argc == 4) + setenv(argv[3], info->name); + else + printf("%s\n", info->name); + + return CMD_RET_SUCCESS; +} +