[OpenBIOS] Patch for auto partition selection
Mark Cave-Ayland
mark.cave-ayland at ilande.co.uk
Fri Nov 30 20:36:29 CET 2012
On 30/11/12 19:24, Programmingkid wrote:
Hi John,
I'm afraid this patch is still incorrect. Comments inline:
> This patch adds a partition auto selection feature. It has been tested against r1075. This patch makes dir cd:,\ actually work.
>
> Index: packages/mac-parts.c
> ===================================================================
> --- packages/mac-parts.c (revision 1075)
> +++ packages/mac-parts.c (working copy)
> @@ -161,29 +161,29 @@
> DPRINTF("mac-parts: counted %d partitions\n", __be32_to_cpu(par.pmMapBlkCnt));
>
> /* No partition was explicitly requested so let's find a suitable partition... */
> - for (parnum = 1; parnum<= __be32_to_cpu(par.pmMapBlkCnt); parnum++) {
> + for (parnum = 1; parnum<= __be32_to_cpu(par.pmMapBlkCnt); parnum++)
> + {
This part is white-space damage and shouldn't be part of the diff.
> SEEK( bs * parnum );
> READ(&par, sizeof(par) );
> - if( __be16_to_cpu(par.pmSig) != DESC_PART_SIGNATURE ||
> - !__be32_to_cpu(par.pmPartBlkCnt) )
> - break;
> -
> +
Ditto.
> DPRINTF("found partition type: %s with status %x\n", par.pmPartType, __be32_to_cpu(par.pmPartStatus));
>
> - /* If we have a valid, allocated and readable partition... */
> - if( (__be32_to_cpu(par.pmPartStatus)& kPartitionAUXIsValid)&&
> - (__be32_to_cpu(par.pmPartStatus)& kPartitionAUXIsAllocated)&&
> - (__be32_to_cpu(par.pmPartStatus)& kPartitionAUXIsReadable) ) {
> + // If an Apple_HFS or Apple_HFSX partition was found
> + if(strcmp(par.pmPartType, "Apple_HFS") == 0 || strcmp(par.pmPartType, "Apple_HFSX") == 0)
> + {
This is the part you likely want to keep.
> offs = (long long)__be32_to_cpu(par.pmPyPartStart) * bs;
> size = (long long)__be32_to_cpu(par.pmPartBlkCnt) * bs;
>
> /* If the filename was set to %BOOT, we actually want the bootcode */
> - if (want_bootcode&& (__be32_to_cpu(par.pmPartStatus)& kPartitionAUXIsBootValid)) {
> + if (want_bootcode&& (__be32_to_cpu(par.pmPartStatus)& kPartitionAUXIsBootValid))
> + {
> offs += (long long)__be32_to_cpu(par.pmLgBootStart) * bs;
> size = (long long)__be32_to_cpu(par.pmBootSize);
> -
> goto found;
> - } else {
More white-space damage - this needs to be removed.
> + }
> +
> + else
> + {
> /* Otherwise we were passed a filename and path. So let's
> choose the first partition with a valid filesystem */
> DPUSH( offs );
> @@ -196,9 +196,31 @@
> }
> }
> }
> -
> - } else {
> - /* Another partition was explicitly requested */
> + }
> +
> + // if no partition and no file was selected - example: "dir cd:,\"
> + else if (parnum == -1)
> + {
> + // search for the first partition of type Apple_HFS or Apple_HFSX
> + for(parnum = 1; parnum<= __be32_to_cpu(par.pmMapBlkCnt); parnum++)
> + {
> + SEEK( bs * parnum );
> + READ(&par, sizeof(par) );
> + DPRINTF("found partition type: %s with status %x\n", par.pmPartType, __be32_to_cpu(par.pmPartStatus));
> + if(strcmp(par.pmPartType, "Apple_HFS") == 0 || strcmp(par.pmPartType, "Apple_HFSX") == 0)
> + {
> + offs = (long long)__be32_to_cpu(par.pmPyPartStart) * bs;
> + size = (long long)__be32_to_cpu(par.pmPartBlkCnt) * bs;
> + goto found;
> + break;
> + }
> + }
> + }
> +
> + // Another partition was explicitly requested
> + else
> + {
> +
This entire section should no longer be needed since r1072.
ATB,
Mark.
More information about the OpenBIOS
mailing list