Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/fdisk Truncate the CHS values correctly in case a parti...



details:   https://anonhg.NetBSD.org/src/rev/34dadcebeb82
branches:  trunk
changeset: 486712:34dadcebeb82
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Sat May 27 19:02:54 2000 +0000

description:
Truncate the CHS values correctly in case a partition boundary exceeds
their range.

diffstat:

 sbin/fdisk/fdisk.c |  11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (39 lines):

diff -r f721bf21bf77 -r 34dadcebeb82 sbin/fdisk/fdisk.c
--- a/sbin/fdisk/fdisk.c        Sat May 27 19:01:13 2000 +0000
+++ b/sbin/fdisk/fdisk.c        Sat May 27 19:02:54 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fdisk.c,v 1.39 2000/01/31 15:54:48 soda Exp $ */
+/*     $NetBSD: fdisk.c,v 1.40 2000/05/27 19:02:54 fvdl Exp $ */
 
 /*
  * Mach Operating System
@@ -29,7 +29,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: fdisk.c,v 1.39 2000/01/31 15:54:48 soda Exp $");
+__RCSID("$NetBSD: fdisk.c,v 1.40 2000/05/27 19:02:54 fvdl Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -1190,6 +1190,11 @@
        unsigned char *cylinderp, *headp, *sectorp;
 {
        int cylinder, head;
+       int biosmaxsec;
+
+       biosmaxsec = dos_cylinders * dos_heads * dos_sectors - 1;
+       if (sector > biosmaxsec)
+               sector = biosmaxsec;
 
        cylinder = sector / dos_cylindersectors;
 
@@ -1198,8 +1203,6 @@
        head = sector / dos_sectors;
        sector -= head * dos_sectors;
 
-       if (cylinder >= MAXCYL)
-               cylinder = MAXCYL - 1;
        *cylinderp = DOSCYL(cylinder);
        *headp = head;
        *sectorp = DOSSECT(sector + 1, cylinder);



Home | Main Index | Thread Index | Old Index