X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=kernel-cn.git;a=blobdiff_plain;f=grub-functions.sh;h=260c611d8ae2d4ed0859d1727d4537665ef76674;hp=feb2481a9e15e0a22892fc157096625a4a269d36;hb=f6676590525ca740e8cc78b7a1a156a8f6a9b9d6;hpb=e7d98e8f3aabd8ac906b73bfa2e301e38d490be8 diff --git a/grub-functions.sh b/grub-functions.sh index feb2481..260c611 100755 --- a/grub-functions.sh +++ b/grub-functions.sh @@ -75,6 +75,34 @@ find_device () echo $device } +find_device_nonresolved () +{ + mount_point=$1 + + # Autodetect current root device + device= + if [ -f /etc/fstab ] ; then + while read DEV MNT FOO; do + if `echo "$DEV" | grep -q "^#"`; then + continue + fi + if [ "$MNT" = "$mount_point" ]; then + device="$DEV"; + fi + done < /etc/fstab + fi + + if [ -n "$device" ] ; then + case "$device" in + LABEL=* | UUID=*) + device=`findfs $device` + ;; + esac + fi + + echo $device +} + find_root_device () { device=$(find_device "/") @@ -242,6 +270,29 @@ convert_default () { fi } +# Usage: resolve_symlink file +# Find the real file/device that file points at +resolve_symlink () { + tmp_fname=$1 + # Resolve symlinks + while test -L $tmp_fname; do + tmp_new_fname=`ls -al $tmp_fname | sed -n 's%.*-> \(.*\)%\1%p'` + if test -z "$tmp_new_fname"; then + echo "Unrecognized ls output" 2>&1 + exit 1 + fi + + # Convert relative symlinks + case $tmp_new_fname in + /*) tmp_fname="$tmp_new_fname" + ;; + *) tmp_fname="`echo $tmp_fname | sed 's%/[^/]*$%%'`/$tmp_new_fname" + ;; + esac + done + echo "$tmp_fname" +} + ## Configuration Options # directory's to look for the grub installation and the menu file grub_dirs="/boot/grub /boot/boot/grub"