Eliminate unaligned access on Alpha and also neaten up this code a little.
Submitted by: dfr
This commit is contained in:
parent
0e9aa62522
commit
e2bde560d5
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id: disk.c,v 1.35 1998/05/19 11:15:44 obrien Exp $
|
||||
* $Id: disk.c,v 1.36 1998/09/15 10:23:17 gibbs Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -43,6 +43,23 @@ Open_Disk(const char *name)
|
||||
return Int_Open_Disk(name,0);
|
||||
}
|
||||
|
||||
static u_int32_t
|
||||
Read_Int32(u_int32_t *p)
|
||||
{
|
||||
u_int8_t *bp = (u_int8_t *)p;
|
||||
return bp[0] | (bp[1] << 8) | (bp[2] << 16) | (bp[3] << 24);
|
||||
}
|
||||
|
||||
static void
|
||||
Write_Int32(u_int32_t *p, u_int32_t v)
|
||||
{
|
||||
u_int8_t *bp = (u_int8_t *)p;
|
||||
bp[0] = (v >> 0) & 0xff;
|
||||
bp[1] = (v >> 8) & 0xff;
|
||||
bp[2] = (v >> 16) & 0xff;
|
||||
bp[3] = (v >> 24) & 0xff;
|
||||
}
|
||||
|
||||
struct disk *
|
||||
Int_Open_Disk(const char *name, u_long size)
|
||||
{
|
||||
@ -94,10 +111,13 @@ Int_Open_Disk(const char *name, u_long size)
|
||||
|
||||
p = read_block(fd,0);
|
||||
dp = (struct dos_partition*)(p+DOSPARTOFF);
|
||||
for(i=0;i<NDOSPART;i++) {
|
||||
if (dp->dp_start >= size) continue;
|
||||
if (dp->dp_start+dp->dp_size >= size) continue;
|
||||
if (!dp->dp_size) continue;
|
||||
for (i=0; i < NDOSPART; i++) {
|
||||
if (Read_Int32(&dp->dp_start) >= size)
|
||||
continue;
|
||||
if (Read_Int32(&dp->dp_start) + Read_Int32(&dp->dp_size) >= size)
|
||||
continue;
|
||||
if (!Read_Int32(&dp->dp_size))
|
||||
continue;
|
||||
|
||||
if (dp->dp_typ == DOSPTYP_ONTRACK) {
|
||||
d->flags |= DISK_ON_TRACK;
|
||||
|
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id: write_disk.c,v 1.20 1997/02/22 15:06:40 peter Exp $
|
||||
* $Id: write_disk.c,v 1.21 1998/06/27 02:01:25 jdp Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -113,6 +113,16 @@ Write_Extended(int fd, struct disk *new, struct disk *old, struct chunk *c1)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
Write_Int32(u_int32_t *p, u_int32_t v)
|
||||
{
|
||||
u_int8_t *bp = (u_int8_t *)p;
|
||||
bp[0] = (v >> 0) & 0xff;
|
||||
bp[1] = (v >> 8) & 0xff;
|
||||
bp[2] = (v >> 16) & 0xff;
|
||||
bp[3] = (v >> 24) & 0xff;
|
||||
}
|
||||
|
||||
int
|
||||
Write_Disk(struct disk *d1)
|
||||
{
|
||||
@ -154,8 +164,8 @@ Write_Disk(struct disk *d1)
|
||||
if (c1->type == freebsd)
|
||||
ret += Write_FreeBSD(fd, d1,old,c1);
|
||||
|
||||
dp[j].dp_start = c1->offset;
|
||||
dp[j].dp_size = c1->size;
|
||||
Write_Int32(&dp[j].dp_start, c1->offset);
|
||||
Write_Int32(&dp[j].dp_size, c1->size);
|
||||
|
||||
i = c1->offset;
|
||||
if (i >= 1024*d1->bios_sect*d1->bios_hd) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user