Commit 856b46ae authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] PPC32: Fix the mkprep util to work correctly on Solaris 8

From: Tom Rini <trini@kernel.crashing.org>
      Peter Wahl <PeterWahl@web.de>

PPC32: Fix the mkprep util to work correctly on Solaris 8.

- There is a very odd problem with the alignment of dword_t values
  which causes this program to not work correctly when compiled on
  Solaris 8.  The workaround is not use a pointer and to memcpy the
  values instead.
parent c2192641
...@@ -12,12 +12,14 @@ ...@@ -12,12 +12,14 @@
* -- Cort * -- Cort
* *
* Modified for x86 hosted builds by Matt Porter <porter@neta.com> * Modified for x86 hosted builds by Matt Porter <porter@neta.com>
* Modified for Sparc hosted builds by Peter Wahl <PeterWahl@web.de>
*/ */
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <strings.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
...@@ -147,7 +149,7 @@ int main(int argc, char *argv[]) ...@@ -147,7 +149,7 @@ int main(int argc, char *argv[])
void write_prep_partition(int in, int out) void write_prep_partition(int in, int out)
{ {
unsigned char block[512]; unsigned char block[512];
partition_entry_t *pe = (partition_entry_t *)&block[0x1BE]; partition_entry_t pe;
dword_t *entry = (dword_t *)&block[0]; dword_t *entry = (dword_t *)&block[0];
dword_t *length = (dword_t *)&block[sizeof(long)]; dword_t *length = (dword_t *)&block[sizeof(long)];
struct stat info; struct stat info;
...@@ -177,8 +179,8 @@ void write_prep_partition(int in, int out) ...@@ -177,8 +179,8 @@ void write_prep_partition(int in, int out)
* Build a "PReP" partition table entry in the boot record * Build a "PReP" partition table entry in the boot record
* - "PReP" may only look at the system_indicator * - "PReP" may only look at the system_indicator
*/ */
pe->boot_indicator = BootActive; pe.boot_indicator = BootActive;
pe->system_indicator = SystemPrep; pe.system_indicator = SystemPrep;
/* /*
* The first block of the diskette is used by this "boot record" which * The first block of the diskette is used by this "boot record" which
* actually contains the partition table. (The first block of the * actually contains the partition table. (The first block of the
...@@ -186,12 +188,12 @@ void write_prep_partition(int in, int out) ...@@ -186,12 +188,12 @@ void write_prep_partition(int in, int out)
* one partition on the diskette and it shall contain the rest of the * one partition on the diskette and it shall contain the rest of the
* diskette. * diskette.
*/ */
pe->starting_head = 0; /* zero-based */ pe.starting_head = 0; /* zero-based */
pe->starting_sector = 2; /* one-based */ pe.starting_sector = 2; /* one-based */
pe->starting_cylinder = 0; /* zero-based */ pe.starting_cylinder = 0; /* zero-based */
pe->ending_head = 1; /* assumes two heads */ pe.ending_head = 1; /* assumes two heads */
pe->ending_sector = 18; /* assumes 18 sectors/track */ pe.ending_sector = 18; /* assumes 18 sectors/track */
pe->ending_cylinder = 79; /* assumes 80 cylinders/diskette */ pe.ending_cylinder = 79; /* assumes 80 cylinders/diskette */
/* /*
* The "PReP" software ignores the above fields and just looks at * The "PReP" software ignores the above fields and just looks at
...@@ -201,20 +203,20 @@ void write_prep_partition(int in, int out) ...@@ -201,20 +203,20 @@ void write_prep_partition(int in, int out)
* - unlike the above sector numbers, the beginning sector is zero-based! * - unlike the above sector numbers, the beginning sector is zero-based!
*/ */
#if 0 #if 0
pe->beginning_sector = cpu_to_le32(1); pe.beginning_sector = cpu_to_le32(1);
#else #else
/* This has to be 0 on the PowerStack? */ /* This has to be 0 on the PowerStack? */
#ifdef __i386__ #ifdef __i386__
pe->beginning_sector = 0; pe.beginning_sector = 0;
#else #else
pe->beginning_sector = cpu_to_le32(0); pe.beginning_sector = cpu_to_le32(0);
#endif /* __i386__ */ #endif /* __i386__ */
#endif #endif
#ifdef __i386__ #ifdef __i386__
pe->number_of_sectors = 2*18*80-1; pe.number_of_sectors = 2*18*80-1;
#else #else
pe->number_of_sectors = cpu_to_le32(2*18*80-1); pe.number_of_sectors = cpu_to_le32(2*18*80-1);
#endif /* __i386__ */ #endif /* __i386__ */
write( out, block, sizeof(block) ); write( out, block, sizeof(block) );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment