Dear Marco,

here is the patched version of the script. Basically if we can't find
the root device with udev, we try to find it by parsing /proc/cmdline.
If that is not a valid block device the script exists, if it is that
device is used for the /dev/root symlink.

Ciao,
Paride

#!/bin/sh -e

RUNDIR=$(udevadm info --run || exit 0)

[ -d $RUNDIR ] || exit 0
mkdir -p $RUNDIR/rules.d/

[ ! -e $RUNDIR/rules.d/61-dev-root-link.rules ] || exit 0

eval $(udevadm info --export --export-prefix=ROOT_ --device-id-of-file=/ || 
true)

[ "$ROOT_MAJOR" -a "$ROOT_MINOR" ] || exit 0

# btrfs filesystems have bogus major/minor numbers
if [ "$ROOT_MAJOR" != 0 ]; then
        echo 'ACTION=="add|change", SUBSYSTEM=="block", 
ENV{MAJOR}=="'$ROOT_MAJOR'", ENV{MINOR}=="'$ROOT_MINOR'", \
                SYMLINK+="root"' > $RUNDIR/root-link-rule
else
        # btrfs filesystems have bogus major/minor numbers,
        # let's try to infer the root device from /proc/cmdline

        DEVNAME=`cat /proc/cmdline`
        DEVNAME=${DEVNAME##*root=}
        DEVNAME=${DEVNAME%% *}
        DEVNAME=${DEVNAME##*/}

        # If $DEVNAME is not a valid block device then exit now.
        if [ ! -b "$DEVNAME" ]; then
                exit 0
        fi

        echo 'ACTION=="add|change", SUBSYSTEM=="block", KERNEL=="'$DEVNAME'", 
SYMLINK+="root"' > $RUNDIR/root-link-rule
fi

mv $RUNDIR/root-link-rule $RUNDIR/rules.d/61-dev-root-link.rules

Attachment: signature.asc
Description: Digital signature

Reply via email to