diff options
Diffstat (limited to 'ubi-utils/src/ubiattach.c')
| -rw-r--r-- | ubi-utils/src/ubiattach.c | 17 | 
1 files changed, 10 insertions, 7 deletions
| diff --git a/ubi-utils/src/ubiattach.c b/ubi-utils/src/ubiattach.c index b1c8d74..4454c38 100644 --- a/ubi-utils/src/ubiattach.c +++ b/ubi-utils/src/ubiattach.c @@ -31,8 +31,9 @@  #include "common.h"  #include "ubiutils-common.h" -#define PROGRAM_VERSION "1.0" +#define PROGRAM_VERSION "1.1"  #define PROGRAM_NAME    "ubiattach" +#define DEFAULT_CTRL_DEV "/dev/ubi_ctrl"  /* The variables below are set by command line arguments */  struct args { @@ -68,13 +69,14 @@ static const char *optionsstr =  "-V, --version                   print program version";  static const char *usage = -"Usage: " PROGRAM_NAME " <UBI control device node file name>\n" +"Usage: " PROGRAM_NAME " [<UBI control device node file name>]\n"  "\t[-m <MTD device number>] [-d <UBI device number>] [-p <path to device>]\n"  "\t[--mtdn=<MTD device number>] [--devn=<UBI device number>]\n"  "\t[--dev-path=<path to device>]\n" -"Example 1: " PROGRAM_NAME " /dev/ubi_ctrl -p /dev/mtd0 - attach /dev/mtd0 to UBI\n" -"Example 2: " PROGRAM_NAME " /dev/ubi_ctrl -m 0 - attach MTD device 0 (mtd0) to UBI\n" -"Example 3: " PROGRAM_NAME " /dev/ubi_ctrl -m 0 -d 3 - attach MTD device 0 (mtd0) to UBI and\n" +"UBI control device defaults to " DEFAULT_CTRL_DEV " if not supplied.\n" +"Example 1: " PROGRAM_NAME " -p /dev/mtd0 - attach /dev/mtd0 to UBI\n" +"Example 2: " PROGRAM_NAME " -m 0 - attach MTD device 0 (mtd0) to UBI\n" +"Example 3: " PROGRAM_NAME " -m 0 -d 3 - attach MTD device 0 (mtd0) to UBI\n"  "           and create UBI device number 3 (ubi3)";  static const struct option long_options[] = { @@ -142,14 +144,15 @@ static int parse_opt(int argc, char * const argv[])  	}  	if (optind == argc) -		return errmsg("UBI control device name was not specified (use -h for help)"); +		args.node = DEFAULT_CTRL_DEV;  	else if (optind != argc - 1)  		return errmsg("more then one UBI control device specified (use -h for help)"); +	else +		args.node = argv[optind];  	if (args.mtdn == -1 && args.dev == NULL)  		return errmsg("MTD device to attach was not specified (use -h for help)"); -	args.node = argv[optind];  	return 0;  } | 
