]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ubi: allow to read from volume with offset
authorAlexey Romanov <avromanov@salutedevices.com>
Thu, 18 Jul 2024 05:45:23 +0000 (08:45 +0300)
committerMichael Trimarchi <michael@amarulasolutions.com>
Thu, 8 Aug 2024 07:27:55 +0000 (09:27 +0200)
Now user can pass an additional parameter 'offset'
to ubi_volume_read() function.

Signed-off-by: Alexey Romanov <avromanov@salutedevices.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Acked-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
cmd/ubi.c
env/ubi.c
include/ubi_uboot.h

index 92998af2b02e4fb3d99f38228d82c826ee1e7a9a..4bf7c099ddea221ac42fde5b68a29a2aa8891329 100644 (file)
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -428,13 +428,13 @@ int ubi_volume_write(char *volume, void *buf, size_t size)
        return ubi_volume_begin_write(volume, buf, size, size);
 }
 
-int ubi_volume_read(char *volume, char *buf, size_t size)
+int ubi_volume_read(char *volume, char *buf, loff_t offset, size_t size)
 {
        int err, lnum, off, len, tbuf_size;
        void *tbuf;
        unsigned long long tmp;
        struct ubi_volume *vol;
-       loff_t offp = 0;
+       loff_t offp = offset;
        size_t len_read;
 
        vol = ubi_find_volume(volume);
@@ -795,7 +795,7 @@ static int do_ubi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
                }
 
                if (argc == 3) {
-                       return ubi_volume_read(argv[3], (char *)addr, size);
+                       return ubi_volume_read(argv[3], (char *)addr, 0, size);
                }
        }
 
index 0c3e93c2bf2d6397c1a7fac4c7672c4f2b548c2d..22f2cafcfbd83da303d4b5508cee2fee3b2b63f6 100644 (file)
--- a/env/ubi.c
+++ b/env/ubi.c
@@ -134,14 +134,14 @@ static int env_ubi_load(void)
                return -EIO;
        }
 
-       read1_fail = ubi_volume_read(CONFIG_ENV_UBI_VOLUME, (void *)tmp_env1,
+       read1_fail = ubi_volume_read(CONFIG_ENV_UBI_VOLUME, (void *)tmp_env1, 0,
                                     CONFIG_ENV_SIZE);
        if (read1_fail)
                printf("\n** Unable to read env from %s:%s **\n",
                       CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME);
 
        read2_fail = ubi_volume_read(CONFIG_ENV_UBI_VOLUME_REDUND,
-                                    (void *)tmp_env2, CONFIG_ENV_SIZE);
+                                    (void *)tmp_env2, 0, CONFIG_ENV_SIZE);
        if (read2_fail)
                printf("\n** Unable to read redundant env from %s:%s **\n",
                       CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME_REDUND);
@@ -171,7 +171,7 @@ static int env_ubi_load(void)
                return -EIO;
        }
 
-       if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, buf, CONFIG_ENV_SIZE)) {
+       if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, buf, 0, CONFIG_ENV_SIZE)) {
                printf("\n** Unable to read env from %s:%s **\n",
                       CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME);
                env_set_default(NULL, 0);
index d7a8851094bc463d04ebb6f8afa4c6a6ccc7f2d1..a4be0feabbd3a62ea56b3e1fcd000ac9d2375e7a 100644 (file)
@@ -49,7 +49,7 @@ extern int ubi_init(void);
 extern void ubi_exit(void);
 extern int ubi_part(char *part_name, const char *vid_header_offset);
 extern int ubi_volume_write(char *volume, void *buf, size_t size);
-extern int ubi_volume_read(char *volume, char *buf, size_t size);
+extern int ubi_volume_read(char *volume, char *buf, loff_t offset, size_t size);
 
 extern struct ubi_device *ubi_devices[];
 int cmd_ubifs_mount(char *vol_name);