]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - fs/fs.c
env: Rename common functions related to setenv()
[people/ms/u-boot.git] / fs / fs.c
diff --git a/fs/fs.c b/fs/fs.c
index ac0897d94a08625de0bca16a913d8fcdb6392884..055dffdafdf023fa39bd4865550630537a988652 100644 (file)
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1,17 +1,7 @@
 /*
  * 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 <http://www.gnu.org/licenses/>.
+ * SPDX-License-Identifier:    GPL-2.0
  */
 
 #include <config.h>
 #include <fat.h>
 #include <fs.h>
 #include <sandboxfs.h>
+#include <ubifs_uboot.h>
 #include <asm/io.h>
 #include <div64.h>
 #include <linux/math64.h>
 
 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");
@@ -90,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);
@@ -156,6 +147,21 @@ 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,
@@ -207,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;
@@ -301,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;
@@ -344,7 +348,7 @@ int do_size(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
        if (fs_size(argv[3], &size) < 0)
                return CMD_RET_FAILURE;
 
-       setenv_hex("filesize", size);
+       env_set_hex("filesize", size);
 
        return 0;
 }
@@ -413,7 +417,8 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
        }
        puts("\n");
 
-       setenv_hex("filesize", len_read);
+       env_set_hex("fileaddr", addr);
+       env_set_hex("filesize", len_read);
 
        return 0;
 }
@@ -504,7 +509,7 @@ int do_fs_uuid(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
                return CMD_RET_FAILURE;
 
        if (argc == 4)
-               setenv(argv[3], uuid);
+               env_set(argv[3], uuid);
        else
                printf("%s\n", uuid);
 
@@ -524,7 +529,7 @@ int do_fs_type(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        info = fs_get_info(fs_type);
 
        if (argc == 4)
-               setenv(argv[3], info->name);
+               env_set(argv[3], info->name);
        else
                printf("%s\n", info->name);