mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH 0/2] mtd-utils: Upgrade and new tool nandmarkbad
@ 2017-08-30 14:49 Alexander Dahl
  2017-08-30 14:49 ` [ptxdist] [PATCH 1/2] mtd-utils: Upgrade from 1.5.2 to 2.0.1 Alexander Dahl
  2017-08-30 14:49 ` [ptxdist] [PATCH 2/2] mtd-utils: Add patch for new tool 'nandmarkbad' Alexander Dahl
  0 siblings, 2 replies; 3+ messages in thread
From: Alexander Dahl @ 2017-08-30 14:49 UTC (permalink / raw)
  To: ptxdist; +Cc: Uwe Kleine-König

Hei hei,

I need to hack on a recent mtd-utils, especially on 'mtdinfo', so I
decided to upgrade the package to the just announced version 2.0.1 of
the package. This includes a switch of the build system. Additionally
Uwe Kleine-König asked me to include his new tool 'nandmarkbad' which
is not yet upstream and still discussed on linux-mtd.

I did not test any tools on the target yet, but would strongly
recommend it!

Also I'd like to hear some feedback on how I set the ./configure
options, this approach is inspired by the util-linux-ng package.

Greets
Alex

Alexander Dahl (2):
  mtd-utils: Upgrade from 1.5.2 to 2.0.1
  mtd-utils: Add patch for new tool 'nandmarkbad'

 .../mtd-utils-1.5.2/0001-make-ubifs-optional.patch |  23 --
 ...0002-Make-liblzo-optional-for-ubifs-tools.patch |  68 ----
 ...change-add_directory-argument-to-existing.patch |  97 ------
 ...use-xmalloc-xzalloc-for-allocating-memory.patch | 143 --------
 ...s.ubifs-simplify-make_path-with-xasprintf.patch |  32 --
 ...mkfs.ubifs-Add-extended-attribute-support.patch | 369 ---------------------
 ...Optionally-create-extended-attribute-with.patch | 188 -----------
 ...flashcp-Use-llu-to-print-filestat.st_size.patch | 101 ------
 patches/mtd-utils-1.5.2/series                     |  11 -
 ...andmarkbad-new-util-to-mark-blocks-as-bad.patch | 158 +++++++++
 patches/mtd-utils-2.0.1/autogen.sh                 |   1 +
 patches/mtd-utils-2.0.1/series                     |   4 +
 rules/mtd-utils.in                                 |  22 +-
 rules/mtd-utils.make                               |  35 +-
 14 files changed, 198 insertions(+), 1054 deletions(-)
 delete mode 100644 patches/mtd-utils-1.5.2/0001-make-ubifs-optional.patch
 delete mode 100644 patches/mtd-utils-1.5.2/0002-Make-liblzo-optional-for-ubifs-tools.patch
 delete mode 100644 patches/mtd-utils-1.5.2/0003-mkfs.ubifs-change-add_directory-argument-to-existing.patch
 delete mode 100644 patches/mtd-utils-1.5.2/0004-mkfs.ubifs-use-xmalloc-xzalloc-for-allocating-memory.patch
 delete mode 100644 patches/mtd-utils-1.5.2/0005-mkfs.ubifs-simplify-make_path-with-xasprintf.patch
 delete mode 100644 patches/mtd-utils-1.5.2/0006-mkfs.ubifs-Add-extended-attribute-support.patch
 delete mode 100644 patches/mtd-utils-1.5.2/0007-mkfs.ubifs-Optionally-create-extended-attribute-with.patch
 delete mode 100644 patches/mtd-utils-1.5.2/0008-flashcp-Use-llu-to-print-filestat.st_size.patch
 delete mode 100644 patches/mtd-utils-1.5.2/series
 create mode 100644 patches/mtd-utils-2.0.1/0001-nandmarkbad-new-util-to-mark-blocks-as-bad.patch
 create mode 120000 patches/mtd-utils-2.0.1/autogen.sh
 create mode 100644 patches/mtd-utils-2.0.1/series

-- 
2.1.4


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ptxdist] [PATCH 1/2] mtd-utils: Upgrade from 1.5.2 to 2.0.1
  2017-08-30 14:49 [ptxdist] [PATCH 0/2] mtd-utils: Upgrade and new tool nandmarkbad Alexander Dahl
@ 2017-08-30 14:49 ` Alexander Dahl
  2017-08-30 14:49 ` [ptxdist] [PATCH 2/2] mtd-utils: Add patch for new tool 'nandmarkbad' Alexander Dahl
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Dahl @ 2017-08-30 14:49 UTC (permalink / raw)
  To: ptxdist; +Cc: Uwe Kleine-König

This is a major upgrade, mtd-utils switched from a hand written Makefile
build to autotools. See the release announcements for 2.0.0 and 2.0.1:

http://lists.infradead.org/pipermail/linux-mtd/2016-December/071145.html
http://lists.infradead.org/pipermail/linux-mtd/2017-August/076477.html

For the ptxdist package the menu entries were kept the same, while some
of them now control the ./configure switches for jffs and ubifs by
selecting new hidden kconfig variables.

On the old patches: 0001 and 0002 made ubifs and lzo configurable at
build time, this is done by autotools with configure options now. All
other patches were applied upstream.

Signed-off-by: Alexander Dahl <ada@thorsis.com>
---
 .../mtd-utils-1.5.2/0001-make-ubifs-optional.patch |  23 --
 ...0002-Make-liblzo-optional-for-ubifs-tools.patch |  68 ----
 ...change-add_directory-argument-to-existing.patch |  97 ------
 ...use-xmalloc-xzalloc-for-allocating-memory.patch | 143 --------
 ...s.ubifs-simplify-make_path-with-xasprintf.patch |  32 --
 ...mkfs.ubifs-Add-extended-attribute-support.patch | 369 ---------------------
 ...Optionally-create-extended-attribute-with.patch | 188 -----------
 ...flashcp-Use-llu-to-print-filestat.st_size.patch | 101 ------
 patches/mtd-utils-1.5.2/series                     |  11 -
 rules/mtd-utils.in                                 |  16 +-
 rules/mtd-utils.make                               |  31 +-
 11 files changed, 25 insertions(+), 1054 deletions(-)
 delete mode 100644 patches/mtd-utils-1.5.2/0001-make-ubifs-optional.patch
 delete mode 100644 patches/mtd-utils-1.5.2/0002-Make-liblzo-optional-for-ubifs-tools.patch
 delete mode 100644 patches/mtd-utils-1.5.2/0003-mkfs.ubifs-change-add_directory-argument-to-existing.patch
 delete mode 100644 patches/mtd-utils-1.5.2/0004-mkfs.ubifs-use-xmalloc-xzalloc-for-allocating-memory.patch
 delete mode 100644 patches/mtd-utils-1.5.2/0005-mkfs.ubifs-simplify-make_path-with-xasprintf.patch
 delete mode 100644 patches/mtd-utils-1.5.2/0006-mkfs.ubifs-Add-extended-attribute-support.patch
 delete mode 100644 patches/mtd-utils-1.5.2/0007-mkfs.ubifs-Optionally-create-extended-attribute-with.patch
 delete mode 100644 patches/mtd-utils-1.5.2/0008-flashcp-Use-llu-to-print-filestat.st_size.patch
 delete mode 100644 patches/mtd-utils-1.5.2/series

diff --git a/patches/mtd-utils-1.5.2/0001-make-ubifs-optional.patch b/patches/mtd-utils-1.5.2/0001-make-ubifs-optional.patch
deleted file mode 100644
index 5e3582e..0000000
--- a/patches/mtd-utils-1.5.2/0001-make-ubifs-optional.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From: Bernhard Walle <bernhard@bwalle.de>
-Date: Sun, 11 Mar 2012 20:03:50 +0100
-Subject: [PATCH] make ubifs optional
-
-Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
----
- Makefile | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/Makefile b/Makefile
-index 3ce8587b22a1..5cc0125c5243 100644
---- a/Makefile
-+++ b/Makefile
-@@ -31,7 +31,9 @@ UBI_BINS = \
- 	ubidetach ubinize ubiformat ubirename mtdinfo ubirsvol ubiblock
- 
- BINS = $(MTD_BINS)
-+ifneq ($(WITHOUT_MKUBIFS), 1)
- BINS += mkfs.ubifs/mkfs.ubifs
-+endif
- BINS += $(addprefix ubi-utils/,$(UBI_BINS))
- SCRIPTS = flash_eraseall
- 
diff --git a/patches/mtd-utils-1.5.2/0002-Make-liblzo-optional-for-ubifs-tools.patch b/patches/mtd-utils-1.5.2/0002-Make-liblzo-optional-for-ubifs-tools.patch
deleted file mode 100644
index e3b6305..0000000
--- a/patches/mtd-utils-1.5.2/0002-Make-liblzo-optional-for-ubifs-tools.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-From: Bernhard Walle <bernhard@bwalle.de>
-Date: Sun, 11 Mar 2012 20:11:14 +0100
-Subject: [PATCH] Make liblzo optional for ubifs tools
-
-Based on patch from Marc Kleine-Budde <mkl@pengutronix.de>.
-
-Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
----
- Makefile           |  2 +-
- mkfs.ubifs/compr.c | 17 +++++++++++++++++
- 2 files changed, 18 insertions(+), 1 deletion(-)
-
-diff --git a/Makefile b/Makefile
-index 5cc0125c5243..9cfd9700a570 100644
---- a/Makefile
-+++ b/Makefile
-@@ -107,7 +107,7 @@ $(call _mkdep,lib/,libmtd.a)
- obj-mkfs.ubifs = crc16.o lpt.o compr.o devtable.o \
- 	hashtable/hashtable.o hashtable/hashtable_itr.o
- LDFLAGS_mkfs.ubifs = $(ZLIBLDFLAGS) $(LZOLDFLAGS) $(UUIDLDFLAGS)
--LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid
-+LDLIBS_mkfs.ubifs = -lz $(LZOLDLIBS) -lm -luuid
- $(call mkdep,mkfs.ubifs/,mkfs.ubifs,,ubi-utils/libubi.a)
- 
- #
-diff --git a/mkfs.ubifs/compr.c b/mkfs.ubifs/compr.c
-index 34b2f6001b6b..549b4de13932 100644
---- a/mkfs.ubifs/compr.c
-+++ b/mkfs.ubifs/compr.c
-@@ -24,7 +24,11 @@
- #include <stdio.h>
- #include <stdint.h>
- #include <string.h>
-+#ifndef WITHOUT_LZO
- #include <lzo/lzo1x.h>
-+#else
-+#define LZO1X_999_MEM_COMPRESS	0
-+#endif
- #include <linux/types.h>
- 
- #define crc32 __zlib_crc32
-@@ -85,6 +89,8 @@ static int zlib_deflate(void *in_buf, size_t in_len, void *out_buf,
- 	return 0;
- }
- 
-+
-+#ifndef WITHOUT_LZO
- static int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
- 			size_t *out_len)
- {
-@@ -102,6 +108,17 @@ static int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
- 
- 	return 0;
- }
-+#else
-+static inline int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
-+			size_t *out_len)
-+{
-+	(void)in_buf;
-+	(void)in_len;
-+	(void)out_buf;
-+	(void)out_len;
-+	return -1;
-+}
-+#endif
- 
- static int no_compress(void *in_buf, size_t in_len, void *out_buf,
- 		       size_t *out_len)
diff --git a/patches/mtd-utils-1.5.2/0003-mkfs.ubifs-change-add_directory-argument-to-existing.patch b/patches/mtd-utils-1.5.2/0003-mkfs.ubifs-change-add_directory-argument-to-existing.patch
deleted file mode 100644
index acff3b6..0000000
--- a/patches/mtd-utils-1.5.2/0003-mkfs.ubifs-change-add_directory-argument-to-existing.patch
+++ /dev/null
@@ -1,97 +0,0 @@
-From: Sascha Hauer <s.hauer@pengutronix.de>
-Date: Fri, 28 Nov 2014 11:04:00 +0100
-Subject: [PATCH] mkfs.ubifs: change add_directory argument to 'existing'
-
-A 'non_existing' argument which is only used with !non_existing
-is just too confusing. Change this to positive logic.
-
-Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-Reviewed-by: Daniel Walter <dwalter@sigma-star.at>
-Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
----
- mkfs.ubifs/mkfs.ubifs.c | 22 +++++++++++-----------
- 1 file changed, 11 insertions(+), 11 deletions(-)
-
-diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c
-index ca17e2bca3ac..1b816ae483e0 100644
---- a/mkfs.ubifs/mkfs.ubifs.c
-+++ b/mkfs.ubifs/mkfs.ubifs.c
-@@ -1395,12 +1395,12 @@ static int add_non_dir(const char *path_name, ino_t *inum, unsigned int nlink,
-  * @dir_name: directory path name
-  * @dir_inum: UBIFS inode number of directory
-  * @st: directory inode statistics
-- * @non_existing: non-zero if this function is called for a directory which
-- *                does not exist on the host file-system and it is being
-- *                created because it is defined in the device table file.
-+ * @existing: zero if this function is called for a directory which
-+ *            does not exist on the host file-system and it is being
-+ *            created because it is defined in the device table file.
-  */
- static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st,
--			 int non_existing)
-+			 int existing)
- {
- 	struct dirent *entry;
- 	DIR *dir = NULL;
-@@ -1416,7 +1416,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st,
- 	unsigned long long dir_creat_sqnum = ++c->max_sqnum;
- 
- 	dbg_msg(2, "%s", dir_name);
--	if (!non_existing) {
-+	if (existing) {
- 		dir = opendir(dir_name);
- 		if (dir == NULL)
- 			return sys_err_msg("cannot open directory '%s'",
-@@ -1434,7 +1434,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st,
- 	 * Before adding the directory itself, we have to iterate over all the
- 	 * entries the device table adds to this directory and create them.
- 	 */
--	for (; !non_existing;) {
-+	for (; existing;) {
- 		struct stat dent_st;
- 
- 		errno = 0;
-@@ -1492,7 +1492,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st,
- 		inum = ++c->highest_inum;
- 
- 		if (S_ISDIR(dent_st.st_mode)) {
--			err = add_directory(name, inum, &dent_st, 0);
-+			err = add_directory(name, inum, &dent_st, 1);
- 			if (err)
- 				goto out_free;
- 			nlink += 1;
-@@ -1544,7 +1544,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st,
- 		inum = ++c->highest_inum;
- 
- 		if (S_ISDIR(nh_elt->mode)) {
--			err = add_directory(name, inum, &fake_st, 1);
-+			err = add_directory(name, inum, &fake_st, 0);
- 			if (err)
- 				goto out_free;
- 			nlink += 1;
-@@ -1570,14 +1570,14 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st,
- 		goto out_free;
- 
- 	free(name);
--	if (!non_existing && closedir(dir) == -1)
-+	if (existing && closedir(dir) == -1)
- 		return sys_err_msg("error closing directory '%s'", dir_name);
- 
- 	return 0;
- 
- out_free:
- 	free(name);
--	if (!non_existing)
-+	if (existing)
- 		closedir(dir);
- 	return -1;
- }
-@@ -1624,7 +1624,7 @@ static int write_data(void)
- 	}
- 
- 	head_flags = 0;
--	err = add_directory(root, UBIFS_ROOT_INO, &root_st, !root);
-+	err = add_directory(root, UBIFS_ROOT_INO, &root_st, !!root);
- 	if (err)
- 		return err;
- 	err = add_multi_linked_files();
diff --git a/patches/mtd-utils-1.5.2/0004-mkfs.ubifs-use-xmalloc-xzalloc-for-allocating-memory.patch b/patches/mtd-utils-1.5.2/0004-mkfs.ubifs-use-xmalloc-xzalloc-for-allocating-memory.patch
deleted file mode 100644
index 4fc8e70..0000000
--- a/patches/mtd-utils-1.5.2/0004-mkfs.ubifs-use-xmalloc-xzalloc-for-allocating-memory.patch
+++ /dev/null
@@ -1,143 +0,0 @@
-From: Sascha Hauer <s.hauer@pengutronix.de>
-Date: Fri, 28 Nov 2014 11:11:26 +0100
-Subject: [PATCH] mkfs.ubifs: use xmalloc/xzalloc for allocating memory
-
-Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-Reviewed-by: Daniel Walter <dwalter@sigma-star.at>
-Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
----
- mkfs.ubifs/mkfs.ubifs.c | 64 +++++++++++--------------------------------------
- 1 file changed, 14 insertions(+), 50 deletions(-)
-
-diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c
-index 1b816ae483e0..049219b52cc5 100644
---- a/mkfs.ubifs/mkfs.ubifs.c
-+++ b/mkfs.ubifs/mkfs.ubifs.c
-@@ -259,13 +259,8 @@ static int is_contained(const char *file, const char *dir)
- 	file_base = dirname(copy);
- 
- 	/* Turn the paths into the canonical form */
--	real_file = malloc(PATH_MAX);
--	if (!real_file)
--		goto out_free;
--
--	real_dir = malloc(PATH_MAX);
--	if (!real_dir)
--		goto out_free;
-+	real_file = xmalloc(PATH_MAX);
-+	real_dir = xmalloc(PATH_MAX);
- 
- 	if (!realpath(file_base, real_file)) {
- 		perror("Could not canonicalize file path");
-@@ -500,9 +495,7 @@ static int get_options(int argc, char**argv)
- 		case 'r':
- 		case 'd':
- 			root_len = strlen(optarg);
--			root = malloc(root_len + 2);
--			if (!root)
--				return err_msg("cannot allocate memory");
-+			root = xmalloc(root_len + 2);
- 
- 			/*
- 			 * The further code expects '/' at the end of the root
-@@ -910,9 +903,7 @@ static int add_to_index(union ubifs_key *key, char *name, int lnum, int offs,
- 	struct idx_entry *e;
- 
- 	dbg_msg(3, "LEB %d offs %d len %d", lnum, offs, len);
--	e = malloc(sizeof(struct idx_entry));
--	if (!e)
--		return err_msg("out of memory");
-+	e = xmalloc(sizeof(struct idx_entry));
- 	e->next = NULL;
- 	e->prev = idx_list_last;
- 	e->key = *key;
-@@ -1193,9 +1184,7 @@ static struct inum_mapping *lookup_inum_mapping(dev_t dev, ino_t inum)
- 			return im;
- 		im = im->next;
- 	}
--	im = malloc(sizeof(struct inum_mapping));
--	if (!im)
--		return NULL;
-+	im = xmalloc(sizeof(struct inum_mapping));
- 	im->next = hash_table[k];
- 	im->prev = NULL;
- 	im->dev = dev;
-@@ -1355,9 +1344,7 @@ static int add_non_dir(const char *path_name, ino_t *inum, unsigned int nlink,
- 			/* New entry */
- 			im->use_inum = *inum;
- 			im->use_nlink = 1;
--			im->path_name = malloc(strlen(path_name) + 1);
--			if (!im->path_name)
--				return err_msg("out of memory");
-+			im->path_name = xmalloc(strlen(path_name) + 1);
- 			strcpy(im->path_name, path_name);
- 		} else {
- 			/* Existing entry */
-@@ -1707,21 +1694,14 @@ static int write_index(void)
- 	head_flags = LPROPS_INDEX;
- 	/* Allocate index node */
- 	idx_sz = ubifs_idx_node_sz(c, c->fanout);
--	idx = malloc(idx_sz);
--	if (!idx)
--		return err_msg("out of memory");
-+	idx = xmalloc(idx_sz);
- 	/* Make an array of pointers to sort the index list */
- 	sz = idx_cnt * sizeof(struct idx_entry *);
- 	if (sz / sizeof(struct idx_entry *) != idx_cnt) {
- 		free(idx);
- 		return err_msg("index is too big (%zu entries)", idx_cnt);
- 	}
--	idx_ptr = malloc(sz);
--	if (!idx_ptr) {
--		free(idx);
--		return err_msg("out of memory - needed %zu bytes for index",
--			       sz);
--	}
-+	idx_ptr = xmalloc(sz);
- 	idx_ptr[0] = idx_list_first;
- 	for (i = 1; i < idx_cnt; i++)
- 		idx_ptr[i] = idx_ptr[i - 1]->next;
-@@ -2164,13 +2144,8 @@ static int init(void)
- 	c->lpt_first = UBIFS_LOG_LNUM + c->log_lebs;
- 	c->lpt_last = c->lpt_first + c->lpt_lebs - 1;
- 
--	c->lpt = malloc(c->main_lebs * sizeof(struct ubifs_lprops));
--	if (!c->lpt)
--		return err_msg("unable to allocate LPT");
--
--	c->ltab = malloc(c->lpt_lebs * sizeof(struct ubifs_lprops));
--	if (!c->ltab)
--		return err_msg("unable to allocate LPT ltab");
-+	c->lpt = xmalloc(c->main_lebs * sizeof(struct ubifs_lprops));
-+	c->ltab = xmalloc(c->lpt_lebs * sizeof(struct ubifs_lprops));
- 
- 	/* Initialize LPT's own lprops */
- 	for (i = 0; i < c->lpt_lebs; i++) {
-@@ -2182,23 +2157,12 @@ static int init(void)
- 	c->dark_wm = ALIGN(UBIFS_MAX_NODE_SZ, c->min_io_size);
- 	dbg_msg(1, "dead_wm %d  dark_wm %d", c->dead_wm, c->dark_wm);
- 
--	leb_buf = malloc(c->leb_size);
--	if (!leb_buf)
--		return err_msg("out of memory");
--
--	node_buf = malloc(NODE_BUFFER_SIZE);
--	if (!node_buf)
--		return err_msg("out of memory");
--
--	block_buf = malloc(UBIFS_BLOCK_SIZE);
--	if (!block_buf)
--		return err_msg("out of memory");
-+	leb_buf = xmalloc(c->leb_size);
-+	node_buf = xmalloc(NODE_BUFFER_SIZE);
-+	block_buf = xmalloc(UBIFS_BLOCK_SIZE);
- 
- 	sz = sizeof(struct inum_mapping *) * HASH_TABLE_SIZE;
--	hash_table = malloc(sz);
--	if (!hash_table)
--		return err_msg("out of memory");
--	memset(hash_table, 0, sz);
-+	hash_table = xzalloc(sz);
- 
- 	err = init_compression();
- 	if (err)
diff --git a/patches/mtd-utils-1.5.2/0005-mkfs.ubifs-simplify-make_path-with-xasprintf.patch b/patches/mtd-utils-1.5.2/0005-mkfs.ubifs-simplify-make_path-with-xasprintf.patch
deleted file mode 100644
index c47a7e0..0000000
--- a/patches/mtd-utils-1.5.2/0005-mkfs.ubifs-simplify-make_path-with-xasprintf.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From: Sascha Hauer <s.hauer@pengutronix.de>
-Date: Fri, 28 Nov 2014 11:15:18 +0100
-Subject: [PATCH] mkfs.ubifs: simplify make_path with xasprintf
-
-Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-Reviewed-by: Daniel Walter <dwalter@sigma-star.at>
-Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
----
- mkfs.ubifs/mkfs.ubifs.c | 10 +++-------
- 1 file changed, 3 insertions(+), 7 deletions(-)
-
-diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c
-index 049219b52cc5..a99c61382304 100644
---- a/mkfs.ubifs/mkfs.ubifs.c
-+++ b/mkfs.ubifs/mkfs.ubifs.c
-@@ -227,13 +227,9 @@ static char *make_path(const char *dir, const char *name)
- {
- 	char *s;
- 
--	s = malloc(strlen(dir) + strlen(name) + 2);
--	if (!s)
--		return NULL;
--	strcpy(s, dir);
--	if (dir[strlen(dir) - 1] != '/')
--		strcat(s, "/");
--	strcat(s, name);
-+	xasprintf(&s, "%s%s%s",
-+		  dir, dir[strlen(dir) - 1] == '/' ? "" : "/", name);
-+
- 	return s;
- }
- 
diff --git a/patches/mtd-utils-1.5.2/0006-mkfs.ubifs-Add-extended-attribute-support.patch b/patches/mtd-utils-1.5.2/0006-mkfs.ubifs-Add-extended-attribute-support.patch
deleted file mode 100644
index 77e1613..0000000
--- a/patches/mtd-utils-1.5.2/0006-mkfs.ubifs-Add-extended-attribute-support.patch
+++ /dev/null
@@ -1,369 +0,0 @@
-From: Sascha Hauer <s.hauer@pengutronix.de>
-Date: Fri, 28 Nov 2014 08:16:15 +0100
-Subject: [PATCH] mkfs.ubifs: Add extended attribute support
-
-This adds extended attribute support to mkfs.ubifs. When creating
-an image from a directory tree the existing extended attributes are
-added to the UBIFS image.
-
-Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
----
- mkfs.ubifs/key.h        |  18 +++++
- mkfs.ubifs/mkfs.ubifs.c | 205 +++++++++++++++++++++++++++++++++++++++++-------
- mkfs.ubifs/ubifs.h      |   9 +++
- 3 files changed, 205 insertions(+), 27 deletions(-)
-
-diff --git a/mkfs.ubifs/key.h b/mkfs.ubifs/key.h
-index d3a02d4ff1a6..39379fd48178 100644
---- a/mkfs.ubifs/key.h
-+++ b/mkfs.ubifs/key.h
-@@ -119,6 +119,24 @@ static inline void dent_key_init(const struct ubifs_info *c,
- }
- 
- /**
-+ * xent_key_init - initialize extended attribute entry key.
-+ * @c: UBIFS file-system description object
-+ * @key: key to initialize
-+ * @inum: host inode number
-+ * @nm: extended attribute entry name and length
-+ */
-+static inline void xent_key_init(const struct ubifs_info *c,
-+				 union ubifs_key *key, ino_t inum,
-+				 const struct qstr *nm)
-+{
-+	uint32_t hash = c->key_hash(nm->name, nm->len);
-+
-+	ubifs_assert(!(hash & ~UBIFS_S_KEY_HASH_MASK));
-+	key->u32[0] = inum;
-+	key->u32[1] = hash | (UBIFS_XENT_KEY << UBIFS_S_KEY_HASH_BITS);
-+}
-+
-+/**
-  * data_key_init - initialize data key.
-  * @c: UBIFS file-system description object
-  * @key: key to initialize
-diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c
-index a99c61382304..30cd10c25819 100644
---- a/mkfs.ubifs/mkfs.ubifs.c
-+++ b/mkfs.ubifs/mkfs.ubifs.c
-@@ -25,6 +25,10 @@
- #include "mkfs.ubifs.h"
- #include <crc32.h>
- #include "common.h"
-+#include <sys/types.h>
-+#ifndef WITHOUT_XATTR
-+#include <attr/xattr.h>
-+#endif
- 
- /* Size (prime number) of hash table for link counting */
- #define HASH_TABLE_SIZE 10099
-@@ -980,20 +984,170 @@ static int add_node(union ubifs_key *key, char *name, void *node, int len)
- 	return 0;
- }
- 
-+#ifdef WITHOUT_XATTR
-+static inline int inode_add_xattr(struct ubifs_ino_node *host_ino,
-+				  const char *path_name, struct stat *st, ino_t inum)
-+{
-+	(void)host_ino;
-+	(void)path_name;
-+	(void)st;
-+	(void)inum;
-+
-+	return 0;
-+}
-+#else
-+static int add_xattr(struct stat *st, ino_t inum, const void *data,
-+		     unsigned int data_len, struct qstr *nm)
-+{
-+	struct ubifs_ino_node *ino;
-+	struct ubifs_dent_node *xent;
-+	union ubifs_key xkey, nkey;
-+	int len, ret;
-+
-+	xent = xzalloc(sizeof(*xent) + nm->len + 1);
-+	ino = xzalloc(sizeof(*ino) + data_len);
-+
-+	xent_key_init(c, &xkey, inum, nm);
-+	xent->ch.node_type = UBIFS_XENT_NODE;
-+	key_write(&xkey, &xent->key);
-+
-+	len = UBIFS_XENT_NODE_SZ + nm->len + 1;
-+
-+	xent->ch.len = len;
-+	xent->padding1 = 0;
-+	xent->type = UBIFS_ITYPE_DIR;
-+	xent->nlen = cpu_to_le16(nm->len);
-+
-+	memcpy(xent->name, nm->name, nm->len + 1);
-+
-+	inum = ++c->highest_inum;
-+	creat_sqnum = ++c->max_sqnum;
-+
-+	xent->inum = cpu_to_le64(inum);
-+
-+	ret = add_node(&xkey, nm->name, xent, len);
-+	if (ret)
-+		goto out;
-+
-+	ino->creat_sqnum = cpu_to_le64(creat_sqnum);
-+	ino->nlink      = cpu_to_le32(st->st_nlink);
-+	/*
-+	 * The time fields are updated assuming the default time granularity
-+	 * of 1 second. To support finer granularities, utime() would be needed.
-+	 */
-+	ino->atime_sec  = cpu_to_le64(st->st_atime);
-+	ino->ctime_sec  = cpu_to_le64(st->st_ctime);
-+	ino->mtime_sec  = cpu_to_le64(st->st_mtime);
-+	ino->atime_nsec = 0;
-+	ino->ctime_nsec = 0;
-+	ino->mtime_nsec = 0;
-+	ino->uid        = cpu_to_le32(st->st_uid);
-+	ino->gid        = cpu_to_le32(st->st_gid);
-+	ino->compr_type = cpu_to_le16(c->default_compr);
-+	ino->ch.node_type = UBIFS_INO_NODE;
-+
-+	ino_key_init(&nkey, inum);
-+	key_write(&nkey, &ino->key);
-+
-+	ino->size       = cpu_to_le64(data_len);
-+	ino->mode       = cpu_to_le32(S_IFREG);
-+	ino->data_len   = cpu_to_le32(data_len);
-+	ino->flags      = cpu_to_le32(UBIFS_XATTR_FL);
-+
-+	if (data_len)
-+		memcpy(&ino->data, data, data_len);
-+
-+	ret = add_node(&nkey, nm->name, ino, UBIFS_INO_NODE_SZ + data_len) ;
-+
-+out:
-+	free(xent);
-+	free(ino);
-+
-+	return ret;
-+}
-+
-+static int inode_add_xattr(struct ubifs_ino_node *host_ino,
-+			   const char *path_name, struct stat *st, ino_t inum)
-+{
-+	int ret;
-+	struct qstr nm;
-+	void *buf = NULL;
-+	ssize_t len;
-+	ssize_t pos = 0;
-+
-+	len = llistxattr(path_name, NULL, 0);
-+	if (len < 0) {
-+		if (errno == ENOENT)
-+			return 0;
-+
-+		sys_err_msg("llistxattr failed on %s", path_name);
-+
-+		return len;
-+	}
-+
-+	if (len == 0)
-+		goto noxattr;
-+
-+	buf = xmalloc(len);
-+
-+	len = llistxattr(path_name, buf, len);
-+	if (len < 0) {
-+		sys_err_msg("llistxattr failed on %s", path_name);
-+		goto out_free;
-+	}
-+
-+	while (pos < len) {
-+		char attrbuf[1024] = { };
-+		char *name;
-+		ssize_t attrsize;
-+
-+		name = buf + pos;
-+		pos += strlen(name) + 1;
-+
-+		attrsize = lgetxattr(path_name, name, attrbuf, sizeof(attrbuf) - 1);
-+		if (attrsize < 0) {
-+			sys_err_msg("lgetxattr failed on %s", path_name);
-+			goto out_free;
-+		}
-+
-+		nm.name = name;
-+		nm.len = strlen(name);
-+
-+		host_ino->xattr_cnt++;
-+		host_ino->xattr_size += CALC_DENT_SIZE(nm.len);
-+		host_ino->xattr_size += CALC_XATTR_BYTES(attrsize);
-+		host_ino->xattr_names += nm.len;
-+
-+		ret = add_xattr(st, inum, attrbuf, attrsize, &nm);
-+		if (ret < 0)
-+			goto out_free;
-+	}
-+
-+noxattr:
-+	free(buf);
-+	return 0;
-+
-+out_free:
-+	free(buf);
-+
-+	return -1;
-+}
-+#endif
-+
- /**
-- * add_inode_with_data - write an inode.
-+ * add_inode - write an inode.
-  * @st: stat information of source inode
-  * @inum: target inode number
-  * @data: inode data (for special inodes e.g. symlink path etc)
-  * @data_len: inode data length
-  * @flags: source inode flags
-  */
--static int add_inode_with_data(struct stat *st, ino_t inum, void *data,
--			       unsigned int data_len, int flags)
-+static int add_inode(struct stat *st, ino_t inum, void *data,
-+		     unsigned int data_len, int flags, const char *xattr_path)
- {
- 	struct ubifs_ino_node *ino = node_buf;
- 	union ubifs_key key;
--	int len, use_flags = 0;
-+	int len, use_flags = 0, ret;
- 
- 	if (c->default_compr != UBIFS_COMPR_NONE)
- 		use_flags |= UBIFS_COMPR_FL;
-@@ -1037,18 +1191,13 @@ static int add_inode_with_data(struct stat *st, ino_t inum, void *data,
- 
- 	len = UBIFS_INO_NODE_SZ + data_len;
- 
--	return add_node(&key, NULL, ino, len);
--}
-+	if (xattr_path) {
-+		ret = inode_add_xattr(ino, xattr_path, st, inum);
-+		if (ret < 0)
-+			return ret;
-+	}
- 
--/**
-- * add_inode - write an inode.
-- * @st: stat information of source inode
-- * @inum: target inode number
-- * @flags: source inode flags
-- */
--static int add_inode(struct stat *st, ino_t inum, int flags)
--{
--	return add_inode_with_data(st, inum, NULL, 0, flags);
-+	return add_node(&key, NULL, ino, len);
- }
- 
- /**
-@@ -1064,8 +1213,8 @@ static int add_inode(struct stat *st, ino_t inum, int flags)
-  * is being created does not exist at the host file system, but is defined by
-  * the device table.
-  */
--static int add_dir_inode(DIR *dir, ino_t inum, loff_t size, unsigned int nlink,
--			 struct stat *st)
-+static int add_dir_inode(const char *path_name, DIR *dir, ino_t inum, loff_t size,
-+			 unsigned int nlink, struct stat *st)
- {
- 	int fd, flags = 0;
- 
-@@ -1080,7 +1229,7 @@ static int add_dir_inode(DIR *dir, ino_t inum, loff_t size, unsigned int nlink,
- 			flags = 0;
- 	}
- 
--	return add_inode(st, inum, flags);
-+	return add_inode(st, inum, NULL, 0, flags, path_name);
- }
- 
- /**
-@@ -1089,12 +1238,12 @@ static int add_dir_inode(DIR *dir, ino_t inum, loff_t size, unsigned int nlink,
-  * @inum: target inode number
-  * @flags: source inode flags
-  */
--static int add_dev_inode(struct stat *st, ino_t inum, int flags)
-+static int add_dev_inode(const char *path_name, struct stat *st, ino_t inum, int flags)
- {
- 	union ubifs_dev_desc dev;
- 
- 	dev.huge = cpu_to_le64(makedev(major(st->st_rdev), minor(st->st_rdev)));
--	return add_inode_with_data(st, inum, &dev, 8, flags);
-+	return add_inode(st, inum, &dev, 8, flags, path_name);
- }
- 
- /**
-@@ -1117,7 +1266,7 @@ static int add_symlink_inode(const char *path_name, struct stat *st, ino_t inum,
- 	if (len > UBIFS_MAX_INO_DATA)
- 		return err_msg("symlink too long for %s", path_name);
- 
--	return add_inode_with_data(st, inum, buf, len, flags);
-+	return add_inode(st, inum, buf, len, flags, path_name);
- }
- 
- /**
-@@ -1275,12 +1424,14 @@ static int add_file(const char *path_name, struct stat *st, ino_t inum,
- 			return err;
- 		}
- 	} while (ret != 0);
-+
- 	if (close(fd) == -1)
- 		return sys_err_msg("failed to close file '%s'", path_name);
- 	if (file_size != st->st_size)
- 		return err_msg("file size changed during writing file '%s'",
- 			       path_name);
--	return add_inode(st, inum, flags);
-+
-+	return add_inode(st, inum, NULL, 0, flags, path_name);
- }
- 
- /**
-@@ -1360,15 +1511,15 @@ static int add_non_dir(const char *path_name, ino_t *inum, unsigned int nlink,
- 	if (S_ISREG(st->st_mode))
- 		return add_file(path_name, st, *inum, flags);
- 	if (S_ISCHR(st->st_mode))
--		return add_dev_inode(st, *inum, flags);
-+		return add_dev_inode(path_name, st, *inum, flags);
- 	if (S_ISBLK(st->st_mode))
--		return add_dev_inode(st, *inum, flags);
-+		return add_dev_inode(path_name, st, *inum, flags);
- 	if (S_ISLNK(st->st_mode))
- 		return add_symlink_inode(path_name, st, *inum, flags);
- 	if (S_ISSOCK(st->st_mode))
--		return add_inode(st, *inum, flags);
-+		return add_inode(st, *inum, NULL, 0, flags, NULL);
- 	if (S_ISFIFO(st->st_mode))
--		return add_inode(st, *inum, flags);
-+		return add_inode(st, *inum, NULL, 0, flags, NULL);
- 
- 	return err_msg("file '%s' has unknown inode type", path_name);
- }
-@@ -1548,7 +1699,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st,
- 
- 	creat_sqnum = dir_creat_sqnum;
- 
--	err = add_dir_inode(dir, dir_inum, size, nlink, st);
-+	err = add_dir_inode(dir ? dir_name : NULL, dir, dir_inum, size, nlink, st);
- 	if (err)
- 		goto out_free;
- 
-diff --git a/mkfs.ubifs/ubifs.h b/mkfs.ubifs/ubifs.h
-index 434b651859b3..2f080a8ce708 100644
---- a/mkfs.ubifs/ubifs.h
-+++ b/mkfs.ubifs/ubifs.h
-@@ -42,6 +42,15 @@
-  */
- #define UBIFS_TRUN_KEY UBIFS_KEY_TYPES_CNT
- 
-+/*
-+ * How much a directory entry/extended attribute entry adds to the parent/host
-+ * inode.
-+ */
-+#define CALC_DENT_SIZE(name_len) ALIGN(UBIFS_DENT_NODE_SZ + (name_len) + 1, 8)
-+
-+/* How much an extended attribute adds to the host inode */
-+#define CALC_XATTR_BYTES(data_len) ALIGN(UBIFS_INO_NODE_SZ + (data_len) + 1, 8)
-+
- /* The below union makes it easier to deal with keys */
- union ubifs_key
- {
diff --git a/patches/mtd-utils-1.5.2/0007-mkfs.ubifs-Optionally-create-extended-attribute-with.patch b/patches/mtd-utils-1.5.2/0007-mkfs.ubifs-Optionally-create-extended-attribute-with.patch
deleted file mode 100644
index c9e725e..0000000
--- a/patches/mtd-utils-1.5.2/0007-mkfs.ubifs-Optionally-create-extended-attribute-with.patch
+++ /dev/null
@@ -1,188 +0,0 @@
-From: Sascha Hauer <s.hauer@pengutronix.de>
-Date: Tue, 25 Nov 2014 15:39:32 +0100
-Subject: [PATCH] mkfs.ubifs: Optionally create extended attribute with inode
- number
-
-This is done to allow creating images suitable for IMA directory
-appraisal. IMA creates a hash for directories and attaches this
-hash to the directory itself as an extended attribute. Among other
-things the inode numbers of the files are hashed. So, to create
-a valid hash in the UBIFS image the evmctl tool needs to know
-the inode numbers which the files in the UBIFS image will have.
-evmctl will read the inode numbers from the user.image-inode-number
-extended attribute. Since extended attributes are inodes themselves
-the inode numbers for the generated image will change when the
-extended attributes change, so to generate a correctly hashed
-UBIFS image, both evmctl and mkfs.ubifs must be run twice:
-
-1) execute evmctl to iterate over the directory tree. This will
-   create the security.ima and security.evm extended attributes.
-   The existence of the attributes makes sure that subsequent
-   calls to mkfs.ubifs will use the same inode numbers. evmctl
-   will use the inode numbers from the host filesystem in this
-   step which makes the resulting image unusable
-2) execute mkfs.ubifs -a. This will create the user.image-inode-number
-   extended attributes on files/directories added to the image.
-3) execture evmctl again. This time evmctl will pick the inode
-   numbers from the user.image-inode-number extended attribute
-   instead of the ones from the host filesystem
-4) execute mkfs.ubifs again. This will create the correct image.
-   The now existing user.image-inode-number extended attributes
-   are ignored and not added to the image.
-
-Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
----
- mkfs.ubifs/mkfs.ubifs.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++-
- 1 file changed, 68 insertions(+), 1 deletion(-)
-
-diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c
-index 30cd10c25819..58200dea9732 100644
---- a/mkfs.ubifs/mkfs.ubifs.c
-+++ b/mkfs.ubifs/mkfs.ubifs.c
-@@ -115,6 +115,7 @@ static char *output;
- static int out_fd;
- static int out_ubi;
- static int squash_owner;
-+static int do_create_inum_attr;
- 
- /* The 'head' (position) which nodes are written */
- static int head_lnum;
-@@ -137,7 +138,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:yh?vVe:c:g:f:Fp:k:x:X:j:R:l:j:UQq";
-+static const char *optstring = "d:r:m:o:D:yh?vVe:c:g:f:Fp:k:x:X:j:R:l:j:UQqa";
- 
- static const struct option longopts[] = {
- 	{"root",               1, NULL, 'r'},
-@@ -161,6 +162,7 @@ static const struct option longopts[] = {
- 	{"log-lebs",           1, NULL, 'l'},
- 	{"orph-lebs",          1, NULL, 'p'},
- 	{"squash-uids" ,       0, NULL, 'U'},
-+	{"set-inode-attr",     0, NULL, 'a'},
- 	{NULL, 0, NULL, 0}
- };
- 
-@@ -201,6 +203,9 @@ static const char *helptext =
- "-V, --version            display version information\n"
- "-g, --debug=LEVEL        display debug information (0 - none, 1 - statistics,\n"
- "                         2 - files, 3 - more details)\n"
-+"-a, --set-inum-attr      create user.image-inode-number extended attribute on files\n"
-+"                         added to the image. The attribute will contain the inode\n"
-+"                         number the file has in the generated image.\n"
- "-h, --help               display this help text\n\n"
- "Note, SIZE is specified in bytes, but it may also be specified in Kilobytes,\n"
- "Megabytes, and Gigabytes if a KiB, MiB, or GiB suffix is used.\n\n"
-@@ -616,6 +621,10 @@ static int get_options(int argc, char**argv)
- 		case 'U':
- 			squash_owner = 1;
- 			break;
-+		case 'a':
-+			do_create_inum_attr = 1;
-+			break;
-+
- 		}
- 	}
- 
-@@ -985,6 +994,14 @@ static int add_node(union ubifs_key *key, char *name, void *node, int len)
- }
- 
- #ifdef WITHOUT_XATTR
-+static inline int create_inum_attr(ino_t inum, const char *name)
-+{
-+	(void)inum;
-+	(void)name;
-+
-+	return 0;
-+}
-+
- static inline int inode_add_xattr(struct ubifs_ino_node *host_ino,
- 				  const char *path_name, struct stat *st, ino_t inum)
- {
-@@ -996,6 +1013,26 @@ static inline int inode_add_xattr(struct ubifs_ino_node *host_ino,
- 	return 0;
- }
- #else
-+static int create_inum_attr(ino_t inum, const char *name)
-+{
-+	char *str;
-+	int ret;
-+
-+	if (!do_create_inum_attr)
-+		return 0;
-+
-+	ret = asprintf(&str, "%llu", (unsigned long long)inum);
-+	if (ret < 0)
-+		return -1;
-+
-+	ret = lsetxattr(name, "user.image-inode-number", str, ret, 0);
-+
-+	free(str);
-+
-+	return ret;
-+}
-+
-+
- static int add_xattr(struct stat *st, ino_t inum, const void *data,
- 		     unsigned int data_len, struct qstr *nm)
- {
-@@ -1110,6 +1147,23 @@ static int inode_add_xattr(struct ubifs_ino_node *host_ino,
- 			goto out_free;
- 		}
- 
-+		if (!strcmp(name, "user.image-inode-number")) {
-+			ino_t inum_from_xattr;
-+
-+			inum_from_xattr = strtoull(attrbuf, NULL, 10);
-+			if (inum != inum_from_xattr) {
-+				errno = EINVAL;
-+				sys_err_msg("calculated inum (%llu) doesn't match inum from xattr (%llu) size (%zd) on %s",
-+					    (unsigned long long)inum,
-+					    (unsigned long long)inum_from_xattr,
-+					    attrsize,
-+					    path_name);
-+				goto out_free;
-+			}
-+
-+			continue;
-+		}
-+
- 		nm.name = name;
- 		nm.len = strlen(name);
- 
-@@ -1637,6 +1691,10 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st,
- 				goto out_free;
- 		}
- 
-+		err = create_inum_attr(inum, name);
-+		if (err)
-+			goto out_free;
-+
- 		err = add_dent_node(dir_inum, entry->d_name, inum, type);
- 		if (err)
- 			goto out_free;
-@@ -1689,6 +1747,10 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st,
- 				goto out_free;
- 		}
- 
-+		err = create_inum_attr(inum, name);
-+		if (err)
-+			goto out_free;
-+
- 		err = add_dent_node(dir_inum, nh_elt->name, inum, type);
- 		if (err)
- 			goto out_free;
-@@ -1758,6 +1820,11 @@ static int write_data(void)
- 	}
- 
- 	head_flags = 0;
-+
-+	err = create_inum_attr(UBIFS_ROOT_INO, root);
-+	if (err)
-+		return err;
-+
- 	err = add_directory(root, UBIFS_ROOT_INO, &root_st, !!root);
- 	if (err)
- 		return err;
diff --git a/patches/mtd-utils-1.5.2/0008-flashcp-Use-llu-to-print-filestat.st_size.patch b/patches/mtd-utils-1.5.2/0008-flashcp-Use-llu-to-print-filestat.st_size.patch
deleted file mode 100644
index 9ce0f9d..0000000
--- a/patches/mtd-utils-1.5.2/0008-flashcp-Use-llu-to-print-filestat.st_size.patch
+++ /dev/null
@@ -1,101 +0,0 @@
-From: Fabien Proriol <Fabien.Proriol@jdsu.com>
-Date: Fri, 7 Nov 2014 13:46:28 +0000
-Subject: [PATCH] flashcp: Use %llu to print filestat.st_size
-
-filestat.st_size type is off_t.
-For some paltforms, off_t can be 32 or 64bit but there is no C99 format specifier for off_t.
-The best way to print it with printf is to cast it to long long and print with %llu
-
-Signed-off-by: Fabien Proriol <fabien.proriol@jdsu.com>
-Signed-off-by: Brian Norris <computersforpeace@gmail.com>
----
- flashcp.c | 32 ++++++++++++++++----------------
- 1 file changed, 16 insertions(+), 16 deletions(-)
-
-diff --git a/flashcp.c b/flashcp.c
-index 86334acf0e4d..3fddeb009ae3 100644
---- a/flashcp.c
-+++ b/flashcp.c
-@@ -296,7 +296,7 @@ int main (int argc,char *argv[])
- 	 * write the entire file to flash *
- 	 **********************************/
- 
--	if (flags & FLAG_VERBOSE) log_printf (LOG_NORMAL,"Writing data: 0k/%luk (0%%)",KB (filestat.st_size));
-+	if (flags & FLAG_VERBOSE) log_printf (LOG_NORMAL,"Writing data: 0k/%lluk (0%%)",KB ((unsigned long long)filestat.st_size));
- 	size = filestat.st_size;
- 	i = BUFSIZE;
- 	written = 0;
-@@ -304,10 +304,10 @@ int main (int argc,char *argv[])
- 	{
- 		if (size < BUFSIZE) i = size;
- 		if (flags & FLAG_VERBOSE)
--			log_printf (LOG_NORMAL,"\rWriting data: %dk/%luk (%lu%%)",
-+			log_printf (LOG_NORMAL,"\rWriting data: %dk/%lluk (%llu%%)",
- 					KB (written + i),
--					KB (filestat.st_size),
--					PERCENTAGE (written + i,filestat.st_size));
-+					KB ((unsigned long long)filestat.st_size),
-+					PERCENTAGE (written + i,(unsigned long long)filestat.st_size));
- 
- 		/* read from filename */
- 		safe_read (fil_fd,filename,src,i,flags & FLAG_VERBOSE);
-@@ -325,8 +325,8 @@ int main (int argc,char *argv[])
- 				exit (EXIT_FAILURE);
- 			}
- 			log_printf (LOG_ERROR,
--					"Short write count returned while writing to x%.8x-0x%.8x on %s: %d/%lu bytes written to flash\n",
--					written,written + i,device,written + result,filestat.st_size);
-+					"Short write count returned while writing to x%.8x-0x%.8x on %s: %d/%llu bytes written to flash\n",
-+					written,written + i,device,written + result,(unsigned long long)filestat.st_size);
- 			exit (EXIT_FAILURE);
- 		}
- 
-@@ -335,10 +335,10 @@ int main (int argc,char *argv[])
- 	}
- 	if (flags & FLAG_VERBOSE)
- 		log_printf (LOG_NORMAL,
--				"\rWriting data: %luk/%luk (100%%)\n",
--				KB (filestat.st_size),
--				KB (filestat.st_size));
--	DEBUG("Wrote %d / %luk bytes\n",written,filestat.st_size);
-+				"\rWriting data: %lluk/%lluk (100%%)\n",
-+				KB ((unsigned long long)filestat.st_size),
-+				KB ((unsigned long long)filestat.st_size));
-+	DEBUG("Wrote %d / %lluk bytes\n",written,(unsigned long long)filestat.st_size);
- 
- 	/**********************************
- 	 * verify that flash == file data *
-@@ -349,16 +349,16 @@ int main (int argc,char *argv[])
- 	size = filestat.st_size;
- 	i = BUFSIZE;
- 	written = 0;
--	if (flags & FLAG_VERBOSE) log_printf (LOG_NORMAL,"Verifying data: 0k/%luk (0%%)",KB (filestat.st_size));
-+	if (flags & FLAG_VERBOSE) log_printf (LOG_NORMAL,"Verifying data: 0k/%lluk (0%%)",KB ((unsigned long long)filestat.st_size));
- 	while (size)
- 	{
- 		if (size < BUFSIZE) i = size;
- 		if (flags & FLAG_VERBOSE)
- 			log_printf (LOG_NORMAL,
--					"\rVerifying data: %dk/%luk (%lu%%)",
-+					"\rVerifying data: %dk/%lluk (%lu%%)",
- 					KB (written + i),
--					KB (filestat.st_size),
--					PERCENTAGE (written + i,filestat.st_size));
-+					KB ((unsigned long long)filestat.st_size),
-+					PERCENTAGE (written + i,(unsigned long long)filestat.st_size));
- 
- 		/* read from filename */
- 		safe_read (fil_fd,filename,src,i,flags & FLAG_VERBOSE);
-@@ -380,10 +380,10 @@ int main (int argc,char *argv[])
- 	}
- 	if (flags & FLAG_VERBOSE)
- 		log_printf (LOG_NORMAL,
--				"\rVerifying data: %luk/%luk (100%%)\n",
-+				"\rVerifying data: %lluk/%lluk (100%%)\n",
- 				KB (filestat.st_size),
- 				KB (filestat.st_size));
--	DEBUG("Verified %d / %luk bytes\n",written,filestat.st_size);
-+	DEBUG("Verified %d / %lluk bytes\n",written,(unsigned long long)filestat.st_size);
- 
- 	exit (EXIT_SUCCESS);
- }
diff --git a/patches/mtd-utils-1.5.2/series b/patches/mtd-utils-1.5.2/series
deleted file mode 100644
index 028b045..0000000
--- a/patches/mtd-utils-1.5.2/series
+++ /dev/null
@@ -1,11 +0,0 @@
-# generated by git-ptx-patches
-#tag:base --start-number 1
-0001-make-ubifs-optional.patch
-0002-Make-liblzo-optional-for-ubifs-tools.patch
-0003-mkfs.ubifs-change-add_directory-argument-to-existing.patch
-0004-mkfs.ubifs-use-xmalloc-xzalloc-for-allocating-memory.patch
-0005-mkfs.ubifs-simplify-make_path-with-xasprintf.patch
-0006-mkfs.ubifs-Add-extended-attribute-support.patch
-0007-mkfs.ubifs-Optionally-create-extended-attribute-with.patch
-0008-flashcp-Use-llu-to-print-filestat.st_size.patch
-# 8764f3d82b4d5ad37ce34647ab99cd01  - git-ptx-patches magic
diff --git a/rules/mtd-utils.in b/rules/mtd-utils.in
index 4d76f5c..552f289 100644
--- a/rules/mtd-utils.in
+++ b/rules/mtd-utils.in
@@ -5,8 +5,7 @@ menuconfig MTD_UTILS
 	prompt "mtd-utils                     "
 	select LIBC_M if MTD_UTILS_MKFS_UBIFS
 	select ZLIB
-	select LIBUUID if MTD_UTILS_MKFS_UBIFS
-	select ATTR if MTD_UTILS_MKFS_UBIFS
+	select LIBUUID if MTD_UTILS_UBIFS
 	select LIBLZO if MTD_UTILS_USE_LIBLZO
 	help
 	  Memory Technology Device Utilities
@@ -16,6 +15,12 @@ menuconfig MTD_UTILS
 
 if MTD_UTILS
 
+config MTD_UTILS_JFFS
+	bool
+
+config MTD_UTILS_UBIFS
+	bool
+
 config MTD_UTILS_USE_LIBLZO
 	bool
 	prompt "liblzo support"
@@ -116,13 +121,15 @@ config MTD_UTILS_FTL_FORMAT
 
 config MTD_UTILS_JFFS2_DUMP
 	bool
-	prompt "jffs2_dump"
+	prompt "jffs2dump"
+	select MTD_UTILS_JFFS
 	help
 	  This utility dumps the contents of a binary JFFS2 image.
 
 #config MTD_UTILS_JFFS2READER
 #	bool
 #	prompt "jffs2reader"
+#	select MTD_UTILS_JFFS
 #	help
 #	  A jffs2 image reader
 
@@ -187,6 +194,7 @@ config MTD_UTILS_NFTLDUMP
 config MTD_UTILS_MKJFFS2
 	bool
 	prompt "mkfs.jffs2"
+	select MTD_UTILS_JFFS
 	help
 	  Build a JFFS2 image in a file, from a given directory tree.
 
@@ -217,6 +225,7 @@ config MTD_UTILS_SERVE_IMAGE
 config MTD_UTILS_SUMTOOL
 	bool
 	prompt "sumtool"
+	select MTD_UTILS_JFFS
 	help
 	  Sumtool can be used to generate EBS(Erase Block Summary)
 	  information for a jffs2 image. This way we can do faster
@@ -335,6 +344,7 @@ comment "busybox' ubiupdatevol is selected!"
 config MTD_UTILS_MKFS_UBIFS
 	bool
 	prompt "mkfs.ubifs"
+	select MTD_UTILS_UBIFS
 	help
 	  Create ubifs filesystems
 
diff --git a/rules/mtd-utils.make b/rules/mtd-utils.make
index ba633c3..d8a8972 100644
--- a/rules/mtd-utils.make
+++ b/rules/mtd-utils.make
@@ -17,8 +17,8 @@ PACKAGES-$(PTXCONF_MTD_UTILS) += mtd-utils
 #
 # Paths and names
 #
-MTD_UTILS_VERSION	:= 1.5.2
-MTD_UTILS_MD5		:= 596bc7b20a6d4fb86d63fc9b8af674d6
+MTD_UTILS_VERSION	:= 2.0.1
+MTD_UTILS_MD5		:= ef065490799f5e21e90199dd25d033b6
 MTD_UTILS		:= mtd-utils-$(MTD_UTILS_VERSION)
 MTD_UTILS_SUFFIX	:= tar.bz2
 MTD_UTILS_URL		:= ftp://ftp.infradead.org/pub/mtd-utils/$(MTD_UTILS).$(MTD_UTILS_SUFFIX)
@@ -30,23 +30,16 @@ MTD_UTILS_LICENSE	:= GPL-2.0+
 # Prepare
 # ----------------------------------------------------------------------------
 
-MTD_UTILS_CONF_TOOL	:= NO
-
-MTD_UTILS_COMPILE_ENV	:= \
-	$(CROSS_ENV) \
-	CROSS="$(COMPILER_PREFIX)" \
-	WITHOUT_XATTR=1
-
-ifndef PTXCONF_MTD_UTILS_USE_LIBLZO
-MTD_UTILS_COMPILE_ENV += WITHOUT_LZO=1
-endif
-
-ifndef PTXCONF_MTD_UTILS_MKFS_UBIFS
-MTD_UTILS_COMPILE_ENV += WITHOUT_MKUBIFS=1
-endif
-
-MTD_UTILS_COMPILE_OPT	:= \
-	BUILDDIR=$(MTD_UTILS_DIR)
+MTD_UTILS_CONF_TOOL	:= autoconf
+MTD_UTILS_CONF_OPT      := \
+        $(CROSS_AUTOCONF_USR) \
+        --disable-unit-tests \
+        --disable-tests \
+        --disable-install-tests \
+        --$(call ptx/wwo, PTXCONF_MTD_UTILS_JFFS2)-jffs \
+        --$(call ptx/wwo, PTXCONF_MTD_UTILS_UBIFS)-ubifs \
+        --without-xattr \
+        --$(call ptx/wwo, PTXCONF_MTD_UTILS_USE_LIBLZO)-lzo
 
 # ----------------------------------------------------------------------------
 # Target-Install
-- 
2.1.4



_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ptxdist] [PATCH 2/2] mtd-utils: Add patch for new tool 'nandmarkbad'
  2017-08-30 14:49 [ptxdist] [PATCH 0/2] mtd-utils: Upgrade and new tool nandmarkbad Alexander Dahl
  2017-08-30 14:49 ` [ptxdist] [PATCH 1/2] mtd-utils: Upgrade from 1.5.2 to 2.0.1 Alexander Dahl
@ 2017-08-30 14:49 ` Alexander Dahl
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Dahl @ 2017-08-30 14:49 UTC (permalink / raw)
  To: ptxdist; +Cc: Uwe Kleine-König

taken from https://patchwork.ozlabs.org/patch/807596/

Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Alexander Dahl <ada@thorsis.com>
---
 ...andmarkbad-new-util-to-mark-blocks-as-bad.patch | 158 +++++++++++++++++++++
 patches/mtd-utils-2.0.1/autogen.sh                 |   1 +
 patches/mtd-utils-2.0.1/series                     |   4 +
 rules/mtd-utils.in                                 |   6 +
 rules/mtd-utils.make                               |   4 +
 5 files changed, 173 insertions(+)
 create mode 100644 patches/mtd-utils-2.0.1/0001-nandmarkbad-new-util-to-mark-blocks-as-bad.patch
 create mode 120000 patches/mtd-utils-2.0.1/autogen.sh
 create mode 100644 patches/mtd-utils-2.0.1/series

diff --git a/patches/mtd-utils-2.0.1/0001-nandmarkbad-new-util-to-mark-blocks-as-bad.patch b/patches/mtd-utils-2.0.1/0001-nandmarkbad-new-util-to-mark-blocks-as-bad.patch
new file mode 100644
index 0000000..1cea5f2
--- /dev/null
+++ b/patches/mtd-utils-2.0.1/0001-nandmarkbad-new-util-to-mark-blocks-as-bad.patch
@@ -0,0 +1,158 @@
+From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>
+Date: Wed, 30 Aug 2017 13:31:46 +0200
+Subject: [PATCH] nandmarkbad: new util to mark blocks as bad
+
+---
+ nand-utils/Makemodule.am |   5 +-
+ nand-utils/nandmarkbad.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 123 insertions(+), 1 deletion(-)
+ create mode 100644 nand-utils/nandmarkbad.c
+
+diff --git a/nand-utils/Makemodule.am b/nand-utils/Makemodule.am
+index d75b0cb3e36c..c31dcb01f06e 100644
+--- a/nand-utils/Makemodule.am
++++ b/nand-utils/Makemodule.am
+@@ -7,6 +7,9 @@ nandwrite_LDADD = libmtd.a
+ nandtest_SOURCES = nand-utils/nandtest.c
+ nandtest_LDADD = libmtd.a
+ 
++nandmarkbad_SOURCES = nand-utils/nandmarkbad.c
++nandmarkbad_LDADD = libmtd.a
++
+ nftldump_SOURCES = nand-utils/nftldump.c
+ nftldump_LDADD = libmtd.a
+ 
+@@ -14,7 +17,7 @@ nftl_format_SOURCES = nand-utils/nftl_format.c
+ nftl_format_LDADD = libmtd.a
+ 
+ NAND_BINS = \
+-	nanddump nandwrite nandtest nftldump nftl_format
++	nanddump nandwrite nandtest nandmarkbad nftldump nftl_format
+ 
+ NAND_SH = \
+ 	nand-utils/load_nandsim.sh
+diff --git a/nand-utils/nandmarkbad.c b/nand-utils/nandmarkbad.c
+new file mode 100644
+index 000000000000..cf05698c3609
+--- /dev/null
++++ b/nand-utils/nandmarkbad.c
+@@ -0,0 +1,119 @@
++#define PROGRAM_NAME "nandmarkbad"
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <unistd.h>
++#include <getopt.h>
++
++#include "common.h"
++#include <libmtd.h>
++
++static void usage(int status)
++{
++	fprintf(status ? stderr : stdout,
++		"usage: %s [OPTIONS] <device>\n\n"
++		"  -b, --markbad=blockno        Mark block bad\n"
++		"  -h, --help                   Display this help and exit\n"
++		"  -V, --version                Output version information and exit\n"
++		"  -y, --i-know-what-i-do       really do mark blocks as bad\n",
++		PROGRAM_NAME);
++	exit(status);
++}
++
++/*
++ * Main program
++ */
++int main(int argc, char **argv)
++{
++	loff_t mark_bad[32];
++	unsigned cnt_bad = 0;
++	struct mtd_dev_info mtd;
++	libmtd_t mtd_desc;
++	int fd;
++	int error = 0;
++	int ret;
++	unsigned int i;
++	int iknowwhatido = 0;
++
++	for (;;) {
++		static const char short_options[] = "b:hVy";
++		static const struct option long_options[] = {
++			{ "help", no_argument, 0, 'h' },
++			{ "markbad", required_argument, 0, 'b' },
++			{ "version", no_argument, 0, 'V'},
++			{ "i-know-what-i-do", no_argument, 0, 'y' },
++			{0, 0, 0, 0},
++		};
++		int option_index = 0;
++		int c = getopt_long(argc, argv, short_options, long_options,
++				    &option_index);
++		if (c == EOF)
++			break;
++
++		switch (c) {
++		case '?':
++			usage(EXIT_FAILURE);
++			break;
++
++		case 'b':
++			if (cnt_bad < ARRAY_SIZE(mark_bad)) {
++				mark_bad[cnt_bad] =
++					simple_strtoll(optarg, &error);
++				++cnt_bad;
++			} else {
++				errmsg_die("Can't handle so many bad blocks\n");
++			}
++
++			break;
++
++		case 'h':
++			usage(EXIT_SUCCESS);
++			break;
++
++		case 'V':
++			common_print_version();
++			return EXIT_SUCCESS;
++
++		case 'y':
++			iknowwhatido = 1;
++			break;
++		}
++	}
++
++	argc -= optind;
++	argv += optind;
++
++	if (error)
++		usage(EXIT_FAILURE);
++
++	if (argc != 1)
++		errmsg_die("You must specify a device to operate on\n");
++
++	if (!cnt_bad)
++		errmsg_die("You must specify at least one block to mark bad\n");
++
++	if (!iknowwhatido)
++		errmsg_die(PROGRAM_NAME " does things that are hard to undo.\n"
++			   "\tPlease convince yourself you understand the risks,\n"
++			   "\tthen add --i-know-what-i-do to the options.\n");
++
++	fd = open(argv[0], O_RDWR);
++	if (fd < 0)
++		sys_errmsg_die("Failed to open mtd device\n");
++
++	mtd_desc = libmtd_open();
++	if (!mtd_desc)
++		errmsg_die("Can't initialize libmtd");
++
++	if (mtd_get_dev_info(mtd_desc, argv[0], &mtd) < 0)
++		errmsg_die("mtd_get_dev_info failed");
++
++	for (i = 0; i < cnt_bad; ++i) {
++		ret = mtd_mark_bad(&mtd, fd, mark_bad[i]);
++		if (ret)
++			sys_errmsg_die("%s: MTD Mark bad block failure",
++				       argv[0]);
++	}
++
++	return EXIT_SUCCESS;
++}
diff --git a/patches/mtd-utils-2.0.1/autogen.sh b/patches/mtd-utils-2.0.1/autogen.sh
new file mode 120000
index 0000000..9f8a4cb
--- /dev/null
+++ b/patches/mtd-utils-2.0.1/autogen.sh
@@ -0,0 +1 @@
+../autogen.sh
\ No newline at end of file
diff --git a/patches/mtd-utils-2.0.1/series b/patches/mtd-utils-2.0.1/series
new file mode 100644
index 0000000..92dc1b9
--- /dev/null
+++ b/patches/mtd-utils-2.0.1/series
@@ -0,0 +1,4 @@
+# generated by git-ptx-patches
+#tag:base --start-number 1
+0001-nandmarkbad-new-util-to-mark-blocks-as-bad.patch
+# 407ded52b82ffa3ff91d50cf6b2388e0  - git-ptx-patches magic
diff --git a/rules/mtd-utils.in b/rules/mtd-utils.in
index 552f289..6e82966 100644
--- a/rules/mtd-utils.in
+++ b/rules/mtd-utils.in
@@ -161,6 +161,12 @@ config MTD_UTILS_NANDDUMP
 comment "busybox' nanddump is selected!"
 	depends on BUSYBOX_NANDDUMP
 
+config MTD_UTILS_NANDMARKBAD
+	bool
+	prompt "nandmarkbad"
+	help
+	  Mark block bad.
+
 config MTD_UTILS_NANDTEST
 	bool
 	prompt "nandtest"
diff --git a/rules/mtd-utils.make b/rules/mtd-utils.make
index d8a8972..5919ac2 100644
--- a/rules/mtd-utils.make
+++ b/rules/mtd-utils.make
@@ -118,6 +118,10 @@ ifdef PTXCONF_MTD_UTILS_NANDDUMP
 	@$(call install_copy, mtd-utils, 0, 0, 0755, -, \
 		/usr/sbin/nanddump)
 endif
+ifdef PTXCONF_MTD_UTILS_NANDMARKBAD
+	@$(call install_copy, mtd-utils, 0, 0, 0755, -, \
+		/usr/sbin/nandmarkbad)
+endif
 ifdef PTXCONF_MTD_UTILS_NANDTEST
 	@$(call install_copy, mtd-utils, 0, 0, 0755, -, \
 		/usr/sbin/nandtest)
-- 
2.1.4


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-30 14:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-30 14:49 [ptxdist] [PATCH 0/2] mtd-utils: Upgrade and new tool nandmarkbad Alexander Dahl
2017-08-30 14:49 ` [ptxdist] [PATCH 1/2] mtd-utils: Upgrade from 1.5.2 to 2.0.1 Alexander Dahl
2017-08-30 14:49 ` [ptxdist] [PATCH 2/2] mtd-utils: Add patch for new tool 'nandmarkbad' Alexander Dahl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox