Return-Path: Received: from mail1.windriver.com (mail1.windriver.com [147.11.146.13]) by mail.openembedded.org (Postfix) with ESMTP id 01C606D12A for ; Tue, 5 Nov 2013 11:49:39 +0000 (UTC) Received: from ALA-HCB.corp.ad.wrs.com (ala-hcb.corp.ad.wrs.com [147.11.189.41]) by mail1.windriver.com (8.14.5/8.14.3) with ESMTP id rA5Bnccp025289 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL) for ; Tue, 5 Nov 2013 03:49:38 -0800 (PST) Received: from PKE-CLU1-D1.corp.ad.wrs.com (128.224.162.203) by ALA-HCB.corp.ad.wrs.com (147.11.189.41) with Microsoft SMTP Server id 14.2.347.0; Tue, 5 Nov 2013 03:49:37 -0800 From: To: Date: Tue, 5 Nov 2013 19:49:30 +0800 Message-ID: <1383652170-11144-1-git-send-email-Chong.Lu@windriver.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Subject: [PATCH] makedevs: several fixes X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Nov 2013 11:49:41 -0000 Content-Type: text/plain From: Lu Chong 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. Signed-off-by: Lu Chong --- .../makedevs/makedevs-1.0.0/makedevs.c | 18 ++++++++++++++++-- 1 file 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 53700c6..003d4c3 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"; @@ -463,9 +461,15 @@ int main(int argc, char **argv) FILE *passwd_file = NULL; FILE *group_file = NULL; FILE *devtable = NULL; + DIR *dir = NULL; 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 +488,11 @@ int main(int argc, char **argv) if (rootdir != default_rootdir) { error_msg_and_die("root directory specified more than once"); } + if ((dir = opendir(optarg)) == NULL) { + perror_msg_and_die(optarg); + } else { + closedir(dir); + } rootdir = xstrdup(optarg); break; @@ -497,6 +506,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