diff options
author | phk <phk@FreeBSD.org> | 1995-04-30 07:30:45 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1995-04-30 07:30:45 +0000 |
commit | e3530256c92006ba39a552dde4dad1c0b68421a9 (patch) | |
tree | 38bde9d4beeed3e530888635ee15cee4b874bdcd /lib | |
parent | 5b57901e70e5cf81adca841053c06d41584ad0e5 (diff) | |
download | FreeBSD-src-e3530256c92006ba39a552dde4dad1c0b68421a9.zip FreeBSD-src-e3530256c92006ba39a552dde4dad1c0b68421a9.tar.gz |
Use 0xff for CHS when past 1024 cyls.
Fix (hopefully) a bug Gary found.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libdisk/disk.c | 19 | ||||
-rw-r--r-- | lib/libdisk/write_disk.c | 56 |
2 files changed, 47 insertions, 28 deletions
diff --git a/lib/libdisk/disk.c b/lib/libdisk/disk.c index fb483e0..c73d819 100644 --- a/lib/libdisk/disk.c +++ b/lib/libdisk/disk.c @@ -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.5 1995/04/29 07:21:11 phk Exp $ + * $Id: disk.c,v 1.6 1995/04/30 06:09:26 phk Exp $ * */ @@ -131,21 +131,28 @@ Int_Open_Disk(char *name, u_long size) warn("failed to add MBR chunk for slice %d",i - 1); if (ds.dss_slices[i].ds_type == 0xa5) { struct disklabel *dl; - int j; dl = read_disklabel(fd, ds.dss_slices[i].ds_offset + LABELSECTOR); if(dl) { char pname[20]; + int j; + u_long l; + if (dl->d_partitions[RAW_PART].p_offset == 0 && + dl->d_partitions[RAW_PART].p_size == + ds.dss_slices[i].ds_size) + l = ds.dss_slices[i].ds_offset; + else + l = 0; for(j=0; j < dl->d_npartitions; j++) { sprintf(pname,"%s%c",sname,j+'a'); - if (j == 2 || j == 3) + if (j == RAW_PART || j == 3) continue; if (!dl->d_partitions[j].p_size) continue; if (Add_Chunk(d, dl->d_partitions[j].p_offset + - ds.dss_slices[i].ds_offset, + l, dl->d_partitions[j].p_size, pname,part,0,0)) warn( @@ -156,11 +163,11 @@ Int_Open_Disk(char *name, u_long size) if (dl->d_partitions[3].p_size) Add_Chunk(d, dl->d_partitions[3].p_offset + - ds.dss_slices[i].ds_offset, + l, dl->d_partitions[3].p_size, pname,part,0,0); + free(dl); } - free(dl); } } close(fd); diff --git a/lib/libdisk/write_disk.c b/lib/libdisk/write_disk.c index f39c67d..51e4e4a 100644 --- a/lib/libdisk/write_disk.c +++ b/lib/libdisk/write_disk.c @@ -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.1 1995/04/29 07:21:14 phk Exp $ + * $Id: write_disk.c,v 1.2 1995/04/30 06:09:29 phk Exp $ * */ @@ -109,7 +109,7 @@ Write_Disk(struct disk *d1) struct chunk *c1; int ret = 0; char device[64]; - void *mbr; + u_char *mbr; struct dos_partition *dp; int s[4]; @@ -141,28 +141,38 @@ Write_Disk(struct disk *d1) dp[j].dp_size = c1->size; i = c1->offset; - if (i >= 1024*d1->bios_sect*d1->bios_hd) - i = 1024*d1->bios_sect*d1->bios_hd - 1; - dp[j].dp_ssect = i % d1->bios_sect; - i -= dp[j].dp_ssect; - i /= d1->bios_sect; - dp[j].dp_ssect++; - dp[j].dp_shd = i % d1->bios_hd; - i -= dp[j].dp_shd; - i /= d1->bios_hd; - dp[j].dp_scyl = i; + if (i >= 1024*d1->bios_sect*d1->bios_hd) { + dp[j].dp_ssect = 0xff; + dp[j].dp_shd = 0xff; + dp[j].dp_scyl = 0xff; + + } else { + dp[j].dp_ssect = i % d1->bios_sect; + i -= dp[j].dp_ssect; + i /= d1->bios_sect; + dp[j].dp_ssect++; + dp[j].dp_shd = i % d1->bios_hd; + i -= dp[j].dp_shd; + i /= d1->bios_hd; + dp[j].dp_scyl = i; + } i = c1->end; - if (i >= 1024*d1->bios_sect*d1->bios_hd) - i = 1024*d1->bios_sect*d1->bios_hd - 1; - dp[j].dp_esect = i % d1->bios_sect; - i -= dp[j].dp_esect; - i /= d1->bios_sect; - dp[j].dp_esect++; - dp[j].dp_ehd = i % d1->bios_hd; - i -= dp[j].dp_ehd; - i /= d1->bios_hd; - dp[j].dp_ecyl = i; + if (i >= 1024*d1->bios_sect*d1->bios_hd) { + dp[j].dp_esect = 0xff; + dp[j].dp_ehd = 0xff; + dp[j].dp_ecyl = 0xff; + } else { + dp[j].dp_esect = i % d1->bios_sect; + i -= dp[j].dp_esect; + i /= d1->bios_sect; + dp[j].dp_esect++; + dp[j].dp_ehd = i % d1->bios_hd; + i -= dp[j].dp_ehd; + i /= d1->bios_hd; + dp[j].dp_ecyl = i; + } + switch (c1->type) { case freebsd: dp[j].dp_typ = 0xa5; @@ -182,6 +192,8 @@ Write_Disk(struct disk *d1) if (!s[i]) memset(dp+i,0,sizeof *dp); + mbr[512-2] = 0x55; + mbr[512-1] = 0xaa; write_block(fd,WHERE(0,d1),mbr); close(fd); |