Skip to contentSkip to conversation

Canonicalize symlinks

PATCH New Seewer Philippe 1 participant 1 message Feb 27, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Canonicalize symlinks

When handling links sometimes one readlink isn't enough. Dracut doesn't need to clone a whole link series, so just use readlink -f

--

 dracut-functions |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
dracut-functions +3 -5
index 2f63e31..0fcfe53 100755
@@ -42,11 +42,9 @@ inst_library() {
     local src=$1 dest=${2:-$1}
     [[ -f $initdir$dest ]] && return 0
     if [[ -L $src ]]; then
-	reallib="$(readlink "$src")"
+	reallib="$(readlink -f "$src")"
 	lib=${src##*/}
-	realsrc="${src%/*}/$reallib"
-	realdest="${dest%/*}/$reallib"
-	inst_simple "$realsrc" "$realdest"
+	inst_simple "$reallib" "$reallib"
 	(cd "${initdir}${dest%/*}" && ln -s "$reallib" "$lib")
     else
 	inst_simple "$src" "$dest"
@@ -124,7 +122,7 @@ inst_symlink() {
     local src=$1 target=$initdir${2:-$1} realsrc
     [[ -L $1 ]] || return 1
     [[ -L $target ]] && return 0
-    realsrc=$(readlink "$src")
+    realsrc=$(readlink -f "$src")
     [[ $realsrc = ${realsrc##*/} ]] && realsrc="${src%/*}/$realsrc"
     inst "$realsrc" && ln -s "$realsrc" "$target"
 }

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html