Re: [PATCH 4/6] rootfs-block: Support lilo style device numbers.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



'Twas brillig, and Harald Hoyer at 24/01/13 11:40 did gyre and gimble:
> Am 23.01.2013 21:15, schrieb Colin Guthrie:
>> Lilo supplies root=900 rather than root=/dev/md0. Similarly it would say root=801 rather
>> than root=/dev/sda1.
>>
>> This patch simply interprets that number and creates appropriate udev rules
>> to create the /dev/root symlink as needed.
>> ---
>>  modules.d/95rootfs-block/block-genrules.sh | 11 ++++++++++-
>>  modules.d/95rootfs-block/parse-block.sh    |  4 ++++
>>  2 files changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/modules.d/95rootfs-block/block-genrules.sh b/modules.d/95rootfs-block/block-genrules.sh
>> index 7f894ee..161183e 100755
>> --- a/modules.d/95rootfs-block/block-genrules.sh
>> +++ b/modules.d/95rootfs-block/block-genrules.sh
>> @@ -2,7 +2,16 @@
>>  # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
>>  # ex: ts=8 sw=4 sts=4 et filetype=sh
>>  
>> -if [ "${root%%:*}" = "block" ]; then
>> +if [ -n "$rootdevnum" ]; then
>> +    major=$(( 0x$rootdevnum / 256 ))
>> +    minor=$(( 0x$rootdevnum - ( $major * 256 ) ))
>> +    {
>> +        printf 'ACTION=="add|change", ENV{MAJOR}=="%d", ENV{MINOR}=="%d", SYMLINK+="root"\n' \
>> +            $major $minor
>> +    } >> /etc/udev/rules.d/99-root.rules
>> +
>> +    wait_for_dev /dev/root
>> +elif [ "${root%%:*}" = "block" ]; then
>>      {
>>          printf 'KERNEL=="%s", SYMLINK+="root"\n' \
>>              ${root#block:/dev/}
>> diff --git a/modules.d/95rootfs-block/parse-block.sh b/modules.d/95rootfs-block/parse-block.sh
>> index 3745352..9efc51f 100755
>> --- a/modules.d/95rootfs-block/parse-block.sh
>> +++ b/modules.d/95rootfs-block/parse-block.sh
>> @@ -19,4 +19,8 @@ case "$root" in
>>      /dev/*)
>>          root="block:${root}"
>>          rootok=1 ;;
>> +    [1-9][0-9][0-9])
>> +        rootdevnum=$root
>> +        root=block:/dev/root
> 
> I would do just:
> 
> major=$(( 0x$root / 256 ))
> minor=$(( 0x$root - ( $major * 256 ) ))
> root=/dev/block/$major:$minor

Hmm, indeed, that does seem simpler :)

Of course this whole scheme is generally stupid anyway (majors have not
been limited to 256 for years), but meh.

Col
-- 

Colin Guthrie
colin(at)mageia.org
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux