Module Name: src
Committed By: martin
Date: Tue Mar 23 20:01:09 UTC 2010
Modified Files:
src/sys/dev/sun: disksubr.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/sun/disksubr.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/sun/disksubr.c
diff -u src/sys/dev/sun/disksubr.c:1.13 src/sys/dev/sun/disksubr.c:1.14
--- src/sys/dev/sun/disksubr.c:1.13 Tue Mar 16 14:53:08 2010
+++ src/sys/dev/sun/disksubr.c Tue Mar 23 20:01:09 2010
@@ -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;