diff options
author | Daniel Baumann <daniel@debian.org> | 2007-09-23 10:05:17 +0200 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2011-03-09 18:22:26 +0100 |
commit | 0d0de885e32ff67d57bb7def451b62d75b8920ab (patch) | |
tree | cd4a159a86207401dbd5990bc0fa3c28825ab6f8 /helpers/lh_losetup | |
parent | c68c0a270832ca340429878ce6a0ab606d435b06 (diff) | |
download | vyos-live-build-0d0de885e32ff67d57bb7def451b62d75b8920ab.tar.gz vyos-live-build-0d0de885e32ff67d57bb7def451b62d75b8920ab.zip |
Adding live-helper 1.0~a22-1.
Diffstat (limited to 'helpers/lh_losetup')
-rwxr-xr-x | helpers/lh_losetup | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/helpers/lh_losetup b/helpers/lh_losetup index c2c7a7b39..8ef33c946 100755 --- a/helpers/lh_losetup +++ b/helpers/lh_losetup @@ -20,7 +20,7 @@ done # Setting static variables DESCRIPTION="wrapper around losetup" HELP="" -USAGE="${PROGRAM} <device> <file> <partition>" +USAGE="${PROGRAM} DEVICE FILE [PARTITION]" Arguments "${@}" @@ -32,30 +32,26 @@ Read_conffile config/binary Read_conffile config/source Set_defaults -if [ -z "${1}" ] -then - DEVICE="`${LH_ROOT_COMMAND} ${LH_LOSETUP} -f`" -else - DEVICE="${1}" -fi - +DEVICE="${1}" FILE="${2}" -PARTITION="${3}" +PARTITION="${3:=1}" ${LH_ROOT_COMMAND} ${LH_LOSETUP} "${DEVICE}" "${FILE}" FDISK_OUT="`fdisk -l -u ${DEVICE} 2>&1`" ${LH_ROOT_COMMAND} ${LH_LOSETUP} -d "${DEVICE}" -LOOPDEVICE="`echo ${DEVICE}p${PARTITION:=1}`" -CYL=`echo "$FDISK_OUT" | sed -ne "s_^$LOOPDEVICE[ *]*\([0-9]*\).*_\1_p"` -#OFFSET="`expr 512 '*' ${CYL}`" -OFFSET="$((CYL*512))" - -echo loop $DEVICE at offset $OFFSET +LOOPDEVICE="`echo ${DEVICE}p${PARTITION}`" if [ "${PARTITION}" = "0" ] then + Echo_message "Mounting ${DEVICE} with offset 0" + ${LH_ROOT_COMMAND} ${LH_LOSETUP} "${DEVICE}" "${FILE}" else + CYLINDERS="`echo "$FDISK_OUT" | sed -ne "s_^$LOOPDEVICE[ *]*\([0-9]*\).*_\1_p"`" + OFFSET="`expr ${CYLINDERS} '*' 512`" + + Echo_message "Mounting ${DEVICE} with offset ${OFFSET}" + ${LH_ROOT_COMMAND} ${LH_LOSETUP} -o "${OFFSET}" "${DEVICE}" "${FILE}" fi |