- micanje grub-related apsolutnih staza, s obzirom da grub functions.sh napravi potre...
[kernel-cn.git] / grub-functions.sh
index feb2481..e68bb42 100755 (executable)
@@ -242,6 +242,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"