Use <sys/disklabel_mbr.h>.

This commit is contained in:
thorpej 1999-01-27 21:30:08 +00:00
parent af39050d19
commit 24d9973308
2 changed files with 15 additions and 62 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: disklabel.h,v 1.2 1998/07/07 04:36:15 thorpej Exp $ */
/* $NetBSD: disklabel.h,v 1.3 1999/01/27 21:30:08 thorpej Exp $ */
/*-
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -39,57 +39,10 @@
#define MAXPARTITIONS 16 /* number of partitions */
#define RAW_PART 2 /* raw partition: XX?c */
/* MBR partition table */
#define MBRSECTOR 0 /* MBR sector number */
#define MBRPARTOFF 446 /* Offset of MBR partition table */
#define NMBRPART 4 /* # of partitions in MBR */
#define MBRMAGICOFF 510 /* Offset of magic number */
#define MBRMAGIC 0xaa55 /* Actual magic number */
struct mbr_partition {
u_int8_t mbr_flag; /* default boot flag */
u_int8_t mbr_shd; /* start head, IsN't Always Meaningful */
u_int8_t mbr_ssect; /* start sector, INAM */
u_int8_t mbr_scyl; /* start cylinder, INAM */
u_int8_t mbr_type; /* partition type */
u_int8_t mbr_ehd; /* end head, INAM */
u_int8_t mbr_esect; /* end sector, INAM */
u_int8_t mbr_ecyl; /* end cylinder, INAM */
u_int32_t mbr_start; /* absolute start sector number */
u_int32_t mbr_size; /* partition size in sectors */
};
/* Known partition types: */
#define MBR_EXTENDED 0x05 /* Extended partition */
#define MBR_NETBSD 0xa9 /* NetBSD partition */
#define MBR_386BSD 0xa5 /* 386BSD partition */
/* For compatibility reasons (mainly for fdisk): */
#define dos_partition mbr_partition
#define dp_flag mbr_flag
#define dp_shd mbr_shd
#define dp_ssect mbr_ssect
#define dp_scyl mbr_scyl
#define dp_typ mbr_type
#define dp_ehd mbr_ehd
#define dp_esect mbr_esect
#define dp_ecyl mbr_ecyl
#define dp_start mbr_start
#define dp_size mbr_size
#define DOSPARTOFF MBRPARTOFF
#define NDOSPART NMBRPART
#define DOSPTYP_NETBSD MBR_NETBSD
struct cpu_disklabel {
int cd_start; /* Offset to NetBSD partition in blocks */
};
/* Isolate the relevant bits to get sector and cylinder. */
#define DPSECT(s) ((s) & 0x3f)
#define DPCYL(c, s) ((c) + (((s) & 0xc0) << 2))
#ifdef _KERNEL
struct disklabel;
int bounds_check_with_label __P((struct buf *bp, struct disklabel *lp, int wlabel));

View File

@ -1,4 +1,4 @@
/* $NetBSD: disksubr.c,v 1.2 1998/09/01 17:42:59 tsubai Exp $ */
/* $NetBSD: disksubr.c,v 1.3 1999/01/27 21:30:08 thorpej Exp $ */
/*
* Copyright (C) 1996 Wolfgang Solfrank.
@ -160,30 +160,30 @@ mbr_to_label(dev, strat, bno, lp, pnpart, osdep, off)
if (biowait(bp))
goto done;
if (get_short(bp->b_data + MBRMAGICOFF) != MBRMAGIC)
if (get_short(bp->b_data + MBR_MAGICOFF) != MBR_MAGIC)
goto done;
/* Extract info from MBR partition table */
mp = (struct mbr_partition *)(bp->b_data + MBRPARTOFF);
mp = (struct mbr_partition *)(bp->b_data + MBR_PARTOFF);
for (i = 0; i < NMBRPART; i++, mp++) {
if (get_long(&mp->mbr_size)) {
switch (mp->mbr_type) {
case MBR_EXTENDED:
if (get_long(&mp->mbrp_size)) {
switch (mp->mbrp_type) {
case MBR_PTYPE_EXT:
if (*pnpart < MAXPARTITIONS) {
pp = lp->d_partitions + *pnpart;
bzero(pp, sizeof *pp);
pp->p_size = get_long(&mp->mbr_size);
pp->p_offset = off + get_long(&mp->mbr_start);
pp->p_size = get_long(&mp->mbrp_size);
pp->p_offset = off + get_long(&mp->mbrp_start);
++*pnpart;
}
if (found = mbr_to_label(dev, strat,
off + get_long(&mp->mbr_start),
off + get_long(&mp->mbrp_start),
lp, pnpart, osdep, off))
goto done;
break;
case MBR_NETBSD:
case MBR_PTYPE_NETBSD:
/* Found the real NetBSD partition, use it */
osdep->cd_start = off + get_long(&mp->mbr_start);
osdep->cd_start = off + get_long(&mp->mbrp_start);
if (found = get_netbsd_label(dev, strat, lp, osdep->cd_start))
goto done;
/* FALLTHROUGH */
@ -191,8 +191,8 @@ mbr_to_label(dev, strat, bno, lp, pnpart, osdep, off)
if (*pnpart < MAXPARTITIONS) {
pp = lp->d_partitions + *pnpart;
bzero(pp, sizeof *pp);
pp->p_size = get_long(&mp->mbr_size);
pp->p_offset = off + get_long(&mp->mbr_start);
pp->p_size = get_long(&mp->mbrp_size);
pp->p_offset = off + get_long(&mp->mbrp_start);
++*pnpart;
}
break;
@ -251,7 +251,7 @@ readdisklabel(dev, strat, lp, osdep)
}
osdep->cd_start = 0; /* XXX for now */
/*mbr_to_label(dev, strat, MBRSECTOR, lp, &lp->d_npartitions, osdep, 0);*/
/*mbr_to_label(dev, strat, MBR_BBSECTOR, lp, &lp->d_npartitions, osdep, 0);*/
return 0;
}