[PATCH mtd-utils] nandmarkbad: new util to mark blocks as bad

David Oberhollenzer david.oberhollenzer at sigma-star.at
Mon Aug 28 04:20:19 PDT 2017


Hi,


On 08/24/2017 05:22 PM, Uwe Kleine-König wrote:
> +void usage(int status)
> +{
> +	fprintf(status ? stderr : stdout,
> +		"usage: %s [OPTIONS] <device>\n\n"
> +		"  -b, --markbad=blockno        Mark block bad\n"
> +		PROGRAM_NAME);
I assume there's a comma missing? Running the program without
arguments segfaults immediately on my system.


> +	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;
> +
> +	for (;;) {
> +		static const char short_options[] = "b:h";
> +		static const struct option long_options[] = {
> +			{ "markbad", required_argument, 0, 'b' },
> +			{0, 0, 0, 0},
> +		};
> +		int option_index = 0;
> +		int c = getopt_long(argc, argv, short_options, long_options,
> +				    &option_index);
> +		if (c == EOF)
> +			break;

A "--help" long option in addition to the "-h" short option would be nice.
And additionally a "--version" long option with a "-V" short option.

There is a helper function called "common_print_version" that basically prints
'PROGRAM_NAME (mtd-utils) PACKAGE_VERSION'.


Thanks,

David



More information about the linux-mtd mailing list