[packages] mtd-utils: upgrade to latest git version

Signed-off-by: Luka Perkov <luka@openwrt.org>

git-svn-id: svn://svn.openwrt.org/openwrt/packages@38300 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
luka 2013-10-04 03:15:02 +00:00
parent a7d9ad0691
commit f7ac493e12
9 changed files with 56 additions and 364 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2009-2010 OpenWrt.org
# Copyright (C) 2009-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@ -8,8 +8,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mtd-utils
PKG_REV:=5319b84974fcb71504aed2d1b8285e9c0a4a4bb8
PKG_VERSION:=1.4.5
PKG_REV:=ab8c6fb93ce9db0f09401c4b819b0b277dc00340
PKG_VERSION:=1.5.0
PKG_RELEASE:=1
PKG_INSTALL:=1
@ -28,17 +28,18 @@ FILES:= \
docfdisk \
flash_erase \
flash_eraseall:+mtd-utils-flash-erase \
flash_info \
flash_lock \
flash_otp_dump \
flash_otp_info \
flash_otp_lock \
flash_otp_write \
flash_unlock \
flashcp \
ftl_check \
ftl_format \
jffs2dump \
jffs2reader \
mkfs.jffs2:+zlib \
mkfs.ubifs:+libuuid:+zlib \
mkfs.ubifs:+libuuid:+liblzo:+zlib \
mtd_debug \
mtdinfo \
nanddump \
@ -100,9 +101,7 @@ MAKE_FLAGS += \
define PartInstall
define Package/mtd-utils-$(subst _,-,$(firstword $(subst :, ,$(1))))/install
$(INSTALL_DIR) \
$$(1)/usr/sbin
$(INSTALL_DIR) $$(1)/usr/sbin
$(INSTALL_BIN) \
$(PKG_INSTALL_DIR)/usr/sbin/$(firstword $(subst :, ,$(1))) \
$$(1)/usr/sbin/

View File

@ -0,0 +1,19 @@
--- a/include/common.h
+++ b/include/common.h
@@ -122,10 +122,12 @@
}
if (strcmp("\n", line) != 0) {
- switch (rpmatch(line)) {
- case 0: ret = false; break;
- case 1: ret = true; break;
- case -1:
+ switch (line[0]) {
+ case 'N':
+ case 'n': ret = false; break;
+ case 'Y':
+ case 'y': ret = true; break;
+ default:
puts("unknown response; please try again");
continue;
}

View File

@ -1,73 +0,0 @@
--- a/mtd_debug.c
+++ b/mtd_debug.c
@@ -238,6 +238,7 @@ int showinfo (int fd)
int i,err,n;
struct mtd_info_user mtd;
static struct region_info_user region[1024];
+ int iNumOfBadBlocks = 0;
err = getmeminfo (fd,&mtd);
if (err < 0)
@@ -330,6 +331,11 @@ int showinfo (int fd)
printf ("\nmtd.oobsize = ");
printsize (mtd.oobsize);
+ printf ("\nmtd.badblockscount = ");
+ iNumOfBadBlocks = get_bb_number(fd, &mtd);
+ if (iNumOfBadBlocks > -1)
+ printf ("%d", iNumOfBadBlocks);
+
printf ("\n"
"regions = %d\n"
"\n",
@@ -349,6 +355,50 @@ int showinfo (int fd)
return (0);
}
+int get_bb_number(int fd, struct mtd_info_user *meminfo)
+{
+ int isNAND = (meminfo->type == MTD_NANDFLASH);
+ int ibbCounter = 0;
+ /* Last 4 blocks of any MTD device are protected and
+ MTD reports them as badblocks. */
+ int usablesize = meminfo->size - (4 * meminfo->erasesize);
+ erase_info_t erase;
+ erase.length = meminfo->erasesize;
+
+ for (erase.start = 0;
+ erase.start < usablesize;
+ erase.start += meminfo->erasesize)
+ {
+ loff_t offset = erase.start;
+ int ret = ioctl(fd, MEMGETBADBLOCK, &offset);
+
+ if (ret > 0)
+ {
+ ibbCounter++;
+ continue;
+ }
+ else if (ret < 0)
+ {
+ if (errno == EOPNOTSUPP)
+ {
+ if (isNAND)
+ {
+ printf("Bad block check not available");
+ return -1;
+ }
+ }
+ else
+ {
+ printf("MTD get bad block failed: %s",
+ strerror(errno));
+ return -1;
+ }
+ }
+ }
+
+ return ibbCounter;
+}
+
void showusage(void)
{
fprintf (stderr,

View File

@ -1,25 +1,23 @@
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
@@ -3,7 +3,7 @@
# -*- sh -*-
VERSION = 1.5.0
-CPPFLAGS += -I./include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS)
+CPPFLAGS += -I./include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS) -I./include/linux/lzma
-CPPFLAGS += -D_GNU_SOURCE -I./include -I$(BUILDDIR)/include -I./ubi-utils/include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS)
+CPPFLAGS += -D_GNU_SOURCE -I./include -I$(BUILDDIR)/include -I./ubi-utils/include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS) -I./include/linux/lzma
ifeq ($(WITHOUT_XATTR), 1)
CPPFLAGS += -DWITHOUT_XATTR
@@ -50,7 +50,9 @@ $(SYMLINKS):
ln -sf ../fs/jffs2/$@ $@
$(BUILDDIR)/mkfs.jffs2: $(addprefix $(BUILDDIR)/,\
- compr_rtime.o mkfs.jffs2.o compr_zlib.o compr_lzo.o \
+ compr_rtime.o mkfs.jffs2.o compr_zlib.o \
+ $(if $(WITHOUT_LZO),,compr_lzo.o) \
+ compr_lzma.o lzma/LzFind.o lzma/LzmaEnc.o lzma/LzmaDec.o \
compr.o rbtree.o)
@@ -84,7 +84,7 @@
#
# Utils in top level
#
-obj-mkfs.jffs2 = compr_rtime.o compr_zlib.o compr_lzo.o compr.o rbtree.o
+obj-mkfs.jffs2 = compr_rtime.o compr_zlib.o $(if $(WITHOUT_LZO),,compr_lzo.o) compr_lzma.o lzma/LzFind.o lzma/LzmaEnc.o lzma/LzmaDec.o compr.o rbtree.o
LDFLAGS_mkfs.jffs2 = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
LDLIBS_mkfs.jffs2 = -lz $(LZOLDLIBS)
--- a/compr.c
+++ b/compr.c
@@ -520,6 +520,9 @@ int jffs2_compressors_init(void)
@ -27,7 +25,7 @@
jffs2_lzo_init();
#endif
+#ifdef CONFIG_JFFS2_LZMA
+ jffs2_lzma_init();
+ jffs2_lzma_init();
+#endif
return 0;
}
@ -37,7 +35,7 @@
jffs2_lzo_exit();
#endif
+#ifdef CONFIG_JFFS2_LZMA
+ jffs2_lzma_exit();
+ jffs2_lzma_exit();
+#endif
return 0;
}
@ -120,7 +118,7 @@
+ return -1;
+ }
+
+ return 0;
+ return 0;
+}
+
+STATIC int jffs2_lzma_compress(unsigned char *data_in, unsigned char *cpage_out,
@ -176,26 +174,26 @@
+
+int INIT jffs2_lzma_init(void)
+{
+ int ret;
+ int ret;
+ CLzmaEncProps props;
+ LzmaEncProps_Init(&props);
+
+ props.dictSize = LZMA_BEST_DICT(0x2000);
+ props.level = LZMA_BEST_LEVEL;
+ props.lc = LZMA_BEST_LC;
+ props.lp = LZMA_BEST_LP;
+ props.pb = LZMA_BEST_PB;
+ props.fb = LZMA_BEST_FB;
+ props.dictSize = LZMA_BEST_DICT(0x2000);
+ props.level = LZMA_BEST_LEVEL;
+ props.lc = LZMA_BEST_LC;
+ props.lp = LZMA_BEST_LP;
+ props.pb = LZMA_BEST_PB;
+ props.fb = LZMA_BEST_FB;
+
+ ret = lzma_alloc_workspace(&props);
+ if (ret < 0)
+ return ret;
+ if (ret < 0)
+ return ret;
+
+ ret = jffs2_register_compressor(&jffs2_lzma_comp);
+ if (ret)
+ lzma_free_workspace();
+
+ return ret;
+ return ret;
+}
+
+void jffs2_lzma_exit(void)
@ -262,16 +260,16 @@
+
+static void *p_lzma_malloc(void *p, size_t size)
+{
+ if (size == 0)
+ return NULL;
+ if (size == 0)
+ return NULL;
+
+ return LZMA_MALLOC(size);
+ return LZMA_MALLOC(size);
+}
+
+static void p_lzma_free(void *p, void *address)
+{
+ if (address != NULL)
+ LZMA_FREE(address);
+ if (address != NULL)
+ LZMA_FREE(address);
+}
+
+static ISzAlloc lzma_alloc = {p_lzma_malloc, p_lzma_free};

View File

@ -1,11 +0,0 @@
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -7,7 +7,7 @@ SUBDIRS =
# CFLAGS += -Werror
CPPFLAGS += -I../include
LIBS = libmtd
-TARGETS = libmtd.a
+override TARGETS = libmtd.a
include ../common.mk

View File

@ -1,119 +0,0 @@
--- a/mkfs.ubifs/compr.c
+++ b/mkfs.ubifs/compr.c
@@ -24,7 +24,6 @@
#include <stdio.h>
#include <stdint.h>
#include <string.h>
-#include <lzo/lzo1x.h>
#include <linux/types.h>
#define crc32 __zlib_crc32
@@ -35,7 +34,6 @@
#include "ubifs-media.h"
#include "mkfs.ubifs.h"
-static void *lzo_mem;
static unsigned long long errcnt = 0;
static struct ubifs_info *c = &info_;
@@ -86,6 +84,25 @@ static int zlib_deflate(void *in_buf, si
return 0;
}
+#ifndef WITHOUT_LZO
+#include <lzo/lzo1x.h>
+
+static void *lzo_mem;
+
+static int lzo_init(void)
+{
+ lzo_mem = malloc(LZO1X_999_MEM_COMPRESS);
+ if (!lzo_mem)
+ return -1;
+
+ return 0;
+}
+
+static void lzo_fini(void)
+{
+ free(lzo_mem);
+}
+
static int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
size_t *out_len)
{
@@ -103,6 +120,12 @@ static int lzo_compress(void *in_buf, si
return 0;
}
+#else
+static inline int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
+ size_t *out_len) { return -1; }
+static inline int lzo_init(void) { return 0; }
+static inline void lzo_fini(void) { }
+#endif
static int no_compress(void *in_buf, size_t in_len, void *out_buf,
size_t *out_len)
@@ -123,7 +146,6 @@ static int favor_lzo_compress(void *in_b
lzo_len = zlib_len = *out_len;
lzo_ret = lzo_compress(in_buf, in_len, out_buf, &lzo_len);
zlib_ret = zlib_deflate(in_buf, in_len, zlib_buf, &zlib_len);
-
if (lzo_ret && zlib_ret)
/* Both compressors failed */
return -1;
@@ -198,23 +220,28 @@ int compress_data(void *in_buf, size_t i
int init_compression(void)
{
- lzo_mem = malloc(LZO1X_999_MEM_COMPRESS);
- if (!lzo_mem)
- return -1;
+ int ret;
+
+ ret = lzo_init();
+ if (ret)
+ goto err;
zlib_buf = malloc(UBIFS_BLOCK_SIZE * WORST_COMPR_FACTOR);
- if (!zlib_buf) {
- free(lzo_mem);
- return -1;
- }
+ if (!zlib_buf)
+ goto err_lzo;
return 0;
+
+err_lzo:
+ lzo_fini();
+err:
+ return ret;
}
void destroy_compression(void)
{
free(zlib_buf);
- free(lzo_mem);
+ lzo_fini();
if (errcnt)
fprintf(stderr, "%llu compression errors occurred\n", errcnt);
}
--- a/mkfs.ubifs/Makefile
+++ b/mkfs.ubifs/Makefile
@@ -6,7 +6,13 @@ ALL_SOURCES=*.[ch] hashtable/*.[ch]
TARGETS = mkfs.ubifs
-LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid -L$(BUILDDIR)/../ubi-utils/ -lubi
+ifeq ($(WITHOUT_LZO), 1)
+ CPPFLAGS += -DWITHOUT_LZO
+else
+ LZOLDLIBS = -llzo2
+endif
+
+LDLIBS_mkfs.ubifs = -lz $(LZOLDLIBS) -lm -luuid -L$(BUILDDIR)/../ubi-utils/ -lubi
LDLIBS_mkfs.ubifs += -L$(BUILDDIR)/../lib -lmtd
LDLIBS_mkfs.ubifs += $(ZLIBLDFLAGS) $(LZOLDFLAGS)

View File

@ -1,28 +0,0 @@
--- a/mkfs.ubifs/mkfs.ubifs.c
+++ b/mkfs.ubifs/mkfs.ubifs.c
@@ -109,7 +109,7 @@ static char *output;
static int out_fd;
static int out_ubi;
static int squash_owner;
-static int squash_rino_perm;
+static int squash_rino_perm = -1;
/* The 'head' (position) which nodes are written */
static int head_lnum;
@@ -683,6 +683,7 @@ static int get_options(int argc, char**a
printf("WARNING: --squash-rino-perm is depricated, do not use it\n");
break;
case 'q':
+ squash_rino_perm = 0;
printf("WARNING: --nosquash-rino-perm is depricated, do not use it\n");
break;
}
@@ -1686,7 +1687,7 @@ static int write_data(void)
if (err)
return sys_err_msg("bad root file-system directory '%s'",
root);
- if (squash_rino_perm) {
+ if (squash_rino_perm > 0) {
root_st.st_uid = root_st.st_gid = 0;
root_st.st_mode = mode;
}

View File

@ -1,61 +0,0 @@
--- a/mkfs.ubifs/mkfs.ubifs.c
+++ b/mkfs.ubifs/mkfs.ubifs.c
@@ -110,6 +110,7 @@ static int out_fd;
static int out_ubi;
static int squash_owner;
static int squash_rino_perm = -1;
+static int overwrite_volume;
/* The 'head' (position) which nodes are written */
static int head_lnum;
@@ -132,7 +133,7 @@ static struct inum_mapping **hash_table;
/* Inode creation sequence number */
static unsigned long long creat_sqnum;
-static const char *optstring = "d:r:m:o:D:h?vVe:c:g:f:Fp:k:x:X:j:R:l:j:UQq";
+static const char *optstring = "d:r:m:o:OD:h?vVe:c:g:f:Fp:k:x:X:j:R:l:j:UQq";
static const struct option longopts[] = {
{"root", 1, NULL, 'r'},
@@ -140,6 +141,7 @@ static const struct option longopts[] =
{"leb-size", 1, NULL, 'e'},
{"max-leb-cnt", 1, NULL, 'c'},
{"output", 1, NULL, 'o'},
+ {"overwrite", 0, NULL, 'O'},
{"devtable", 1, NULL, 'D'},
{"help", 0, NULL, 'h'},
{"verbose", 0, NULL, 'v'},
@@ -176,6 +178,7 @@ static const char *helptext =
"-e, --leb-size=SIZE logical erase block size\n"
"-c, --max-leb-cnt=COUNT maximum logical erase block count\n"
"-o, --output=FILE output to FILE\n"
+"-O, --overwrite force overwriting of the existing volume\n"
"-j, --jrn-size=SIZE journal size\n"
"-R, --reserved=SIZE how much space should be reserved for the super-user\n"
"-x, --compr=TYPE compression type - \"lzo\", \"favor_lzo\", \"zlib\" or\n"
@@ -594,6 +597,9 @@ static int get_options(int argc, char**a
case 'o':
output = strdup(optarg);
break;
+ case 'O':
+ overwrite_volume = 1;
+ break;
case 'D':
tbl_file = optarg;
if (stat(tbl_file, &st) < 0)
@@ -2180,8 +2186,13 @@ static int open_target(void)
if (ubi_set_property(out_fd, UBI_PROP_DIRECT_WRITE, 1))
return sys_err_msg("ubi_set_property failed");
- if (check_volume_empty())
- return err_msg("UBI volume is not empty");
+ if (check_volume_empty()) {
+ if (overwrite_volume)
+ if (verbose)
+ printf("Warning: overwriting existing data\n");
+ else
+ return err_msg("UBI volume is not empty");
+ }
} else {
out_fd = open(output, O_CREAT | O_RDWR | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);

View File

@ -1,32 +0,0 @@
--- a/ubi-utils/Makefile
+++ b/ubi-utils/Makefile
@@ -22,7 +22,7 @@ $(TARGETS): $(addprefix $(BUILDDIR)/,\
# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -lubi -o $@
$(BUILDDIR)/ubicrc32: $(addprefix $(BUILDDIR)/,\
- ubicrc32.o)
+ ../lib/libcrc32.o ubicrc32.o)
# $(CC) $(CFLAGS) -o $@ $^
$(BUILDDIR)/ubinize: $(addprefix $(BUILDDIR)/,\
@@ -30,16 +30,17 @@ $(BUILDDIR)/ubinize: $(addprefix $(BUILD
# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -liniparser -lubigen -o $@
$(BUILDDIR)/mtdinfo: $(addprefix $(BUILDDIR)/,\
- libubigen.a ubiutils-common.o)
+ ../lib/libmtd.o ../lib/libmtd_legacy.o libubigen.a ubiutils-common.o)
# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -lmtd -lubigen -o $@
$(BUILDDIR)/ubiformat: $(addprefix $(BUILDDIR)/,\
- ubiformat.o ubiutils-common.o libscan.a libubi.a libubigen.a)
+ ../lib/libmtd.o ../lib/libmtd_legacy.o ubiformat.o ubiutils-common.o libscan.a libubi.a libubigen.a)
# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -lmtd -lscan -lubi -lubigen -o $@
$(BUILDDIR)/libubi.a: $(BUILDDIR)/libubi.o
-$(BUILDDIR)/libubigen.a: $(BUILDDIR)/libubigen.o
+$(BUILDDIR)/libubigen.a: $(addprefix $(BUILDDIR)/,\
+ ../lib/libcrc32.o libubigen.o)
$(BUILDDIR)/libiniparser.a: $(addprefix $(BUILDDIR)/,\
libiniparser.o dictionary.o)