summaryrefslogtreecommitdiffstats
path: root/sbin/i386/fdisk
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1996-10-13 18:18:50 +0000
committerbde <bde@FreeBSD.org>1996-10-13 18:18:50 +0000
commitf35890901a4ab4f3504147eecc4f8e1e8343dd12 (patch)
treef230e334eed9814485ffff75d9f771085d5586f3 /sbin/i386/fdisk
parentc4eeb055c16b0d23129bdef9a0d9d2f8abdb8c75 (diff)
downloadFreeBSD-src-f35890901a4ab4f3504147eecc4f8e1e8343dd12.zip
FreeBSD-src-f35890901a4ab4f3504147eecc4f8e1e8343dd12.tar.gz
The dos() function needs a new second argument, containing the size
of the partition. Only if the size is 0 should the special handling of 0 as first argument be triggered. [This bug caused offset 0 to give C/H/S = 0/0/0 instead of 0/0/1.] The init_sector0 function needs to decrease the first argument to the second call to dos() by one to be consistent with the calls to dos() in change_part(). [This bug caused fdisk -i to create bogus partition tables with the ending C/H/S value 1 too high. This usually gives S = 1 instead of S = maximum, so the geometry guessing in the slice code and perhaps in SCSI BIOSes was defeated.] Submitted by: Tor Egge <tegge@itea.ntnu.no>
Diffstat (limited to 'sbin/i386/fdisk')
-rw-r--r--sbin/i386/fdisk/fdisk.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/sbin/i386/fdisk/fdisk.c b/sbin/i386/fdisk/fdisk.c
index de26e60..13418c8 100644
--- a/sbin/i386/fdisk/fdisk.c
+++ b/sbin/i386/fdisk/fdisk.c
@@ -183,7 +183,8 @@ static void change_part(int i);
static void print_params();
static void change_active(int which);
static void get_params_to_use();
-static void dos(int sec, unsigned char *c, unsigned char *s, unsigned char *h);
+static void dos(int sec, int size, unsigned char *c, unsigned char *s,
+ unsigned char *h);
static int open_disk(int u_flag);
static ssize_t read_disk(off_t sector, void *buf);
static ssize_t write_disk(off_t sector, void *buf);
@@ -372,8 +373,10 @@ unsigned long size = disksecs - start;
partp->dp_start = start;
partp->dp_size = size;
- dos(partp->dp_start, &partp->dp_scyl, &partp->dp_ssect, &partp->dp_shd);
- dos(partp->dp_start+partp->dp_size, &partp->dp_ecyl, &partp->dp_esect, &partp->dp_ehd);
+ dos(partp->dp_start, partp->dp_size,
+ &partp->dp_scyl, &partp->dp_ssect, &partp->dp_shd);
+ dos(partp->dp_start + partp->dp_size - 1, partp->dp_size,
+ &partp->dp_ecyl, &partp->dp_esect, &partp->dp_ehd);
}
static void
@@ -424,10 +427,10 @@ struct dos_partition *partp = ((struct dos_partition *) &mboot.parts) + i;
partp->dp_esect = DOSSECT(tsec,tcyl);
partp->dp_ehd = thd;
} else {
- dos(partp->dp_start,
- &partp->dp_scyl, &partp->dp_ssect, &partp->dp_shd);
- dos(partp->dp_start+partp->dp_size - 1,
- &partp->dp_ecyl, &partp->dp_esect, &partp->dp_ehd);
+ dos(partp->dp_start, partp->dp_size,
+ &partp->dp_scyl, &partp->dp_ssect, &partp->dp_shd);
+ dos(partp->dp_start + partp->dp_size - 1, partp->dp_size,
+ &partp->dp_ecyl, &partp->dp_esect, &partp->dp_ehd);
}
print_part(i);
@@ -491,14 +494,14 @@ get_params_to_use()
* Change real numbers into strange dos numbers *
\***********************************************/
static void
-dos(sec, c, s, h)
-int sec;
+dos(sec, size, c, s, h)
+int sec, size;
unsigned char *c, *s, *h;
{
int cy;
int hd;
- if (sec == 0) {
+ if (sec == 0 && size == 0) {
*s = *c = *h = 0;
return;
}
OpenPOWER on IntegriCloud