[PATCH] mtd-utils: ubinfo, add parameter check

Aaron Marcher me at drkhsh.at
Tue Aug 8 03:50:28 PDT 2017


From: aaron marcher <me at drkhsh.at>

without specifying the UBI device number, ubinfo with the volume name
parameter returns an error that it cannot find the specified volume on
ubi-1. -1 comes from the default value of devn used for internal checks.
i added a check to fix this behaviour and print out an error message
instead.
---
 ubi-utils/ubinfo.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ubi-utils/ubinfo.c b/ubi-utils/ubinfo.c
index 82d4f18..29530be 100644
--- a/ubi-utils/ubinfo.c
+++ b/ubi-utils/ubinfo.c
@@ -399,6 +399,12 @@ int main(int argc, char * const argv[])
 			goto out_libubi;
 	}
 
+	if (args.vol_name && args.devn == -1) {
+		errmsg("volume name is specified, but UBI device number is not "
+			   "(use -h for help)\n");
+		goto out_libubi;
+	}
+
 	if (args.vol_name) {
 		err = get_vol_id_by_name(libubi, args.devn, args.vol_name);
 		if (err)
-- 
2.14.0





More information about the linux-mtd mailing list