<div class="gmail_quote">On Mon, May 10, 2010 at 6:27 PM, Alan Pevec <span dir="ltr"><<a href="mailto:apevec@gmail.com" target="_blank">apevec@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On Mon, May 10, 2010 at 10:20 PM, David Huff <<a href="mailto:dhuff@redhat.com" target="_blank">dhuff@redhat.com</a>> wrote:<br>
> Frederick's patch fixes issues with SD cards that do not have a standard<br>
> partitioning layout and requires part0 ie: /dev/mmcblk0<br>
<br>
</div>issue is that partitions on mmc device use separator p i.e. 1st<br>
partition is mmcblk0p1<br>
<div><br>
> However the proposed patch requires users specify a<br>
> partition for the storage device or have --format option require a<br>
> partition number.<br>
<br>
</div>--format will create one, first partition, so it doesn't make sense to<br>
specify the partition number<br></blockquote><div><br></div><div>Yes, currently we don't support multiple partition devices. That will be</div><div>another bug and patch upcoming.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><br>
> Any comments on this?<br>
><br>
> Also Frederick can you please resend the patch to the list, that way I<br>
> can apply it and retain all header info for the commit.<br>
<br>
</div>patch in BZ also merged checkLVMActive() which is now committed<br>
<br>
I don't like special case for mmc:<br>
[[ "${path/*mmc*/yes}" = yes ]] && mmc=p<br>
<br>
instead, why not simply detect partition separator here:<br>
<br>
path=/dev/`basename $path`<br>
partnum0=${path##$device}<br>
partnum=${partnum0/#p/}<br>
if [ "$partnum" = "$partnum0" ]; then<br>
separator=""<br>
else<br>
separator="p"<br>
fi<br>
...<br>
USBDEV=${device}${separator}${partnum:-1}</blockquote><div><br></div><div>A problem arises because users are allowed to --reset-mbr --format a partition by simply supplying a device node such as /dev/sdb. This means the code must determine an appropriate partition name when one is not supplied. So the suggested test fails for the case where "... --format /dev/mmcblk0 ..." is supplied to livecd-iso-to-disk.</div>
<div><br></div><div>The path test works, but assumes that the separator is used, and apparently some older systems did not use a 'p' separator. So, better to just read from /proc/partitions.</div><div><br>
</div><div>The following patch is proposed--but note: It has NOT been tested on EFI code paths.</div><div><br></div><div> --Fred</div><div><br></div><div><br></div><div><div><div><div>diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh</div>
<div>index f4d0855..f92fe2b 100755</div><div>--- a/tools/livecd-iso-to-disk.sh</div><div>+++ b/tools/livecd-iso-to-disk.sh</div><div>@@ -47,21 +47,24 @@ getdisk() {</div><div> return</div><div> fi</div><div> </div>
<div>- p=$(udevadm info -q path -n $DEV)</div><div>- if [ -e /sys/$p/device ]; then</div><div>-<span class="Apple-tab-span" style="white-space:pre">        </span>device=$(basename /sys/$p)</div><div>+ path=$(udevadm info -q path -n $DEV)</div>
<div>+ if [ -e /sys/$path/device ]; then</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span> device=$(basename /sys/$path)</div><div> else</div><div>-<span class="Apple-tab-span" style="white-space:pre">        </span>device=$(basename $(readlink -f /sys/$p/../))</div>
<div>+<span class="Apple-tab-span" style="white-space:pre">        </span> device=$(basename $(readlink -f /sys/$path/../))</div><div> fi</div><div> if [ ! -e /sys/block/$device -o ! -e /dev/$device ]; then</div><div>
-<span class="Apple-tab-span" style="white-space:pre">        </span>echo "Error finding block device of $DEV. Aborting!"</div><div>-<span class="Apple-tab-span" style="white-space:pre">        </span>exitclean</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span> echo "Error finding block device of $DEV. Aborting!"</div>
<div>+<span class="Apple-tab-span" style="white-space:pre">        </span> exitclean</div><div> fi</div><div>-</div><div>- device="/dev/$device"</div><div>+ </div><div> # FIXME: weird dev names could mess this up I guess</div>
<div>- p=/dev/`basename $p`</div><div>- partnum=${p##$device}</div><div>+ set $( awk '$4 ~ /'${device#/}'.*[0-9]$/ {print $4}' /proc/partitions )</div><div>+ partition=$1</div><div>+ path=/dev/$(basename $path)</div>
<div>+ partnum=${path##$device}</div><div>+ [[ -z "$partnum" ]] && partnum=${partition##$device}</div><div>+ device="/dev/$device"</div><div> }</div><div> </div><div> resetMBR() {</div>
<div>@@ -157,16 +160,17 @@ createGPTLayout() {</div><div> echo "WARNING: THIS WILL DESTROY ANY DATA ON $device!!!"</div><div> echo "Press Enter to continue or ctrl-c to abort"</div><div> read</div>
<div>- umount ${device}? &> /dev/null</div><div>+ umount ${device}* &> /dev/null</div><div> /sbin/parted --script $device mklabel gpt</div><div> partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print" |grep ^$device:)</div>
<div> size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')</div><div> /sbin/parted --script $device unit b mkpart '"EFI System Partition"' fat32 17408 $(($size - 17408)) set 1 boot on</div>
<div>- USBDEV=${device}1</div><div> # Sometimes automount can be _really_ annoying.</div><div> echo "Waiting for devices to settle..."</div><div> /sbin/udevadm settle</div><div> sleep 5</div>
<div>
+ partnum=$( awk '$4 ~ /'${device#/}'.*[0-9]$/ {print $4}' /proc/partitions )</div><div>+ USBDEV=${device}${partnum}</div><div> umount $USBDEV &> /dev/null</div><div> /sbin/mkdosfs -n LIVE $USBDEV</div>
<div> USBLABEL="UUID=$(/sbin/blkid -s UUID -o value $USBDEV)"</div><div>@@ -179,16 +183,17 @@ createMSDOSLayout() {</div><div> echo "WARNING: THIS WILL DESTROY ANY DATA ON $device!!!"</div><div>
echo "Press Enter to continue or ctrl-c to abort"</div><div> read</div><div>- umount ${device}? &> /dev/null</div><div>+ umount ${device}* &> /dev/null</div><div> /sbin/parted --script $device mklabel msdos</div>
<div> partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print" |grep ^$device:)</div><div> size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')</div><div> /sbin/parted --script $device unit b mkpart primary fat32 17408 $(($size - 17408)) set 1 boot on</div>
<div>- USBDEV=${device}1</div><div> # Sometimes automount can be _really_ annoying.</div><div> echo "Waiting for devices to settle..."</div><div> /sbin/udevadm settle</div><div> sleep 5</div>
<div>
+ partnum=$( awk '$4 ~ /'${device#/}'.*[0-9]$/ {print $4}' /proc/partitions )</div><div>+ USBDEV=${device}${partnum}</div><div> umount $USBDEV &> /dev/null</div><div> /sbin/mkdosfs -n LIVE $USBDEV</div>
<div> USBLABEL="UUID=$(/sbin/blkid -s UUID -o value $USBDEV)"</div></div></div></div></div>