diff options
Diffstat (limited to 'helpers/lh_losetup')
-rwxr-xr-x | helpers/lh_losetup | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/helpers/lh_losetup b/helpers/lh_losetup index e2b3c0d..442afdb 100755 --- a/helpers/lh_losetup +++ b/helpers/lh_losetup @@ -2,7 +2,13 @@ # lh_losetup <device> <file> <partition> -DEVICE="${1}" +if [ -z "${1}" ] +then + DEVICE="`losetup -f`" +else + DEVICE="${1}" +fi + FILE="${2}" PARTITION="${3}" @@ -11,7 +17,7 @@ FDISK_OUT="`fdisk -l -u ${DEVICE} 2>&1`" losetup -d "${DEVICE}" LOOPDEVICE="`echo ${DEVICE}p${PARTITION:=1}`" -CYL="`echo ${FDISK_OUT} | sed -ne "s_^${LOOPDEVICE}[ *]*\([0-9]*\).*_\1_p" `" +CYL=`echo "$FDISK_OUT" | sed -ne "s_^$LOOPDEVICE[ *]*\([0-9]*\).*_\1_p"` #OFFSET="`expr 512 '*' ${CYL}`" OFFSET="$((CYL*512))" |