From: Antonio Ospite Date: Tue, 13 Sep 2011 13:16:38 +0000 (+0200) Subject: Add an alternative way to find the root device X-Git-Tag: v0.1~1 X-Git-Url: https://git.ao2.it/kboot-utils.git/commitdiff_plain/ba32c0d281280ce7c63394b1d71404fdb6d18b18?ds=sidebyside Add an alternative way to find the root device This one works under 'piuparts' as well, the previous one based on 'mount' was producing a string not usable with 'readlink' --- diff --git a/kboot-mkconfig_lib b/kboot-mkconfig_lib index ef31905..155cca0 100644 --- a/kboot-mkconfig_lib +++ b/kboot-mkconfig_lib @@ -21,7 +21,9 @@ exec_prefix=${prefix} bindir=${exec_prefix}/bin libdir=${exec_prefix}/lib -LINUX_ROOT_DEVICE="$(readlink -f $(mount | grep ' / ' | cut -d ' ' -f 1))" +# TODO: remove this if the following find_linux_root_device() +# is found to be reliable enough +#LINUX_ROOT_DEVICE="$(readlink -f $(mount | grep ' / ' | cut -d ' ' -f 1))" if $(which gettext >/dev/null 2>/dev/null) ; then gettext="gettext" @@ -87,6 +89,21 @@ version_find_latest () echo "$a" } +linux_find_root_device() { + RDEV=$(mountpoint -d /) + + for devnode in $(find /dev); + do + if [ $(stat --printf="%t:%T" "$devnode") = $RDEV ]; + then + ROOTDEVICE="$devnode" + break + fi + done + + echo "$ROOTDEVICE" +} + linux_entry () { os="$1" @@ -125,7 +142,9 @@ list_kernels () version=`echo $basename | sed -e "s,^[^0-9]*-,,g"` alt_version=`echo $version | sed -e "s,\.old$,,g"` - linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" + # TODO: remove this too + #linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" + linux_root_device_thisversion=linux_find_root_device initrd= for i in "initrd.img-${version}" "initrd-${version}.img" \