Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/sun Properly convert values according to block size ...



details:   https://anonhg.NetBSD.org/src/rev/45ad696063c1
branches:  trunk
changeset: 753353:45ad696063c1
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Mar 23 20:01:09 2010 +0000

description:
Properly convert values according to block size differences between the
underlying device (might be a CD drive) and the sun label when carrying
over defaults from a ISO9660 partition.

diffstat:

 sys/dev/sun/disksubr.c |  15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diffs (58 lines):

diff -r fe8b32725df6 -r 45ad696063c1 sys/dev/sun/disksubr.c
--- a/sys/dev/sun/disksubr.c    Tue Mar 23 19:22:41 2010 +0000
+++ b/sys/dev/sun/disksubr.c    Tue Mar 23 20:01:09 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disksubr.c,v 1.13 2010/03/16 14:53:08 martin Exp $ */
+/*     $NetBSD: disksubr.c,v 1.14 2010/03/23 20:01:09 martin Exp $ */
 
 /*
  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.13 2010/03/16 14:53:08 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.14 2010/03/23 20:01:09 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -281,6 +281,7 @@
        struct partition *npp;
        struct sun_dkpart *spp;
        int i, secpercyl;
+       unsigned int secpblck;
        u_short cksum, *sp1, *sp2;
 
        sl = (struct sun_disklabel *)cp;
@@ -299,6 +300,8 @@
        lp->d_magic2 = DISKMAGIC;
        memcpy(lp->d_packname, sl->sl_text, sizeof(lp->d_packname));
 
+       secpblck = lp->d_secsize / 512;
+       if (secpblck == 0) secpblck = 1; /* can't happen */
        lp->d_secsize = 512;
        lp->d_nsectors   = sl->sl_nsectors;
        lp->d_ntracks    = sl->sl_ntracks;
@@ -321,9 +324,10 @@
        for (i = 0; i < 8; i++) {
                spp = &sl->sl_part[i];
                npp = &lp->d_partitions[i];
+
                if (npp->p_fstype == FS_ISO9660
-                   && spp->sdkp_cyloffset * secpercyl == npp->p_offset
-                   && spp->sdkp_nsectors <= npp->p_size
+                   && spp->sdkp_cyloffset * secpercyl == npp->p_offset*secpblck
+                   && spp->sdkp_nsectors <= npp->p_size*secpblck
                    && npp->p_size > 0 && spp->sdkp_nsectors > 0) {
                        /*
                         * This happens for example on sunlabel'd hybrid
@@ -332,6 +336,9 @@
                         * partition (including session parameters), so
                         * we better not overwrite it.
                         */
+                       npp->p_offset *= secpblck;
+                       npp->p_size = spp->sdkp_nsectors;
+                       npp->p_cdsession *= secpblck;
                        continue;
                }
                npp->p_offset = spp->sdkp_cyloffset * secpercyl;



Home | Main Index | Thread Index | Old Index