Align slices to cylinder boundries.
Submitted By: phk
This commit is contained in:
parent
0412e9f72c
commit
2f2a4e7a4a
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id: change.c,v 1.3 1995/04/29 04:00:53 phk Exp $
|
||||
* $Id: change.c,v 1.5 1995/05/01 04:05:23 phk Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -55,5 +55,10 @@ All_FreeBSD(struct disk *d)
|
||||
goto again;
|
||||
}
|
||||
c=d->chunks;
|
||||
if (d->flags & DISK_ON_TRACK) {
|
||||
c->offset += 63;
|
||||
c->part->offset += 63;
|
||||
d->flags &= ~DISK_ON_TRACK;
|
||||
}
|
||||
Create_Chunk(d,c->offset,c->size,freebsd,0xa5,0);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id: create_chunk.c,v 1.17 1995/05/15 19:03:08 phk Exp $
|
||||
* $Id: create_chunk.c,v 1.18 1995/05/20 19:11:44 phk Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -155,11 +155,18 @@ int
|
||||
Create_Chunk(struct disk *d, u_long offset, u_long size, chunk_e type, int subtype, u_long flags)
|
||||
{
|
||||
int i;
|
||||
u_long l;
|
||||
|
||||
/* Never use the first track */
|
||||
if (!offset) {
|
||||
offset += d->bios_sect;
|
||||
size -= d->bios_sect;
|
||||
}
|
||||
|
||||
/* Always end on cylinder boundary */
|
||||
l = (offset+size) % (d->bios_sect * d->bios_hd);
|
||||
size -= l;
|
||||
|
||||
i = Add_Chunk(d,offset,size,"X",type,subtype,flags);
|
||||
Fixup_Names(d);
|
||||
return i;
|
||||
|
@ -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.10 1995/05/18 22:25:37 phk Exp $
|
||||
* $Id: write_disk.c,v 1.11 1995/05/21 07:47:24 phk Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -24,7 +24,6 @@
|
||||
#include "libdisk.h"
|
||||
|
||||
#define DOSPTYP_EXTENDED 5
|
||||
#define DOSPTYP_ONTRACK 84
|
||||
#define BBSIZE 8192
|
||||
|
||||
#define WHERE(offset,disk) (disk->flags & DISK_ON_TRACK ? offset + 63 : offset)
|
||||
@ -38,7 +37,7 @@ Write_FreeBSD(int fd, struct disk *new, struct disk *old, struct chunk *c1)
|
||||
u_char buf[BBSIZE];
|
||||
|
||||
for(i=0;i<BBSIZE/512;i++) {
|
||||
p = read_block(fd,i + c1->offset);
|
||||
p = read_block(fd,WHERE(i + c1->offset,new));
|
||||
memcpy(buf+512*i,p,512);
|
||||
free(p);
|
||||
}
|
||||
@ -124,7 +123,7 @@ Write_Disk(struct disk *d1)
|
||||
}
|
||||
|
||||
memset(s,0,sizeof s);
|
||||
mbr = read_block(fd,0);
|
||||
mbr = read_block(fd,WHERE(0,d1));
|
||||
dp = (struct dos_partition*) (mbr + DOSPARTOFF);
|
||||
memcpy(work,dp,sizeof work);
|
||||
dp = work;
|
||||
@ -201,7 +200,7 @@ Write_Disk(struct disk *d1)
|
||||
if (dp[i].dp_typ == 0xa5)
|
||||
dp[i].dp_flag = 0x80;
|
||||
|
||||
mbr = read_block(fd,0);
|
||||
mbr = read_block(fd,WHERE(0,d1));
|
||||
if (d1->bootmgr)
|
||||
memcpy(mbr,d1->bootmgr,DOSPARTOFF);
|
||||
memcpy(mbr+DOSPARTOFF,dp,sizeof *dp * NDOSPART);
|
||||
|
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id: change.c,v 1.3 1995/04/29 04:00:53 phk Exp $
|
||||
* $Id: change.c,v 1.5 1995/05/01 04:05:23 phk Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -55,5 +55,10 @@ All_FreeBSD(struct disk *d)
|
||||
goto again;
|
||||
}
|
||||
c=d->chunks;
|
||||
if (d->flags & DISK_ON_TRACK) {
|
||||
c->offset += 63;
|
||||
c->part->offset += 63;
|
||||
d->flags &= ~DISK_ON_TRACK;
|
||||
}
|
||||
Create_Chunk(d,c->offset,c->size,freebsd,0xa5,0);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id: create_chunk.c,v 1.17 1995/05/15 19:03:08 phk Exp $
|
||||
* $Id: create_chunk.c,v 1.18 1995/05/20 19:11:44 phk Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -155,11 +155,18 @@ int
|
||||
Create_Chunk(struct disk *d, u_long offset, u_long size, chunk_e type, int subtype, u_long flags)
|
||||
{
|
||||
int i;
|
||||
u_long l;
|
||||
|
||||
/* Never use the first track */
|
||||
if (!offset) {
|
||||
offset += d->bios_sect;
|
||||
size -= d->bios_sect;
|
||||
}
|
||||
|
||||
/* Always end on cylinder boundary */
|
||||
l = (offset+size) % (d->bios_sect * d->bios_hd);
|
||||
size -= l;
|
||||
|
||||
i = Add_Chunk(d,offset,size,"X",type,subtype,flags);
|
||||
Fixup_Names(d);
|
||||
return i;
|
||||
|
@ -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.10 1995/05/18 22:25:37 phk Exp $
|
||||
* $Id: write_disk.c,v 1.11 1995/05/21 07:47:24 phk Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -24,7 +24,6 @@
|
||||
#include "libdisk.h"
|
||||
|
||||
#define DOSPTYP_EXTENDED 5
|
||||
#define DOSPTYP_ONTRACK 84
|
||||
#define BBSIZE 8192
|
||||
|
||||
#define WHERE(offset,disk) (disk->flags & DISK_ON_TRACK ? offset + 63 : offset)
|
||||
@ -38,7 +37,7 @@ Write_FreeBSD(int fd, struct disk *new, struct disk *old, struct chunk *c1)
|
||||
u_char buf[BBSIZE];
|
||||
|
||||
for(i=0;i<BBSIZE/512;i++) {
|
||||
p = read_block(fd,i + c1->offset);
|
||||
p = read_block(fd,WHERE(i + c1->offset,new));
|
||||
memcpy(buf+512*i,p,512);
|
||||
free(p);
|
||||
}
|
||||
@ -124,7 +123,7 @@ Write_Disk(struct disk *d1)
|
||||
}
|
||||
|
||||
memset(s,0,sizeof s);
|
||||
mbr = read_block(fd,0);
|
||||
mbr = read_block(fd,WHERE(0,d1));
|
||||
dp = (struct dos_partition*) (mbr + DOSPARTOFF);
|
||||
memcpy(work,dp,sizeof work);
|
||||
dp = work;
|
||||
@ -201,7 +200,7 @@ Write_Disk(struct disk *d1)
|
||||
if (dp[i].dp_typ == 0xa5)
|
||||
dp[i].dp_flag = 0x80;
|
||||
|
||||
mbr = read_block(fd,0);
|
||||
mbr = read_block(fd,WHERE(0,d1));
|
||||
if (d1->bootmgr)
|
||||
memcpy(mbr,d1->bootmgr,DOSPARTOFF);
|
||||
memcpy(mbr+DOSPARTOFF,dp,sizeof *dp * NDOSPART);
|
||||
|
Loading…
x
Reference in New Issue
Block a user