Openembedded Core Discussions
 help / color / mirror / Atom feed
From: <Chong.Lu@windriver.com>
To: <openembedded-core@lists.openembedded.org>
Subject: [PATCH] makedevs: fix return error value when input invalid arguments
Date: Mon, 4 Nov 2013 16:41:15 +0800	[thread overview]
Message-ID: <1383554475-20223-1-git-send-email-Chong.Lu@windriver.com> (raw)

From: Lu Chong <Chong.Lu@windriver.com>

Remove "-q" and "--squash" options of help information.
Print help information and return non-zero value when makedevs has none option.
If rootdir is not exist, there would be print error messages.

Signed-off-by: Lu Chong <Chong.Lu@windriver.com>
---
 .../makedevs/makedevs-1.0.0/makedevs.c             |   15 +++++++++++++--
 1 file changed, 13 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 53700c6..96362a5 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)
 static struct option long_options[] = {
 	{"root", 1, NULL, 'r'},
 	{"help", 0, NULL, 'h'},
-	{"squash", 0, NULL, 'q'},
 	{"version", 0, NULL, 'v'},
 	{"devtable", 1, NULL, 'D'},
 	{NULL, 0, NULL, 0}
@@ -446,7 +445,6 @@ static char *helptext =
 	"Options:\n"
 	"  -r, -d, --root=DIR     Build filesystem from directory DIR (default: cwd)\n"
 	"  -D, --devtable=FILE    Use the named FILE as a device table file\n"
-	"  -q, --squash           Squash permissions and owners making all files be owned by root\n"
 	"  -h, --help             Display this help text\n"
 	"  -v, --version          Display version information\n\n";
 
@@ -466,6 +464,11 @@ int main(int argc, char **argv)
 
 	umask (0);
 
+	if (argc==1) {
+		fprintf(stderr, helptext);
+		exit(1);
+	}
+
 	while ((opt = getopt_long(argc, argv, "D:d:r:qhv", 
 			long_options, &c)) >= 0) {
 		switch (opt) {
@@ -484,6 +487,9 @@ int main(int argc, char **argv)
 			if (rootdir != default_rootdir) {
 				error_msg_and_die("root directory specified more than once");
 			}
+			if (NULL==opendir(optarg)) {
+				perror_msg_and_die(optarg);
+			}
 			rootdir = xstrdup(optarg);
 			break;
 
@@ -497,6 +503,11 @@ int main(int argc, char **argv)
 		}
 	}
 
+	if (argv[optind] != NULL) {
+		fprintf(stderr, helptext);
+		exit(1);
+	}
+
 	// Get name-id mapping
 	sprintf(passwd_path, "%s/etc/passwd", rootdir);
 	sprintf(group_path, "%s/etc/group", rootdir);
-- 
1.7.9.5



             reply	other threads:[~2013-11-04  8:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-04  8:41 Chong.Lu [this message]
2013-11-04 11:40 ` [PATCH] makedevs: fix return error value when input invalid arguments Richard Purdie
2013-11-05  8:34   ` Lu Chong
2013-11-05  8:39     ` Richard Purdie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1383554475-20223-1-git-send-email-Chong.Lu@windriver.com \
    --to=chong.lu@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox