linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [ubinfo] Add -N option to get info by name of ubi volume
@ 2010-03-23 15:16 Jon Ringle
  2010-04-08  8:29 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Jon Ringle @ 2010-03-23 15:16 UTC (permalink / raw)
  To: linux-mtd; +Cc: Jon Ringle

Signed-off-by: Jon Ringle <jon@ringle.org>
---
 ubi-utils/src/ubinfo.c |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/ubi-utils/src/ubinfo.c b/ubi-utils/src/ubinfo.c
index 8c5a1a9..cd011c5 100644
--- a/ubi-utils/src/ubinfo.c
+++ b/ubi-utils/src/ubinfo.c
@@ -39,6 +39,7 @@ struct args {
 	int vol_id;
 	int all;
 	const char *node;
+	const char *vol_name;
 };
 
 static struct args args = {
@@ -46,6 +47,7 @@ static struct args args = {
 	.devn = -1,
 	.all = 0,
 	.node = NULL,
+	.vol_name = NULL,
 };
 
 static const char *doc = PROGRAM_NAME " version " PROGRAM_VERSION
@@ -87,7 +89,7 @@ static int parse_opt(int argc, char * const argv[])
 		int key;
 		char *endp;
 
-		key = getopt_long(argc, argv, "an:d:hV", long_options, NULL);
+		key = getopt_long(argc, argv, "an:N:d:hV", long_options, NULL);
 		if (key == -1)
 			break;
 
@@ -102,6 +104,10 @@ static int parse_opt(int argc, char * const argv[])
 				return errmsg("bad volume ID: " "\"%s\"", optarg);
 			break;
 
+		case 'N':
+			args.vol_name = optarg;
+			break;
+
 		case 'd':
 			args.devn = strtoul(optarg, &endp, 0);
 			if (*endp != '\0' || endp == optarg || args.devn < 0)
@@ -174,6 +180,20 @@ static int translate_dev(libubi_t libubi, const char *node)
 	return 0;
 }
 
+static int get_vol_id_by_name(libubi_t libubi, int dev_num, const char *name)
+{
+	int err;
+	struct ubi_vol_info vol_info;
+
+	err = ubi_get_vol_info1_nm(libubi, dev_num, name, &vol_info);
+	if (err)
+		return sys_errmsg("cannot get information about volume \"%s\" on ubi%d\n", name, dev_num);
+
+	args.vol_id = vol_info.vol_id;
+
+	return 0;
+}
+
 static int print_vol_info(libubi_t libubi, int dev_num, int vol_id)
 {
 	int err;
@@ -377,6 +397,12 @@ int main(int argc, char * const argv[])
 			goto out_libubi;
 	}
 
+	if (args.vol_name) {
+		err = get_vol_id_by_name(libubi, args.devn, args.vol_name);
+		if (err)
+			goto out_libubi;
+	}
+
 	if (args.vol_id != -1 && args.devn == -1) {
 		errmsg("volume ID is specified, but UBI device number is not "
 		       "(use -h for help)\n");
-- 
1.7.0.2.182.ge007

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

* Re: [PATCH] [ubinfo] Add -N option to get info by name of ubi volume
  2010-03-23 15:16 [PATCH] [ubinfo] Add -N option to get info by name of ubi volume Jon Ringle
@ 2010-04-08  8:29 ` Artem Bityutskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2010-04-08  8:29 UTC (permalink / raw)
  To: Jon Ringle; +Cc: linux-mtd

On Tue, 2010-03-23 at 11:16 -0400, Jon Ringle wrote:
> Signed-off-by: Jon Ringle <jon@ringle.org>
> ---
>  ubi-utils/src/ubinfo.c |   28 +++++++++++++++++++++++++++-
>  1 files changed, 27 insertions(+), 1 deletions(-)

Pushed to mtd-utils.git, thank you!

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

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

end of thread, other threads:[~2010-04-08  8:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-23 15:16 [PATCH] [ubinfo] Add -N option to get info by name of ubi volume Jon Ringle
2010-04-08  8:29 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).