Use <sys/disklabel_mbr.h> rather than our own home-grown.
This commit is contained in:
parent
41c5275965
commit
4731b4c5b0
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mbrlabel.c,v 1.2 1998/12/03 11:20:50 fair Exp $ */
|
||||
/* $NetBSD: mbrlabel.c,v 1.3 1999/01/27 20:44:04 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1998 Wolfgang Solfrank.
|
||||
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: mbrlabel.c,v 1.2 1998/12/03 11:20:50 fair Exp $");
|
||||
__RCSID("$NetBSD: mbrlabel.c,v 1.3 1999/01/27 20:44:04 thorpej Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -44,9 +44,9 @@ __RCSID("$NetBSD: mbrlabel.c,v 1.2 1998/12/03 11:20:50 fair Exp $");
|
|||
|
||||
#include <sys/param.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "mbrlabel.h"
|
||||
#include "dkcksum.h"
|
||||
|
||||
#define FIRSTPART 0
|
||||
|
@ -98,15 +98,15 @@ static struct typetab {
|
|||
int mbrtype;
|
||||
int nbsdtype;
|
||||
} typetable[] = {
|
||||
{ MBR_NETBSD, FS_BSDFFS },
|
||||
{ MBR_386BSD, FS_BSDFFS },
|
||||
{ MBR_FAT12, FS_MSDOS },
|
||||
{ MBR_FAT16S, FS_MSDOS },
|
||||
{ MBR_FAT16B, FS_MSDOS },
|
||||
{ MBR_FAT32, FS_MSDOS },
|
||||
{ MBR_FAT32L, FS_MSDOS },
|
||||
{ MBR_FAT16L, FS_MSDOS },
|
||||
{ MBR_LNXEXT2, FS_EX2FS },
|
||||
{ MBR_PTYPE_NETBSD, FS_BSDFFS },
|
||||
{ MBR_PTYPE_386BSD, FS_BSDFFS },
|
||||
{ MBR_PTYPE_FAT12, FS_MSDOS },
|
||||
{ MBR_PTYPE_FAT16S, FS_MSDOS },
|
||||
{ MBR_PTYPE_FAT16B, FS_MSDOS },
|
||||
{ MBR_PTYPE_FAT32, FS_MSDOS },
|
||||
{ MBR_PTYPE_FAT32L, FS_MSDOS },
|
||||
{ MBR_PTYPE_FAT16L, FS_MSDOS },
|
||||
{ MBR_PTYPE_LNXEXT2, FS_EX2FS },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
@ -153,20 +153,20 @@ getparts(sd, np, off)
|
|||
}
|
||||
if (buf[0x1fe] != 0x55 || buf[0x1ff] != 0xaa)
|
||||
return np;
|
||||
mpart = (void *)(buf + MBRPARTOFF);
|
||||
mpart = (void *)(buf + MBR_PARTOFF);
|
||||
for (epart = mpart + NMBRPART; mpart < epart; mpart++) {
|
||||
switch (mpart->mp_typ) {
|
||||
switch (mpart->mbrp_typ) {
|
||||
case 0:
|
||||
/* Nothing to do */
|
||||
break;
|
||||
case MBR_EXT:
|
||||
case MBR_EXT_LBA:
|
||||
case MBR_PTYPE_EXT:
|
||||
case MBR_PTYPE_EXT_LBA:
|
||||
/* Will be handled below */
|
||||
break;
|
||||
default:
|
||||
label.d_partitions[np].p_size = getlong(&mpart->mp_size);
|
||||
label.d_partitions[np].p_offset = getlong(&mpart->mp_start) + off;
|
||||
label.d_partitions[np].p_fstype = nbsdtype(mpart->mp_typ);
|
||||
label.d_partitions[np].p_size = getlong(&mpart->mbrp_size);
|
||||
label.d_partitions[np].p_offset = getlong(&mpart->mbrp_start) + off;
|
||||
label.d_partitions[np].p_fstype = nbsdtype(mpart->mbrp_typ);
|
||||
switch (label.d_partitions[np].p_fstype) {
|
||||
case FS_BSDFFS:
|
||||
label.d_partitions[np].p_size = 16384;
|
||||
|
@ -191,12 +191,12 @@ getparts(sd, np, off)
|
|||
if (np == RAW_PART)
|
||||
np++;
|
||||
}
|
||||
mpart = (void *)(buf + MBRPARTOFF);
|
||||
mpart = (void *)(buf + MBR_PARTOFF);
|
||||
for (epart = mpart + NMBRPART; mpart < epart; mpart++) {
|
||||
switch (mpart->mp_typ) {
|
||||
case MBR_EXT:
|
||||
case MBR_EXT_LBA:
|
||||
np = getparts(sd, np, getlong(&mpart->mp_start) + off);
|
||||
switch (mpart->mbrp_typ) {
|
||||
case MBR_PTYPE_EXT:
|
||||
case MBR_PTYPE_EXT_LBA:
|
||||
np = getparts(sd, np, getlong(&mpart->mbrp_start) + off);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -231,7 +231,7 @@ main(argc, argv)
|
|||
exit(1);
|
||||
}
|
||||
getlabel(sd);
|
||||
np = getparts(sd, FIRSTPART, MBRSECTOR);
|
||||
np = getparts(sd, FIRSTPART, MBR_BBSECTOR);
|
||||
if (np > label.d_npartitions)
|
||||
label.d_npartitions = np;
|
||||
setlabel(sd);
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
/* $NetBSD: mbrlabel.h,v 1.1 1998/11/16 18:44:26 ws Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Mostly stolen from <sys/arch/i386/disklabel.h>.
|
||||
* This file should most likely be somewhere else in the include hierarchy.
|
||||
*/
|
||||
|
||||
/* DOS partition table -- located in boot block */
|
||||
#define MBRSECTOR 0 /* MBR relative sector # */
|
||||
#define MBRPARTOFF 446
|
||||
#define NMBRPART 4
|
||||
|
||||
struct mbr_partition {
|
||||
unsigned char mp_flag; /* bootstrap flags */
|
||||
unsigned char mp_shd; /* starting head */
|
||||
unsigned char mp_ssect; /* starting sector */
|
||||
unsigned char mp_scyl; /* starting cylinder */
|
||||
unsigned char mp_typ; /* partition type (see below) */
|
||||
unsigned char mp_ehd; /* end head */
|
||||
unsigned char mp_esect; /* end sector */
|
||||
unsigned char mp_ecyl; /* end cylinder */
|
||||
unsigned long mp_start; /* absolute starting sector number */
|
||||
unsigned long mp_size; /* partition size in sectors */
|
||||
};
|
||||
|
||||
/* Known MBR partition types: */
|
||||
#define MBR_NETBSD 0xa9 /* NetBSD partition type */
|
||||
#define MBR_386BSD 0xa5 /* 386BSD partition type */
|
||||
#define MBR_FAT12 0x01 /* 12-bit FAT */
|
||||
#define MBR_FAT16S 0x04 /* 16-bit FAT, less than 32M */
|
||||
#define MBR_EXT 0x05 /* extended partition */
|
||||
#define MBR_FAT16B 0x06 /* 16-bit FAT, more than 32M */
|
||||
#define MBR_FAT32 0x0b /* 32-bit FAT */
|
||||
#define MBR_FAT32L 0x0c /* 32-bit FAT, LBA-mapped */
|
||||
#define MBR_FAT16L 0x0e /* 16-bit FAT, LBA-mapped */
|
||||
#define MBR_EXT_LBA 0x0f /* extended partition, LBA-mapped */
|
||||
#define MBR_LNXEXT2 0x83 /* Linux native */
|
Loading…
Reference in New Issue