diff options
Diffstat (limited to 'sys/arch/aviion')
-rw-r--r-- | sys/arch/aviion/aviion/disksubr.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/sys/arch/aviion/aviion/disksubr.c b/sys/arch/aviion/aviion/disksubr.c index 3a439fbae1b..d2359312979 100644 --- a/sys/arch/aviion/aviion/disksubr.c +++ b/sys/arch/aviion/aviion/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.16 2007/02/03 18:22:33 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.17 2007/02/18 13:49:22 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -71,6 +71,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) struct partition *pp; struct disklabel *dlp; unsigned long extoff = 0; + unsigned int fattest; struct buf *bp = NULL; daddr_t part_blkno = DOSBBSECTOR; char *msg = NULL; @@ -215,6 +216,33 @@ donot: lp->d_sbsize = 64*1024; /* XXX ? */ lp->d_npartitions = MAXPARTITIONS; + if (n == 0 && part_blkno == DOSBBSECTOR) { + /* Check for a short jump instruction. */ + fattest = ((bp->b_data[0] << 8) & 0xff00) | (bp->b_data[2] & + 0xff); + if (fattest != 0xeb90 && fattest != 0xe900) + goto notfat; + + /* Check for a valid bytes per sector value. */ + fattest = ((bp->b_data[12] << 8) & 0xff00) | (bp->b_data[11] & + 0xff); + if (fattest < 512 || fattest > 4096 || (fattest % 512 != 0)) + goto notfat; + + /* Check the end of sector marker. */ + fattest = ((bp->b_data[510] << 8) & 0xff00) | (bp->b_data[511] & + 0xff); + if (fattest != 0x55aa) + goto notfat; + + /* Looks like a FAT filesystem. Spoof 'i'. */ + lp->d_partitions['i' - 'a'].p_size = + lp->d_partitions[RAW_PART].p_size; + lp->d_partitions['i' - 'a'].p_offset = 0; + lp->d_partitions['i' - 'a'].p_fstype = FS_MSDOS; + } +notfat: + /* don't read the on-disk label if we are in spoofed-only mode */ if (spoofonly) goto done; |