Subject: DOS filesystems on disks with no NetBSD partition
To: None <port-i386@NetBSD.ORG>
From: Greg Hudson <ghudson@MIT.EDU>
List: port-i386
Date: 03/02/1996 03:38:55
Included below is a patch to allow users to mount primary DOS
partitions on disks with no NetBSD partition. The patch does
essentially two things:
1. It puts the primary MBR partitions in the default disklabel
as partitions e, f, g, and h (i.e. after the raw
partition).
2. When it installs an MBR partition in the disklabel, it
compares the MBR partition type against four FAT filesystem
types; if it matches any of them, the disklabel partition
gets a p_type of FS_MSDOS.
The patch is straightforward, and I've tested it. I'll check this in
in a few days if there aren't objections.
*** sys/arch/i386/include/disklabel.h 1996/03/02 07:44:35 1.1
--- sys/arch/i386/include/disklabel.h 1996/03/02 07:54:39
***************
*** 59,64 ****
--- 59,68 ----
/* Known DOS partition types. */
#define DOSPTYP_386BSD 0xa5 /* 386BSD partition type */
#define DOSPTYP_NETBSD DOSPTYP_386BSD /* NetBSD partition type (XXX) */
+ #define DOSPTYP_FAT12 0x1 /* 12-bit FAT */
+ #define DOSPTYP_FAT16S 0x4 /* 16-bit FAT, less than 32M */
+ #define DOSPTYP_FAT16B 0x6 /* 16-bit FAT, more than 32M */
+ #define DOSPTYP_FAT16C 0xe /* 16-bit FAT, CHS-mapped */
#include <sys/dkbad.h>
struct cpu_disklabel {
*** sys/arch/i386/i386/disksubr.c 1996/03/01 22:21:56 1.1
--- sys/arch/i386/i386/disksubr.c 1996/03/02 08:33:53
***************
*** 43,48 ****
--- 43,51 ----
#define b_cylin b_resid
+ int fat_types[] = { DOSPTYP_FAT12, DOSPTYP_FAT16S,
+ DOSPTYP_FAT16B, DOSPTYP_FAT16C, -1 };
+
/*
* Attempt to read a disk label from a device
* using the indicated stategy routine.
***************
*** 66,71 ****
--- 69,75 ----
struct cpu_disklabel *osdep;
{
struct dos_partition *dp = osdep->dosparts;
+ struct partition *pp;
struct dkbad *bdp = &osdep->bad;
struct buf *bp;
struct disklabel *dlp;
***************
*** 109,115 ****
/* XXX how do we check veracity/bounds of this? */
bcopy(bp->b_data + DOSPARTOFF, dp,
NDOSPART * sizeof(*dp));
! for (i = 0; i < NDOSPART; i++, dp++)
/* is this ours? */
if (dp->dp_size && dp->dp_typ == DOSPTYP_386BSD
&& dospartoff == 0) {
--- 113,128 ----
/* XXX how do we check veracity/bounds of this? */
bcopy(bp->b_data + DOSPARTOFF, dp,
NDOSPART * sizeof(*dp));
! for (i = 0; i < NDOSPART; i++, dp++) {
! /* Install in partition e, f, g, or h. */
! pp = &lp->d_partitions[RAW_PART + 1 + i];
! pp->p_offset = dp->dp_start;
! pp->p_size = dp->dp_size;
! for (ip = fat_types; *ip != -1; ip++) {
! if (dp->dp_typ == *ip)
! pp->p_fstype = FS_MSDOS;
! }
!
/* is this ours? */
if (dp->dp_size && dp->dp_typ == DOSPTYP_386BSD
&& dospartoff == 0) {
***************
*** 128,135 ****
lp->d_secpercyl =
lp->d_ntracks * lp->d_nsectors;
}
}
-
}
/* next, dig out disk label */
--- 141,149 ----
lp->d_secpercyl =
lp->d_ntracks * lp->d_nsectors;
}
+ }
+ lp->d_npartitions = RAW_PART + 1 + i;
}
}
/* next, dig out disk label */