-check MBR signature before using MBR partition data
-add new FAT types and Linux EXT2 to the faked-up partition table
This commit is contained in:
parent
74b401ffd1
commit
e225b4cbdd
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disksubr.c,v 1.24 1998/02/19 14:07:33 drochner Exp $ */
|
||||
/* $NetBSD: disksubr.c,v 1.25 1998/02/22 14:48:27 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
|
||||
|
@ -43,8 +43,13 @@
|
|||
|
||||
#define b_cylin b_resid
|
||||
|
||||
#define MBRSIGOFS 0x1fe
|
||||
static char mbrsig[2] = {0x55, 0xaa};
|
||||
|
||||
int fat_types[] = { DOSPTYP_FAT12, DOSPTYP_FAT16S,
|
||||
DOSPTYP_FAT16B, DOSPTYP_FAT16C, -1 };
|
||||
DOSPTYP_FAT16B, DOSPTYP_FAT32,
|
||||
DOSPTYP_FAT32L, DOSPTYP_FAT16L,
|
||||
-1 };
|
||||
|
||||
/*
|
||||
* Attempt to read a disk label from a device
|
||||
|
@ -97,7 +102,9 @@ readdisklabel(dev, strat, lp, osdep)
|
|||
/* do dos partitions in the process of getting disklabel? */
|
||||
dospartoff = 0;
|
||||
cyl = LABELSECTOR / lp->d_secpercyl;
|
||||
if (osdep && (dp = osdep->dosparts) != NULL) {
|
||||
if (!osdep || (dp = osdep->dosparts) == NULL)
|
||||
goto nombrpart;
|
||||
|
||||
/* read master boot record */
|
||||
bp->b_blkno = DOSBBSECTOR;
|
||||
bp->b_bcount = lp->d_secsize;
|
||||
|
@ -112,6 +119,9 @@ readdisklabel(dev, strat, lp, osdep)
|
|||
} else {
|
||||
struct dos_partition *ourdp = NULL;
|
||||
|
||||
if (bcmp(bp->b_data + MBRSIGOFS, mbrsig, sizeof(mbrsig)))
|
||||
goto nombrpart;
|
||||
|
||||
/* XXX how do we check veracity/bounds of this? */
|
||||
bcopy(bp->b_data + DOSPARTOFF, dp,
|
||||
NDOSPART * sizeof(*dp));
|
||||
|
@ -144,6 +154,8 @@ readdisklabel(dev, strat, lp, osdep)
|
|||
if (dp->dp_typ == *ip)
|
||||
pp->p_fstype = FS_MSDOS;
|
||||
}
|
||||
if (dp->dp_typ == DOSPTYP_LNXEXT2)
|
||||
pp->p_fstype = FS_EX2FS;
|
||||
|
||||
/* is this ours? */
|
||||
if (dp == ourdp) {
|
||||
|
@ -165,8 +177,8 @@ readdisklabel(dev, strat, lp, osdep)
|
|||
}
|
||||
lp->d_npartitions = RAW_PART + 1 + i;
|
||||
}
|
||||
}
|
||||
|
||||
nombrpart:
|
||||
/* next, dig out disk label */
|
||||
bp->b_blkno = dospartoff + LABELSECTOR;
|
||||
bp->b_cylin = cyl;
|
||||
|
@ -318,7 +330,9 @@ writedisklabel(dev, strat, lp, osdep)
|
|||
/* do dos partitions in the process of getting disklabel? */
|
||||
dospartoff = 0;
|
||||
cyl = LABELSECTOR / lp->d_secpercyl;
|
||||
if (osdep && (dp = osdep->dosparts) != NULL) {
|
||||
if (!osdep || (dp = osdep->dosparts) == NULL)
|
||||
goto nombrpart;
|
||||
|
||||
/* read master boot record */
|
||||
bp->b_blkno = DOSBBSECTOR;
|
||||
bp->b_bcount = lp->d_secsize;
|
||||
|
@ -329,6 +343,9 @@ writedisklabel(dev, strat, lp, osdep)
|
|||
if ((error = biowait(bp)) == 0) {
|
||||
struct dos_partition *ourdp = NULL;
|
||||
|
||||
if (bcmp(bp->b_data + MBRSIGOFS, mbrsig, sizeof(mbrsig)))
|
||||
goto nombrpart;
|
||||
|
||||
/* XXX how do we check veracity/bounds of this? */
|
||||
bcopy(bp->b_data + DOSPARTOFF, dp,
|
||||
NDOSPART * sizeof(*dp));
|
||||
|
@ -359,8 +376,8 @@ writedisklabel(dev, strat, lp, osdep)
|
|||
cyl = DPCYL(dp->dp_scyl, dp->dp_ssect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nombrpart:
|
||||
#ifdef maybe
|
||||
/* disklabel in appropriate location? */
|
||||
if (lp->d_partitions[2].p_offset != 0
|
||||
|
|
Loading…
Reference in New Issue