1.1 --- a/makesd-partition-table Fri May 24 01:05:24 2019 +0200
1.2 +++ b/makesd-partition-table Fri May 24 18:26:28 2019 +0200
1.3 @@ -38,34 +38,16 @@
1.4
1.5 emit_partition_fields()
1.6 {
1.7 - if [ "$PREVSTART" = '0' ] ; then
1.8 - FIRSTPART=yes
1.9 - else
1.10 - FIRSTPART=
1.11 - fi
1.12 -
1.13 - PREVSTART=`align_cylinder $PREVSTART`
1.14 -
1.15 - if [ "$PREVSTART" = '0' ] ; then
1.16 - PREVSTART=1
1.17 - fi
1.18 -
1.19 echo -n " start=${PREVSTART}${SFDISK_UNIT_SUFFIX}"
1.20
1.21 - # Obtain any explicitly stated size.
1.22 + REMAINING=$(($DEVSIZE - $PREVSTART))
1.23 +
1.24 + # Retain any previously calculated size.
1.25 # Without a size, use start details to calculate a size.
1.26 # Without start details, claim the rest of the device.
1.27
1.28 - REMAINING=$(($DEVSIZE - $PREVSTART))
1.29 -
1.30 if [ "$PREVSIZE" ] ; then
1.31 - PREVSIZE=$((($PREVSIZE * $DEVSIZE) / 100))
1.32 - PREVSIZE=`align_cylinder $PREVSIZE`
1.33 -
1.34 - if [ "$FIRSTPART" ] ; then
1.35 - PREVSIZE=$(($PREVSIZE - 1))
1.36 - fi
1.37 -
1.38 + :
1.39 elif [ "$START" ] ; then
1.40 PREVSIZE=$((`align_cylinder $START` - $PREVSTART))
1.41 else
1.42 @@ -89,17 +71,38 @@
1.43
1.44 store_partition()
1.45 {
1.46 + # Define the partition start using a specified position.
1.47 + # Alternatively, use previous start and size information.
1.48 + # Otherwise, the first partition is being defined.
1.49 +
1.50 if [ "$START" ] ; then
1.51 - PREVSTART=$START
1.52 + PREVSTART=`align_cylinder $START`
1.53 elif [ "$PREVSTART" ] && [ "$PREVSIZE" ] ; then
1.54 - PREVSIZE=$(($PREVSIZE * $DEVSIZE / 100))
1.55 - PREVSIZE=`align_cylinder $PREVSIZE`
1.56 - PREVSTART=$(($PREVSTART + $PREVSIZE))
1.57 + PREVSTART=`align_cylinder $(($PREVSTART + $PREVSIZE))`
1.58 else
1.59 PREVSTART=0
1.60 fi
1.61
1.62 - PREVSIZE=$SIZE
1.63 + # Ensure that the first partition starts at sector one.
1.64 +
1.65 + if [ "$PREVSTART" = '0' ] ; then
1.66 + PREVSTART=1
1.67 + fi
1.68 +
1.69 + # Calculate and align the stated size.
1.70 + # Otherwise, defer the calculation until emitting the details.
1.71 +
1.72 + if [ "$SIZE" ] ; then
1.73 + PREVSIZE=$(($SIZE * $DEVSIZE / 100))
1.74 + PREVSIZE=`align_cylinder $PREVSIZE`
1.75 +
1.76 + if [ "$PREVSTART" = '1' ] ; then
1.77 + PREVSIZE=$(($PREVSIZE - 1))
1.78 + fi
1.79 + else
1.80 + PREVSIZE=
1.81 + fi
1.82 +
1.83 PREVTYPE=$TYPE
1.84 }
1.85