Skip to content

Commit 15c6720

Browse files
committed
fix(base): support readlink applet from busybox
busybox's `readlink` applet does not support the option `-e` option. These `readlink` calls can be replaced by `realpath`, but `realpath` is not included in the initrd. So support using `readlink` (when busybox is used) and fall back to keep using `readlink` otherwise. Since `realpath` will return successfully on non-existing path, check the path exists if needed. Part of: #2437
1 parent c051f59 commit 15c6720

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

modules.d/80base/dracut-lib.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,17 @@ udevproperty() {
512512
done
513513
}
514514

515+
_resolve_path() {
516+
if command -v pidof > /dev/null; then
517+
realpath "$@"
518+
else
519+
readlink -e -q "$@"
520+
fi
521+
}
522+
515523
find_mount() {
516524
local dev wanted_dev
517-
wanted_dev="$(readlink -e -q "$1")"
525+
wanted_dev="$(_resolve_path "$1")"
518526
while read -r dev _ || [ -n "$dev" ]; do
519527
[ "$dev" = "$wanted_dev" ] && echo "$dev" && return 0
520528
done < /proc/mounts
@@ -645,7 +653,7 @@ copytree() {
645653
local src="$1" dest="$2"
646654
[ -d "$src" ] || return 1
647655
mkdir -p "$dest" || return 1
648-
dest=$(readlink -e -q "$dest") || return 1
656+
dest=$(resolve_path "$dest") || return 1
649657
(
650658
cd "$src" || exit 1
651659
cp -af . -t "$dest"
@@ -727,8 +735,9 @@ devnames() {
727735
esac
728736

729737
for d in $dev; do
738+
[ -e "$d" ] || return 255
730739
names="$names
731-
$(readlink -e -q "$d")" || return 255
740+
$(_resolve_path "$d")"
732741
done
733742

734743
echo "${names#

0 commit comments

Comments
 (0)