diff options
author | Lu Chong <Chong.Lu@windriver.com> | 2013-11-05 19:49:30 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-11-08 17:25:34 +0000 |
commit | 25443599ba615ca6f61fe30650b300ef6c898d82 (patch) | |
tree | 8ace026ab3ab5881ab364ffc094ba69daaca2655 /meta/recipes-devtools | |
parent | 575dc3be347f3047d1012c273deb8fd5365f38ae (diff) | |
download | poky-25443599ba615ca6f61fe30650b300ef6c898d82.tar.gz |
makedevs: several fixes
This patch fixes below issues:
1. In makedevs.c file, it lost related functions definition about "-q" and
"--squash" options. So we should remove help information of these options
from makedevs.c to fix this issue.
2. Previously, It returned nothing when makedevs command be executed with
none or invalid option. We hope to print help information and return non-zero
value.
3. If use '-d' option to pick non-existent dir, error messages should be returned.
(From OE-Core rev: 24089364c3d11665c9ac3210c1fa2488017b6b73)
Signed-off-by: Lu Chong <Chong.Lu@windriver.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r-- | meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c b/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c index 53700c687f..003d4c3fa4 100644 --- a/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c +++ b/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c | |||
@@ -434,7 +434,6 @@ static int parse_devtable(FILE * devtable) | |||
434 | static struct option long_options[] = { | 434 | static struct option long_options[] = { |
435 | {"root", 1, NULL, 'r'}, | 435 | {"root", 1, NULL, 'r'}, |
436 | {"help", 0, NULL, 'h'}, | 436 | {"help", 0, NULL, 'h'}, |
437 | {"squash", 0, NULL, 'q'}, | ||
438 | {"version", 0, NULL, 'v'}, | 437 | {"version", 0, NULL, 'v'}, |
439 | {"devtable", 1, NULL, 'D'}, | 438 | {"devtable", 1, NULL, 'D'}, |
440 | {NULL, 0, NULL, 0} | 439 | {NULL, 0, NULL, 0} |
@@ -446,7 +445,6 @@ static char *helptext = | |||
446 | "Options:\n" | 445 | "Options:\n" |
447 | " -r, -d, --root=DIR Build filesystem from directory DIR (default: cwd)\n" | 446 | " -r, -d, --root=DIR Build filesystem from directory DIR (default: cwd)\n" |
448 | " -D, --devtable=FILE Use the named FILE as a device table file\n" | 447 | " -D, --devtable=FILE Use the named FILE as a device table file\n" |
449 | " -q, --squash Squash permissions and owners making all files be owned by root\n" | ||
450 | " -h, --help Display this help text\n" | 448 | " -h, --help Display this help text\n" |
451 | " -v, --version Display version information\n\n"; | 449 | " -v, --version Display version information\n\n"; |
452 | 450 | ||
@@ -463,9 +461,15 @@ int main(int argc, char **argv) | |||
463 | FILE *passwd_file = NULL; | 461 | FILE *passwd_file = NULL; |
464 | FILE *group_file = NULL; | 462 | FILE *group_file = NULL; |
465 | FILE *devtable = NULL; | 463 | FILE *devtable = NULL; |
464 | DIR *dir = NULL; | ||
466 | 465 | ||
467 | umask (0); | 466 | umask (0); |
468 | 467 | ||
468 | if (argc==1) { | ||
469 | fprintf(stderr, helptext); | ||
470 | exit(1); | ||
471 | } | ||
472 | |||
469 | while ((opt = getopt_long(argc, argv, "D:d:r:qhv", | 473 | while ((opt = getopt_long(argc, argv, "D:d:r:qhv", |
470 | long_options, &c)) >= 0) { | 474 | long_options, &c)) >= 0) { |
471 | switch (opt) { | 475 | switch (opt) { |
@@ -484,6 +488,11 @@ int main(int argc, char **argv) | |||
484 | if (rootdir != default_rootdir) { | 488 | if (rootdir != default_rootdir) { |
485 | error_msg_and_die("root directory specified more than once"); | 489 | error_msg_and_die("root directory specified more than once"); |
486 | } | 490 | } |
491 | if ((dir = opendir(optarg)) == NULL) { | ||
492 | perror_msg_and_die(optarg); | ||
493 | } else { | ||
494 | closedir(dir); | ||
495 | } | ||
487 | rootdir = xstrdup(optarg); | 496 | rootdir = xstrdup(optarg); |
488 | break; | 497 | break; |
489 | 498 | ||
@@ -497,6 +506,11 @@ int main(int argc, char **argv) | |||
497 | } | 506 | } |
498 | } | 507 | } |
499 | 508 | ||
509 | if (argv[optind] != NULL) { | ||
510 | fprintf(stderr, helptext); | ||
511 | exit(1); | ||
512 | } | ||
513 | |||
500 | // Get name-id mapping | 514 | // Get name-id mapping |
501 | sprintf(passwd_path, "%s/etc/passwd", rootdir); | 515 | sprintf(passwd_path, "%s/etc/passwd", rootdir); |
502 | sprintf(group_path, "%s/etc/group", rootdir); | 516 | sprintf(group_path, "%s/etc/group", rootdir); |