From patchwork Fri Dec 14 12:01:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1/1] makedevs: Improved handling of multiple device generation i.e. count > 0 in device table Date: Fri, 14 Dec 2012 02:01:35 -0000 From: =?utf-8?q?Kim_B=C3=B8ndergaard?= X-Patchwork-Id: 206418 Message-Id: <00e516dc8a1188982f4b5d229a0e428bca4a13f9.1355486138.git.kibo@prevas.dk> To: --- recipes/makedevs/makedevs-1.0.0/makedevs.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/recipes/makedevs/makedevs-1.0.0/makedevs.c b/recipes/makedevs/makedevs-1.0.0/makedevs.c index c7ad722..4953d79 100644 --- a/recipes/makedevs/makedevs-1.0.0/makedevs.c +++ b/recipes/makedevs/makedevs-1.0.0/makedevs.c @@ -179,6 +179,10 @@ 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 */ static int interpret_table_entry(char *line) { @@ -186,14 +190,24 @@ 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; + int do_hex = 0; - if (0 > sscanf(line, "%40s %c %lo %lu %lu %lu %lu %lu %lu %lu", path, + if (0 > sscanf(line, "%40s %c %lo %lu %lu %lu %lu %lu %lu %20s", path, &type, &mode, &uid, &gid, &major, &minor, &start, - &increment, &count)) + &increment, &countstr)) { return 1; } + if (countstr[0] == 'h') { + pcountstr++; + do_hex = 1; + } + if (0 > sscanf(pcountstr,"%lu", &count)) { + return 1; + } if (!strcmp(path, "/")) { error_msg_and_die("Device table entries require absolute paths"); } @@ -222,7 +236,11 @@ static int interpret_table_entry(char *line) char buf[80]; for (i = start; i < count; i++) { - sprintf(buf, "%s%d", name, i); + if (do_hex) { + sprintf(buf, "%s%x", name, i); + } else { + sprintf(buf, "%s%d", name, i); + } /* FIXME: MKDEV uses illicit insider knowledge of kernel * major/minor representation... */ rdev = MKDEV(major, minor + (i * increment - start));