[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#717805: Patch for dealing with newer initramfs images with microcode headers



On Tue, 2013-09-24 at 16:11 +0100, Brett Parker wrote:
> Hi,
> 
> Here's a patch to lsinitramfs to deal with initramfs images that start
> with the microcode archive and then a real archive afterwards.

Thanks, Brett.

> --- initramfs-tools/lsinitramfs 2012-03-25 05:12:23.000000000 +0100
> +++ initramfs-tools-0.109.1.new/lsinitramfs     2013-09-24 16:05:13.024780933 +0100
> @@ -53,8 +53,25 @@
>                 elif bzip2 -t "$initramfs" >/dev/null 2>&1 ; then
>                         bzip2 -c -d "$initramfs" | cpio ${cpio_args}
>                 elif lzop -t "$initramfs" >/dev/null 2>&1 ; then
>                         lzop -c -d "$initramfs" | cpio ${cpio_args}
> +               elif cpio ${cpio_args} < "$initramfs" >/dev/null 2>&1; then
> +                       # this is a straight cpio archive followed by a compressed one, yay!
> +                       cpio ${cpio_args} < "$initramfs"
> +                       real_offset=$(cpio --io-size=1 --extract --list < "$initramfs" 2>&1 >/dev/null | sed -e '$ { s# .*$##; p; }; d;')
> +                       # now we need to find the beginning of the actual archive, this is
> +                       # going to be the number of bytes from above + 8

So add this magic value of 8 (what is that, anyway?) to real_offset so
you don't need to keep writing real_offset+8.

> +                       # use same logic as above to loop through the potentials

Can this maybe be factored into a subroutine, rather than repeating it
here?

> +                       if (dd if="$initramfs" bs=$((real_offset+8)) skip=1 status=noxfer 2>/dev/null | zcat -t >/dev/null 2>&1); then
> +                               dd if="$initramfs" bs=$((real_offset+8)) skip=1 status=noxfer 2>/dev/null | zcat | cpio ${cpio_args}

Why redirect the stderr of dd when we do this for real?

> +                       elif (dd if="$initramfs" bs=$((real_offset+8)) skip=1 status=noxfer 2>/dev/null | xzcat -t >/dev/null 2>&1); then
> +                               dd if="$initramfs" bs=$((real_offset+8)) skip=1 status=noxfer 2>/dev/null | xzcat | cpio ${cpio_args}
> +                       fi
> +                       elif (dd if="$initramfs" bs=$((real_offset+8)) skip=1 status=noxfer 2>/dev/null | bzip2 -t >/dev/null 2>&1); then
> +                               dd if="$initramfs" bs=$((real_offset+8)) skip=1 status=noxfer 2>/dev/null | bzip2 -c -d | cpio ${cpio_args}
> +                       elif (dd if="$initramfs" bs=$((real_offset+8)) skip=1 status=noxfer 2>/dev/null | lzop -t >/dev/null 2>&1); then
> +                               dd if="$initramfs" bs=$((real_offset+8)) skip=1 status=noxfer 2>/dev/null | lzop -c -d | cpio ${cpio_args}

Surely these two cases need to be above above the 'fi'?

>                 fi
>  
>         fi
>  done
> 
> 
-- 
Ben Hutchings
Humans are not rational beings; they are rationalising beings.

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: