[PATCH v2] mtdinfo: add regioninfo/eraseblock map display

Mike Frysinger vapier at gentoo.org
Wed Jun 8 14:26:01 EDT 2011


On Wed, Jun 8, 2011 at 09:35, Artem Bityutskiy wrote:
> On Tue, 2011-06-07 at 11:53 -0400, Mike Frysinger wrote:
>> @@ -110,6 +114,10 @@ static int parse_opt(int argc, char * const argv[])
>>                       warnmsg("-m/--mtdn is depecated, will be removed in mtd-utils-1.4.6");
>>                       break;
>>
>> +             case 'M':
>> +                     args.map = 1;
>> +                     break;
>> +
>>               case 'h':
>>                       printf("%s\n\n", doc);
>>                       printf("%s\n\n", usage);
>
> Would you also please add the following code near the end of the
> 'parse_opt()' function:
>
> +       if (args.map && !args.node)
> +               return errmsg("-M requires MTD device node name");
>
> This will anyway be true when we remove -m, a the checks like "if
> (args.node)" will be not needed.

the -a/--all option will need reworking, but that'll have to happen
anyways once we punt -m

>> @@ -196,8 +235,26 @@ static int print_dev_info(libmtd_t libmtd, const struct mtd_info *mtd_info, int
>>       if (mtd.oob_size > 0)
>>               printf("OOB size:                       %d bytes\n",
>>                      mtd.oob_size);
>> -     if (mtd.region_cnt > 0)
>> +     if (mtd.region_cnt > 0) {
>>               printf("Additional erase regions:       %d\n", mtd.oob_size);
>> +             if (args.node)
>> +                     fd = open(args.node, O_RDONLY | O_CLOEXEC);
>
> We do want to print error message if open fails. E.g., I use -M and I do
> not see any eraseblock map - because I am not root!
>
> If open fails, we need to print something like "cannot fetch information
> about regions - error blah (blah blah)". And may be we can just
> continue.

i can add a warning when the open() fails

i have some ideas for the rest, so i'll just send a new patch which
should make us both happy i think
-mike



More information about the linux-mtd mailing list