]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
added new function to resolve_symlink to grub-install.in
authorjthomas <jthomas@localhost>
Wed, 13 Aug 2003 02:14:46 +0000 (02:14 +0000)
committerjthomas <jthomas@localhost>
Wed, 13 Aug 2003 02:14:46 +0000 (02:14 +0000)
moved code from find_device to this function
install_device is now run through the new function

ChangeLog
util/grub-install.in

index 46983c6dccdb8f01d06b33305ef4d23cf45fb693..51c4301308d2285754261b263111dbed6fb0b071 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2003-08-13  Jason Thomas  <jason@intology.com.au>
+
+       * util/grub-install.in (resolve_symlink): New function to resolve symlinks
+       (find_device): moved symlink code to new function
+       Before we convert the install_device we attempt to resolve it if its a
+       symlink using the new function
+
 2003-06-17  Jochen Hoenicke  <jochen@gnu.org>
 
        * stage2/fsys_reiserfs.c (read_tree_node): Fixed a typo; only
index 4cf263b096cbf970a801398e3f7813e6742a9786..c6131d08210b47f048ed3c1bac7dee9b8d4b64f7 100644 (file)
@@ -181,6 +181,29 @@ convert () {
     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"
+}
+
 # Usage: find_device file
 # Find block device on which the file resides.
 find_device () {
@@ -193,20 +216,8 @@ find_device () {
        exit 1
     fi
 
-    # 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
+       tmp_fname=`resolve_symlink $tmp_fname`
 
-       # 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"
 }
 
@@ -338,6 +349,7 @@ fi
 # Check for INSTALL_DEVICE.
 case "$install_device" in
 /dev/*)
+    install_device=`resolve_symlink "$install_device"`
     install_drive=`convert "$install_device"`
     # I don't know why, but some shells wouldn't die if exit is
     # called in a function.