All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] mtd-utils: miscellaneous fixes
@ 2018-05-14  8:53 David Oberhollenzer
  2018-05-14  8:53 ` [PATCH 1/3] ubiformat: process command line arguments first David Oberhollenzer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: David Oberhollenzer @ 2018-05-14  8:53 UTC (permalink / raw)
  To: linux-mtd; +Cc: richard

This patch set contains various fixes for problems that have been reported
on the mtd IRC channel over the weekend.

The first patch fiexes command line option processing for ubiformat, the
second patch removes the old no-volume-table option from ubiformat.

The last patch contains another build system fixup and should in theory make
sure that the configure script from the distribution tar ball produces a
sensible error message if pkg-config is missing on a system instead of just
exploding somewhere else because some make variables are empty.

Regards,

David

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

* [PATCH 1/3] ubiformat: process command line arguments first
  2018-05-14  8:53 [PATCH 0/3] mtd-utils: miscellaneous fixes David Oberhollenzer
@ 2018-05-14  8:53 ` David Oberhollenzer
  2018-05-14  8:53 ` [PATCH 2/3] ubiformat: remove no-volume-table option David Oberhollenzer
  2018-05-14  8:53 ` [PATCH 3/3] mtd-utils: make sure pkg-config is installed in configure script David Oberhollenzer
  2 siblings, 0 replies; 4+ messages in thread
From: David Oberhollenzer @ 2018-05-14  8:53 UTC (permalink / raw)
  To: linux-mtd; +Cc: richard, David Oberhollenzer

If libmtd_open fails, the program always exists with failure status
and prints "MTD subsystem is not present".

Even `ubiformat --help` produces the same result, which is definitely
undesired.

This patch moves command line option processing first to get the desired
behavior.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 ubi-utils/ubiformat.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/ubi-utils/ubiformat.c b/ubi-utils/ubiformat.c
index c38b9b4..694ab4c 100644
--- a/ubi-utils/ubiformat.c
+++ b/ubi-utils/ubiformat.c
@@ -692,13 +692,14 @@ int main(int argc, char * const argv[])
 	struct ubigen_info ui;
 	struct ubi_scan_info *si;
 
-	libmtd = libmtd_open();
-	if (!libmtd)
-		return errmsg("MTD subsystem is not present");
 
 	err = parse_opt(argc, argv);
 	if (err)
-		goto out_close_mtd;
+		return -1;
+
+	libmtd = libmtd_open();
+	if (!libmtd)
+		return errmsg("MTD subsystem is not present");
 
 	err = mtd_get_info(libmtd, &mtd_info);
 	if (err) {
-- 
2.17.0

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

* [PATCH 2/3] ubiformat: remove no-volume-table option
  2018-05-14  8:53 [PATCH 0/3] mtd-utils: miscellaneous fixes David Oberhollenzer
  2018-05-14  8:53 ` [PATCH 1/3] ubiformat: process command line arguments first David Oberhollenzer
@ 2018-05-14  8:53 ` David Oberhollenzer
  2018-05-14  8:53 ` [PATCH 3/3] mtd-utils: make sure pkg-config is installed in configure script David Oberhollenzer
  2 siblings, 0 replies; 4+ messages in thread
From: David Oberhollenzer @ 2018-05-14  8:53 UTC (permalink / raw)
  To: linux-mtd; +Cc: richard, David Oberhollenzer

Using the -n or --no-volume-table flags, ubiformat can format an mtd device
to a broken UBI that does not attach on a recent kernel. Only very old UBIs
had no volume table.

This patch removes the option entirely from ubiformat.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 ubi-utils/ubiformat.c | 52 ++++++++++++++++---------------------------
 1 file changed, 19 insertions(+), 33 deletions(-)

diff --git a/ubi-utils/ubiformat.c b/ubi-utils/ubiformat.c
index 694ab4c..2ee14eb 100644
--- a/ubi-utils/ubiformat.c
+++ b/ubi-utils/ubiformat.c
@@ -52,7 +52,6 @@ struct args {
 	unsigned int quiet:1;
 	unsigned int verbose:1;
 	unsigned int override_ec:1;
-	unsigned int novtbl:1;
 	unsigned int manual_subpage;
 	int subpage_size;
 	int vid_hdr_offs;
@@ -82,8 +81,6 @@ static const char optionsstr[] =
 "                             physical eraseblock (default is the next\n"
 "                             minimum I/O unit or sub-page after the EC\n"
 "                             header)\n"
-"-n, --no-volume-table        only erase all eraseblock and preserve erase\n"
-"                             counters, do not write empty volume table\n"
 "-f, --flash-image=<file>     flash image file, or '-' for stdin\n"
 "-S, --image-size=<bytes>     bytes in input, if not reading from file\n"
 "-e, --erase-counter=<value>  use <value> as the erase counter value for all\n"
@@ -114,7 +111,6 @@ static const char usage[] =
 static const struct option long_options[] = {
 	{ .name = "sub-page-size",   .has_arg = 1, .flag = NULL, .val = 's' },
 	{ .name = "vid-hdr-offset",  .has_arg = 1, .flag = NULL, .val = 'O' },
-	{ .name = "no-volume-table", .has_arg = 0, .flag = NULL, .val = 'n' },
 	{ .name = "flash-image",     .has_arg = 1, .flag = NULL, .val = 'f' },
 	{ .name = "image-size",      .has_arg = 1, .flag = NULL, .val = 'S' },
 	{ .name = "yes",             .has_arg = 0, .flag = NULL, .val = 'y' },
@@ -174,10 +170,6 @@ static int parse_opt(int argc, char * const argv[])
 				return errmsg("bad image-size: \"%s\"", optarg);
 			break;
 
-		case 'n':
-			args.novtbl = 1;
-			break;
-
 		case 'y':
 			args.yes = 1;
 			break;
@@ -236,10 +228,6 @@ static int parse_opt(int argc, char * const argv[])
 	else if (optind != argc - 1)
 		return errmsg("more then one MTD device specified (use -h for help)");
 
-	if (args.image && args.novtbl)
-		return errmsg("-n cannot be used together with -f");
-
-
 	args.node = argv[optind];
 	return 0;
 }
@@ -554,7 +542,7 @@ out_close:
 
 static int format(libmtd_t libmtd, const struct mtd_dev_info *mtd,
 		  const struct ubigen_info *ui, struct ubi_scan_info *si,
-		  int start_eb, int novtbl)
+		  int start_eb)
 {
 	int eb, err, write_size;
 	struct ubi_ec_hdr *hdr;
@@ -609,7 +597,7 @@ static int format(libmtd_t libmtd, const struct mtd_dev_info *mtd,
 			continue;
 		}
 
-		if ((eb1 == -1 || eb2 == -1) && !novtbl) {
+		if (eb1 == -1 || eb2 == -1) {
 			if (eb1 == -1) {
 				eb1 = eb;
 				ec1 = ec;
@@ -654,24 +642,22 @@ static int format(libmtd_t libmtd, const struct mtd_dev_info *mtd,
 	if (!args.quiet && !args.verbose)
 		printf("\n");
 
-	if (!novtbl) {
-		if (eb1 == -1 || eb2 == -1) {
-			errmsg("no eraseblocks for volume table");
-			goto out_free;
-		}
+	if (eb1 == -1 || eb2 == -1) {
+		errmsg("no eraseblocks for volume table");
+		goto out_free;
+	}
 
-		verbose(args.verbose, "write volume table to eraseblocks %d and %d", eb1, eb2);
-		vtbl = ubigen_create_empty_vtbl(ui);
-		if (!vtbl)
-			goto out_free;
+	verbose(args.verbose, "write volume table to eraseblocks %d and %d", eb1, eb2);
+	vtbl = ubigen_create_empty_vtbl(ui);
+	if (!vtbl)
+		goto out_free;
 
-		err = ubigen_write_layout_vol(ui, eb1, eb2, ec1,  ec2, vtbl,
-					      args.node_fd);
-		free(vtbl);
-		if (err) {
-			errmsg("cannot write layout volume");
-			goto out_free;
-		}
+	err = ubigen_write_layout_vol(ui, eb1, eb2, ec1,  ec2, vtbl,
+				args.node_fd);
+	free(vtbl);
+	if (err) {
+		errmsg("cannot write layout volume");
+		goto out_free;
 	}
 
 	free(hdr);
@@ -816,7 +802,7 @@ int main(int argc, char * const argv[])
 		goto out_free;
 	}
 
-	if (si->good_cnt < 2 && (!args.novtbl || args.image)) {
+	if (si->good_cnt < 2) {
 		errmsg("too few non-bad eraseblocks (%d) on mtd%d",
 		       si->good_cnt, mtd.mtd_num);
 		goto out_free;
@@ -916,11 +902,11 @@ int main(int argc, char * const argv[])
 		if (err < 0)
 			goto out_free;
 
-		err = format(libmtd, &mtd, &ui, si, err, 1);
+		err = format(libmtd, &mtd, &ui, si, err);
 		if (err)
 			goto out_free;
 	} else {
-		err = format(libmtd, &mtd, &ui, si, 0, args.novtbl);
+		err = format(libmtd, &mtd, &ui, si, 0);
 		if (err)
 			goto out_free;
 	}
-- 
2.17.0

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

* [PATCH 3/3] mtd-utils: make sure pkg-config is installed in configure script
  2018-05-14  8:53 [PATCH 0/3] mtd-utils: miscellaneous fixes David Oberhollenzer
  2018-05-14  8:53 ` [PATCH 1/3] ubiformat: process command line arguments first David Oberhollenzer
  2018-05-14  8:53 ` [PATCH 2/3] ubiformat: remove no-volume-table option David Oberhollenzer
@ 2018-05-14  8:53 ` David Oberhollenzer
  2 siblings, 0 replies; 4+ messages in thread
From: David Oberhollenzer @ 2018-05-14  8:53 UTC (permalink / raw)
  To: linux-mtd; +Cc: richard, David Oberhollenzer

This patch adds a check to configure.ac that tests if pkg-config
is available on the system.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 configure.ac | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/configure.ac b/configure.ac
index 1ac45c7..f5538a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,6 +24,15 @@ AC_DISABLE_STATIC
 AC_PROG_CC
 AC_PROG_INSTALL
 
+
+m4_ifndef([PKG_PROG_PKG_CONFIG],
+  [m4_fatal([Could not locate the pkg-config autoconf
+    macros. These are usually located in /usr/share/aclocal/pkg.m4.
+    If your macros are in a different location, try setting the
+    environment variable AL_OPTS="-I/other/macro/dir" before running
+    ./autogen.sh or autoreconf again. Make sure pkg-config is installed.])])
+PKG_PROG_PKG_CONFIG
+
 ## compiler warnings
 UL_WARN_ADD([-Wall])
 UL_WARN_ADD([-Wextra])
-- 
2.17.0

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

end of thread, other threads:[~2018-05-14  8:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-14  8:53 [PATCH 0/3] mtd-utils: miscellaneous fixes David Oberhollenzer
2018-05-14  8:53 ` [PATCH 1/3] ubiformat: process command line arguments first David Oberhollenzer
2018-05-14  8:53 ` [PATCH 2/3] ubiformat: remove no-volume-table option David Oberhollenzer
2018-05-14  8:53 ` [PATCH 3/3] mtd-utils: make sure pkg-config is installed in configure script David Oberhollenzer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.