From patchwork Fri Oct 4 13:24:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Kim_B=C3=B8ndergaard?= X-Patchwork-Id: 280608 X-Patchwork-Delegate: esben@haabendal.dk Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hugin.dotsrc.org (hugin.dotsrc.org [IPv6:2001:878:346::102]) by ozlabs.org (Postfix) with ESMTP id B7FBB2C00E0 for ; Fri, 4 Oct 2013 23:24:37 +1000 (EST) Received: from hugin.dotsrc.org (localhost [127.0.0.1]) by hugin.dotsrc.org (Postfix) with ESMTP id A590044803 for ; Fri, 4 Oct 2013 15:24:35 +0200 (CEST) X-Original-To: dev@oe-lite.org Delivered-To: dev@oe-lite.org Received: from mail02.prevas.se (mail02.prevas.se [62.95.78.10]) by hugin.dotsrc.org (Postfix) with ESMTPS id DBB12447F1 for ; Fri, 4 Oct 2013 15:24:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=prevas.dk; i=@prevas.dk; l=2831; q=dns/txt; s=ironport2; t=1380893066; x=1412429066; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=ZLNMjT5GgHt2F3oiYp0EMvBmIPR2T4eKFoIjAQBpNM8=; b=W4tVzaxLSqoRZpkfNPnr73fzl451E0NoIBEsvQWP8Bu4DHxQ9Q2227CW 39RKPgCHdcOtrZ20VcQzdHkxfy33UIt6iylzDr+MT51roVM9EdUVXIEHm 0q/fAOwrUnPmlSRh6BlW+RL1m9ck5kV4BxNX6WpP1YxBsNdNv2wGtw6fd U=; X-IronPort-AV: E=Sophos;i="4.90,1033,1371074400"; d="scan'208";a="3749086" Received: from vmprevas3.prevas.se (HELO smtp.prevas.se) ([172.16.8.103]) by ironport2.prevas.se with ESMTP/TLS/AES128-SHA; 04 Oct 2013 15:24:26 +0200 Received: from localhost (172.16.10.102) by smtp.prevas.se (172.16.8.105) with Microsoft SMTP Server id 14.2.347.0; Fri, 4 Oct 2013 15:24:25 +0200 Received: by localhost (Postfix, from userid 30019) id C3BDA681AF8; Fri, 4 Oct 2013 13:24:25 +0000 (UTC) From: =?UTF-8?q?Kim=20B=C3=B8ndergaard?= To: Subject: [PATCH 15/17] makedevs: Fixed problem with unassigned variable. Added hex mode to conf file Date: Fri, 4 Oct 2013 13:24:21 +0000 Message-ID: <58a0201a699ec98dad42a3ffa03ee3f4ef2f48d7.1380892944.git.kibo@prevas.dk> X-Mailer: git-send-email 1.8.4 In-Reply-To: References: MIME-Version: 1.0 Cc: =?UTF-8?q?Kim=20B=C3=B8ndergaard?= X-BeenThere: dev@oe-lite.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: OE-lite development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dev-bounces@oe-lite.org Errors-To: dev-bounces@oe-lite.org --- recipes/makedevs/makedevs-1.0.0/makedevs.c | 52 ++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/recipes/makedevs/makedevs-1.0.0/makedevs.c b/recipes/makedevs/makedevs-1.0.0/makedevs.c index 5a017c5..2fb6fc9 100644 --- a/recipes/makedevs/makedevs-1.0.0/makedevs.c +++ b/recipes/makedevs/makedevs-1.0.0/makedevs.c @@ -180,9 +180,18 @@ static void add_new_fifo(char *name, char *path, unsigned long uid, Regular files must exist in the target root directory. If a char, block, fifo, or directory does not exist, it will be created. - count can be prepended with an 'h' to indicate the numbers to append must be hex. - I.e. if start, inc and count are 0,1,h12 respectively the devices will be appended with - 0,1,2....9,a,b and not 0,1,2....9,10,11 which is the case if 'h' is omitted + count can be prepended with 'h' to indicate the device numbers must be in hex. + Notice the number specified in the file must be decimal even with 'h' prepended. + + count can also be specified directly as a hex number by prepending 0x. + I.e. to generate 12 instances of a device can be done using either: + 12, h12 or 0xc + resulting in the device being numbered: + 0,1,2,....10,11 + 0,1,2,....a,b + 0,1,2.....a,b + respectively + */ static int interpret_table_entry(char *line) { @@ -190,23 +199,38 @@ static int interpret_table_entry(char *line) char path[4096], type; unsigned long mode = 0755, uid = 0, gid = 0, major = 0, minor = 0; unsigned long start = 0, increment = 1, count = 0; - char countstr[20+1]; - char*pcountstr = countstr; + char scanstr[8][200]; int do_hex = 0; + int i; + + for(i=0; i < 8; i++) { + scanstr[i][0] = '\0'; + } - if (0 > sscanf(line, "%40s %c %lo %lu %lu %lu %lu %lu %lu %20s", path, - &type, &mode, &uid, &gid, &major, &minor, &start, - &increment, countstr)) + if ( 0 > sscanf(line, "%40s %c %s %s %s %s %s %s %s %s", + path, &type, + scanstr[0], scanstr[1], + scanstr[2], scanstr[3], + scanstr[4], scanstr[5], + scanstr[6], scanstr[7])) { return 1; } - - if (countstr[0] == 'h') { - pcountstr++; + sscanf(scanstr[0], "%lo", &mode); + sscanf(scanstr[1], "%lu", &uid); + sscanf(scanstr[2], "%lu", &gid); + sscanf(scanstr[3], "%lu", &major); + sscanf(scanstr[4], "%lu", &minor); + sscanf(scanstr[5], "%lu", &start); + sscanf(scanstr[6], "%lu", &increment); + + if (1 == sscanf(scanstr[7], "h%lu",&count)) do_hex = 1; - } - sscanf(pcountstr,"%lu", &count); - + else if (1 == sscanf(scanstr[7], "%lx", &count)) + do_hex = 1; + else + sscanf(scanstr[7], "%lu", &count); + if (!strcmp(path, "/")) { error_msg_and_die("Device table entries require absolute paths"); }