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.
This commit is contained in:
martin 2010-03-23 20:01:09 +00:00
parent 4af989b1cc
commit d6bdba5871

View File

@ -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 @@ disklabel_sun_to_bsd(char *cp, struct disklabel *lp)
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 @@ disklabel_sun_to_bsd(char *cp, struct disklabel *lp)
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 @@ disklabel_sun_to_bsd(char *cp, struct disklabel *lp)
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 @@ disklabel_sun_to_bsd(char *cp, struct disklabel *lp)
* 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;