uboot-envtools: update to 2015.10
[openwrt.git] / package / boot / uboot-envtools / patches / 300-support-env-in-ubivol-chardev.patch
index 96a95f7..75d3804 100644 (file)
@@ -1,4 +1,4 @@
-From ee2c9e3aef32c05b1d7891858baff19bffed1652 Mon Sep 17 00:00:00 2001
+From 6e2630a0fc872d0db34157972f6dc3941f6d66dd Mon Sep 17 00:00:00 2001
 From: Daniel Golle <daniel@makrotopia.org>
 Date: Mon, 19 May 2014 21:38:01 +0200
 Subject: [PATCH] tools/env: add support for env in ubi volume chardev
@@ -6,30 +6,28 @@ Subject: [PATCH] tools/env: add support for env in ubi volume chardev
 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
 ---
  tools/env/Makefile |  5 ++++
- tools/env/fw_env.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++--------
- 2 files changed, 69 insertions(+), 10 deletions(-)
+ tools/env/fw_env.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++-------
+ 2 files changed, 71 insertions(+), 10 deletions(-)
 
-diff --git a/tools/env/Makefile b/tools/env/Makefile
-index f5368bc..d006a93 100644
 --- a/tools/env/Makefile
 +++ b/tools/env/Makefile
-@@ -20,6 +20,11 @@ ifeq ($(MTD_VERSION),old)
+@@ -24,6 +24,13 @@ ifeq ($(MTD_VERSION),old)
  HOST_EXTRACFLAGS += -DMTD_OLD
  endif
  
 +ifeq ($(UBI),y)
 +HOST_EXTRACFLAGS += -DUBI
 +HOST_LOADLIBES = "-Wl,--gc-sections,-lubi-utils"
++else
++HOST_LOADLIBES = "-Wl,--gc-sections"
 +endif
 +
  always := fw_printenv
- hostprogs-y := fw_printenv_unstripped
+ hostprogs-y := fw_printenv
  
-diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
-index 30d5b03..5c0acd5 100644
 --- a/tools/env/fw_env.c
 +++ b/tools/env/fw_env.c
-@@ -29,6 +29,9 @@
+@@ -31,6 +31,9 @@
  # include <mtd/mtd-user.h>
  #endif
  
@@ -39,7 +37,7 @@ index 30d5b03..5c0acd5 100644
  #include "fw_env.h"
  
  #include <aes.h>
-@@ -809,6 +812,11 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count,
+@@ -811,6 +814,11 @@ static int flash_write_buf (int dev, int
        off_t top_of_range;     /* end of the last block we may use */
        loff_t blockstart;      /* running start of the current block -
                                   MEMGETBADBLOCK needs 64 bits */
@@ -51,7 +49,7 @@ index 30d5b03..5c0acd5 100644
        int rc;
  
        /*
-@@ -914,7 +922,30 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count,
+@@ -916,7 +924,30 @@ static int flash_write_buf (int dev, int
                        continue;
                }
  
@@ -83,7 +81,7 @@ index 30d5b03..5c0acd5 100644
                        erase.start = blockstart;
                        ioctl(fd, MEMUNLOCK, &erase);
                        /* These do not need an explicit erase cycle */
-@@ -931,7 +962,8 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count,
+@@ -933,7 +964,8 @@ static int flash_write_buf (int dev, int
                        fprintf (stderr,
                                 "Seek error on %s: %s\n",
                                 DEVNAME (dev), strerror (errno));
@@ -93,7 +91,7 @@ index 30d5b03..5c0acd5 100644
                }
  
  #ifdef DEBUG
-@@ -941,10 +973,11 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count,
+@@ -943,10 +975,11 @@ static int flash_write_buf (int dev, int
                if (write (fd, data + processed, erasesize) != erasesize) {
                        fprintf (stderr, "Write error on %s: %s\n",
                                 DEVNAME (dev), strerror (errno));
@@ -107,17 +105,19 @@ index 30d5b03..5c0acd5 100644
                        ioctl(fd, MEMLOCK, &erase);
  
                processed  += erasesize;
-@@ -955,6 +988,9 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count,
+@@ -957,6 +990,11 @@ static int flash_write_buf (int dev, int
        if (write_total > count)
                free (data);
  
 +out:
++#ifdef UBI
 +      if (libubi)
 +              libubi_close(libubi);
++#endif
        return processed;
  }
  
-@@ -1066,12 +1102,8 @@ static int flash_read (int fd)
+@@ -1068,12 +1106,8 @@ static int flash_read (int fd)
  
        if (S_ISCHR(st.st_mode)) {
                rc = ioctl(fd, MEMGETINFO, &mtdinfo);
@@ -132,7 +132,7 @@ index 30d5b03..5c0acd5 100644
                    mtdinfo.type != MTD_NANDFLASH &&
                    mtdinfo.type != MTD_DATAFLASH &&
                    mtdinfo.type != MTD_UBIVOLUME) {
-@@ -1079,6 +1111,28 @@ static int flash_read (int fd)
+@@ -1081,6 +1115,28 @@ static int flash_read (int fd)
                                 mtdinfo.type, DEVNAME(dev_current));
                        return -1;
                }
@@ -161,6 +161,3 @@ index 30d5b03..5c0acd5 100644
        } else {
                memset(&mtdinfo, 0, sizeof(mtdinfo));
                mtdinfo.type = MTD_ABSENT;
--- 
-1.9.2
-