hop siup z /dev/sd{a,b}... [testcase]
Paweł Sikora
pluto at agmk.net
Thu Feb 16 18:56:43 CET 2012
On Thursday 16 of February 2012 10:52:26 Paweł Sikora wrote:
> $ sh -x test.sh
> + ROOT=/dev/sda1
> + device=/dev/no_partition_found
> + awk -v c=/dev/sda1
> BEGIN {
> num_pattern_short = "[0-9a-f][0-9a-f][0-9a-f]";
> num_pattern = "[0-9a-f]" num_pattern_short;
> dev_pattern = "[hms][a-z][a-z]([0-9])+";
> partition = "no_partition_found";
> min = -1; maj = -1;
>
> sub("^0x", "", c);
> if (c ~ "^" num_pattern_short "$") sub("^", "0", c);
> if (c ~ "^" num_pattern "$") {
> maj = sprintf("%s",substr(c,1,2));
> min = sprintf("%s",substr(c,3));
> }
> if (c ~ "^\/dev\/" dev_pattern "$") sub("^/dev/","", c);
> if (c ~ "^" dev_pattern "$") partition = c;
> }
>
> $4 ~ partition { maj = $1; min = $2; }
> $1 ~ maj && $2 ~ min { partition = $4; }
>
> END {
> printf("device=/dev/%s; maj=%s; min=%s;\n", partition, maj, min);
> }
> ./test.partitions
> + eval device=/dev/sdb; maj=8; min=1;
> + device=/dev/sdb
> + maj=8
> + min=1
>
>
> jak widac z ROOT=/dev/sda1 wyszlo /dev/sdb :>
>
> uprasza sie autorow tego awk-owego cuda o poprawke ;)
ztcw, to juz poprawione w geninitrd-12462-4.
More information about the pld-devel-pl
mailing list