Overhaul MBR handling (part 1):
<sys/bootblock.h>: * Added definitions for the Master Boot Record (MBR) used by a variety of systems (primarily i386), including the format of the BIOS Parameter Block (BPB). This information was cribbed from a variety of sources including <sys/disklabel_mbr.h> which this is a superset of. As part of this, some data structure elements and #defines were renamed to be more "namespace friendly" and consistent with other bootblocks and MBR documentation. Update all uses of the old names to the new names. <sys/disklabel_mbr.h>: * Deprecated in favor of <sys/bootblock.h> (the latter is more "host tool" friendly). amd64 & i386: * Renamed /usr/mdec/bootxx_dosfs to /usr/mdec/bootxx_msdos, to be consistent with the naming convention of the msdosfs tools. * Removed /usr/mdec/bootxx_ufs, as it's equivalent to bootxx_ffsv1 and it's confusing to have two functionally equivalent bootblocks, especially given that "ufs" has multiple meanings (it could be a synonym for "ffs", or the group of ffs/lfs/ext2fs file systems). * Rework pbr.S (the first sector of bootxx_*): + Ensure that BPB (bytes 11..89) and the partition table (bytes 446..509) do not contain code. + Add support for booting from FAT partitions if BOOT_FROM_FAT is defined. (Only set for bootxx_msdos). + Remove "dummy" partition 3; if people want to installboot(8) these to the start of the disk they can use fdisk(8) to create a real MBR partition table... + Compile with TERSE_ERROR so it fits because of the above. Whilst this is less user friendly, I feel it's important to have a valid partition table and BPB in the MBR/PBR. * Renamed /usr/mdec/biosboot to /usr/mdec/boot, to be consistent with other platforms. * Enable SUPPORT_DOSFS in /usr/mdec/boot (stage2), so that we can boot off FAT partitions. * Crank version of /usr/mdec/boot to 3.1, and fix some of the other entries in the version file. installboot(8) (i386): * Read the existing MBR of the filesystem and retain the BIOS Parameter Block (BPB) in bytes 11..89 and the MBR partition table in bytes 446..509. (Previously installboot(8) would trash those two sections of the MBR.) mbrlabel(8): * Use sys/lib/libkern/xlat_mbr_fstype.c instead of homegrown code to map the MBR partition type to the NetBSD disklabel type. Test built "make release" for i386, and new bootblocks verified to work (even off FAT!).
This commit is contained in:
parent
1ea85577bc
commit
1c33b4e6a4
7
UPDATING
7
UPDATING
|
@ -1,4 +1,4 @@
|
|||
$NetBSD: UPDATING,v 1.96 2003/09/06 22:12:42 christos Exp $
|
||||
$NetBSD: UPDATING,v 1.97 2003/10/08 04:25:43 lukem Exp $
|
||||
|
||||
This file is intended to be a brief introduction to the build
|
||||
process and a reference on what to do if something doesn't work.
|
||||
|
@ -8,6 +8,11 @@ For a more detailed description see Makefile.
|
|||
Recent changes:
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
20031008:
|
||||
/usr/include/sys/disklabel_mbr.h was removed.
|
||||
It's necessary to "make cleandir" to ensure that
|
||||
the dependencies will be rebuilt correctly.
|
||||
|
||||
20030906:
|
||||
With the addition of siginfo support the old signal trampoline
|
||||
code has been deprecated to COMPAT_16. Make sure that your running
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile.bootfloppy,v 1.5 2003/07/26 08:32:19 dsl Exp $
|
||||
# $NetBSD: Makefile.bootfloppy,v 1.6 2003/10/08 04:25:43 lukem Exp $
|
||||
#
|
||||
# Makefile snippet to create a set of USTAR floppies
|
||||
#
|
||||
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# Optional variables:
|
||||
# FLOPPYKERNDIR ${FLOPPYKERNEL} is from ${.CURDIR}/../${FLOPPYKERNDIR}
|
||||
# FLOPPY_BOOT Bootstrap to use. [${DESTDIR}/usr/mdec/biosboot]
|
||||
# FLOPPY_BOOT Bootstrap to use. [${DESTDIR}/usr/mdec/boot]
|
||||
# FLOPPYBOOTOPTIONS Options for installboot, eg -o console=com0
|
||||
#
|
||||
|
||||
|
@ -31,7 +31,7 @@ MDEC= ${DESTDIR}/usr/mdec
|
|||
FLOPPYINSTBOOT= "${TOOL_INSTALLBOOT} ${FLOPPYBOOTOPTIONS} -m${MACHINE} @IMAGE@ ${MDEC}/bootxx_ustarfs"
|
||||
FLOPPYKERNOBJ!= cd ${.CURDIR}/../${FLOPPYKERNDIR} && ${PRINTOBJDIR}
|
||||
|
||||
FLOPPY_BOOT?= ${MDEC}/biosboot
|
||||
FLOPPY_BOOT?= ${MDEC}/boot
|
||||
FLOPPY_NETBSD= ${FLOPPYKERNOBJ}/${FLOPPYKERNEL}
|
||||
FLOPPYFILES= boot ${FLOPPYMETAFILE} netbsd
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile.ramdisk,v 1.2 2003/07/25 21:24:37 dsl Exp $
|
||||
# $NetBSD: Makefile.ramdisk,v 1.3 2003/10/08 04:25:43 lukem Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
|
||||
|
@ -16,7 +16,7 @@ MTREECONF= ${DISTRIBDIR}/common/mtree.common
|
|||
IMAGEENDIAN= le
|
||||
IMAGEDEPENDS+= ${CRUNCHBIN} \
|
||||
dot.profile termcap.mini \
|
||||
${DESTDIR}/usr/mdec/biosboot \
|
||||
${DESTDIR}/usr/mdec/boot \
|
||||
${DESTDIR}/usr/mdec/bootxx_ffsv1 \
|
||||
${DESTDIR}/usr/mdec/mbr \
|
||||
${DESTDIR}/usr/mdec/mbr_ext \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: list.ramdisk,v 1.2 2003/07/25 21:24:37 dsl Exp $
|
||||
# $NetBSD: list.ramdisk,v 1.3 2003/10/08 04:25:43 lukem Exp $
|
||||
|
||||
SRCDIRS bin sbin usr.bin usr.sbin gnu/usr.bin
|
||||
|
||||
|
@ -16,7 +16,7 @@ COPY ${NETBSDSRCDIR}/etc/protocols etc/protocols
|
|||
COPY ${NETBSDSRCDIR}/etc/services etc/services
|
||||
|
||||
# we need the boot block in /usr/mdec + the MBR copy
|
||||
COPY ${DESTDIR}/usr/mdec/biosboot usr/mdec/biosboot
|
||||
COPY ${DESTDIR}/usr/mdec/boot usr/mdec/boot
|
||||
COPY ${DESTDIR}/usr/mdec/bootxx_ffsv1 usr/mdec/bootxx_ffsv1
|
||||
COPY ${DESTDIR}/usr/mdec/mbr usr/mdec/mbr
|
||||
COPY ${DESTDIR}/usr/mdec/mbr_ext usr/mdec/mbr_ext
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile.bootfloppy,v 1.16 2003/07/26 08:26:08 dsl Exp $
|
||||
# $NetBSD: Makefile.bootfloppy,v 1.17 2003/10/08 04:25:43 lukem Exp $
|
||||
#
|
||||
# Makefile snippet to create a set of USTAR floppies
|
||||
#
|
||||
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# Optional variables:
|
||||
# FLOPPYKERNDIR ${FLOPPYKERNEL} is from ${.CURDIR}/../${FLOPPYKERNDIR}
|
||||
# FLOPPY_BOOT Bootstrap to use. [${DESTDIR}/usr/mdec/biosboot]
|
||||
# FLOPPY_BOOT Bootstrap to use. [${DESTDIR}/usr/mdec/boot]
|
||||
# FLOPPYBOOTOPTIONS Options for installboot, eg -o console=com0
|
||||
#
|
||||
|
||||
|
@ -31,7 +31,7 @@ MDEC= ${DESTDIR}/usr/mdec
|
|||
FLOPPYINSTBOOT= "${TOOL_INSTALLBOOT} ${FLOPPYBOOTOPTIONS} -m${MACHINE} @IMAGE@ ${MDEC}/bootxx_ustarfs"
|
||||
FLOPPYKERNOBJ!= cd ${.CURDIR}/../${FLOPPYKERNDIR} && ${PRINTOBJDIR}
|
||||
|
||||
FLOPPY_BOOT?= ${MDEC}/biosboot
|
||||
FLOPPY_BOOT?= ${MDEC}/boot
|
||||
FLOPPY_NETBSD= ${FLOPPYKERNOBJ}/${FLOPPYKERNEL}
|
||||
FLOPPYFILES= boot ${FLOPPYMETAFILE} netbsd
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile.ramdisk,v 1.20 2003/06/05 14:30:11 dsl Exp $
|
||||
# $NetBSD: Makefile.ramdisk,v 1.21 2003/10/08 04:25:43 lukem Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
|
||||
|
@ -16,7 +16,7 @@ MTREECONF= ${DISTRIBDIR}/common/mtree.common
|
|||
IMAGEENDIAN= le
|
||||
IMAGEDEPENDS+= ${CRUNCHBIN} \
|
||||
dot.profile termcap.mini \
|
||||
${DESTDIR}/usr/mdec/biosboot \
|
||||
${DESTDIR}/usr/mdec/boot \
|
||||
${DESTDIR}/usr/mdec/bootxx_ffsv1 \
|
||||
${DESTDIR}/usr/mdec/mbr \
|
||||
${DESTDIR}/usr/mdec/mbr_ext \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: list.ramdisk,v 1.9 2003/06/05 14:30:11 dsl Exp $
|
||||
# $NetBSD: list.ramdisk,v 1.10 2003/10/08 04:25:43 lukem Exp $
|
||||
|
||||
SRCDIRS bin sbin usr.bin usr.sbin gnu/usr.bin
|
||||
|
||||
|
@ -16,7 +16,7 @@ COPY ${NETBSDSRCDIR}/etc/protocols etc/protocols
|
|||
COPY ${NETBSDSRCDIR}/etc/services etc/services
|
||||
|
||||
# we need the boot block in /usr/mdec + the MBR copy
|
||||
COPY ${DESTDIR}/usr/mdec/biosboot usr/mdec/biosboot
|
||||
COPY ${DESTDIR}/usr/mdec/boot usr/mdec/boot
|
||||
COPY ${DESTDIR}/usr/mdec/bootxx_ffsv1 usr/mdec/bootxx_ffsv1
|
||||
COPY ${DESTDIR}/usr/mdec/mbr usr/mdec/mbr
|
||||
COPY ${DESTDIR}/usr/mdec/mbr_ext usr/mdec/mbr_ext
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
# $NetBSD: md.amd64,v 1.4 2003/09/27 02:09:36 mrg Exp $
|
||||
# $NetBSD: md.amd64,v 1.5 2003/10/08 04:25:43 lukem Exp $
|
||||
./sbin/fdisk base-sysutil-root
|
||||
./usr/bin/fdformat base-util-bin
|
||||
./usr/lib/libx86_64.so.0 base-sys-shlib
|
||||
./usr/lib/libx86_64.so.0.0 base-sys-shlib
|
||||
./usr/mdec/biosboot base-sysutil-bin
|
||||
./usr/mdec/bootxx_dosfs base-sysutil-bin
|
||||
./usr/mdec/boot base-sysutil-bin
|
||||
./usr/mdec/bootxx_ffsv1 base-sysutil-bin
|
||||
./usr/mdec/bootxx_ffsv2 base-sysutil-bin
|
||||
./usr/mdec/bootxx_lfsv1 base-sysutil-bin
|
||||
./usr/mdec/bootxx_lfsv2 base-sysutil-bin
|
||||
./usr/mdec/bootxx_ufs base-sysutil-bin
|
||||
./usr/mdec/bootxx_msdos base-sysutil-bin
|
||||
./usr/mdec/bootxx_ustarfs base-sysutil-bin
|
||||
./usr/mdec/dosboot.com base-sysutil-bin
|
||||
./usr/mdec/mbr base-sysutil-bin
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: md.i386,v 1.103 2003/09/11 19:21:00 christos Exp $
|
||||
# $NetBSD: md.i386,v 1.104 2003/10/08 04:25:43 lukem Exp $
|
||||
./lib/libm387.so.0 base-sys-shlib
|
||||
./lib/libm387.so.0.0 base-sys-shlib
|
||||
./sbin/fdisk base-sysutil-root
|
||||
|
@ -21,13 +21,12 @@
|
|||
./usr/lkm/exec_linux_elf.o base-sys-lkm
|
||||
./usr/lkm/exec_pecoff.o base-sys-lkm
|
||||
./usr/lkm/exec_svr4_elf.o base-sys-lkm
|
||||
./usr/mdec/biosboot base-sysutil-bin
|
||||
./usr/mdec/bootxx_dosfs base-sysutil-bin
|
||||
./usr/mdec/boot base-sysutil-bin
|
||||
./usr/mdec/bootxx_ffsv1 base-sysutil-bin
|
||||
./usr/mdec/bootxx_ffsv2 base-sysutil-bin
|
||||
./usr/mdec/bootxx_lfsv1 base-sysutil-bin
|
||||
./usr/mdec/bootxx_lfsv2 base-sysutil-bin
|
||||
./usr/mdec/bootxx_ufs base-sysutil-bin
|
||||
./usr/mdec/bootxx_msdos base-sysutil-bin
|
||||
./usr/mdec/bootxx_ustarfs base-sysutil-bin
|
||||
./usr/mdec/dosboot.com base-sysutil-bin
|
||||
./usr/mdec/mbr base-sysutil-bin
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
# $NetBSD: obsolete.amd64,v 1.2 2003/07/26 08:43:02 dsl Exp $
|
||||
# $NetBSD: obsolete.amd64,v 1.3 2003/10/08 04:25:43 lukem Exp $
|
||||
./dev/lms0
|
||||
./dev/mms0
|
||||
./usr/mdec/biosboot
|
||||
./usr/mdec/biosboot.sym
|
||||
./usr/mdec/biosboot_com0.sym
|
||||
./usr/mdec/biosboot_com0_115200.sym
|
||||
./usr/mdec/biosboot_com0_38400.sym
|
||||
./usr/mdec/biosboot_com0_57600.sym
|
||||
./usr/mdec/biosboot_com0_9600.sym
|
||||
./usr/mdec/bootxx_dosfs
|
||||
./usr/mdec/bootxx_ufs
|
||||
./usr/mdec/installboot
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: obsolete.i386,v 1.14 2003/07/26 08:43:02 dsl Exp $
|
||||
# $NetBSD: obsolete.i386,v 1.15 2003/10/08 04:25:43 lukem Exp $
|
||||
./dev/lms0
|
||||
./dev/mms0
|
||||
./dev/pms0
|
||||
|
@ -12,6 +12,7 @@
|
|||
./dev/vga
|
||||
./usr/bin/fontedit
|
||||
./usr/bin/vttest
|
||||
./usr/mdec/biosboot
|
||||
./usr/mdec/biosboot.sym
|
||||
./usr/mdec/biosboot_com0.sym
|
||||
./usr/mdec/biosboot_com0_115200.sym
|
||||
|
@ -23,6 +24,8 @@
|
|||
./usr/mdec/bootfd
|
||||
./usr/mdec/bootsd
|
||||
./usr/mdec/bootwd
|
||||
./usr/mdec/bootxx_dosfs
|
||||
./usr/mdec/bootxx_ufs
|
||||
./usr/mdec/fdboot
|
||||
./usr/mdec/installboot
|
||||
./usr/mdec/sdboot
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: mi,v 1.626 2003/10/03 18:46:22 wiz Exp $
|
||||
# $NetBSD: mi,v 1.627 2003/10/08 04:25:43 lukem Exp $
|
||||
./usr/bin/addr2line comp-debug-bin
|
||||
./usr/bin/ar comp-util-bin
|
||||
./usr/bin/as comp-util-bin
|
||||
|
@ -741,7 +741,6 @@
|
|||
./usr/include/sys/disk.h comp-c-include
|
||||
./usr/include/sys/disklabel.h comp-c-include
|
||||
./usr/include/sys/disklabel_acorn.h comp-c-include
|
||||
./usr/include/sys/disklabel_mbr.h comp-c-include
|
||||
./usr/include/sys/dkbad.h comp-c-include
|
||||
./usr/include/sys/dkio.h comp-c-include
|
||||
./usr/include/sys/dkstat.h comp-c-include
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: obsolete.mi,v 1.99 2003/10/01 01:31:20 christos Exp $
|
||||
# $NetBSD: obsolete.mi,v 1.100 2003/10/08 04:25:43 lukem Exp $
|
||||
./usr/bin/genclass
|
||||
./usr/bin/gettextize
|
||||
./usr/include/bfd
|
||||
|
@ -556,6 +556,7 @@
|
|||
./usr/include/smbfs
|
||||
./usr/include/sys/bootinfo.h
|
||||
./usr/include/sys/clist.h
|
||||
./usr/include/sys/disklabel_mbr.h
|
||||
./usr/include/sys/dmap.h
|
||||
./usr/include/sys/float_ieee.h
|
||||
./usr/include/sys/fnv_hash.h
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: md.c,v 1.96 2003/08/31 16:41:53 fvdl Exp $ */
|
||||
/* $NetBSD: md.c,v 1.97 2003/10/08 04:25:43 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -66,7 +66,7 @@ static struct biosdisk_info *biosdisk = NULL;
|
|||
|
||||
static int mbr_root_above_chs(void);
|
||||
static void md_upgrade_mbrtype(void);
|
||||
static int md_read_bootcode(const char *, mbr_sector_t *);
|
||||
static int md_read_bootcode(const char *, struct mbr_sector *);
|
||||
static unsigned int get_bootmodel(void);
|
||||
|
||||
|
||||
|
@ -74,7 +74,7 @@ int
|
|||
md_get_info(void)
|
||||
{
|
||||
mbr_info_t *ext;
|
||||
mbr_partition_t *p;
|
||||
struct mbr_partition *p;
|
||||
const char *bootcode;
|
||||
int i;
|
||||
int names, fl, ofl;
|
||||
|
@ -104,12 +104,12 @@ edit:
|
|||
}
|
||||
|
||||
/* Ensure the install partition and active partition are bootable */
|
||||
fl = BFL_NEWMBR;
|
||||
fl = MBR_BS_NEWMBR;
|
||||
names = 0;
|
||||
for (ext = &mbr; ext != NULL; ext = ext->extended) {
|
||||
p = ext->mbr.mbr_parts;
|
||||
for (i = 0; i < NMBRPART; p++, i++) {
|
||||
if (p->mbrp_flag == MBR_FLAGS_ACTIVE) {
|
||||
for (i = 0; i < MBR_PART_COUNT; p++, i++) {
|
||||
if (p->mbrp_flag == MBR_PFLAG_ACTIVE) {
|
||||
fl |= ACTIVE_FOUND;
|
||||
if (ext->sector + p->mbrp_start == ptstart)
|
||||
fl |= NETBSD_ACTIVE;
|
||||
|
@ -123,10 +123,10 @@ edit:
|
|||
continue;
|
||||
}
|
||||
if (ext->sector != 0)
|
||||
fl |= BFL_EXTLBA;
|
||||
fl |= MBR_BS_EXTLBA;
|
||||
if (ext->sector + p->mbrp_start == ptstart)
|
||||
fl |= NETBSD_NAMED;
|
||||
else if (p->mbrp_flag == MBR_FLAGS_ACTIVE)
|
||||
else if (p->mbrp_flag == MBR_PFLAG_ACTIVE)
|
||||
fl |= ACTIVE_NAMED;
|
||||
else
|
||||
names++;
|
||||
|
@ -149,7 +149,7 @@ edit:
|
|||
goto edit;
|
||||
}
|
||||
|
||||
if ((fl & BFL_EXTLBA) &&
|
||||
if ((fl & MBR_BS_EXTLBA) &&
|
||||
(biosdisk == NULL || !(biosdisk->bi_flags & BIFLAG_EXTINT13))) {
|
||||
/* Need unsupported LBA reads to read boot sectors */
|
||||
msg_display(MSG_no_extended_bootmenu);
|
||||
|
@ -160,33 +160,33 @@ edit:
|
|||
|
||||
if (names > 0 || fl & (NETBSD_NAMED | ACTIVE_NAMED)) {
|
||||
/* Need bootselect code */
|
||||
fl |= BFL_SELACTIVE;
|
||||
bootcode = fl & BFL_EXTLBA ? _PATH_BOOTEXT : _PATH_BOOTSEL;
|
||||
fl |= MBR_BS_ACTIVE;
|
||||
bootcode = fl & MBR_BS_EXTLBA ? _PATH_BOOTEXT : _PATH_BOOTSEL;
|
||||
} else
|
||||
bootcode = _PATH_MBR;
|
||||
|
||||
/* Look at what is installed */
|
||||
if (mbr.mbr.mbr_bootsel.mbrb_magic == htole16(MBR_MAGIC))
|
||||
if (mbr.mbr.mbr_bootsel.mbrbs_magic == htole16(MBR_MAGIC))
|
||||
/* Netbsd bootcode, grab its features */
|
||||
ofl = mbr.mbr.mbr_bootsel.mbrb_flags;
|
||||
ofl = mbr.mbr.mbr_bootsel.mbrbs_flags;
|
||||
else {
|
||||
/* Not netbsd code, might be ok if we are booting the active
|
||||
* partition.
|
||||
*/
|
||||
if (mbr.mbr.mbr_signature == htole16(MBR_MAGIC) &&
|
||||
mbr.mbr.mbr_bootinst[0] != 0 &&
|
||||
(fl & (BFL_SELACTIVE | BFL_EXTLBA)) == 0 &&
|
||||
if (mbr.mbr.mbr_magic == htole16(MBR_MAGIC) &&
|
||||
mbr.mbr.mbr_jmpboot[0] != 0 &&
|
||||
(fl & (MBR_BS_ACTIVE | MBR_BS_EXTLBA)) == 0 &&
|
||||
!mbr_root_above_chs())
|
||||
ofl = BFL_NEWMBR;
|
||||
ofl = MBR_BS_NEWMBR;
|
||||
else
|
||||
ofl = 0;
|
||||
}
|
||||
|
||||
fl &= BFL_NEWMBR | BFL_SELACTIVE | BFL_EXTLBA;
|
||||
ofl &= BFL_NEWMBR | BFL_SELACTIVE | BFL_EXTLBA;
|
||||
fl &= MBR_BS_NEWMBR | MBR_BS_ACTIVE | MBR_BS_EXTLBA;
|
||||
ofl &= MBR_BS_NEWMBR | MBR_BS_ACTIVE | MBR_BS_EXTLBA;
|
||||
if (fl & ~ofl) {
|
||||
/* Existing boot code isn't the right one... */
|
||||
if (fl & BFL_SELACTIVE)
|
||||
if (fl & MBR_BS_ACTIVE)
|
||||
msg_display(MSG_installbootsel);
|
||||
else
|
||||
msg_display(MSG_installmbr);
|
||||
|
@ -206,12 +206,12 @@ edit:
|
|||
* The existing partition table and bootselect configuration is kept.
|
||||
*/
|
||||
static int
|
||||
md_read_bootcode(const char *path, mbr_sector_t *mbrs)
|
||||
md_read_bootcode(const char *path, struct mbr_sector *mbrs)
|
||||
{
|
||||
int fd;
|
||||
struct stat st;
|
||||
size_t len;
|
||||
mbr_sector_t new_mbr;
|
||||
struct mbr_sector new_mbr;
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0)
|
||||
|
@ -228,24 +228,24 @@ md_read_bootcode(const char *path, mbr_sector_t *mbrs)
|
|||
}
|
||||
close(fd);
|
||||
|
||||
if (new_mbr.mbr_bootsel.mbrb_magic != htole16(MBR_MAGIC))
|
||||
if (new_mbr.mbr_bootsel.mbrbs_magic != htole16(MBR_MAGIC))
|
||||
return -1;
|
||||
|
||||
if (mbrs->mbr_bootsel.mbrb_magic == htole16(MBR_MAGIC)) {
|
||||
len = offsetof(mbr_sector_t, mbr_bootsel);
|
||||
if (!(mbrs->mbr_bootsel.mbrb_flags & BFL_NEWMBR))
|
||||
if (mbrs->mbr_bootsel.mbrbs_magic == htole16(MBR_MAGIC)) {
|
||||
len = offsetof(struct mbr_sector, mbr_bootsel);
|
||||
if (!(mbrs->mbr_bootsel.mbrbs_flags & MBR_BS_NEWMBR))
|
||||
/*
|
||||
* Meaning of keys has changed, force a sensible
|
||||
* default (old code didn't preseve the answer).
|
||||
*/
|
||||
mbrs->mbr_bootsel.mbrb_defkey = SCAN_ENTER;
|
||||
mbrs->mbr_bootsel.mbrbs_defkey = SCAN_ENTER;
|
||||
} else
|
||||
len = offsetof(mbr_sector_t, mbr_parts);
|
||||
len = offsetof(struct mbr_sector, mbr_parts);
|
||||
|
||||
memcpy(mbrs, &new_mbr, len);
|
||||
/* Keep flags from object file - indicate the properties */
|
||||
mbrs->mbr_bootsel.mbrb_flags = new_mbr.mbr_bootsel.mbrb_flags;
|
||||
mbrs->mbr_signature = htole16(MBR_MAGIC);
|
||||
mbrs->mbr_bootsel.mbrbs_flags = new_mbr.mbr_bootsel.mbrbs_flags;
|
||||
mbrs->mbr_magic = htole16(MBR_MAGIC);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -280,12 +280,12 @@ md_post_newfs(void)
|
|||
size_t len;
|
||||
int td, sd;
|
||||
char bootxx[8192 + 4];
|
||||
static struct i386_boot_params boottype =
|
||||
static struct x86_boot_params boottype =
|
||||
{sizeof boottype, 0, 10, 0, 9600, ""};
|
||||
static int conmib[] = {CTL_MACHDEP, CPU_CONSDEV};
|
||||
struct termios t;
|
||||
dev_t condev;
|
||||
#define bp (*(struct i386_boot_params *)(bootxx + 512 * 2 + 8))
|
||||
#define bp (*(struct x86_boot_params *)(bootxx + 512 * 2 + 8))
|
||||
|
||||
/*
|
||||
* Get console device, should either be ttyE0 or tty0n.
|
||||
|
@ -309,7 +309,7 @@ md_post_newfs(void)
|
|||
if (bp.bp_consdev == ~0)
|
||||
return 0;
|
||||
|
||||
ret = cp_to_target("/usr/mdec/biosboot", "/boot");
|
||||
ret = cp_to_target("/usr/mdec/boot", "/boot");
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -404,16 +404,16 @@ md_upgrade_mbrtype(void)
|
|||
|
||||
mbrp = &mbr.mbr.mbr_parts[0];
|
||||
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (mbrp[i].mbrp_typ == MBR_PTYPE_386BSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (mbrp[i].mbrp_type == MBR_PTYPE_386BSD) {
|
||||
oldbsdpart = i;
|
||||
oldbsdcount++;
|
||||
} else if (mbrp[i].mbrp_typ == MBR_PTYPE_NETBSD)
|
||||
} else if (mbrp[i].mbrp_type == MBR_PTYPE_NETBSD)
|
||||
netbsdpart = i;
|
||||
}
|
||||
|
||||
if (netbsdpart == -1 && oldbsdcount == 1) {
|
||||
mbrp[oldbsdpart].mbrp_typ = MBR_PTYPE_NETBSD;
|
||||
mbrp[oldbsdpart].mbrp_type = MBR_PTYPE_NETBSD;
|
||||
write_mbr(diskdev, &mbr, 0);
|
||||
}
|
||||
}
|
||||
|
@ -561,8 +561,8 @@ count_mbr_parts(pt)
|
|||
{
|
||||
int i, count = 0;
|
||||
|
||||
for (i = 0; i < NMBRPART; i++)
|
||||
if (pt[i].mbrp_typ != 0)
|
||||
for (i = 0; i < MBR_PART_COUNT; i++)
|
||||
if (pt[i].mbrp_type != 0)
|
||||
count++;
|
||||
|
||||
return count;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: menus.md,v 1.7 2003/07/27 20:25:07 dsl Exp $ */
|
||||
/* $NetBSD: menus.md,v 1.8 2003/10/08 04:25:43 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -40,30 +40,30 @@
|
|||
|
||||
menu getboottype, title MSG_Bootblocks_selection, y=10, exit;
|
||||
display action { msg_display(MSG_getboottype);
|
||||
if (((struct i386_boot_params *)arg)->bp_consdev == 0)
|
||||
if (((struct x86_boot_params *)arg)->bp_consdev == 0)
|
||||
msg_display_add(MSG_console_PC);
|
||||
else
|
||||
msg_display_add(MSG_console_com,
|
||||
((struct i386_boot_params *)arg)->bp_consdev - 1,
|
||||
((struct i386_boot_params *)arg)->bp_conspeed);
|
||||
((struct x86_boot_params *)arg)->bp_consdev - 1,
|
||||
((struct x86_boot_params *)arg)->bp_conspeed);
|
||||
};
|
||||
option MSG_Use_normal_bootblocks, action
|
||||
{((struct i386_boot_params *)arg)->bp_consdev = 0;};
|
||||
{((struct x86_boot_params *)arg)->bp_consdev = 0;};
|
||||
option MSG_Use_serial_com0, action
|
||||
{((struct i386_boot_params *)arg)->bp_consdev = 1;};
|
||||
{((struct x86_boot_params *)arg)->bp_consdev = 1;};
|
||||
option MSG_Use_serial_com1, action
|
||||
{((struct i386_boot_params *)arg)->bp_consdev = 2;};
|
||||
{((struct x86_boot_params *)arg)->bp_consdev = 2;};
|
||||
option MSG_Use_serial_com2, action
|
||||
{((struct i386_boot_params *)arg)->bp_consdev = 3;};
|
||||
{((struct x86_boot_params *)arg)->bp_consdev = 3;};
|
||||
option MSG_Use_serial_com3, action
|
||||
{((struct i386_boot_params *)arg)->bp_consdev = 4;};
|
||||
{((struct x86_boot_params *)arg)->bp_consdev = 4;};
|
||||
option MSG_serial_baud_rate, sub menu consolebaud;
|
||||
option MSG_Use_existing_bootblocks, action
|
||||
{((struct i386_boot_params *)arg)->bp_consdev = ~0;};
|
||||
{((struct x86_boot_params *)arg)->bp_consdev = ~0;};
|
||||
|
||||
menu consolebaud, title MSG_serial_baud_rate, x=40, y=13;
|
||||
display action {
|
||||
switch (((struct i386_boot_params *)arg)->bp_conspeed) {
|
||||
switch (((struct x86_boot_params *)arg)->bp_conspeed) {
|
||||
case 9600: menu->cursel = 0; break;
|
||||
case 19200: menu->cursel = 1; break;
|
||||
case 38400: menu->cursel = 2; break;
|
||||
|
@ -71,15 +71,15 @@ menu consolebaud, title MSG_serial_baud_rate, x=40, y=13;
|
|||
case 115200: menu->cursel = 4; break;
|
||||
}};
|
||||
option "9600", exit, action
|
||||
{((struct i386_boot_params *)arg)->bp_conspeed = 9600;};
|
||||
{((struct x86_boot_params *)arg)->bp_conspeed = 9600;};
|
||||
option "19200", exit, action
|
||||
{((struct i386_boot_params *)arg)->bp_conspeed = 19200;};
|
||||
{((struct x86_boot_params *)arg)->bp_conspeed = 19200;};
|
||||
option "38400", exit, action
|
||||
{((struct i386_boot_params *)arg)->bp_conspeed = 38400;};
|
||||
{((struct x86_boot_params *)arg)->bp_conspeed = 38400;};
|
||||
option "57600", exit, action
|
||||
{((struct i386_boot_params *)arg)->bp_conspeed = 57600;};
|
||||
{((struct x86_boot_params *)arg)->bp_conspeed = 57600;};
|
||||
option "115200", exit, action
|
||||
{((struct i386_boot_params *)arg)->bp_conspeed = 115200;};
|
||||
{((struct x86_boot_params *)arg)->bp_conspeed = 115200;};
|
||||
|
||||
menu biosonematch;
|
||||
option MSG_This_is_the_correct_geometry, exit, action { };
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mbr.c,v 1.53 2003/09/27 10:39:35 dsl Exp $ */
|
||||
/* $NetBSD: mbr.c,v 1.54 2003/10/08 04:25:43 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -185,7 +185,7 @@ remove_old_partitions(uint start, int size)
|
|||
}
|
||||
|
||||
static int
|
||||
find_mbr_space(mbr_sector_t *mbrs, uint *start, uint *size, int from, int ignore)
|
||||
find_mbr_space(struct mbr_sector *mbrs, uint *start, uint *size, int from, int ignore)
|
||||
{
|
||||
int sz;
|
||||
int i;
|
||||
|
@ -193,7 +193,7 @@ find_mbr_space(mbr_sector_t *mbrs, uint *start, uint *size, int from, int ignore
|
|||
|
||||
check_again:
|
||||
sz = dlsize - from;
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (i == ignore)
|
||||
continue;
|
||||
s = mbrs->mbr_parts[i].mbrp_start;
|
||||
|
@ -214,13 +214,13 @@ find_mbr_space(mbr_sector_t *mbrs, uint *start, uint *size, int from, int ignore
|
|||
return 0;
|
||||
}
|
||||
|
||||
static mbr_partition_t *
|
||||
static struct mbr_partition *
|
||||
get_mbrp(mbr_info_t **mbrip, int opt)
|
||||
{
|
||||
mbr_info_t *mbri = *mbrip;
|
||||
|
||||
if (opt >= NMBRPART)
|
||||
for (opt -= NMBRPART - 1; opt; opt--)
|
||||
if (opt >= MBR_PART_COUNT)
|
||||
for (opt -= MBR_PART_COUNT - 1; opt; opt--)
|
||||
mbri = mbri->extended;
|
||||
|
||||
*mbrip = mbri;
|
||||
|
@ -233,7 +233,7 @@ set_mbr_type(menudesc *m, void *arg)
|
|||
mbr_info_t *mbri = arg;
|
||||
mbr_info_t *ombri = arg;
|
||||
mbr_info_t *ext;
|
||||
mbr_partition_t *mbrp;
|
||||
struct mbr_partition *mbrp;
|
||||
char *cp;
|
||||
int opt = mbri->opt;
|
||||
int type;
|
||||
|
@ -242,7 +242,7 @@ set_mbr_type(menudesc *m, void *arg)
|
|||
char numbuf[4];
|
||||
|
||||
mbrp = get_mbrp(&mbri, opt);
|
||||
if (opt >= NMBRPART)
|
||||
if (opt >= MBR_PART_COUNT)
|
||||
opt = 0;
|
||||
|
||||
type = m->cursel;
|
||||
|
@ -250,7 +250,7 @@ set_mbr_type(menudesc *m, void *arg)
|
|||
return 1;
|
||||
type = part_ids[type - 1].id;
|
||||
while (type == -1) {
|
||||
snprintf(numbuf, sizeof numbuf, "%u", mbrp->mbrp_typ);
|
||||
snprintf(numbuf, sizeof numbuf, "%u", mbrp->mbrp_type);
|
||||
msg_prompt_win(MSG_get_ptn_id, -1, 18, 0, 0,
|
||||
numbuf, numbuf, sizeof numbuf);
|
||||
type = strtoul(numbuf, &cp, 0);
|
||||
|
@ -258,13 +258,13 @@ set_mbr_type(menudesc *m, void *arg)
|
|||
type = -1;
|
||||
}
|
||||
|
||||
if (type == mbrp->mbrp_typ)
|
||||
if (type == mbrp->mbrp_type)
|
||||
/* type not changed... */
|
||||
return 1;
|
||||
|
||||
mbri->last_mounted[opt < NMBRPART ? opt : 0] = NULL;
|
||||
mbri->last_mounted[opt < MBR_PART_COUNT ? opt : 0] = NULL;
|
||||
|
||||
if (MBR_IS_EXTENDED(mbrp->mbrp_typ)) {
|
||||
if (MBR_IS_EXTENDED(mbrp->mbrp_type)) {
|
||||
/* deleting extended partition.... */
|
||||
if (mbri->sector || mbri->extended->extended)
|
||||
/* We should have stopped this happening... */
|
||||
|
@ -275,7 +275,7 @@ set_mbr_type(menudesc *m, void *arg)
|
|||
|
||||
if (type == 0) {
|
||||
/* Deleting partition */
|
||||
mbrp->mbrp_typ = 0;
|
||||
mbrp->mbrp_type = 0;
|
||||
remove_old_partitions(mbri->sector + mbrp->mbrp_start,
|
||||
mbrp->mbrp_size);
|
||||
#ifdef BOOTSEL
|
||||
|
@ -291,12 +291,12 @@ set_mbr_type(menudesc *m, void *arg)
|
|||
|
||||
/* Merge with previous and next free areas */
|
||||
ext = mbri->prev_ext;
|
||||
if (ext != NULL && ext->mbr.mbr_parts[0].mbrp_typ == 0) {
|
||||
if (ext != NULL && ext->mbr.mbr_parts[0].mbrp_type == 0) {
|
||||
mbri = ext;
|
||||
ombri->opt--;
|
||||
}
|
||||
while ((ext = mbri->extended)) {
|
||||
if (ext->mbr.mbr_parts[0].mbrp_typ != 0)
|
||||
if (ext->mbr.mbr_parts[0].mbrp_type != 0)
|
||||
break;
|
||||
sz = ext->mbr.mbr_parts[0].mbrp_start +
|
||||
ext->mbr.mbr_parts[0].mbrp_size;
|
||||
|
@ -330,11 +330,11 @@ set_mbr_type(menudesc *m, void *arg)
|
|||
mbrp->mbrp_size = sz;
|
||||
/* If there isn't an active partition mark this one active */
|
||||
if (!MBR_IS_EXTENDED(type)) {
|
||||
for (i = 0; i < NMBRPART; i++)
|
||||
for (i = 0; i < MBR_PART_COUNT; i++)
|
||||
if (mbri->mbr.mbr_parts[i].mbrp_flag != 0)
|
||||
break;
|
||||
if (i == NMBRPART)
|
||||
mbrp->mbrp_flag = MBR_FLAGS_ACTIVE;
|
||||
if (i == MBR_PART_COUNT)
|
||||
mbrp->mbrp_flag = MBR_PFLAG_ACTIVE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -354,7 +354,7 @@ set_mbr_type(menudesc *m, void *arg)
|
|||
ext->mbr.mbr_parts[0].mbrp_start = bsec;
|
||||
ext->mbr.mbr_parts[0].mbrp_size = mbrp->mbrp_size - bsec;
|
||||
}
|
||||
mbrp->mbrp_typ = type;
|
||||
mbrp->mbrp_type = type;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ edit_mbr_start(menudesc *m, void *arg)
|
|||
{
|
||||
mbr_info_t *mbri = arg;
|
||||
mbr_info_t *ext;
|
||||
mbr_partition_t *mbrp;
|
||||
struct mbr_partition *mbrp;
|
||||
int opt = mbri->opt;
|
||||
uint start, sz;
|
||||
uint new_r, new, limit, dflt_r;
|
||||
|
@ -419,29 +419,29 @@ edit_mbr_start(menudesc *m, void *arg)
|
|||
uint start;
|
||||
uint start_r;
|
||||
uint limit;
|
||||
} freespace[NMBRPART];
|
||||
} freespace[MBR_PART_COUNT];
|
||||
int spaces;
|
||||
int i;
|
||||
char prompt[NMBRPART * 60];
|
||||
char prompt[MBR_PART_COUNT * 60];
|
||||
int len;
|
||||
char numbuf[12];
|
||||
|
||||
if (opt >= NMBRPART)
|
||||
if (opt >= MBR_PART_COUNT)
|
||||
/* should not be able to get here... */
|
||||
return 1;
|
||||
|
||||
mbrp = mbri->mbr.mbr_parts + opt;
|
||||
/* locate the start of all free areas */
|
||||
spaces = 0;
|
||||
for (start = bsec, i = 0; i < NMBRPART; start += sz, i++) {
|
||||
for (start = bsec, i = 0; i < MBR_PART_COUNT; start += sz, i++) {
|
||||
if (find_mbr_space(&mbri->mbr, &start, &sz, start, opt))
|
||||
break;
|
||||
if (MBR_IS_EXTENDED(mbrp->mbrp_typ)) {
|
||||
if (MBR_IS_EXTENDED(mbrp->mbrp_type)) {
|
||||
/* Only want the area that contains this partition */
|
||||
if (mbrp->mbrp_start < start ||
|
||||
mbrp->mbrp_start >= start + sz)
|
||||
continue;
|
||||
i = NMBRPART - 1;
|
||||
i = MBR_PART_COUNT - 1;
|
||||
}
|
||||
freespace[spaces].start = start;
|
||||
freespace[spaces].start_r = start / sizemult;
|
||||
|
@ -494,8 +494,8 @@ edit_mbr_start(menudesc *m, void *arg)
|
|||
}
|
||||
limit = freespace[i].limit;
|
||||
if (new > mbrp->mbrp_start &&
|
||||
MBR_IS_EXTENDED(mbrp->mbrp_typ) &&
|
||||
(mbri->extended->mbr.mbr_parts[0].mbrp_typ != 0 ||
|
||||
MBR_IS_EXTENDED(mbrp->mbrp_type) &&
|
||||
(mbri->extended->mbr.mbr_parts[0].mbrp_type != 0 ||
|
||||
mbri->extended->mbr.mbr_parts[0].mbrp_size <
|
||||
new - mbrp->mbrp_start)) {
|
||||
errmsg = MSG_Space_allocated;
|
||||
|
@ -510,9 +510,9 @@ edit_mbr_start(menudesc *m, void *arg)
|
|||
limit = mbrp->mbrp_start + mbrp->mbrp_size;
|
||||
|
||||
delta = new - mbrp->mbrp_start;
|
||||
if (MBR_IS_EXTENDED(mbrp->mbrp_typ)) {
|
||||
if (MBR_IS_EXTENDED(mbrp->mbrp_type)) {
|
||||
ext = mbri->extended;
|
||||
if (ext->mbr.mbr_parts[0].mbrp_typ != 0) {
|
||||
if (ext->mbr.mbr_parts[0].mbrp_type != 0) {
|
||||
/* allocate an extended ptn for the free item */
|
||||
ext = calloc(1, sizeof *ext);
|
||||
if (!ext)
|
||||
|
@ -523,7 +523,7 @@ edit_mbr_start(menudesc *m, void *arg)
|
|||
mbri->extended = ext;
|
||||
ext->mbr.mbr_parts[0].mbrp_start = bsec;
|
||||
ext->mbr.mbr_parts[0].mbrp_size = -bsec;
|
||||
ext->mbr.mbr_parts[1].mbrp_typ = MBR_PTYPE_EXT;
|
||||
ext->mbr.mbr_parts[1].mbrp_type = MBR_PTYPE_EXT;
|
||||
ext->mbr.mbr_parts[1].mbrp_start = 0;
|
||||
ext->mbr.mbr_parts[1].mbrp_size =
|
||||
ext->extended->mbr.mbr_parts[0].mbrp_start +
|
||||
|
@ -554,7 +554,7 @@ edit_mbr_size(menudesc *m, void *arg)
|
|||
mbr_info_t *mbri = arg;
|
||||
mbr_info_t *ombri = arg;
|
||||
mbr_info_t *ext;
|
||||
mbr_partition_t *mbrp;
|
||||
struct mbr_partition *mbrp;
|
||||
int opt = mbri->opt;
|
||||
uint start, max, max_r, dflt, dflt_r, new;
|
||||
uint freespace;
|
||||
|
@ -565,7 +565,7 @@ edit_mbr_size(menudesc *m, void *arg)
|
|||
|
||||
mbrp = get_mbrp(&mbri, opt);
|
||||
dflt = mbrp->mbrp_size;
|
||||
if (opt < NMBRPART) {
|
||||
if (opt < MBR_PART_COUNT) {
|
||||
max = 0;
|
||||
find_mbr_space(&mbri->mbr, &start, &max, mbrp->mbrp_start, opt);
|
||||
if (start != mbrp->mbrp_start)
|
||||
|
@ -575,7 +575,7 @@ edit_mbr_size(menudesc *m, void *arg)
|
|||
} else {
|
||||
ext = mbri->extended;
|
||||
max = dflt;
|
||||
if (ext != NULL && ext->mbr.mbr_parts[0].mbrp_typ == 0) {
|
||||
if (ext != NULL && ext->mbr.mbr_parts[0].mbrp_type == 0) {
|
||||
/* Easier to merge now and split later... */
|
||||
if (ext->extended)
|
||||
ext->extended->prev_ext = mbri;
|
||||
|
@ -624,21 +624,21 @@ edit_mbr_size(menudesc *m, void *arg)
|
|||
errmsg = MSG_Too_large;
|
||||
continue;
|
||||
}
|
||||
if (!MBR_IS_EXTENDED(mbrp->mbrp_typ) || new == dflt)
|
||||
if (!MBR_IS_EXTENDED(mbrp->mbrp_type) || new == dflt)
|
||||
break;
|
||||
/* Must keep extended list aligned */
|
||||
for (ext = mbri->extended; ext->extended; ext = ext->extended)
|
||||
continue;
|
||||
if ((new < dflt && (ext->mbr.mbr_parts[0].mbrp_typ != 0
|
||||
if ((new < dflt && (ext->mbr.mbr_parts[0].mbrp_type != 0
|
||||
|| (mbrp->mbrp_start + new < ext->sector + bsec
|
||||
&& mbrp->mbrp_start + new != ext->sector)))
|
||||
|| (new > dflt && ext->mbr.mbr_parts[0].mbrp_typ != 0
|
||||
|| (new > dflt && ext->mbr.mbr_parts[0].mbrp_type != 0
|
||||
&& new < dflt + bsec)) {
|
||||
errmsg = MSG_Space_allocated;
|
||||
continue;
|
||||
}
|
||||
delta = new - dflt;
|
||||
if (ext->mbr.mbr_parts[0].mbrp_typ == 0) {
|
||||
if (ext->mbr.mbr_parts[0].mbrp_type == 0) {
|
||||
/* adjust size of last item (free space) */
|
||||
if (mbrp->mbrp_start + new == ext->sector) {
|
||||
/* kill last extended ptn */
|
||||
|
@ -667,23 +667,23 @@ edit_mbr_size(menudesc *m, void *arg)
|
|||
ext->sector = mbri->sector + mbri->mbr.mbr_parts[0].mbrp_start
|
||||
+ mbri->mbr.mbr_parts[0].mbrp_size;
|
||||
mbri->mbr.mbr_parts[1].mbrp_start = ext->sector - ombri->sector;
|
||||
mbri->mbr.mbr_parts[1].mbrp_typ = MBR_PTYPE_EXT;
|
||||
mbri->mbr.mbr_parts[1].mbrp_type = MBR_PTYPE_EXT;
|
||||
mbri->mbr.mbr_parts[1].mbrp_size = delta;
|
||||
break;
|
||||
}
|
||||
|
||||
if (opt >= NMBRPART && max - new <= bsec)
|
||||
if (opt >= MBR_PART_COUNT && max - new <= bsec)
|
||||
/* round up if not enough space for a header */
|
||||
new = max;
|
||||
|
||||
if (new != mbrp->mbrp_size) {
|
||||
mbri->last_mounted[opt < NMBRPART ? opt : 0] = NULL;
|
||||
mbri->last_mounted[opt < MBR_PART_COUNT ? opt : 0] = NULL;
|
||||
remove_old_partitions(mbri->sector + mbrp->mbrp_start +
|
||||
mbrp->mbrp_size, new - mbrp->mbrp_size);
|
||||
}
|
||||
|
||||
mbrp->mbrp_size = new;
|
||||
if (opt < NMBRPART || new == max)
|
||||
if (opt < MBR_PART_COUNT || new == max)
|
||||
return 0;
|
||||
|
||||
/* Need to allocate an extra item for the free space */
|
||||
|
@ -709,7 +709,7 @@ edit_mbr_size(menudesc *m, void *arg)
|
|||
ext->sector = mbri->sector + mbri->mbr.mbr_parts[0].mbrp_start
|
||||
+ mbri->mbr.mbr_parts[0].mbrp_size;
|
||||
mbri->mbr.mbr_parts[1].mbrp_start = ext->sector - ombri->sector;
|
||||
mbri->mbr.mbr_parts[1].mbrp_typ = MBR_PTYPE_EXT;
|
||||
mbri->mbr.mbr_parts[1].mbrp_type = MBR_PTYPE_EXT;
|
||||
mbri->mbr.mbr_parts[1].mbrp_size = freespace;
|
||||
|
||||
return 0;
|
||||
|
@ -722,21 +722,21 @@ edit_mbr_active(menudesc *m, void *arg)
|
|||
int i;
|
||||
uint8_t *fl;
|
||||
|
||||
if (mbri->opt >= NMBRPART)
|
||||
if (mbri->opt >= MBR_PART_COUNT)
|
||||
/* sanity */
|
||||
return 0;
|
||||
|
||||
/* Invert active flag */
|
||||
fl = &mbri->mbr.mbr_parts[mbri->opt].mbrp_flag;
|
||||
if (*fl == MBR_FLAGS_ACTIVE) {
|
||||
if (*fl == MBR_PFLAG_ACTIVE) {
|
||||
*fl = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Ensure there is at most one active partition */
|
||||
for (i = 0; i < NMBRPART; i++)
|
||||
for (i = 0; i < MBR_PART_COUNT; i++)
|
||||
mbri->mbr.mbr_parts[i].mbrp_flag = 0;
|
||||
*fl = MBR_FLAGS_ACTIVE;
|
||||
*fl = MBR_PFLAG_ACTIVE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -746,12 +746,12 @@ edit_mbr_install(menudesc *m, void *arg)
|
|||
{
|
||||
mbr_info_t *mbri = arg;
|
||||
mbr_info_t *ombri = arg;
|
||||
mbr_partition_t *mbrp;
|
||||
struct mbr_partition *mbrp;
|
||||
int opt = mbri->opt;
|
||||
uint start;
|
||||
|
||||
mbrp = get_mbrp(&mbri, opt);
|
||||
if (opt >= NMBRPART)
|
||||
if (opt >= MBR_PART_COUNT)
|
||||
opt = 0;
|
||||
|
||||
start = mbri->sector + mbrp->mbrp_start;
|
||||
|
@ -768,11 +768,11 @@ edit_mbr_bootmenu(menudesc *m, void *arg)
|
|||
{
|
||||
mbr_info_t *mbri = arg;
|
||||
mbr_info_t *ombri = arg;
|
||||
mbr_partition_t *mbrp;
|
||||
struct mbr_partition *mbrp;
|
||||
int opt = mbri->opt;
|
||||
|
||||
mbrp = get_mbrp(&mbri, opt);
|
||||
if (opt >= NMBRPART)
|
||||
if (opt >= MBR_PART_COUNT)
|
||||
opt = 0;
|
||||
|
||||
msg_prompt_win(/* XXX */ "bootmenu", -1, 18, 0, 0,
|
||||
|
@ -793,7 +793,7 @@ edit_mbr_bootdefault(menudesc *m, void *arg)
|
|||
{
|
||||
mbr_info_t *mbri = arg;
|
||||
mbr_info_t *ombri = arg;
|
||||
mbr_partition_t *mbrp;
|
||||
struct mbr_partition *mbrp;
|
||||
|
||||
mbrp = get_mbrp(&mbri, mbri->opt);
|
||||
|
||||
|
@ -852,7 +852,7 @@ set_ptn_label(menudesc *m, int line, void *arg)
|
|||
{
|
||||
mbr_info_t *mbri = arg;
|
||||
mbr_info_t *ombri = arg;
|
||||
mbr_partition_t *mbrp;
|
||||
struct mbr_partition *mbrp;
|
||||
int opt;
|
||||
static const char *yes, *no;
|
||||
|
||||
|
@ -863,13 +863,13 @@ set_ptn_label(menudesc *m, int line, void *arg)
|
|||
|
||||
opt = mbri->opt;
|
||||
mbrp = get_mbrp(&mbri, opt);
|
||||
if (opt >= NMBRPART)
|
||||
if (opt >= MBR_PART_COUNT)
|
||||
opt = 0;
|
||||
|
||||
switch (line) {
|
||||
case PTN_OPT_TYPE:
|
||||
wprintw(m->mw, msg_string(MSG_ptn_type),
|
||||
get_partname(mbrp->mbrp_typ));
|
||||
get_partname(mbrp->mbrp_type));
|
||||
break;
|
||||
case PTN_OPT_START:
|
||||
wprintw(m->mw, msg_string(MSG_ptn_start),
|
||||
|
@ -888,12 +888,12 @@ set_ptn_label(menudesc *m, int line, void *arg)
|
|||
break;
|
||||
case PTN_OPT_ACTIVE:
|
||||
wprintw(m->mw, msg_string(MSG_ptn_active),
|
||||
mbrp->mbrp_flag == MBR_FLAGS_ACTIVE ? yes : no);
|
||||
mbrp->mbrp_flag == MBR_PFLAG_ACTIVE ? yes : no);
|
||||
break;
|
||||
case PTN_OPT_INSTALL:
|
||||
wprintw(m->mw, msg_string(MSG_ptn_install),
|
||||
mbri->sector + mbrp->mbrp_start == ombri->install &&
|
||||
mbrp->mbrp_typ == MBR_PTYPE_NETBSD ? yes : no);
|
||||
mbrp->mbrp_type == MBR_PTYPE_NETBSD ? yes : no);
|
||||
break;
|
||||
#ifdef BOOTSEL
|
||||
case PTN_OPT_BOOTMENU:
|
||||
|
@ -913,14 +913,14 @@ static void
|
|||
set_ptn_header(menudesc *m, void *arg)
|
||||
{
|
||||
mbr_info_t *mbri = arg;
|
||||
mbr_partition_t *mbrp;
|
||||
struct mbr_partition *mbrp;
|
||||
int opt = mbri->opt;
|
||||
int typ;
|
||||
|
||||
mbrp = get_mbrp(&mbri, opt);
|
||||
if (opt >= NMBRPART)
|
||||
if (opt >= MBR_PART_COUNT)
|
||||
opt = 0;
|
||||
typ = mbrp->mbrp_typ;
|
||||
typ = mbrp->mbrp_type;
|
||||
|
||||
#define DISABLE(opt,cond) \
|
||||
if (cond) \
|
||||
|
@ -930,7 +930,7 @@ set_ptn_header(menudesc *m, void *arg)
|
|||
|
||||
/* Can't change type of the extended partition unless it is empty */
|
||||
DISABLE(PTN_OPT_TYPE, MBR_IS_EXTENDED(typ) &&
|
||||
(mbri->extended->mbr.mbr_parts[0].mbrp_typ != 0 ||
|
||||
(mbri->extended->mbr.mbr_parts[0].mbrp_type != 0 ||
|
||||
mbri->extended->extended != NULL));
|
||||
|
||||
/* It is unnecessary to be able to change the base of an extended ptn */
|
||||
|
@ -963,16 +963,16 @@ set_mbr_label(menudesc *m, int opt, void *arg)
|
|||
{
|
||||
mbr_info_t *mbri = arg;
|
||||
mbr_info_t *ombri = arg;
|
||||
mbr_partition_t *mbrp;
|
||||
struct mbr_partition *mbrp;
|
||||
uint rstart, rend;
|
||||
const char *name, *cp, *mounted;
|
||||
int len;
|
||||
|
||||
mbrp = get_mbrp(&mbri, opt);
|
||||
if (opt >= NMBRPART)
|
||||
if (opt >= MBR_PART_COUNT)
|
||||
opt = 0;
|
||||
|
||||
if (mbrp->mbrp_typ == 0 && mbri->sector == 0) {
|
||||
if (mbrp->mbrp_type == 0 && mbri->sector == 0) {
|
||||
len = snprintf(0, 0, msg_string(MSG_part_row_used), 0, 0, 0);
|
||||
wprintw(m->mw, "%*s", len, "");
|
||||
} else {
|
||||
|
@ -981,15 +981,15 @@ set_mbr_label(menudesc *m, int opt, void *arg)
|
|||
rstart = rstart / sizemult;
|
||||
wprintw(m->mw, msg_string(MSG_part_row_used),
|
||||
rstart, rend - rstart,
|
||||
mbrp->mbrp_flag == MBR_FLAGS_ACTIVE ? 'a' : ' ',
|
||||
mbrp->mbrp_flag == MBR_PFLAG_ACTIVE ? 'a' : ' ',
|
||||
#ifdef BOOTSEL
|
||||
ombri->bootsec == mbri->sector + mbrp->mbrp_start ? 'd' :
|
||||
#endif
|
||||
' ',
|
||||
mbri->sector + mbrp->mbrp_start == ombri->install &&
|
||||
mbrp->mbrp_typ == MBR_PTYPE_NETBSD ? 'I' : ' ');
|
||||
mbrp->mbrp_type == MBR_PTYPE_NETBSD ? 'I' : ' ');
|
||||
}
|
||||
name = get_partname(mbrp->mbrp_typ);
|
||||
name = get_partname(mbrp->mbrp_type);
|
||||
mounted = mbri->last_mounted[opt];
|
||||
len = strlen(name);
|
||||
cp = strchr(name, ',');
|
||||
|
@ -1002,7 +1002,7 @@ set_mbr_label(menudesc *m, int opt, void *arg)
|
|||
#ifdef BOOTSEL
|
||||
if (mbri->nametab[opt][0] != 0) {
|
||||
int x, y;
|
||||
if (opt >= NMBRPART)
|
||||
if (opt >= MBR_PART_COUNT)
|
||||
opt = 0;
|
||||
getyx(m->mw, y, x);
|
||||
if (x > 52) {
|
||||
|
@ -1040,13 +1040,13 @@ set_mbr_header(menudesc *m, void *arg)
|
|||
}
|
||||
|
||||
/* First four items are the main partitions */
|
||||
for (op = opts, i = 0; i < NMBRPART; op++, i++) {
|
||||
for (op = opts, i = 0; i < MBR_PART_COUNT; op++, i++) {
|
||||
op->opt_name = NULL;
|
||||
op->opt_menu = OPT_NOMENU;
|
||||
op->opt_flags = OPT_SUB;
|
||||
op->opt_action = edit_mbr_entry;
|
||||
}
|
||||
left = num_opts - NMBRPART;
|
||||
left = num_opts - MBR_PART_COUNT;
|
||||
|
||||
/* Followed by the extended partitions */
|
||||
for (ext = mbri->extended; ext; left--, op++, ext = ext->extended) {
|
||||
|
@ -1083,7 +1083,7 @@ set_mbr_header(menudesc *m, void *arg)
|
|||
int
|
||||
edit_mbr(mbr_info_t *mbri)
|
||||
{
|
||||
mbr_sector_t *mbrs = &mbri->mbr;
|
||||
struct mbr_sector *mbrs = &mbri->mbr;
|
||||
mbr_info_t *ext;
|
||||
struct mbr_partition *part;
|
||||
int i, j;
|
||||
|
@ -1104,8 +1104,8 @@ edit_mbr(mbr_info_t *mbri)
|
|||
if (usefull) {
|
||||
/* Count nonempty, non-BSD partitions. */
|
||||
numbsd = 0;
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
j = part[i].mbrp_typ;
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
j = part[i].mbrp_type;
|
||||
if (j == 0)
|
||||
continue;
|
||||
numbsd++;
|
||||
|
@ -1129,14 +1129,14 @@ edit_mbr(mbr_info_t *mbri)
|
|||
mbri->extended = ext->extended;
|
||||
free(ext);
|
||||
}
|
||||
memset(part, 0, NMBRPART * sizeof *part);
|
||||
memset(part, 0, MBR_PART_COUNT * sizeof *part);
|
||||
#ifdef BOOTSEL
|
||||
memset(&mbri->nametab, 0, sizeof mbri->nametab);
|
||||
#endif
|
||||
part[0].mbrp_typ = MBR_PTYPE_NETBSD;
|
||||
part[0].mbrp_type = MBR_PTYPE_NETBSD;
|
||||
part[0].mbrp_size = dlsize - bsec;
|
||||
part[0].mbrp_start = bsec;
|
||||
part[0].mbrp_flag = MBR_FLAGS_ACTIVE;
|
||||
part[0].mbrp_flag = MBR_PFLAG_ACTIVE;
|
||||
|
||||
ptstart = bsec;
|
||||
ptsize = dlsize - bsec;
|
||||
|
@ -1164,10 +1164,10 @@ edit_mbr(mbr_info_t *mbri)
|
|||
bsdsize = 0;
|
||||
for (ext = mbri; ext; ext = ext->extended) {
|
||||
part = ext->mbr.mbr_parts;
|
||||
for (i = 0; i < NMBRPART; part++, i++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; part++, i++) {
|
||||
if (part->mbrp_flag != 0)
|
||||
activepart = 1;
|
||||
if (part->mbrp_typ != MBR_PTYPE_NETBSD)
|
||||
if (part->mbrp_type != MBR_PTYPE_NETBSD)
|
||||
continue;
|
||||
start = ext->sector + part->mbrp_start;
|
||||
if (start == mbri->install) {
|
||||
|
@ -1233,7 +1233,7 @@ int
|
|||
read_mbr(const char *disk, mbr_info_t *mbri)
|
||||
{
|
||||
struct mbr_partition *mbrp;
|
||||
mbr_sector_t *mbrs = &mbri->mbr;
|
||||
struct mbr_sector *mbrs = &mbri->mbr;
|
||||
mbr_info_t *ext = NULL;
|
||||
char diskpath[MAXPATHLEN];
|
||||
int fd, i;
|
||||
|
@ -1262,12 +1262,12 @@ read_mbr(const char *disk, mbr_info_t *mbri)
|
|||
mbrp = &mbrs->mbr_parts[0];
|
||||
if (ext_base != 0) {
|
||||
/* sanity check extended chain */
|
||||
if (MBR_IS_EXTENDED(mbrp[0].mbrp_typ))
|
||||
if (MBR_IS_EXTENDED(mbrp[0].mbrp_type))
|
||||
break;
|
||||
if (mbrp[1].mbrp_typ != 0 &&
|
||||
!MBR_IS_EXTENDED(mbrp[1].mbrp_typ))
|
||||
if (mbrp[1].mbrp_type != 0 &&
|
||||
!MBR_IS_EXTENDED(mbrp[1].mbrp_type))
|
||||
break;
|
||||
if (mbrp[2].mbrp_typ != 0 || mbrp[3].mbrp_typ != 0)
|
||||
if (mbrp[2].mbrp_type != 0 || mbrp[3].mbrp_type != 0)
|
||||
break;
|
||||
mbri->extended = ext;
|
||||
ext->prev_ext = ext_base != 0 ? mbri : NULL;
|
||||
|
@ -1277,28 +1277,28 @@ read_mbr(const char *disk, mbr_info_t *mbri)
|
|||
}
|
||||
#if BOOTSEL
|
||||
else {
|
||||
if (mbrs->mbr_bootsel.mbrb_magic == htole16(MBR_MAGIC))
|
||||
bootkey = mbrs->mbr_bootsel.mbrb_defkey;
|
||||
if (mbrs->mbr_bootsel.mbrbs_magic == htole16(MBR_MAGIC))
|
||||
bootkey = mbrs->mbr_bootsel.mbrbs_defkey;
|
||||
else
|
||||
bootkey = 0;
|
||||
bootkey -= SCAN_1;
|
||||
}
|
||||
if (mbrs->mbr_bootsel.mbrb_magic == htole16(MBR_MAGIC))
|
||||
memcpy(mbri->nametab, mbrs->mbr_bootsel.mbrb_nametab,
|
||||
if (mbrs->mbr_bootsel.mbrbs_magic == htole16(MBR_MAGIC))
|
||||
memcpy(mbri->nametab, mbrs->mbr_bootsel.mbrbs_nametab,
|
||||
sizeof mbri->nametab);
|
||||
#endif
|
||||
mbri->sector = next_ext + ext_base;
|
||||
next_ext = 0;
|
||||
rval = 0;
|
||||
for (i = 0; i < NMBRPART; mbrp++, i++) {
|
||||
if (mbrp->mbrp_typ == 0) {
|
||||
for (i = 0; i < MBR_PART_COUNT; mbrp++, i++) {
|
||||
if (mbrp->mbrp_type == 0) {
|
||||
/* type is unused, discard scum */
|
||||
memset(mbrp, 0, sizeof *mbrp);
|
||||
continue;
|
||||
}
|
||||
mbrp->mbrp_start = le32toh(mbrp->mbrp_start);
|
||||
mbrp->mbrp_size = le32toh(mbrp->mbrp_size);
|
||||
if (MBR_IS_EXTENDED(mbrp->mbrp_typ)) {
|
||||
if (MBR_IS_EXTENDED(mbrp->mbrp_type)) {
|
||||
next_ext = mbrp->mbrp_start;
|
||||
if (ext_base == 0)
|
||||
ext_size = mbrp->mbrp_size;
|
||||
|
@ -1325,17 +1325,17 @@ read_mbr(const char *disk, mbr_info_t *mbri)
|
|||
unsigned int base;
|
||||
if (limit == 0)
|
||||
limit = ext_size;
|
||||
mbrp -= NMBRPART;
|
||||
mbrp -= MBR_PART_COUNT;
|
||||
base =mbri->sector + mbrp->mbrp_start + mbrp->mbrp_size;
|
||||
if (mbrp->mbrp_typ != 0 && ext_base + limit != base) {
|
||||
if (mbrp->mbrp_type != 0 && ext_base + limit != base) {
|
||||
/* Mock up an extry for the space */
|
||||
ext = calloc(1, sizeof *ext);
|
||||
if (!ext)
|
||||
break;
|
||||
ext->sector = base;
|
||||
ext->mbr.mbr_signature = htole16(MBR_MAGIC);
|
||||
ext->mbr.mbr_magic = htole16(MBR_MAGIC);
|
||||
ext->mbr.mbr_parts[1] = mbrp[1];
|
||||
mbrp[1].mbrp_typ = MBR_PTYPE_EXT;
|
||||
mbrp[1].mbrp_type = MBR_PTYPE_EXT;
|
||||
mbrp[1].mbrp_start = base - ext_base;
|
||||
mbrp[1].mbrp_size = limit - mbrp[1].mbrp_start;
|
||||
mbri->extended = ext;
|
||||
|
@ -1364,7 +1364,7 @@ read_mbr(const char *disk, mbr_info_t *mbri)
|
|||
close(fd);
|
||||
if (rval == -1) {
|
||||
memset(&mbrs->mbr_parts, 0, sizeof mbrs->mbr_parts);
|
||||
mbrs->mbr_signature = htole16(MBR_MAGIC);
|
||||
mbrs->mbr_magic = htole16(MBR_MAGIC);
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
@ -1376,15 +1376,15 @@ write_mbr(const char *disk, mbr_info_t *mbri, int convert)
|
|||
int fd, i, ret = 0;
|
||||
struct mbr_partition *mbrp;
|
||||
u_int32_t pstart, psize;
|
||||
mbr_sector_t *mbrs;
|
||||
struct mbr_sector *mbrs;
|
||||
mbr_info_t *ext;
|
||||
#ifdef BOOTSEL
|
||||
int netbsd_bootcode;
|
||||
int8_t key = SCAN_1;
|
||||
|
||||
if (mbri->mbr.mbr_bootsel.mbrb_magic == htole16(MBR_MAGIC)) {
|
||||
if (mbri->mbr.mbr_bootsel.mbrbs_magic == htole16(MBR_MAGIC)) {
|
||||
netbsd_bootcode = 1;
|
||||
mbri->mbr.mbr_bootsel.mbrb_defkey = SCAN_ENTER;
|
||||
mbri->mbr.mbr_bootsel.mbrbs_defkey = SCAN_ENTER;
|
||||
} else
|
||||
netbsd_bootcode = 0;
|
||||
#endif
|
||||
|
@ -1398,13 +1398,13 @@ write_mbr(const char *disk, mbr_info_t *mbri, int convert)
|
|||
mbrs = &ext->mbr;
|
||||
#ifdef BOOTSEL
|
||||
if (netbsd_bootcode) {
|
||||
mbrs->mbr_bootsel.mbrb_magic = htole16(MBR_MAGIC);
|
||||
memcpy(&mbrs->mbr_bootsel.mbrb_nametab, &ext->nametab,
|
||||
sizeof mbrs->mbr_bootsel.mbrb_nametab);
|
||||
mbrs->mbr_bootsel.mbrbs_magic = htole16(MBR_MAGIC);
|
||||
memcpy(&mbrs->mbr_bootsel.mbrbs_nametab, &ext->nametab,
|
||||
sizeof mbrs->mbr_bootsel.mbrbs_nametab);
|
||||
}
|
||||
#endif
|
||||
mbrp = &mbrs->mbr_parts[0];
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (mbrp[i].mbrp_start == 0 && mbrp[i].mbrp_size == 0) {
|
||||
mbrp[i].mbrp_scyl = 0;
|
||||
mbrp[i].mbrp_shd = 0;
|
||||
|
@ -1429,16 +1429,16 @@ write_mbr(const char *disk, mbr_info_t *mbri, int convert)
|
|||
#ifdef BOOTSEL
|
||||
if (netbsd_bootcode && ext->nametab[i][0] != 0) {
|
||||
if (ext->sector + pstart == mbri->bootsec)
|
||||
mbri->mbr.mbr_bootsel.mbrb_defkey = key;
|
||||
mbri->mbr.mbr_bootsel.mbrbs_defkey = key;
|
||||
key++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
mbrs->mbr_signature = htole16(MBR_MAGIC);
|
||||
mbrs->mbr_magic = htole16(MBR_MAGIC);
|
||||
/*
|
||||
* Sector zero is written outside the loop after we have
|
||||
* set mbrb_defkey.
|
||||
* set mbrbs_defkey.
|
||||
*/
|
||||
if (ext->sector != 0 && pwrite(fd, mbrs, sizeof *mbrs,
|
||||
ext->sector * (off_t)MBR_SECSIZE) < 0)
|
||||
|
@ -1453,10 +1453,10 @@ write_mbr(const char *disk, mbr_info_t *mbri, int convert)
|
|||
}
|
||||
|
||||
int
|
||||
valid_mbr(mbr_sector_t *mbrs)
|
||||
valid_mbr(struct mbr_sector *mbrs)
|
||||
{
|
||||
|
||||
return (le16toh(mbrs->mbr_signature) == MBR_MAGIC);
|
||||
return (le16toh(mbrs->mbr_magic) == MBR_MAGIC);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1494,7 +1494,7 @@ convert_mbr_chs(int cyl, int head, int sec,
|
|||
int
|
||||
guess_biosgeom_from_mbr(mbr_info_t *mbri, int *cyl, int *head, int *sec)
|
||||
{
|
||||
mbr_sector_t *mbrs = &mbri->mbr;
|
||||
struct mbr_sector *mbrs = &mbri->mbr;
|
||||
struct mbr_partition *parts = &mbrs->mbr_parts[0];
|
||||
int xcylinders, xheads, xsectors, i, j;
|
||||
int c1, h1, s1, c2, h2, s2;
|
||||
|
@ -1525,10 +1525,10 @@ guess_biosgeom_from_mbr(mbr_info_t *mbri, int *cyl, int *head, int *sec)
|
|||
xheads = -1;
|
||||
|
||||
/* Try to deduce the number of heads from two different mappings. */
|
||||
for (i = 0; i < NMBRPART * 2 - 1; i++) {
|
||||
for (i = 0; i < MBR_PART_COUNT * 2 - 1; i++) {
|
||||
if (get_mapping(parts, i, &c1, &h1, &s1, &a1) < 0)
|
||||
continue;
|
||||
for (j = i + 1; j < NMBRPART * 2; j++) {
|
||||
for (j = i + 1; j < MBR_PART_COUNT * 2; j++) {
|
||||
if (get_mapping(parts, j, &c2, &h2, &s2, &a2) < 0)
|
||||
continue;
|
||||
a1 -= s1;
|
||||
|
@ -1561,7 +1561,7 @@ guess_biosgeom_from_mbr(mbr_info_t *mbri, int *cyl, int *head, int *sec)
|
|||
* Be willing to shove cylinders up a little bit to make things work,
|
||||
* but translation mismatches are fatal.
|
||||
*/
|
||||
for (i = 0; i < NMBRPART * 2; i++) {
|
||||
for (i = 0; i < MBR_PART_COUNT * 2; i++) {
|
||||
if (get_mapping(parts, i, &c1, &h1, &s1, &a1) < 0)
|
||||
continue;
|
||||
if (c1 >= MAXCYL - 1)
|
||||
|
@ -1582,12 +1582,12 @@ guess_biosgeom_from_mbr(mbr_info_t *mbri, int *cyl, int *head, int *sec)
|
|||
}
|
||||
|
||||
static int
|
||||
get_mapping(mbr_partition_t *parts, int i,
|
||||
get_mapping(struct mbr_partition *parts, int i,
|
||||
int *cylinder, int *head, int *sector, unsigned long *absolute)
|
||||
{
|
||||
struct mbr_partition *apart = &parts[i / 2];
|
||||
|
||||
if (apart->mbrp_typ == 0)
|
||||
if (apart->mbrp_type == 0)
|
||||
return -1;
|
||||
if (i % 2 == 0) {
|
||||
*cylinder = MBR_PCYL(apart->mbrp_scyl, apart->mbrp_ssect);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mbr.h,v 1.17 2003/07/25 08:26:22 dsl Exp $ */
|
||||
/* $NetBSD: mbr.h,v 1.18 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997, 1988 Piermont Information Systems Inc.
|
||||
|
@ -47,7 +47,7 @@
|
|||
|
||||
/* constants and defines */
|
||||
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
/*
|
||||
* XXX I (dsl) haven't the foggiest idea what the MBR extended chain
|
||||
|
@ -60,14 +60,14 @@
|
|||
|
||||
typedef struct mbr_info_t mbr_info_t;
|
||||
struct mbr_info_t {
|
||||
mbr_sector_t mbr;
|
||||
struct mbr_sector mbr;
|
||||
#ifdef BOOTSEL
|
||||
char nametab[NMBRPART][PARTNAMESIZE + 1];
|
||||
char nametab[MBR_PART_COUNT][MBR_BS_PARTNAMESIZE + 1];
|
||||
#endif
|
||||
uint sector; /* where we read this from */
|
||||
mbr_info_t *extended; /* next in extended partition list */
|
||||
mbr_info_t *prev_ext; /* and back ptr */
|
||||
const char *last_mounted[NMBRPART];
|
||||
const char *last_mounted[MBR_PART_COUNT];
|
||||
/* only in first item... */
|
||||
int opt; /* entry being edited */
|
||||
uint install; /* start sector of install partition */
|
||||
|
@ -83,7 +83,19 @@ EXTERN mbr_info_t mbr;
|
|||
|
||||
#ifdef BOOTSEL
|
||||
struct mbr_bootsel *mbs;
|
||||
#endif
|
||||
|
||||
/* sync with src/sbin/fdisk/fdisk.c */
|
||||
#define DEFAULT_BOOTDIR "/usr/mdec"
|
||||
#define DEFAULT_BOOTCODE "mbr"
|
||||
#define DEFAULT_BOOTSELCODE "mbr_bootsel"
|
||||
#define DEFAULT_BOOTEXTCODE "mbr_ext"
|
||||
|
||||
/* Scan values for the various keys we use, as returned by the BIOS */
|
||||
#define SCAN_ENTER 0x1c
|
||||
#define SCAN_F1 0x3b
|
||||
#define SCAN_1 0x2
|
||||
|
||||
#endif /* BOOTSEL */
|
||||
|
||||
/* from mbr.c */
|
||||
void set_fdisk_geom(void); /* edit incore BIOS geometry */
|
||||
|
@ -98,7 +110,7 @@ int partsoverlap(struct mbr_partition *, int, int);
|
|||
|
||||
int read_mbr(const char *, mbr_info_t *);
|
||||
int write_mbr(const char *, mbr_info_t *, int);
|
||||
int valid_mbr(mbr_sector_t *);
|
||||
int valid_mbr(struct mbr_sector *);
|
||||
int guess_biosgeom_from_mbr(mbr_info_t *, int *, int *, int *);
|
||||
int md_bios_info(char *);
|
||||
void set_bios_geom(int, int, int);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.206 $>
|
||||
LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.207 $>
|
||||
|
||||
|
||||
[Note: This file does not mention every change made to the NetBSD source tree.
|
||||
|
@ -486,3 +486,10 @@ Changes from NetBSD 1.6 to NetBSD 2.0:
|
|||
sgimips: O2 (IP32) support is now functional again by fixes
|
||||
contributed by Christopher SEKIYA. [tsutsui 20031005]
|
||||
awk(1): Updated gawk to 3.1.3. [wiz 20031006]
|
||||
installboot(8): On i386, preserve BIOS Parameter Block and MBR
|
||||
partition table. [lukem 20031008]
|
||||
i386 & amd64: Rename /usr/mdec/biosboot to /usr/mdec/boot and
|
||||
add support for booting off FAT partitions. Rename
|
||||
/usr/mdec/bootxx_dosfs to /usr/mdec/bootxx_msdos.
|
||||
Deprecate /usr/mdec/bootxx_ufs (use bootxx_ffsv1).
|
||||
[lukem 20031008].
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.c,v 1.118 2003/08/07 10:04:12 agc Exp $ */
|
||||
/* $NetBSD: disklabel.c,v 1.119 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1993
|
||||
|
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993\n\
|
|||
static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95";
|
||||
/* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */
|
||||
#else
|
||||
__RCSID("$NetBSD: disklabel.c,v 1.118 2003/08/07 10:04:12 agc Exp $");
|
||||
__RCSID("$NetBSD: disklabel.c,v 1.119 2003/10/08 04:25:44 lukem Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -55,12 +55,7 @@ __RCSID("$NetBSD: disklabel.c,v 1.118 2003/08/07 10:04:12 agc Exp $");
|
|||
#define DKTYPENAMES
|
||||
#define FSTYPENAMES
|
||||
#include <sys/disklabel.h>
|
||||
#ifdef __alpha__
|
||||
#include <sys/bootblock.h>
|
||||
#endif
|
||||
#ifdef USE_MBR
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#endif
|
||||
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
|
@ -638,10 +633,10 @@ static struct mbr_partition *
|
|||
readmbr(int f)
|
||||
{
|
||||
struct mbr_partition *dp;
|
||||
mbr_sector_t mbr;
|
||||
struct mbr_sector mbr;
|
||||
int part;
|
||||
uint ext_base, next_ext, this_ext;
|
||||
static mbr_partition_t netbsd_part;
|
||||
static struct mbr_partition netbsd_part;
|
||||
|
||||
/*
|
||||
* Don't (yet) know disk geometry (BIOS), use
|
||||
|
@ -661,7 +656,7 @@ readmbr(int f)
|
|||
}
|
||||
|
||||
/* Check if table is valid. */
|
||||
if (mbr.mbr_signature != htole16(MBR_MAGIC)) {
|
||||
if (mbr.mbr_magic != htole16(MBR_MAGIC)) {
|
||||
warnx("Invalid signature in mbr record %d", next_ext);
|
||||
return 0;
|
||||
}
|
||||
|
@ -669,16 +664,16 @@ readmbr(int f)
|
|||
dp = &mbr.mbr_parts[0];
|
||||
#if defined(_no_longer_needed) && !defined(__i386__) && !defined(__x86_64__)
|
||||
/* avoid alignment error */
|
||||
memcpy(mbr, dp, NMBRPART * sizeof(*dp));
|
||||
memcpy(mbr, dp, MBR_PART_COUNT * sizeof(*dp));
|
||||
dp = (struct mbr_partition *)mbr;
|
||||
#endif /* ! __i386__ */
|
||||
next_ext = 0;
|
||||
|
||||
/* Find NetBSD partition. */
|
||||
for (part = 0; part < NMBRPART; dp++, part++) {
|
||||
for (part = 0; part < MBR_PART_COUNT; dp++, part++) {
|
||||
dp->mbrp_start = le32toh(dp->mbrp_start);
|
||||
dp->mbrp_size = le32toh(dp->mbrp_size);
|
||||
switch (dp->mbrp_typ) {
|
||||
switch (dp->mbrp_type) {
|
||||
case MBR_PTYPE_NETBSD:
|
||||
netbsd_part = *dp;
|
||||
break;
|
||||
|
@ -698,7 +693,7 @@ readmbr(int f)
|
|||
}
|
||||
break;
|
||||
}
|
||||
if (part < NMBRPART)
|
||||
if (part < MBR_PART_COUNT)
|
||||
/* We found a netbsd partition */
|
||||
break;
|
||||
if (next_ext == 0)
|
||||
|
@ -715,7 +710,7 @@ readmbr(int f)
|
|||
}
|
||||
}
|
||||
|
||||
if (netbsd_part.mbrp_typ == 0) {
|
||||
if (netbsd_part.mbrp_type == 0) {
|
||||
/*
|
||||
* Table doesn't contain a partition for us. Keep a flag
|
||||
* remembering us to warn before it is destroyed.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fdisk.c,v 1.70 2003/09/19 08:41:28 itojun Exp $ */
|
||||
/* $NetBSD: fdisk.c,v 1.71 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Mach Operating System
|
||||
|
@ -35,12 +35,12 @@
|
|||
#include <sys/cdefs.h>
|
||||
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: fdisk.c,v 1.70 2003/09/19 08:41:28 itojun Exp $");
|
||||
__RCSID("$NetBSD: fdisk.c,v 1.71 2003/10/08 04:25:44 lukem Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -51,9 +51,10 @@ __RCSID("$NetBSD: fdisk.c,v 1.70 2003/09/19 08:41:28 itojun Exp $");
|
|||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <paths.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <util.h>
|
||||
|
@ -61,6 +62,17 @@ __RCSID("$NetBSD: fdisk.c,v 1.70 2003/09/19 08:41:28 itojun Exp $");
|
|||
#if defined(__i386__) || defined(__x86_64__)
|
||||
#include <machine/cpu.h>
|
||||
#define BOOTSEL
|
||||
|
||||
#define DEFAULT_BOOTDIR "/usr/mdec"
|
||||
#define DEFAULT_BOOTCODE "mbr"
|
||||
#define DEFAULT_BOOTSELCODE "mbr_bootsel"
|
||||
#define DEFAULT_BOOTEXTCODE "mbr_ext"
|
||||
|
||||
/* Scan values for the various keys we use, as returned by the BIOS */
|
||||
#define SCAN_ENTER 0x1c
|
||||
#define SCAN_F1 0x3b
|
||||
#define SCAN_1 0x2
|
||||
|
||||
#endif
|
||||
|
||||
#define LBUF 100
|
||||
|
@ -82,11 +94,11 @@ uint cylinders, sectors, heads;
|
|||
daddr_t disksectors;
|
||||
#define cylindersectors (heads * sectors)
|
||||
|
||||
mbr_sector_t mboot;
|
||||
struct mbr_sector mboot;
|
||||
|
||||
|
||||
struct {
|
||||
mbr_sector_t *ptn; /* array of pbrs */
|
||||
struct mbr_sector *ptn; /* array of pbrs */
|
||||
daddr_t base; /* first sector of ext. ptn */
|
||||
daddr_t limit; /* last sector of ext. ptn */
|
||||
int num_ptn; /* number of contained partitions */
|
||||
|
@ -140,7 +152,7 @@ int B_flag; /* Edit/install bootselect code */
|
|||
int E_flag; /* extended partition number */
|
||||
int b_cyl, b_head, b_sec; /* b_flag values. */
|
||||
|
||||
mbr_sector_t bootcode[8192 / sizeof (mbr_sector_t)];
|
||||
struct mbr_sector bootcode[8192 / sizeof (struct mbr_sector)];
|
||||
int bootsize; /* actual size of bootcode */
|
||||
int boot_installed; /* 1 if we've copied code into the mbr */
|
||||
|
||||
|
@ -276,8 +288,8 @@ struct part_type {
|
|||
|
||||
void usage(void);
|
||||
void print_s0(int);
|
||||
void print_part(mbr_sector_t *, int, daddr_t);
|
||||
void print_mbr_partition(mbr_sector_t *, int, daddr_t, daddr_t, int);
|
||||
void print_part(struct mbr_sector *, int, daddr_t);
|
||||
void print_mbr_partition(struct mbr_sector *, int, daddr_t, daddr_t, int);
|
||||
int read_boot(const char *, void *, size_t, int);
|
||||
void init_sector0(int);
|
||||
void intuit_translated_geometry(void);
|
||||
|
@ -293,7 +305,7 @@ int open_disk(int);
|
|||
int read_disk(daddr_t, void *);
|
||||
int write_disk(daddr_t, void *);
|
||||
int get_params(void);
|
||||
int read_s0(daddr_t, mbr_sector_t *);
|
||||
int read_s0(daddr_t, struct mbr_sector *);
|
||||
int write_mbr(void);
|
||||
int yesno(const char *, ...);
|
||||
int decimal(const char *, int, int, int, int);
|
||||
|
@ -581,7 +593,7 @@ print_s0(int which)
|
|||
if (which == -1) {
|
||||
if (!sh_flag)
|
||||
printf("Partition table:\n");
|
||||
for (part = 0; part < NMBRPART; part++) {
|
||||
for (part = 0; part < MBR_PART_COUNT; part++) {
|
||||
if (!sh_flag)
|
||||
printf("%d: ", part);
|
||||
print_part(&mboot, part, 0);
|
||||
|
@ -605,12 +617,12 @@ print_s0(int which)
|
|||
}
|
||||
#ifdef BOOTSEL
|
||||
if (!sh_flag &&
|
||||
le16toh(mboot.mbr_bootsel.mbrb_magic) == MBR_MAGIC){
|
||||
le16toh(mboot.mbr_bootsel.mbrbs_magic) == MBR_MAGIC){
|
||||
int tmo;
|
||||
printf("Bootselector ");
|
||||
if (mboot.mbr_bootsel.mbrb_flags & BFL_SELACTIVE) {
|
||||
if (mboot.mbr_bootsel.mbrbs_flags & MBR_BS_ACTIVE) {
|
||||
printf("enabled");
|
||||
tmo = le16toh(mboot.mbr_bootsel.mbrb_timeo);
|
||||
tmo = le16toh(mboot.mbr_bootsel.mbrbs_timeo);
|
||||
if (tmo == 0xffff)
|
||||
printf(", infinite timeout");
|
||||
else
|
||||
|
@ -639,9 +651,9 @@ print_s0(int which)
|
|||
}
|
||||
|
||||
void
|
||||
print_part(mbr_sector_t *boot, int part, daddr_t offset)
|
||||
print_part(struct mbr_sector *boot, int part, daddr_t offset)
|
||||
{
|
||||
mbr_partition_t *partp;
|
||||
struct mbr_partition *partp;
|
||||
char *e;
|
||||
|
||||
if (!sh_flag) {
|
||||
|
@ -656,12 +668,12 @@ print_part(mbr_sector_t *boot, int part, daddr_t offset)
|
|||
} else
|
||||
e = "";
|
||||
|
||||
if (partp->mbrp_typ == 0) {
|
||||
if (partp->mbrp_type == 0) {
|
||||
printf("PART%s%dSIZE=0\n", e, part);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("PART%s%dID=%d\n", e, part, partp->mbrp_typ);
|
||||
printf("PART%s%dID=%d\n", e, part, partp->mbrp_type);
|
||||
printf("PART%s%dSIZE=%u\n", e, part, le32toh(partp->mbrp_size));
|
||||
printf("PART%s%dSTART=%"PRIdaddr"\n", e, part,
|
||||
offset + le32toh(partp->mbrp_start));
|
||||
|
@ -692,34 +704,34 @@ pr_cyls(daddr_t sector)
|
|||
}
|
||||
|
||||
void
|
||||
print_mbr_partition(mbr_sector_t *boot, int part,
|
||||
print_mbr_partition(struct mbr_sector *boot, int part,
|
||||
daddr_t offset, daddr_t exoffset, int indent)
|
||||
{
|
||||
daddr_t start;
|
||||
daddr_t size;
|
||||
mbr_partition_t *partp = &boot->mbr_parts[part];
|
||||
mbr_sector_t eboot;
|
||||
struct mbr_partition *partp = &boot->mbr_parts[part];
|
||||
struct mbr_sector eboot;
|
||||
int p;
|
||||
static int dumped = 0;
|
||||
|
||||
if (partp->mbrp_typ == 0 && v_flag < 2) {
|
||||
if (partp->mbrp_type == 0 && v_flag < 2) {
|
||||
printf("<UNUSED>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
start = le32toh(partp->mbrp_start);
|
||||
size = le32toh(partp->mbrp_size);
|
||||
if (MBR_IS_EXTENDED(partp->mbrp_typ))
|
||||
if (MBR_IS_EXTENDED(partp->mbrp_type))
|
||||
start += exoffset;
|
||||
else
|
||||
start += offset;
|
||||
|
||||
printf("%s (sysid %d)\n", get_type(partp->mbrp_typ), partp->mbrp_typ);
|
||||
printf("%s (sysid %d)\n", get_type(partp->mbrp_type), partp->mbrp_type);
|
||||
#ifdef BOOTSEL
|
||||
if (le16toh(boot->mbr_bootsel.mbrb_magic) == MBR_MAGIC &&
|
||||
boot->mbr_bootsel.mbrb_nametab[part][0])
|
||||
if (le16toh(boot->mbr_bootsel.mbrbs_magic) == MBR_MAGIC &&
|
||||
boot->mbr_bootsel.mbrbs_nametab[part][0])
|
||||
printf("%*s bootmenu: %s\n", indent, "",
|
||||
boot->mbr_bootsel.mbrb_nametab[part]);
|
||||
boot->mbr_bootsel.mbrbs_nametab[part]);
|
||||
#endif
|
||||
|
||||
printf("%*s start %"PRIdaddr", size %"PRIdaddr,
|
||||
|
@ -738,7 +750,7 @@ print_mbr_partition(mbr_sector_t *boot, int part,
|
|||
switch (partp->mbrp_flag) {
|
||||
case 0:
|
||||
break;
|
||||
case MBR_FLAGS_ACTIVE:
|
||||
case MBR_PFLAG_ACTIVE:
|
||||
printf(", Active");
|
||||
break;
|
||||
default:
|
||||
|
@ -758,7 +770,7 @@ print_mbr_partition(mbr_sector_t *boot, int part,
|
|||
partp->mbrp_ehd, MBR_PSECT(partp->mbrp_esect));
|
||||
}
|
||||
|
||||
if (!MBR_IS_EXTENDED(partp->mbrp_typ) ||
|
||||
if (!MBR_IS_EXTENDED(partp->mbrp_type) ||
|
||||
(v_flag <= 2 && !ext.is_corrupt))
|
||||
return;
|
||||
|
||||
|
@ -774,7 +786,7 @@ print_mbr_partition(mbr_sector_t *boot, int part,
|
|||
indent += 4;
|
||||
if (read_s0(start, &eboot) == -1)
|
||||
return;
|
||||
for (p = 0; p < NMBRPART; p++) {
|
||||
for (p = 0; p < MBR_PART_COUNT; p++) {
|
||||
printf("%*s%d: ", indent, "", p);
|
||||
print_mbr_partition(&eboot, p, start,
|
||||
exoffset ? exoffset : start, indent);
|
||||
|
@ -821,7 +833,7 @@ read_boot(const char *name, void *buf, size_t len, int err_exit)
|
|||
/*
|
||||
* Do some sanity checking here
|
||||
*/
|
||||
if (le16toh(bootcode[0].mbr_signature) != MBR_MAGIC) {
|
||||
if (le16toh(bootcode[0].mbr_magic) != MBR_MAGIC) {
|
||||
warnx("%s: invalid magic", boot_path);
|
||||
goto fail;
|
||||
}
|
||||
|
@ -841,7 +853,7 @@ void
|
|||
init_sector0(int dopart)
|
||||
{
|
||||
int i;
|
||||
int copy_size = MBR_PARTOFF;
|
||||
int copy_size = MBR_PART_OFFSET;
|
||||
|
||||
#ifdef DEFAULT_BOOTCODE
|
||||
if (bootsize == 0)
|
||||
|
@ -849,34 +861,34 @@ init_sector0(int dopart)
|
|||
sizeof bootcode, 1);
|
||||
#endif
|
||||
#ifdef BOOTSEL
|
||||
if (le16toh(mboot.mbr_bootsel.mbrb_magic) == MBR_MAGIC
|
||||
&& le16toh(bootcode[0].mbr_bootsel.mbrb_magic) == MBR_MAGIC)
|
||||
copy_size = MBR_BOOTSELOFF;
|
||||
if (le16toh(mboot.mbr_bootsel.mbrbs_magic) == MBR_MAGIC
|
||||
&& le16toh(bootcode[0].mbr_bootsel.mbrbs_magic) == MBR_MAGIC)
|
||||
copy_size = MBR_BOOTSEL_OFFSET;
|
||||
#endif
|
||||
|
||||
if (bootsize != 0) {
|
||||
boot_installed = 1;
|
||||
memcpy(&mboot.mbr_bootinst, bootcode, copy_size);
|
||||
memcpy(&mboot, bootcode, copy_size);
|
||||
}
|
||||
mboot.mbr_signature = htole16(MBR_MAGIC);
|
||||
mboot.mbr_magic = htole16(MBR_MAGIC);
|
||||
|
||||
if (!dopart)
|
||||
return;
|
||||
for (i = 0; i < 4; i++)
|
||||
for (i = 0; i < MBR_PART_COUNT; i++)
|
||||
memset(&mboot.mbr_parts[i], 0, sizeof(mboot.mbr_parts[i]));
|
||||
}
|
||||
|
||||
void
|
||||
get_extended_ptn(void)
|
||||
{
|
||||
mbr_partition_t *mp;
|
||||
mbr_sector_t *boot;
|
||||
struct mbr_partition *mp;
|
||||
struct mbr_sector *boot;
|
||||
daddr_t offset;
|
||||
mbr_sector_t *nptn;
|
||||
struct mbr_sector *nptn;
|
||||
|
||||
/* find first (there should only be one) extended partition */
|
||||
for (mp = mboot.mbr_parts; !MBR_IS_EXTENDED(mp->mbrp_typ); mp++)
|
||||
if (mp >= &mboot.mbr_parts[NMBRPART])
|
||||
for (mp = mboot.mbr_parts; !MBR_IS_EXTENDED(mp->mbrp_type); mp++)
|
||||
if (mp >= &mboot.mbr_parts[MBR_PART_COUNT])
|
||||
return;
|
||||
|
||||
/*
|
||||
|
@ -895,24 +907,24 @@ get_extended_ptn(void)
|
|||
if (read_s0(offset + ext.base, boot) == -1)
|
||||
break;
|
||||
/* expect p0 to be valid and p1 to be another extended ptn */
|
||||
if (MBR_IS_EXTENDED(boot->mbr_parts[0].mbrp_typ))
|
||||
if (MBR_IS_EXTENDED(boot->mbr_parts[0].mbrp_type))
|
||||
break;
|
||||
if (boot->mbr_parts[1].mbrp_typ != 0 &&
|
||||
!MBR_IS_EXTENDED(boot->mbr_parts[1].mbrp_typ))
|
||||
if (boot->mbr_parts[1].mbrp_type != 0 &&
|
||||
!MBR_IS_EXTENDED(boot->mbr_parts[1].mbrp_type))
|
||||
break;
|
||||
/* p2 and p3 should be unallocated */
|
||||
if (boot->mbr_parts[2].mbrp_typ != 0 ||
|
||||
boot->mbr_parts[3].mbrp_typ != 0)
|
||||
if (boot->mbr_parts[2].mbrp_type != 0 ||
|
||||
boot->mbr_parts[3].mbrp_type != 0)
|
||||
break;
|
||||
/* data ptn inside extended one */
|
||||
if (boot->mbr_parts[0].mbrp_typ != 0 &&
|
||||
if (boot->mbr_parts[0].mbrp_type != 0 &&
|
||||
offset + le32toh(boot->mbr_parts[0].mbrp_start)
|
||||
+ le32toh(boot->mbr_parts[0].mbrp_size) > ext.limit)
|
||||
break;
|
||||
|
||||
ext.num_ptn++;
|
||||
|
||||
if (boot->mbr_parts[1].mbrp_typ == 0)
|
||||
if (boot->mbr_parts[1].mbrp_type == 0)
|
||||
/* end of extended partition chain */
|
||||
return;
|
||||
/* must be in sector order */
|
||||
|
@ -1021,21 +1033,21 @@ get_default_boot(void)
|
|||
uint id;
|
||||
int p;
|
||||
|
||||
if (le16toh(mboot.mbr_bootsel.mbrb_magic) != MBR_MAGIC)
|
||||
if (le16toh(mboot.mbr_bootsel.mbrbs_magic) != MBR_MAGIC)
|
||||
/* default to first active partition */
|
||||
return DEFAULT_ACTIVE;
|
||||
|
||||
if (mboot.mbr_bootsel.mbrb_defkey == SCAN_ENTER)
|
||||
if (mboot.mbr_bootsel.mbrbs_defkey == SCAN_ENTER)
|
||||
return DEFAULT_ACTIVE;
|
||||
|
||||
id = mboot.mbr_bootsel.mbrb_defkey;
|
||||
if (!(mboot.mbr_bootsel.mbrb_flags & BFL_NEWMBR)) {
|
||||
id = mboot.mbr_bootsel.mbrbs_defkey;
|
||||
if (!(mboot.mbr_bootsel.mbrbs_flags & MBR_BS_NEWMBR)) {
|
||||
/* F1..F4 => ptn 0..3, F5+ => disk 0+ */
|
||||
id -= SCAN_F1;
|
||||
if (id >= NMBRPART)
|
||||
if (id >= MBR_PART_COUNT)
|
||||
/* Return number of disk */
|
||||
return id - NMBRPART;
|
||||
if (mboot.mbr_parts[id].mbrp_typ != 0)
|
||||
return id - MBR_PART_COUNT;
|
||||
if (mboot.mbr_parts[id].mbrp_type != 0)
|
||||
return le32toh(mboot.mbr_parts[id].mbrp_start);
|
||||
return DEFAULT_ACTIVE;
|
||||
}
|
||||
|
@ -1045,19 +1057,19 @@ get_default_boot(void)
|
|||
return id - SCAN_F1;
|
||||
id -= SCAN_1;
|
||||
|
||||
for (p = 0; p < NMBRPART; p++) {
|
||||
if (mboot.mbr_parts[p].mbrp_typ == 0)
|
||||
for (p = 0; p < MBR_PART_COUNT; p++) {
|
||||
if (mboot.mbr_parts[p].mbrp_type == 0)
|
||||
continue;
|
||||
if (mboot.mbr_bootsel.mbrb_nametab[p][0] == 0)
|
||||
if (mboot.mbr_bootsel.mbrbs_nametab[p][0] == 0)
|
||||
continue;
|
||||
if (id-- == 0)
|
||||
return le32toh(mboot.mbr_parts[p].mbrp_start);
|
||||
}
|
||||
|
||||
for (p = 0; p < ext.num_ptn; p++) {
|
||||
if (ext.ptn[p].mbr_parts[0].mbrp_typ == 0)
|
||||
if (ext.ptn[p].mbr_parts[0].mbrp_type == 0)
|
||||
continue;
|
||||
if (ext.ptn[p].mbr_bootsel.mbrb_nametab[0][0] == 0)
|
||||
if (ext.ptn[p].mbr_bootsel.mbrbs_nametab[0][0] == 0)
|
||||
continue;
|
||||
if (id-- == 0)
|
||||
return ext_offset(p)
|
||||
|
@ -1073,39 +1085,39 @@ set_default_boot(daddr_t default_ptn)
|
|||
int p;
|
||||
int key = SCAN_1;
|
||||
|
||||
if (le16toh(mboot.mbr_bootsel.mbrb_magic) != MBR_MAGIC)
|
||||
if (le16toh(mboot.mbr_bootsel.mbrbs_magic) != MBR_MAGIC)
|
||||
/* sanity */
|
||||
return;
|
||||
|
||||
if (default_ptn == DEFAULT_ACTIVE) {
|
||||
mboot.mbr_bootsel.mbrb_defkey = SCAN_ENTER;
|
||||
mboot.mbr_bootsel.mbrbs_defkey = SCAN_ENTER;
|
||||
return;
|
||||
}
|
||||
|
||||
for (p = 0; p < NMBRPART; p++) {
|
||||
if (mboot.mbr_parts[p].mbrp_typ == 0)
|
||||
for (p = 0; p < MBR_PART_COUNT; p++) {
|
||||
if (mboot.mbr_parts[p].mbrp_type == 0)
|
||||
continue;
|
||||
if (mboot.mbr_bootsel.mbrb_nametab[p][0] == 0)
|
||||
if (mboot.mbr_bootsel.mbrbs_nametab[p][0] == 0)
|
||||
continue;
|
||||
if (le32toh(mboot.mbr_parts[p].mbrp_start) == default_ptn) {
|
||||
if (mboot.mbr_bootsel.mbrb_flags & BFL_NEWMBR)
|
||||
mboot.mbr_bootsel.mbrb_defkey = key;
|
||||
if (mboot.mbr_bootsel.mbrbs_flags & MBR_BS_NEWMBR)
|
||||
mboot.mbr_bootsel.mbrbs_defkey = key;
|
||||
else
|
||||
mboot.mbr_bootsel.mbrb_defkey = SCAN_F1 + p;
|
||||
mboot.mbr_bootsel.mbrbs_defkey = SCAN_F1 + p;
|
||||
return;
|
||||
}
|
||||
key++;
|
||||
}
|
||||
|
||||
if (mboot.mbr_bootsel.mbrb_flags & BFL_EXTLBA) {
|
||||
if (mboot.mbr_bootsel.mbrbs_flags & MBR_BS_EXTLBA) {
|
||||
for (p = 0; p < ext.num_ptn; p++) {
|
||||
if (ext.ptn[p].mbr_parts[0].mbrp_typ == 0)
|
||||
if (ext.ptn[p].mbr_parts[0].mbrp_type == 0)
|
||||
continue;
|
||||
if (ext.ptn[p].mbr_bootsel.mbrb_nametab[0][0] == 0)
|
||||
if (ext.ptn[p].mbr_bootsel.mbrbs_nametab[0][0] == 0)
|
||||
continue;
|
||||
if (le32toh(ext.ptn[p].mbr_parts[0].mbrp_start) +
|
||||
ext_offset(p) == default_ptn) {
|
||||
mboot.mbr_bootsel.mbrb_defkey = key;
|
||||
mboot.mbr_bootsel.mbrbs_defkey = key;
|
||||
return;
|
||||
}
|
||||
key++;
|
||||
|
@ -1113,16 +1125,16 @@ set_default_boot(daddr_t default_ptn)
|
|||
}
|
||||
|
||||
if (default_ptn < 8) {
|
||||
if (mboot.mbr_bootsel.mbrb_flags & BFL_NEWMBR)
|
||||
if (mboot.mbr_bootsel.mbrbs_flags & MBR_BS_NEWMBR)
|
||||
key = SCAN_F1;
|
||||
else
|
||||
key = SCAN_F1 + 4;
|
||||
mboot.mbr_bootsel.mbrb_defkey = key + default_ptn;
|
||||
mboot.mbr_bootsel.mbrbs_defkey = key + default_ptn;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Default to first active partition */
|
||||
mboot.mbr_bootsel.mbrb_defkey = SCAN_ENTER;
|
||||
mboot.mbr_bootsel.mbrbs_defkey = SCAN_ENTER;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1134,36 +1146,36 @@ install_bootsel(int needed)
|
|||
char *code;
|
||||
|
||||
/* Work out which boot code we need for this configuration */
|
||||
for (p = 0; p < NMBRPART; p++) {
|
||||
if (mboot.mbr_parts[p].mbrp_typ == 0)
|
||||
for (p = 0; p < MBR_PART_COUNT; p++) {
|
||||
if (mboot.mbr_parts[p].mbrp_type == 0)
|
||||
continue;
|
||||
if (le16toh(mbs->mbrb_magic) != MBR_MAGIC)
|
||||
if (le16toh(mbs->mbrbs_magic) != MBR_MAGIC)
|
||||
break;
|
||||
if (mbs->mbrb_nametab[p][0] == 0)
|
||||
if (mbs->mbrbs_nametab[p][0] == 0)
|
||||
continue;
|
||||
needed |= BFL_SELACTIVE;
|
||||
needed |= MBR_BS_ACTIVE;
|
||||
if (le32toh(mboot.mbr_parts[p].mbrp_start) >= dos_totalsectors)
|
||||
ext13 = BFL_EXTINT13;
|
||||
ext13 = MBR_BS_EXTINT13;
|
||||
}
|
||||
|
||||
for (p = 0; p < ext.num_ptn; p++) {
|
||||
if (le16toh(ext.ptn[p].mbr_bootsel.mbrb_magic) != MBR_MAGIC)
|
||||
if (le16toh(ext.ptn[p].mbr_bootsel.mbrbs_magic) != MBR_MAGIC)
|
||||
continue;
|
||||
if (ext.ptn[p].mbr_parts[0].mbrp_typ == 0)
|
||||
if (ext.ptn[p].mbr_parts[0].mbrp_type == 0)
|
||||
continue;
|
||||
if (ext.ptn[p].mbr_bootsel.mbrb_nametab[p][0] == 0)
|
||||
if (ext.ptn[p].mbr_bootsel.mbrbs_nametab[p][0] == 0)
|
||||
continue;
|
||||
needed |= BFL_EXTLBA | BFL_SELACTIVE;
|
||||
needed |= MBR_BS_EXTLBA | MBR_BS_ACTIVE;
|
||||
}
|
||||
|
||||
if (B_flag)
|
||||
needed |= BFL_SELACTIVE;
|
||||
needed |= MBR_BS_ACTIVE;
|
||||
|
||||
/* Is the installed code good enough ? */
|
||||
if (!i_flag && (needed == 0 || (le16toh(mbs->mbrb_magic) == MBR_MAGIC
|
||||
&& (mbs->mbrb_flags & needed) == needed))) {
|
||||
if (!i_flag && (needed == 0 || (le16toh(mbs->mbrbs_magic) == MBR_MAGIC
|
||||
&& (mbs->mbrbs_flags & needed) == needed))) {
|
||||
/* yes - just set flags */
|
||||
mbs->mbrb_flags |= ext13;
|
||||
mbs->mbrbs_flags |= ext13;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1181,8 +1193,8 @@ install_bootsel(int needed)
|
|||
/* Were we told a specific file ? (which we have already read) */
|
||||
/* If so check that it supports what we need. */
|
||||
if (bootsize != 0 && needed != 0
|
||||
&& (le16toh(bootcode[0].mbr_bootsel.mbrb_magic) != MBR_MAGIC
|
||||
|| ((bootcode[0].mbr_bootsel.mbrb_flags & needed) != needed))) {
|
||||
&& (le16toh(bootcode[0].mbr_bootsel.mbrbs_magic) != MBR_MAGIC
|
||||
|| ((bootcode[0].mbr_bootsel.mbrbs_flags & needed) != needed))) {
|
||||
/* No it doesn't... */
|
||||
if (f_flag)
|
||||
warnx("Bootfile %s doesn't support "
|
||||
|
@ -1198,10 +1210,10 @@ install_bootsel(int needed)
|
|||
if (bootsize == 0) {
|
||||
/* Get name of bootfile that supports the required facilities */
|
||||
code = DEFAULT_BOOTCODE;
|
||||
if (needed & BFL_SELACTIVE)
|
||||
if (needed & MBR_BS_ACTIVE)
|
||||
code = DEFAULT_BOOTSELCODE;
|
||||
#ifdef DEFAULT_BOOTEXTCODE
|
||||
if (needed & BFL_EXTLBA)
|
||||
if (needed & MBR_BS_EXTLBA)
|
||||
code = DEFAULT_BOOTEXTCODE;
|
||||
#endif
|
||||
|
||||
|
@ -1209,10 +1221,10 @@ install_bootsel(int needed)
|
|||
if (bootsize == 0)
|
||||
/* The old bootcode is better than no bootcode at all */
|
||||
return;
|
||||
if ((bootcode[0].mbr_bootsel.mbrb_flags & needed) != needed)
|
||||
if ((bootcode[0].mbr_bootsel.mbrbs_flags & needed) != needed)
|
||||
warnx("Default bootfile %s doesn't support required "
|
||||
"options. Got flags 0x%x, wanted 0x%x\n",
|
||||
boot_path, bootcode[0].mbr_bootsel.mbrb_flags,
|
||||
boot_path, bootcode[0].mbr_bootsel.mbrbs_flags,
|
||||
needed);
|
||||
}
|
||||
|
||||
|
@ -1221,8 +1233,8 @@ install_bootsel(int needed)
|
|||
|
||||
init_sector0(0);
|
||||
|
||||
if (le16toh(mbs->mbrb_magic) == MBR_MAGIC)
|
||||
mbs->mbrb_flags = bootcode[0].mbr_bootsel.mbrb_flags | ext13;
|
||||
if (le16toh(mbs->mbrbs_magic) == MBR_MAGIC)
|
||||
mbs->mbrbs_flags = bootcode[0].mbr_bootsel.mbrbs_flags | ext13;
|
||||
}
|
||||
|
||||
daddr_t
|
||||
|
@ -1248,13 +1260,13 @@ configure_bootsel(daddr_t default_ptn)
|
|||
* Newer bootcode always waits for 1 tick, so treats 0xffff
|
||||
* as wait forever.
|
||||
*/
|
||||
tmo = le16toh(mbs->mbrb_timeo);
|
||||
tmo = le16toh(mbs->mbrbs_timeo);
|
||||
tmo = tmo == 0xffff ? -1 : (10 * tmo + 9) / 182;
|
||||
tmo = decimal("Timeout value (0 to 3600 seconds, -1 => never)",
|
||||
tmo, 0, -1, 3600);
|
||||
mbs->mbrb_timeo = htole16(tmo == -1 ? 0xffff : (tmo * 182) / 10);
|
||||
mbs->mbrbs_timeo = htole16(tmo == -1 ? 0xffff : (tmo * 182) / 10);
|
||||
|
||||
off = calloc(1 + NMBRPART + ext.num_ptn + num_bios_disks, sizeof *off);
|
||||
off = calloc(1 + MBR_PART_COUNT + ext.num_ptn + num_bios_disks, sizeof *off);
|
||||
if (off == NULL)
|
||||
err(1, "Malloc failed");
|
||||
|
||||
|
@ -1263,24 +1275,24 @@ configure_bootsel(daddr_t default_ptn)
|
|||
opt = 0;
|
||||
off[opt] = DEFAULT_ACTIVE;
|
||||
printf("%d: The first active partition\n", opt);
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (mboot.mbr_parts[i].mbrp_typ == 0)
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (mboot.mbr_parts[i].mbrp_type == 0)
|
||||
continue;
|
||||
if (mbs->mbrb_nametab[i][0] == 0)
|
||||
if (mbs->mbrbs_nametab[i][0] == 0)
|
||||
continue;
|
||||
printf("%d: %s\n", ++opt, &mbs->mbrb_nametab[i][0]);
|
||||
printf("%d: %s\n", ++opt, &mbs->mbrbs_nametab[i][0]);
|
||||
off[opt] = le32toh(mboot.mbr_parts[i].mbrp_start);
|
||||
if (off[opt] == default_ptn)
|
||||
item = opt;
|
||||
}
|
||||
if (mbs->mbrb_flags & BFL_EXTLBA) {
|
||||
if (mbs->mbrbs_flags & MBR_BS_EXTLBA) {
|
||||
for (i = 0; i < ext.num_ptn; i++) {
|
||||
if (ext.ptn[i].mbr_parts[0].mbrp_typ == 0)
|
||||
if (ext.ptn[i].mbr_parts[0].mbrp_type == 0)
|
||||
continue;
|
||||
if (ext.ptn[i].mbr_bootsel.mbrb_nametab[0][0] == 0)
|
||||
if (ext.ptn[i].mbr_bootsel.mbrbs_nametab[0][0] == 0)
|
||||
continue;
|
||||
printf("%d: %s\n",
|
||||
++opt, ext.ptn[i].mbr_bootsel.mbrb_nametab[0]);
|
||||
++opt, ext.ptn[i].mbr_bootsel.mbrbs_nametab[0]);
|
||||
off[opt] = ext_offset(i) +
|
||||
le32toh(ext.ptn[i].mbr_parts[0].mbrp_start);
|
||||
if (off[opt] == default_ptn)
|
||||
|
@ -1354,10 +1366,10 @@ intuit_translated_geometry(void)
|
|||
}
|
||||
|
||||
/* Try to deduce the number of heads from two different mappings. */
|
||||
for (i = 0; i < NMBRPART * 2 - 1; i++) {
|
||||
for (i = 0; i < MBR_PART_COUNT * 2 - 1; i++) {
|
||||
if (get_mapping(i, &c1, &h1, &s1, &a1) < 0)
|
||||
continue;
|
||||
for (j = i + 1; j < NMBRPART * 2; j++) {
|
||||
for (j = i + 1; j < MBR_PART_COUNT * 2; j++) {
|
||||
if (get_mapping(j, &c2, &h2, &s2, &a2) < 0)
|
||||
continue;
|
||||
a1 -= s1;
|
||||
|
@ -1387,7 +1399,7 @@ intuit_translated_geometry(void)
|
|||
* Be willing to shove cylinders up a little bit to make things work,
|
||||
* but translation mismatches are fatal.
|
||||
*/
|
||||
for (i = 0; i < NMBRPART * 2; i++) {
|
||||
for (i = 0; i < MBR_PART_COUNT * 2; i++) {
|
||||
if (get_mapping(i, &c1, &h1, &s1, &a1) < 0)
|
||||
continue;
|
||||
if (c1 >= MAXCYL - 2)
|
||||
|
@ -1420,9 +1432,9 @@ int
|
|||
get_mapping(int i, uint *cylinder, uint *head, uint *sector,
|
||||
unsigned long *absolute)
|
||||
{
|
||||
mbr_partition_t *part = &mboot.mbr_parts[i / 2];
|
||||
struct mbr_partition *part = &mboot.mbr_parts[i / 2];
|
||||
|
||||
if (part->mbrp_typ == 0)
|
||||
if (part->mbrp_type == 0)
|
||||
return -1;
|
||||
if (i % 2 == 0) {
|
||||
*cylinder = MBR_PCYL(part->mbrp_scyl, part->mbrp_ssect);
|
||||
|
@ -1452,7 +1464,7 @@ delete_ptn(int part)
|
|||
memset(&ext, 0, sizeof ext);
|
||||
}
|
||||
|
||||
mboot.mbr_parts[part].mbrp_typ = 0;
|
||||
mboot.mbr_parts[part].mbrp_type = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1460,7 +1472,7 @@ delete_ext_ptn(int part)
|
|||
{
|
||||
|
||||
if (part == 0) {
|
||||
ext.ptn[0].mbr_parts[0].mbrp_typ = 0;
|
||||
ext.ptn[0].mbr_parts[0].mbrp_type = 0;
|
||||
return;
|
||||
}
|
||||
ext.ptn[part - 1].mbr_parts[1] = ext.ptn[part].mbr_parts[1];
|
||||
|
@ -1473,8 +1485,8 @@ static int
|
|||
add_ext_ptn(daddr_t start, daddr_t size)
|
||||
{
|
||||
int part;
|
||||
mbr_partition_t *partp;
|
||||
mbr_sector_t *nptn;
|
||||
struct mbr_partition *partp;
|
||||
struct mbr_sector *nptn;
|
||||
|
||||
nptn = realloc(ext.ptn, (ext.num_ptn + 1) * sizeof *ext.ptn);
|
||||
if (!nptn)
|
||||
|
@ -1487,7 +1499,7 @@ add_ext_ptn(daddr_t start, daddr_t size)
|
|||
memmove(&ext.ptn[part + 1], &ext.ptn[part],
|
||||
(ext.num_ptn - part) * sizeof ext.ptn[0]);
|
||||
memset(&ext.ptn[part], 0, sizeof ext.ptn[0]);
|
||||
ext.ptn[part].mbr_signature = htole16(MBR_MAGIC);
|
||||
ext.ptn[part].mbr_magic = htole16(MBR_MAGIC);
|
||||
/* we will be 'part' */
|
||||
if (part == 0) {
|
||||
/* link us to 'next' */
|
||||
|
@ -1504,7 +1516,7 @@ add_ext_ptn(daddr_t start, daddr_t size)
|
|||
partp->mbrp_start = htole32(start - dos_sectors - ext.base);
|
||||
partp->mbrp_size = htole32(size + dos_sectors);
|
||||
}
|
||||
partp->mbrp_typ = 5; /* as used by win98 */
|
||||
partp->mbrp_type = 5; /* as used by win98 */
|
||||
partp->mbrp_flag = 0;
|
||||
/* wallop in some CHS values - win98 doesn't saturate them */
|
||||
dos(le32toh(partp->mbrp_start),
|
||||
|
@ -1527,8 +1539,8 @@ check_overlap(int part, int sysid, daddr_t start, daddr_t size, int fix)
|
|||
return "Track zero is reserved for the BIOS";
|
||||
if (start + size > dos_disksectors)
|
||||
return "Partition exceeds size of disk";
|
||||
for (p = 0; p < NMBRPART; p++) {
|
||||
if (p == part || mboot.mbr_parts[p].mbrp_typ == 0)
|
||||
for (p = 0; p < MBR_PART_COUNT; p++) {
|
||||
if (p == part || mboot.mbr_parts[p].mbrp_type == 0)
|
||||
continue;
|
||||
p_s = le32toh(mboot.mbr_parts[p].mbrp_start);
|
||||
p_e = p_s + le32toh(mboot.mbr_parts[p].mbrp_size);
|
||||
|
@ -1544,7 +1556,7 @@ check_overlap(int part, int sysid, daddr_t start, daddr_t size, int fix)
|
|||
}
|
||||
|
||||
/* Are we trying to create an extended partition */
|
||||
if (!MBR_IS_EXTENDED(mboot.mbr_parts[part].mbrp_typ)) {
|
||||
if (!MBR_IS_EXTENDED(mboot.mbr_parts[part].mbrp_type)) {
|
||||
/* this wasn't the extended partition */
|
||||
if (!MBR_IS_EXTENDED(sysid))
|
||||
return 0;
|
||||
|
@ -1560,7 +1572,7 @@ check_overlap(int part, int sysid, daddr_t start, daddr_t size, int fix)
|
|||
ext.ptn = calloc(1, sizeof ext.ptn[0]);
|
||||
if (ext.ptn == NULL)
|
||||
err(1, "Malloc failed");
|
||||
ext.ptn[0].mbr_signature = htole16(MBR_MAGIC);
|
||||
ext.ptn[0].mbr_magic = htole16(MBR_MAGIC);
|
||||
ext.ptn_id = part;
|
||||
ext.base = start;
|
||||
ext.limit = start + size;
|
||||
|
@ -1579,7 +1591,7 @@ check_overlap(int part, int sysid, daddr_t start, daddr_t size, int fix)
|
|||
return 0;
|
||||
}
|
||||
if (ext.num_ptn == 0 ||
|
||||
(ext.num_ptn == 1 && ext.ptn[0].mbr_parts[0].mbrp_typ == 0))
|
||||
(ext.num_ptn == 1 && ext.ptn[0].mbr_parts[0].mbrp_type == 0))
|
||||
/* nothing in extended partition */
|
||||
return 0;
|
||||
if (f_flag)
|
||||
|
@ -1594,7 +1606,7 @@ check_overlap(int part, int sysid, daddr_t start, daddr_t size, int fix)
|
|||
return 0;
|
||||
|
||||
for (p = ext.num_ptn; --p >= 0;) {
|
||||
if (ext.ptn[p].mbr_parts[0].mbrp_typ == 0)
|
||||
if (ext.ptn[p].mbr_parts[0].mbrp_type == 0)
|
||||
continue;
|
||||
p_s = ext_offset(p);
|
||||
p_e = p_s + le32toh(ext.ptn[p].mbr_parts[0].mbrp_start)
|
||||
|
@ -1614,7 +1626,7 @@ check_overlap(int part, int sysid, daddr_t start, daddr_t size, int fix)
|
|||
le32toh(ext.ptn[p].mbr_parts[1].mbrp_start)
|
||||
+ ext.base - start);
|
||||
/* and maybe an empty partition at the start */
|
||||
if (ext.ptn[0].mbr_parts[0].mbrp_typ == 0) {
|
||||
if (ext.ptn[0].mbr_parts[0].mbrp_type == 0) {
|
||||
if (le32toh(ext.ptn[0].mbr_parts[1].mbrp_start) == 0) {
|
||||
/* don't need the empty slot */
|
||||
memmove(&ext.ptn[0], &ext.ptn[1],
|
||||
|
@ -1657,7 +1669,7 @@ check_ext_overlap(int part, int sysid, daddr_t start, daddr_t size, int fix)
|
|||
return 0;
|
||||
|
||||
for (p = ext.num_ptn; --p >= 0;) {
|
||||
if (p == part || ext.ptn[p].mbr_parts[0].mbrp_typ == 0)
|
||||
if (p == part || ext.ptn[p].mbr_parts[0].mbrp_type == 0)
|
||||
continue;
|
||||
p_s = ext_offset(p);
|
||||
p_e = p_s + le32toh(ext.ptn[p].mbr_parts[0].mbrp_start)
|
||||
|
@ -1673,7 +1685,7 @@ check_ext_overlap(int part, int sysid, daddr_t start, daddr_t size, int fix)
|
|||
delete_ext_ptn(p);
|
||||
else
|
||||
/* must not change numbering yet */
|
||||
ext.ptn[p].mbr_parts[0].mbrp_typ = 0;
|
||||
ext.ptn[p].mbr_parts[0].mbrp_type = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1684,8 +1696,8 @@ int
|
|||
change_part(int extended, int part, int sysid, daddr_t start, daddr_t size,
|
||||
char *bootmenu)
|
||||
{
|
||||
mbr_partition_t *partp;
|
||||
mbr_sector_t *boot;
|
||||
struct mbr_partition *partp;
|
||||
struct mbr_sector *boot;
|
||||
daddr_t offset;
|
||||
char *e;
|
||||
int upart = part;
|
||||
|
@ -1694,8 +1706,8 @@ change_part(int extended, int part, int sysid, daddr_t start, daddr_t size,
|
|||
daddr_t n_s, n_e;
|
||||
const char *errtext;
|
||||
#ifdef BOOTSEL
|
||||
char tmp_bootmenu[NMBRPART * (PARTNAMESIZE + 1)];
|
||||
int bootmenu_len = (extended ? NMBRPART : 1) * (PARTNAMESIZE + 1);
|
||||
char tmp_bootmenu[MBR_PART_COUNT * (MBR_BS_PARTNAMESIZE + 1)];
|
||||
int bootmenu_len = (extended ? MBR_PART_COUNT : 1) * (MBR_BS_PARTNAMESIZE + 1);
|
||||
#endif
|
||||
|
||||
if (extended) {
|
||||
|
@ -1728,9 +1740,9 @@ change_part(int extended, int part, int sysid, daddr_t start, daddr_t size,
|
|||
strlcpy(tmp_bootmenu, bootmenu, bootmenu_len);
|
||||
else
|
||||
if (boot != NULL &&
|
||||
le16toh(boot->mbr_bootsel.mbrb_magic) == MBR_MAGIC)
|
||||
le16toh(boot->mbr_bootsel.mbrbs_magic) == MBR_MAGIC)
|
||||
strlcpy(tmp_bootmenu,
|
||||
boot->mbr_bootsel.mbrb_nametab[upart],
|
||||
boot->mbr_bootsel.mbrbs_nametab[upart],
|
||||
bootmenu_len);
|
||||
else
|
||||
tmp_bootmenu[0] = 0;
|
||||
|
@ -1738,7 +1750,7 @@ change_part(int extended, int part, int sysid, daddr_t start, daddr_t size,
|
|||
|
||||
if (!s_flag && partp != NULL) {
|
||||
/* values not specified, default to current ones */
|
||||
sysid = partp->mbrp_typ;
|
||||
sysid = partp->mbrp_type;
|
||||
start = offset + le32toh(partp->mbrp_start);
|
||||
size = le32toh(partp->mbrp_size);
|
||||
}
|
||||
|
@ -1748,7 +1760,7 @@ change_part(int extended, int part, int sysid, daddr_t start, daddr_t size,
|
|||
/* non-extended partition */
|
||||
start = ext.base;
|
||||
for (p = 0; p < ext.num_ptn; p++) {
|
||||
if (ext.ptn[p].mbr_parts[0].mbrp_typ == 0)
|
||||
if (ext.ptn[p].mbr_parts[0].mbrp_type == 0)
|
||||
continue;
|
||||
n_s = ext_offset(p);
|
||||
if (n_s > start + dos_sectors)
|
||||
|
@ -1769,8 +1781,8 @@ change_part(int extended, int part, int sysid, daddr_t start, daddr_t size,
|
|||
/* first see if old start is free */
|
||||
if (start < dos_sectors)
|
||||
start = 0;
|
||||
for (p = 0; start != 0 && p < NMBRPART; p++) {
|
||||
if (mboot.mbr_parts[p].mbrp_typ == 0)
|
||||
for (p = 0; start != 0 && p < MBR_PART_COUNT; p++) {
|
||||
if (mboot.mbr_parts[p].mbrp_type == 0)
|
||||
continue;
|
||||
n_s = le32toh(mboot.mbr_parts[p].mbrp_start);
|
||||
if (start >= n_s &&
|
||||
|
@ -1780,8 +1792,8 @@ change_part(int extended, int part, int sysid, daddr_t start, daddr_t size,
|
|||
if (start == 0) {
|
||||
/* Look for first gap */
|
||||
start = dos_sectors;
|
||||
for (p = 0; p < NMBRPART; p++) {
|
||||
if (mboot.mbr_parts[p].mbrp_typ == 0)
|
||||
for (p = 0; p < MBR_PART_COUNT; p++) {
|
||||
if (mboot.mbr_parts[p].mbrp_type == 0)
|
||||
continue;
|
||||
n_s = le32toh(mboot.mbr_parts[p].mbrp_start);
|
||||
n_e = n_s + le32toh(mboot.mbr_parts[p].mbrp_size);
|
||||
|
@ -1826,7 +1838,7 @@ change_part(int extended, int part, int sysid, daddr_t start, daddr_t size,
|
|||
for (p = 0; p < ext.num_ptn; p++) {
|
||||
if (p == part)
|
||||
continue;
|
||||
if (ext.ptn[p].mbr_parts[0].mbrp_typ == 0)
|
||||
if (ext.ptn[p].mbr_parts[0].mbrp_type == 0)
|
||||
continue;
|
||||
n_s = ext_offset(p);
|
||||
if (n_s > start && n_s < lim)
|
||||
|
@ -1839,10 +1851,10 @@ change_part(int extended, int part, int sysid, daddr_t start, daddr_t size,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
for (p = 0; p < NMBRPART; p++) {
|
||||
for (p = 0; p < MBR_PART_COUNT; p++) {
|
||||
if (p == part)
|
||||
continue;
|
||||
if (mboot.mbr_parts[p].mbrp_typ == 0)
|
||||
if (mboot.mbr_parts[p].mbrp_type == 0)
|
||||
continue;
|
||||
n_s = le32toh(mboot.mbr_parts[p].mbrp_start);
|
||||
if (n_s > start && n_s < lim)
|
||||
|
@ -1916,9 +1928,9 @@ change_part(int extended, int part, int sysid, daddr_t start, daddr_t size,
|
|||
if (start == 0 && size == 0)
|
||||
memset(partp, 0, sizeof *partp);
|
||||
#ifdef BOOTSEL
|
||||
if (le16toh(boot->mbr_bootsel.mbrb_magic) == MBR_MAGIC)
|
||||
memset(boot->mbr_bootsel.mbrb_nametab[upart], 0,
|
||||
sizeof boot->mbr_bootsel.mbrb_nametab[0]);
|
||||
if (le16toh(boot->mbr_bootsel.mbrbs_magic) == MBR_MAGIC)
|
||||
memset(boot->mbr_bootsel.mbrbs_nametab[upart], 0,
|
||||
sizeof boot->mbr_bootsel.mbrbs_nametab[0]);
|
||||
#endif
|
||||
if (extended)
|
||||
delete_ext_ptn(part);
|
||||
|
@ -1943,7 +1955,7 @@ change_part(int extended, int part, int sysid, daddr_t start, daddr_t size,
|
|||
offset = ext_offset(part);
|
||||
}
|
||||
|
||||
partp->mbrp_typ = sysid;
|
||||
partp->mbrp_type = sysid;
|
||||
partp->mbrp_start = htole32( start - offset);
|
||||
partp->mbrp_size = htole32( size);
|
||||
dos(start, &partp->mbrp_scyl, &partp->mbrp_shd, &partp->mbrp_ssect);
|
||||
|
@ -1951,20 +1963,20 @@ change_part(int extended, int part, int sysid, daddr_t start, daddr_t size,
|
|||
&partp->mbrp_ecyl, &partp->mbrp_ehd, &partp->mbrp_esect);
|
||||
#ifdef BOOTSEL
|
||||
if (extended) {
|
||||
boot->mbr_bootsel.mbrb_magic = htole16(MBR_MAGIC);
|
||||
strncpy(boot->mbr_bootsel.mbrb_nametab[upart], tmp_bootmenu,
|
||||
boot->mbr_bootsel.mbrbs_magic = htole16(MBR_MAGIC);
|
||||
strncpy(boot->mbr_bootsel.mbrbs_nametab[upart], tmp_bootmenu,
|
||||
bootmenu_len);
|
||||
} else {
|
||||
/* We need to bootselect code installed in order to have
|
||||
* somewhere to safely write the menu tag.
|
||||
*/
|
||||
if (le16toh(boot->mbr_bootsel.mbrb_magic) != MBR_MAGIC) {
|
||||
if (le16toh(boot->mbr_bootsel.mbrbs_magic) != MBR_MAGIC) {
|
||||
if (yesno("The bootselect code is not installed, "
|
||||
"do you want to install it now?"))
|
||||
install_bootsel(BFL_SELACTIVE);
|
||||
install_bootsel(MBR_BS_ACTIVE);
|
||||
}
|
||||
if (le16toh(boot->mbr_bootsel.mbrb_magic) == MBR_MAGIC) {
|
||||
strncpy(boot->mbr_bootsel.mbrb_nametab[upart],
|
||||
if (le16toh(boot->mbr_bootsel.mbrbs_magic) == MBR_MAGIC) {
|
||||
strncpy(boot->mbr_bootsel.mbrbs_nametab[upart],
|
||||
tmp_bootmenu, bootmenu_len);
|
||||
}
|
||||
}
|
||||
|
@ -2007,7 +2019,7 @@ change_part(int extended, int part, int sysid, daddr_t start, daddr_t size,
|
|||
*/
|
||||
if (extended && f_flag) {
|
||||
for (p = ext.num_ptn; --p >= 0;)
|
||||
if (ext.ptn[p].mbr_parts[0].mbrp_typ == 0)
|
||||
if (ext.ptn[p].mbr_parts[0].mbrp_type == 0)
|
||||
delete_ext_ptn(p);
|
||||
}
|
||||
return 1;
|
||||
|
@ -2042,36 +2054,37 @@ print_params(void)
|
|||
void
|
||||
change_active(int which)
|
||||
{
|
||||
mbr_partition_t *partp;
|
||||
struct mbr_partition *partp;
|
||||
int part;
|
||||
int active = 4;
|
||||
int active = MBR_PART_COUNT;
|
||||
|
||||
partp = &mboot.mbr_parts[0];
|
||||
|
||||
if (a_flag && which != -1)
|
||||
active = which;
|
||||
else {
|
||||
for (part = 0; part < NMBRPART; part++)
|
||||
if (partp[part].mbrp_flag & MBR_FLAGS_ACTIVE)
|
||||
for (part = 0; part < MBR_PART_COUNT; part++)
|
||||
if (partp[part].mbrp_flag & MBR_PFLAG_ACTIVE)
|
||||
active = part;
|
||||
}
|
||||
if (!f_flag) {
|
||||
if (yesno("Do you want to change the active partition?")) {
|
||||
printf ("Choosing 4 will make no partition active.\n");
|
||||
printf ("Choosing %d will make no partition active.\n",
|
||||
MBR_PART_COUNT);
|
||||
do {
|
||||
active = decimal("active partition",
|
||||
active, 0, 0, 4);
|
||||
active, 0, 0, MBR_PART_COUNT);
|
||||
} while (!yesno("Are you happy with this choice?"));
|
||||
} else
|
||||
return;
|
||||
} else
|
||||
if (active != 4)
|
||||
if (active != MBR_PART_COUNT)
|
||||
printf ("Making partition %d active.\n", active);
|
||||
|
||||
for (part = 0; part < NMBRPART; part++)
|
||||
partp[part].mbrp_flag &= ~MBR_FLAGS_ACTIVE;
|
||||
if (active < 4)
|
||||
partp[active].mbrp_flag |= MBR_FLAGS_ACTIVE;
|
||||
for (part = 0; part < MBR_PART_COUNT; part++)
|
||||
partp[part].mbrp_flag &= ~MBR_PFLAG_ACTIVE;
|
||||
if (active < MBR_PART_COUNT)
|
||||
partp[active].mbrp_flag |= MBR_PFLAG_ACTIVE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2234,15 +2247,15 @@ get_params(void)
|
|||
}
|
||||
|
||||
int
|
||||
read_s0(daddr_t offset, mbr_sector_t *boot)
|
||||
read_s0(daddr_t offset, struct mbr_sector *boot)
|
||||
{
|
||||
|
||||
if (read_disk(offset, &boot->mbr_bootinst) == -1) {
|
||||
if (read_disk(offset, boot) == -1) {
|
||||
warn("Can't read %spartition table",
|
||||
offset ? "extended " : "");
|
||||
return -1;
|
||||
}
|
||||
if (le16toh(boot->mbr_signature) != MBR_MAGIC) {
|
||||
if (le16toh(boot->mbr_magic) != MBR_MAGIC) {
|
||||
warnx("%spartition table invalid, no magic in sector %"PRIdaddr,
|
||||
offset ? "extended " : "", offset);
|
||||
return -1;
|
||||
|
@ -2266,7 +2279,7 @@ write_mbr(void)
|
|||
flag = 1;
|
||||
if (wfd == fd && ioctl(wfd, DIOCWLABEL, &flag) < 0)
|
||||
warn("DIOCWLABEL");
|
||||
if (write_disk(0, &mboot.mbr_bootinst) == -1) {
|
||||
if (write_disk(0, &mboot) == -1) {
|
||||
warn("Can't write fdisk partition table");
|
||||
goto protect_label;
|
||||
}
|
||||
|
@ -2406,7 +2419,7 @@ ptn_id(const char *prompt, int *extended)
|
|||
if (*cp != '\0')
|
||||
continue;
|
||||
|
||||
if (*extended || acc < NMBRPART)
|
||||
if (*extended || acc < MBR_PART_COUNT)
|
||||
return acc;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
# $NetBSD: Makefile,v 1.4 2002/08/19 10:16:55 lukem Exp $
|
||||
# $NetBSD: Makefile,v 1.5 2003/10/08 04:25:44 lukem Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
DISKLABELPATH= ${NETBSDSRCDIR}/sbin/disklabel
|
||||
PROG= mbrlabel
|
||||
SRCS= mbrlabel.c dkcksum.c printlabel.c
|
||||
SRCS= mbrlabel.c dkcksum.c printlabel.c xlat_mbr_fstype.c
|
||||
CPPFLAGS+= -I${DISKLABELPATH}
|
||||
MAN= mbrlabel.8
|
||||
LDADD+= -lutil
|
||||
|
||||
.PATH: ${DISKLABELPATH}
|
||||
.PATH: ${DISKLABELPATH} ${NETBSDSRCDIR}/sys/lib/libkern
|
||||
.include <bsd.prog.mk>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mbrlabel.c,v 1.22 2003/06/07 10:03:39 dsl Exp $ */
|
||||
/* $NetBSD: mbrlabel.c,v 1.23 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1998 Wolfgang Solfrank.
|
||||
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: mbrlabel.c,v 1.22 2003/06/07 10:03:39 dsl Exp $");
|
||||
__RCSID("$NetBSD: mbrlabel.c,v 1.23 2003/10/08 04:25:44 lukem Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -46,7 +46,7 @@ __RCSID("$NetBSD: mbrlabel.c,v 1.22 2003/06/07 10:03:39 dsl Exp $");
|
|||
#include <sys/param.h>
|
||||
#define FSTYPENAMES
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "dkcksum.h"
|
||||
|
@ -57,7 +57,6 @@ void usage(void);
|
|||
void getlabel(int);
|
||||
void setlabel(int, int);
|
||||
int getparts(int, u_int32_t, u_int32_t, int);
|
||||
int nbsdtype(int);
|
||||
u_int16_t getshort(void *);
|
||||
u_int32_t getlong(void *);
|
||||
|
||||
|
@ -96,36 +95,6 @@ setlabel(int sd, int doraw)
|
|||
|
||||
}
|
||||
|
||||
static struct typetab {
|
||||
int mbrtype;
|
||||
int nbsdtype;
|
||||
} typetable[] = {
|
||||
{ MBR_PTYPE_386BSD, FS_BSDFFS },
|
||||
{ MBR_PTYPE_FAT12, FS_MSDOS },
|
||||
{ MBR_PTYPE_FAT16B, FS_MSDOS },
|
||||
{ MBR_PTYPE_FAT16L, FS_MSDOS },
|
||||
{ MBR_PTYPE_FAT16S, FS_MSDOS },
|
||||
{ MBR_PTYPE_FAT32, FS_MSDOS },
|
||||
{ MBR_PTYPE_FAT32L, FS_MSDOS },
|
||||
{ MBR_PTYPE_LNXEXT2, FS_EX2FS },
|
||||
{ MBR_PTYPE_LNXSWAP, FS_SWAP },
|
||||
{ MBR_PTYPE_NETBSD, FS_BSDFFS },
|
||||
{ MBR_PTYPE_NTFS, FS_NTFS },
|
||||
{ MBR_PTYPE_APPLEUFS, FS_APPLEUFS },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int
|
||||
nbsdtype(int type)
|
||||
{
|
||||
struct typetab *tt;
|
||||
|
||||
for (tt = typetable; tt->mbrtype; tt++)
|
||||
if (tt->mbrtype == type)
|
||||
return (tt->nbsdtype);
|
||||
return (FS_OTHER);
|
||||
}
|
||||
|
||||
u_int16_t
|
||||
getshort(void *p)
|
||||
{
|
||||
|
@ -146,7 +115,7 @@ int
|
|||
getparts(int sd, u_int32_t off, u_int32_t extoff, int verbose)
|
||||
{
|
||||
unsigned char buf[DEV_BSIZE];
|
||||
struct mbr_partition parts[NMBRPART];
|
||||
struct mbr_partition parts[MBR_PART_COUNT];
|
||||
struct partition npe;
|
||||
off_t loff;
|
||||
int i, j, unused, changed;
|
||||
|
@ -162,21 +131,21 @@ getparts(int sd, u_int32_t off, u_int32_t extoff, int verbose)
|
|||
perror("read label");
|
||||
exit(1);
|
||||
}
|
||||
if (getshort(buf + MBR_MAGICOFF) != MBR_MAGIC)
|
||||
if (getshort(buf + MBR_MAGIC_OFFSET) != MBR_MAGIC)
|
||||
return (changed);
|
||||
memcpy(parts, buf + MBR_PARTOFF, sizeof parts);
|
||||
memcpy(parts, buf + MBR_PART_OFFSET, sizeof parts);
|
||||
|
||||
/* scan partition table */
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (parts[i].mbrp_typ == 0 ||
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (parts[i].mbrp_type == 0 ||
|
||||
/* extended partitions are handled below */
|
||||
MBR_IS_EXTENDED(parts[i].mbrp_typ))
|
||||
MBR_IS_EXTENDED(parts[i].mbrp_type))
|
||||
continue;
|
||||
|
||||
memset((void *)&npe, 0, sizeof(npe));
|
||||
npe.p_size = getlong(&parts[i].mbrp_size);
|
||||
npe.p_offset = getlong(&parts[i].mbrp_start) + off;
|
||||
npe.p_fstype = nbsdtype(parts[i].mbrp_typ);
|
||||
npe.p_fstype = xlat_mbr_fstype(parts[i].mbrp_type);
|
||||
|
||||
/* find existing entry, or first free slot */
|
||||
unused = -1; /* flag as no free slot */
|
||||
|
@ -249,10 +218,10 @@ getparts(int sd, u_int32_t off, u_int32_t extoff, int verbose)
|
|||
}
|
||||
|
||||
/* recursively scan extended partitions */
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
u_int32_t poff;
|
||||
|
||||
if (MBR_IS_EXTENDED(parts[i].mbrp_typ)) {
|
||||
if (MBR_IS_EXTENDED(parts[i].mbrp_type)) {
|
||||
poff = getlong(&parts[i].mbrp_start) + extoff;
|
||||
changed += getparts(sd, poff,
|
||||
extoff ? extoff : poff, verbose);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: boot.8,v 1.33 2003/08/14 09:55:29 dsl Exp $
|
||||
.\" $NetBSD: boot.8,v 1.34 2003/10/08 04:25:44 lukem Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -53,8 +53,8 @@ can use any of the following boot procedures, depending on what the hardware and
|
|||
.Tn BIOS
|
||||
support:
|
||||
.Pp
|
||||
.Bl -tag -width "biosboot(8)"
|
||||
.It biosboot
|
||||
.Bl -tag -width "pxeboot(8)"
|
||||
.It boot
|
||||
bootstrap
|
||||
.Nx
|
||||
from the system
|
||||
|
@ -255,7 +255,7 @@ boot program code loaded by the primary bootstrap
|
|||
system code
|
||||
.It Pa /netbsd.gz
|
||||
gzip-compressed system code
|
||||
.It Pa /usr/mdec/biosboot
|
||||
.It Pa /usr/mdec/boot
|
||||
master copy of the boot program (copy to /boot)
|
||||
.It Pa /usr/mdec/bootxx_fstype
|
||||
primary bootstrap for filesystem type fstype, copied to the start of
|
||||
|
@ -276,7 +276,7 @@ the netbsd partition by
|
|||
.Xr w95boot 8
|
||||
.Sh BUGS
|
||||
This manual page documents the
|
||||
.Pa biosboot
|
||||
.Pa boot
|
||||
interface, which is used by ports other than
|
||||
.Nx Ns /i386 .
|
||||
.Pp
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: autoconf.c,v 1.5 2003/08/07 16:26:35 agc Exp $ */
|
||||
/* $NetBSD: autoconf.c,v 1.6 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -44,7 +44,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.5 2003/08/07 16:26:35 agc Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.6 2003/10/08 04:25:44 lukem Exp $");
|
||||
|
||||
#include "opt_multiprocessor.h"
|
||||
|
||||
|
@ -243,8 +243,8 @@ matchbiosdisks()
|
|||
if (be->flags & BI_GEOM_INVALID)
|
||||
continue;
|
||||
if (be->cksum == ck &&
|
||||
!memcmp(&mbr[MBR_PARTOFF], be->dosparts,
|
||||
NMBRPART *
|
||||
!memcmp(&mbr[MBR_PART_OFFSET], be->dosparts,
|
||||
MBR_PART_COUNT *
|
||||
sizeof (struct mbr_partition))) {
|
||||
#ifdef GEOM_DEBUG
|
||||
printf("matched bios disk %x with %s\n",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disksubr.c,v 1.7 2003/08/07 16:26:35 agc Exp $ */
|
||||
/* $NetBSD: disksubr.c,v 1.8 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.7 2003/08/07 16:26:35 agc Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.8 2003/10/08 04:25:44 lukem Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -74,16 +74,16 @@ mbr_findslice(dp, bp)
|
|||
int i;
|
||||
|
||||
/* Note: Magic number is little-endian. */
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGICOFF);
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGIC_OFFSET);
|
||||
if (*mbrmagicp != MBR_MAGIC)
|
||||
return (NO_MBR_SIGNATURE);
|
||||
|
||||
/* XXX how do we check veracity/bounds of this? */
|
||||
memcpy(dp, bp->b_data + MBR_PARTOFF, NMBRPART * sizeof(*dp));
|
||||
memcpy(dp, bp->b_data + MBR_PART_OFFSET, MBR_PART_COUNT * sizeof(*dp));
|
||||
|
||||
/* look for NetBSD partition */
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_NETBSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_NETBSD) {
|
||||
ourdp = &dp[i];
|
||||
break;
|
||||
}
|
||||
|
@ -92,8 +92,8 @@ mbr_findslice(dp, bp)
|
|||
#ifdef COMPAT_386BSD_MBRPART
|
||||
/* didn't find it -- look for 386BSD partition */
|
||||
if (!ourdp) {
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_386BSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_386BSD) {
|
||||
printf("WARNING: old BSD partition ID!\n");
|
||||
ourdp = &dp[i];
|
||||
/*
|
||||
|
@ -194,19 +194,19 @@ readdisklabel(dev, strat, lp, osdep)
|
|||
if (ourdp == NO_MBR_SIGNATURE)
|
||||
goto nombrpart;
|
||||
|
||||
for (i = 0; i < NMBRPART; i++, dp++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
|
||||
/* Install in partition e, f, g, or h. */
|
||||
pp = &lp->d_partitions[RAW_PART + 1 + i];
|
||||
pp->p_offset = dp->mbrp_start;
|
||||
pp->p_size = dp->mbrp_size;
|
||||
for (ip = fat_types; *ip != -1; ip++) {
|
||||
if (dp->mbrp_typ == *ip)
|
||||
if (dp->mbrp_type == *ip)
|
||||
pp->p_fstype = FS_MSDOS;
|
||||
}
|
||||
if (dp->mbrp_typ == MBR_PTYPE_LNXEXT2)
|
||||
if (dp->mbrp_type == MBR_PTYPE_LNXEXT2)
|
||||
pp->p_fstype = FS_EX2FS;
|
||||
|
||||
if (dp->mbrp_typ == MBR_PTYPE_NTFS)
|
||||
if (dp->mbrp_type == MBR_PTYPE_NTFS)
|
||||
pp->p_fstype = FS_NTFS;
|
||||
|
||||
/* is this ours? */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.3 2003/08/04 10:09:10 dsl Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.4 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
|
@ -44,7 +44,7 @@
|
|||
* MAXPARTITIONS was increased.
|
||||
*/
|
||||
/* Pull in MBR partition definitions. */
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
#include <sys/dkbad.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disksubr.c,v 1.18 2003/08/07 16:26:47 agc Exp $ */
|
||||
/* $NetBSD: disksubr.c,v 1.19 2003/10/08 04:25:44 lukem Exp $ */
|
||||
/* $OpenBSD: disksubr.c,v 1.14 1997/05/08 00:14:29 deraadt Exp $ */
|
||||
/* NetBSD: disksubr.c,v 1.40 1999/05/06 15:45:51 christos Exp */
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.18 2003/08/07 16:26:47 agc Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.19 2003/10/08 04:25:44 lukem Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -79,17 +79,17 @@ mbr_findslice(dp, bp)
|
|||
|
||||
#if 0
|
||||
/* Note: Magic number is little-endian. */
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGICOFF);
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGIC_OFFSET);
|
||||
if (*mbrmagicp != MBR_MAGIC)
|
||||
return (NO_MBR_SIGNATURE);
|
||||
#endif
|
||||
|
||||
/* XXX how do we check veracity/bounds of this? */
|
||||
memcpy(dp, bp->b_data + MBR_PARTOFF, NMBRPART * sizeof(*dp));
|
||||
memcpy(dp, bp->b_data + MBR_PART_OFFSET, MBR_PART_COUNT * sizeof(*dp));
|
||||
|
||||
/* look for NetBSD partition */
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_NETBSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_NETBSD) {
|
||||
ourdp = &dp[i];
|
||||
break;
|
||||
}
|
||||
|
@ -98,8 +98,8 @@ mbr_findslice(dp, bp)
|
|||
#ifdef COMPAT_386BSD_MBRPART
|
||||
/* didn't find it -- look for 386BSD partition */
|
||||
if (!ourdp) {
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_386BSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_386BSD) {
|
||||
printf("WARNING: old BSD partition ID!\n");
|
||||
ourdp = &dp[i];
|
||||
/*
|
||||
|
@ -116,8 +116,8 @@ mbr_findslice(dp, bp)
|
|||
|
||||
/* didn't find it -- look for OpenBSD partition */
|
||||
if (!ourdp) {
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_OPENBSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_OPENBSD) {
|
||||
printf("WARNING: using OpenBSD partition\n");
|
||||
ourdp = &dp[i];
|
||||
break;
|
||||
|
@ -213,19 +213,19 @@ readdisklabel(dev, strat, lp, osdep)
|
|||
if (ourdp == NO_MBR_SIGNATURE)
|
||||
goto nombrpart;
|
||||
|
||||
for (i = 0; i < NMBRPART; i++, dp++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
|
||||
/* Install in partition e, f, g, or h. */
|
||||
pp = &lp->d_partitions[RAW_PART + 1 + i];
|
||||
pp->p_offset = dp->mbrp_start;
|
||||
pp->p_size = dp->mbrp_size;
|
||||
for (ip = fat_types; *ip != -1; ip++) {
|
||||
if (dp->mbrp_typ == *ip)
|
||||
if (dp->mbrp_type == *ip)
|
||||
pp->p_fstype = FS_MSDOS;
|
||||
}
|
||||
if (dp->mbrp_typ == MBR_PTYPE_LNXEXT2)
|
||||
if (dp->mbrp_type == MBR_PTYPE_LNXEXT2)
|
||||
pp->p_fstype = FS_EX2FS;
|
||||
|
||||
if (dp->mbrp_typ == MBR_PTYPE_NTFS)
|
||||
if (dp->mbrp_type == MBR_PTYPE_NTFS)
|
||||
pp->p_fstype = FS_NTFS;
|
||||
|
||||
/* is this ours? */
|
||||
|
@ -241,7 +241,7 @@ readdisklabel(dev, strat, lp, osdep)
|
|||
lp->d_partitions[2].p_offset =
|
||||
dp->mbrp_start;
|
||||
|
||||
if (dp->mbrp_typ == MBR_PTYPE_OPENBSD) {
|
||||
if (dp->mbrp_type == MBR_PTYPE_OPENBSD) {
|
||||
use_openbsd_part = 1;
|
||||
}
|
||||
#if 0
|
||||
|
@ -453,7 +453,7 @@ writedisklabel(dev, strat, lp, osdep)
|
|||
goto nombrpart;
|
||||
|
||||
if (ourdp) {
|
||||
if (ourdp->mbrp_typ == MBR_PTYPE_OPENBSD) {
|
||||
if (ourdp->mbrp_type == MBR_PTYPE_OPENBSD) {
|
||||
/* do not override OpenBSD disklabel */
|
||||
error = ESRCH;
|
||||
goto done;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.6 2003/05/10 16:12:02 thorpej Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.7 2003/10/08 04:25:44 lukem Exp $ */
|
||||
/* $OpenBSD: disklabel.h,v 1.14 1999/03/23 16:36:17 millert Exp $ */
|
||||
/* NetBSD: disklabel.h,v 1.3 1996/03/09 20:52:54 ghudson Exp */
|
||||
|
||||
|
@ -43,14 +43,11 @@
|
|||
#define OPENBSD_RAW_PART 2 /* raw partition: XX?c */
|
||||
|
||||
/* Pull in MBR partition definitions. */
|
||||
#include <sys/disklabel_mbr.h>
|
||||
/* XXX - should move to <sys/disklabel_mbr.h> */
|
||||
#define MBR_PTYPE_OPENBSD 0xa6 /* OpenBSD partition type */
|
||||
#define MBR_PTYPE_ONTRACK 0x54
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#include <sys/dkbad.h>
|
||||
struct cpu_disklabel {
|
||||
struct mbr_partition dosparts[NMBRPART];
|
||||
struct mbr_partition dosparts[MBR_PART_COUNT];
|
||||
struct dkbad bad;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disksubr_mbr.c,v 1.3 2003/08/07 16:26:52 agc Exp $ */
|
||||
/* $NetBSD: disksubr_mbr.c,v 1.4 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Christopher G. Demetriou. All rights reserved.
|
||||
|
@ -68,7 +68,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr_mbr.c,v 1.3 2003/08/07 16:26:52 agc Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr_mbr.c,v 1.4 2003/10/08 04:25:44 lukem Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -133,26 +133,26 @@ mbr_label_read(dev, strat, lp, osdep, msgp, cylp, netbsd_label_offp)
|
|||
}
|
||||
|
||||
/* XXX how do we check veracity/bounds of this? */
|
||||
bcopy(bp->b_data + MBR_PARTOFF, mbrp,
|
||||
NMBRPART * sizeof(*mbrp));
|
||||
bcopy(bp->b_data + MBR_PART_OFFSET, mbrp,
|
||||
MBR_PART_COUNT * sizeof(*mbrp));
|
||||
|
||||
/* look for NetBSD partition */
|
||||
ourmbrp = NULL;
|
||||
for (i = 0; !ourmbrp && i < NMBRPART; i++) {
|
||||
if (mbrp[i].mbrp_typ == MBR_PTYPE_NETBSD)
|
||||
for (i = 0; !ourmbrp && i < MBR_PART_COUNT; i++) {
|
||||
if (mbrp[i].mbrp_type == MBR_PTYPE_NETBSD)
|
||||
ourmbrp = &mbrp[i];
|
||||
}
|
||||
#ifdef COMPAT_386BSD_MBRPART
|
||||
/* didn't find it -- look for 386BSD partition */
|
||||
for (i = 0; !ourmbrp && i < NMBRPART; i++) {
|
||||
if (mbrp[i].mbrp_typ == MBR_PTYPE_386BSD) {
|
||||
for (i = 0; !ourmbrp && i < MBR_PART_COUNT; i++) {
|
||||
if (mbrp[i].mbrp_type == MBR_PTYPE_386BSD) {
|
||||
printf("WARNING: old BSD partition ID!\n");
|
||||
ourmbrp = &mbrp[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (i = 0; i < NMBRPART; i++, mbrp++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, mbrp++) {
|
||||
|
||||
strncpy(lp->d_packname, "fictitious-MBR",
|
||||
sizeof lp->d_packname);
|
||||
|
@ -162,10 +162,10 @@ mbr_label_read(dev, strat, lp, osdep, msgp, cylp, netbsd_label_offp)
|
|||
pp->p_offset = mbrp->mbrp_start;
|
||||
pp->p_size = mbrp->mbrp_size;
|
||||
for (ip = fat_types; *ip != -1; ip++) {
|
||||
if (mbrp->mbrp_typ == *ip)
|
||||
if (mbrp->mbrp_type == *ip)
|
||||
pp->p_fstype = FS_MSDOS;
|
||||
}
|
||||
if (mbrp->mbrp_typ == MBR_PTYPE_LNXEXT2)
|
||||
if (mbrp->mbrp_type == MBR_PTYPE_LNXEXT2)
|
||||
pp->p_fstype = FS_EX2FS;
|
||||
|
||||
/* is this ours? */
|
||||
|
@ -241,18 +241,18 @@ mbr_label_locate(dev, strat, lp, osdep, cylp, netbsd_label_offp)
|
|||
}
|
||||
|
||||
/* XXX how do we check veracity/bounds of this? */
|
||||
bcopy(bp->b_data + MBR_PARTOFF, mbrp, NMBRPART * sizeof(*mbrp));
|
||||
bcopy(bp->b_data + MBR_PART_OFFSET, mbrp, MBR_PART_COUNT * sizeof(*mbrp));
|
||||
|
||||
/* look for NetBSD partition */
|
||||
ourmbrp = NULL;
|
||||
for (i = 0; !ourmbrp && i < NMBRPART; i++) {
|
||||
if (mbrp[i].mbrp_typ == MBR_PTYPE_NETBSD)
|
||||
for (i = 0; !ourmbrp && i < MBR_PART_COUNT; i++) {
|
||||
if (mbrp[i].mbrp_type == MBR_PTYPE_NETBSD)
|
||||
ourmbrp = &mbrp[i];
|
||||
}
|
||||
#ifdef COMPAT_386BSD_MBRPART
|
||||
/* didn't find it -- look for 386BSD partition */
|
||||
for (i = 0; !ourmbrp && i < NMBRPART; i++) {
|
||||
if (mbrp[i].mbrp_typ == MBR_PTYPE_386BSD) {
|
||||
for (i = 0; !ourmbrp && i < MBR_PART_COUNT; i++) {
|
||||
if (mbrp[i].mbrp_type == MBR_PTYPE_386BSD) {
|
||||
printf("WARNING: old BSD partition ID!\n");
|
||||
ourmbrp = &mbrp[i];
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.3 2003/05/10 16:12:03 thorpej Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.4 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Mark Brinicombe.
|
||||
|
@ -53,10 +53,10 @@
|
|||
|
||||
#include <sys/dkbad.h>
|
||||
#include <sys/disklabel_acorn.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
struct cpu_disklabel {
|
||||
struct mbr_partition mbrparts[NMBRPART];
|
||||
struct mbr_partition mbrparts[MBR_PART_COUNT];
|
||||
struct dkbad bad;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disksubr.c,v 1.15 2003/08/07 16:27:09 agc Exp $ */
|
||||
/* $NetBSD: disksubr.c,v 1.16 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.15 2003/08/07 16:27:09 agc Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.16 2003/10/08 04:25:44 lukem Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -71,16 +71,16 @@ mbr_findslice(dp, bp)
|
|||
int i;
|
||||
|
||||
/* Note: Magic number is little-endian. */
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGICOFF);
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGIC_OFFSET);
|
||||
if (*mbrmagicp != MBR_MAGIC)
|
||||
return (NO_MBR_SIGNATURE);
|
||||
|
||||
/* XXX how do we check veracity/bounds of this? */
|
||||
memcpy(dp, bp->b_data + MBR_PARTOFF, NMBRPART * sizeof(*dp));
|
||||
memcpy(dp, bp->b_data + MBR_PART_OFFSET, MBR_PART_COUNT * sizeof(*dp));
|
||||
|
||||
/* look for NetBSD partition */
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_NETBSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_NETBSD) {
|
||||
ourdp = &dp[i];
|
||||
break;
|
||||
}
|
||||
|
@ -89,8 +89,8 @@ mbr_findslice(dp, bp)
|
|||
#ifdef COMPAT_386BSD_MBRPART
|
||||
/* didn't find it -- look for 386BSD partition */
|
||||
if (!ourdp) {
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_386BSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_386BSD) {
|
||||
printf("WARNING: old BSD partition ID!\n");
|
||||
ourdp = &dp[i];
|
||||
/*
|
||||
|
@ -191,19 +191,19 @@ readdisklabel(dev, strat, lp, osdep)
|
|||
if (ourdp == NO_MBR_SIGNATURE)
|
||||
goto nombrpart;
|
||||
|
||||
for (i = 0; i < NMBRPART; i++, dp++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
|
||||
/* Install in partition e, f, g, or h. */
|
||||
pp = &lp->d_partitions[RAW_PART + 1 + i];
|
||||
pp->p_offset = dp->mbrp_start;
|
||||
pp->p_size = dp->mbrp_size;
|
||||
for (ip = fat_types; *ip != -1; ip++) {
|
||||
if (dp->mbrp_typ == *ip)
|
||||
if (dp->mbrp_type == *ip)
|
||||
pp->p_fstype = FS_MSDOS;
|
||||
}
|
||||
if (dp->mbrp_typ == MBR_PTYPE_LNXEXT2)
|
||||
if (dp->mbrp_type == MBR_PTYPE_LNXEXT2)
|
||||
pp->p_fstype = FS_EX2FS;
|
||||
|
||||
if (dp->mbrp_typ == MBR_PTYPE_NTFS)
|
||||
if (dp->mbrp_type == MBR_PTYPE_NTFS)
|
||||
pp->p_fstype = FS_NTFS;
|
||||
|
||||
/* is this ours? */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.5 2003/05/10 16:12:03 thorpej Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.6 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
|
@ -39,11 +39,11 @@
|
|||
#define RAW_PART 3 /* raw partition: XX?d (XXX) */
|
||||
|
||||
/* Pull in MBR partition definitions. */
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#include <sys/dkbad.h>
|
||||
struct cpu_disklabel {
|
||||
struct mbr_partition dosparts[NMBRPART];
|
||||
struct mbr_partition dosparts[MBR_PART_COUNT];
|
||||
struct dkbad bad;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disksubr.c,v 1.13 2003/09/12 14:59:12 tsutsui Exp $ */
|
||||
/* $NetBSD: disksubr.c,v 1.14 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
|
||||
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.13 2003/09/12 14:59:12 tsutsui Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.14 2003/10/08 04:25:44 lukem Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -60,16 +60,16 @@ mbr_findslice(dp, bp)
|
|||
int i;
|
||||
|
||||
/* Note: Magic number is little-endian. */
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGICOFF);
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGIC_OFFSET);
|
||||
if (*mbrmagicp != MBR_MAGIC)
|
||||
return (NO_MBR_SIGNATURE);
|
||||
|
||||
/* XXX how do we check veracity/bounds of this? */
|
||||
memcpy(dp, bp->b_data + MBR_PARTOFF, NMBRPART * sizeof(*dp));
|
||||
memcpy(dp, bp->b_data + MBR_PART_OFFSET, MBR_PART_COUNT * sizeof(*dp));
|
||||
|
||||
/* look for NetBSD partition */
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_NETBSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_NETBSD) {
|
||||
ourdp = &dp[i];
|
||||
break;
|
||||
}
|
||||
|
@ -161,15 +161,15 @@ readdisklabel(dev, strat, lp, osdep)
|
|||
if (ourdp == NO_MBR_SIGNATURE)
|
||||
goto nombrpart;
|
||||
|
||||
for (i = 0; i < NMBRPART; i++, dp++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
|
||||
/* Install in partition e, f, g, or h. */
|
||||
pp = &lp->d_partitions[RAW_PART + 1 + i];
|
||||
pp->p_offset = dp->mbrp_start;
|
||||
pp->p_size = dp->mbrp_size;
|
||||
if (dp->mbrp_typ == MBR_PTYPE_LNXEXT2)
|
||||
if (dp->mbrp_type == MBR_PTYPE_LNXEXT2)
|
||||
pp->p_fstype = FS_EX2FS;
|
||||
|
||||
if (dp->mbrp_typ == MBR_PTYPE_LNXSWAP)
|
||||
if (dp->mbrp_type == MBR_PTYPE_LNXSWAP)
|
||||
pp->p_fstype = FS_SWAP;
|
||||
|
||||
/* is this ours? */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.6 2003/09/12 14:59:14 tsutsui Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.7 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
|
@ -39,12 +39,12 @@
|
|||
#define RAW_PART 3
|
||||
|
||||
/* Pull in MBR partition definitions. */
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
#include <sys/dkbad.h>
|
||||
struct cpu_disklabel {
|
||||
struct mbr_partition dosparts[NMBRPART];
|
||||
struct mbr_partition dosparts[MBR_PART_COUNT];
|
||||
struct dkbad bad;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: wd.c,v 1.1 2003/06/25 17:24:23 cdi Exp $ */
|
||||
/* $NetBSD: wd.c,v 1.2 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -147,7 +147,7 @@ wdgetdisklabel(wd)
|
|||
if (wdstrategy(wd, F_READ, MBR_BBSECTOR, DEV_BSIZE, buf, &rsize))
|
||||
return EOFFSET;
|
||||
|
||||
if (*(u_int16_t *)&buf[MBR_MAGICOFF] == MBR_MAGIC) {
|
||||
if (*(u_int16_t *)&buf[MBR_MAGIC_OFFSET] == MBR_MAGIC) {
|
||||
int i;
|
||||
struct mbr_partition *mp;
|
||||
|
||||
|
@ -155,9 +155,9 @@ wdgetdisklabel(wd)
|
|||
* Lookup NetBSD slice. If there is none, go ahead
|
||||
* and try to read the disklabel off sector #0.
|
||||
*/
|
||||
mp = (struct mbr_partition *)&buf[MBR_PARTOFF];
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (mp[i].mbrp_typ == MBR_PTYPE_NETBSD) {
|
||||
mp = (struct mbr_partition *)&buf[MBR_PART_OFFSET];
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (mp[i].mbrp_type == MBR_PTYPE_NETBSD) {
|
||||
sector = mp[i].mbrp_start;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: wdc.c,v 1.1 2003/06/25 17:24:23 cdi Exp $ */
|
||||
/* $NetBSD: wdc.c,v 1.2 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#include <lib/libsa/stand.h>
|
||||
#include <machine/param.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: wdvar.h,v 1.1 2003/06/25 17:24:23 cdi Exp $ */
|
||||
/* $NetBSD: wdvar.h,v 1.2 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -40,7 +40,7 @@
|
|||
#include <mips/cpuregs.h>
|
||||
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#define WDC_TIMEOUT 2000000
|
||||
#define PCIIDE_CHANNEL_NDEV 2
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disksubr.c,v 1.8 2003/08/07 16:27:46 agc Exp $ */
|
||||
/* $NetBSD: disksubr.c,v 1.9 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.8 2003/08/07 16:27:46 agc Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.9 2003/10/08 04:25:44 lukem Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -67,16 +67,16 @@ mbr_findslice(struct mbr_partition *dp, struct buf *bp)
|
|||
int i;
|
||||
|
||||
/* Note: Magic number is little-endian. */
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGICOFF);
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGIC_OFFSET);
|
||||
if (*mbrmagicp != MBR_MAGIC)
|
||||
return (NO_MBR_SIGNATURE);
|
||||
|
||||
/* XXX how do we check veracity/bounds of this? */
|
||||
memcpy(dp, bp->b_data + MBR_PARTOFF, NMBRPART * sizeof(*dp));
|
||||
memcpy(dp, bp->b_data + MBR_PART_OFFSET, MBR_PART_COUNT * sizeof(*dp));
|
||||
|
||||
/* look for NetBSD partition */
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_NETBSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_NETBSD) {
|
||||
ourdp = &dp[i];
|
||||
break;
|
||||
}
|
||||
|
@ -85,8 +85,8 @@ mbr_findslice(struct mbr_partition *dp, struct buf *bp)
|
|||
#ifdef COMPAT_386BSD_MBRPART
|
||||
/* didn't find it -- look for 386BSD partition */
|
||||
if (!ourdp) {
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_386BSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_386BSD) {
|
||||
printf("WARNING: old BSD partition ID!\n");
|
||||
ourdp = &dp[i];
|
||||
/*
|
||||
|
@ -184,19 +184,19 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
|
|||
if (ourdp == NO_MBR_SIGNATURE)
|
||||
goto nombrpart;
|
||||
|
||||
for (i = 0; i < NMBRPART; i++, dp++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
|
||||
/* Install in partition e, f, g, or h. */
|
||||
pp = &lp->d_partitions[RAW_PART + 1 + i];
|
||||
pp->p_offset = dp->mbrp_start;
|
||||
pp->p_size = dp->mbrp_size;
|
||||
for (ip = fat_types; *ip != -1; ip++) {
|
||||
if (dp->mbrp_typ == *ip)
|
||||
if (dp->mbrp_type == *ip)
|
||||
pp->p_fstype = FS_MSDOS;
|
||||
}
|
||||
if (dp->mbrp_typ == MBR_PTYPE_LNXEXT2)
|
||||
if (dp->mbrp_type == MBR_PTYPE_LNXEXT2)
|
||||
pp->p_fstype = FS_EX2FS;
|
||||
|
||||
if (dp->mbrp_typ == MBR_PTYPE_NTFS)
|
||||
if (dp->mbrp_type == MBR_PTYPE_NTFS)
|
||||
pp->p_fstype = FS_NTFS;
|
||||
|
||||
/* is this ours? */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.1 2001/02/09 18:35:25 uch Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.2 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/* Windows CE architecture */
|
||||
|
||||
|
@ -8,4 +8,4 @@
|
|||
#define RAW_PART 3 /* raw partition: XX?d (XXX) */
|
||||
|
||||
/* Pull in MBR partition definitions. */
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: winblk.c,v 1.1 2001/02/09 18:35:37 uch Exp $ */
|
||||
/* $NetBSD: winblk.c,v 1.2 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 Shin Takemura.
|
||||
|
@ -65,7 +65,7 @@
|
|||
struct winblk {
|
||||
HANDLE hDevice;
|
||||
DISK_INFO di;
|
||||
struct mbr_partition mbr[NMBRPART];
|
||||
struct mbr_partition mbr[MBR_PART_COUNT];
|
||||
struct disklabel dl;
|
||||
char buf[BLKSZ];
|
||||
int start;
|
||||
|
@ -207,13 +207,13 @@ winblkopen(struct open_file *f, ...)
|
|||
if (error = rawread(ctx, MBR_BBSECTOR, 1, ctx->buf)) {
|
||||
goto end;
|
||||
}
|
||||
memcpy(&ctx->mbr, &ctx->buf[MBR_PARTOFF], sizeof(ctx->mbr));
|
||||
memcpy(&ctx->mbr, &ctx->buf[MBR_PART_OFFSET], sizeof(ctx->mbr));
|
||||
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
DEBUG_PRINTF((TEXT("%d: type=%d %d(%d) (%d:%d:%d - %d:%d:%d)")
|
||||
TEXT(" flag=0x%02x\n"),
|
||||
i,
|
||||
ctx->mbr[i].mbrp_typ,
|
||||
ctx->mbr[i].mbrp_type,
|
||||
ctx->mbr[i].mbrp_start,
|
||||
ctx->mbr[i].mbrp_size,
|
||||
ctx->mbr[i].mbrp_scyl,
|
||||
|
@ -230,12 +230,12 @@ winblkopen(struct open_file *f, ...)
|
|||
*/
|
||||
ctx->start = -1;
|
||||
start_386bsd = -1;
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (ctx->mbr[i].mbrp_typ == MBR_PTYPE_NETBSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (ctx->mbr[i].mbrp_type == MBR_PTYPE_NETBSD) {
|
||||
ctx->start = ctx->mbr[i].mbrp_start;
|
||||
break;
|
||||
}
|
||||
if (ctx->mbr[i].mbrp_typ == MBR_PTYPE_386BSD) {
|
||||
if (ctx->mbr[i].mbrp_type == MBR_PTYPE_386BSD) {
|
||||
start_386bsd = ctx->mbr[i].mbrp_start;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.3 2003/05/10 16:12:03 thorpej Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.4 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
|
@ -39,12 +39,12 @@
|
|||
#define RAW_PART 3 /* raw partition: XX?d (XXX) */
|
||||
|
||||
/* Pull in MBR partition definitions. */
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
#include <sys/dkbad.h>
|
||||
struct cpu_disklabel {
|
||||
struct mbr_partition dosparts[NMBRPART];
|
||||
struct mbr_partition dosparts[MBR_PART_COUNT];
|
||||
struct dkbad bad;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.5 2003/05/10 16:12:04 thorpej Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.6 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
|
@ -53,12 +53,12 @@
|
|||
((part) / OLDMAXPARTITIONS) * (__HPCMIPS_MAXDISKS * OLDMAXPARTITIONS))
|
||||
|
||||
/* Pull in MBR partition definitions. */
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
#include <sys/dkbad.h>
|
||||
struct cpu_disklabel {
|
||||
struct mbr_partition dosparts[NMBRPART];
|
||||
struct mbr_partition dosparts[MBR_PART_COUNT];
|
||||
struct dkbad bad;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: winblk.c,v 1.4 2000/08/29 15:10:17 takemura Exp $ */
|
||||
/* $NetBSD: winblk.c,v 1.5 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 Shin Takemura.
|
||||
|
@ -65,7 +65,7 @@
|
|||
struct winblk {
|
||||
HANDLE hDevice;
|
||||
DISK_INFO di;
|
||||
struct mbr_partition mbr[NMBRPART];
|
||||
struct mbr_partition mbr[MBR_PART_COUNT];
|
||||
struct disklabel dl;
|
||||
char buf[BLKSZ];
|
||||
int start;
|
||||
|
@ -212,13 +212,13 @@ winblkopen(struct open_file *f, ...)
|
|||
if (error = rawread(ctx, MBR_BBSECTOR, 1, ctx->buf)) {
|
||||
goto end;
|
||||
}
|
||||
memcpy(&ctx->mbr, &ctx->buf[MBR_PARTOFF], sizeof(ctx->mbr));
|
||||
memcpy(&ctx->mbr, &ctx->buf[MBR_PART_OFFSET], sizeof(ctx->mbr));
|
||||
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
DEBUG_PRINTF((TEXT("%d: type=%d %d(%d) (%d:%d:%d - %d:%d:%d)")
|
||||
TEXT(" flag=0x%02x\n"),
|
||||
i,
|
||||
ctx->mbr[i].mbrp_typ,
|
||||
ctx->mbr[i].mbrp_type,
|
||||
ctx->mbr[i].mbrp_start,
|
||||
ctx->mbr[i].mbrp_size,
|
||||
ctx->mbr[i].mbrp_scyl,
|
||||
|
@ -235,12 +235,12 @@ winblkopen(struct open_file *f, ...)
|
|||
*/
|
||||
ctx->start = -1;
|
||||
start_386bsd = -1;
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (ctx->mbr[i].mbrp_typ == MBR_PTYPE_NETBSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (ctx->mbr[i].mbrp_type == MBR_PTYPE_NETBSD) {
|
||||
ctx->start = ctx->mbr[i].mbrp_start;
|
||||
break;
|
||||
}
|
||||
if (ctx->mbr[i].mbrp_typ == MBR_PTYPE_386BSD) {
|
||||
if (ctx->mbr[i].mbrp_type == MBR_PTYPE_386BSD) {
|
||||
start_386bsd = ctx->mbr[i].mbrp_start;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: autoconf.c,v 1.72 2003/08/07 16:27:53 agc Exp $ */
|
||||
/* $NetBSD: autoconf.c,v 1.73 2003/10/08 04:25:44 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -44,7 +44,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.72 2003/08/07 16:27:53 agc Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.73 2003/10/08 04:25:44 lukem Exp $");
|
||||
|
||||
#include "opt_compat_oldboot.h"
|
||||
#include "opt_multiprocessor.h"
|
||||
|
@ -282,8 +282,8 @@ matchbiosdisks(void)
|
|||
if (be->flags & BI_GEOM_INVALID)
|
||||
continue;
|
||||
if (be->cksum == ck &&
|
||||
!memcmp(&mbr[MBR_PARTOFF], be->dosparts,
|
||||
NMBRPART *
|
||||
!memcmp(&mbr[MBR_PART_OFFSET], be->dosparts,
|
||||
MBR_PART_COUNT *
|
||||
sizeof (struct mbr_partition))) {
|
||||
#ifdef GEOM_DEBUG
|
||||
printf("matched bios disk %x with %s\n",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.11 2003/07/07 13:30:10 dsl Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.12 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
|
@ -53,7 +53,7 @@
|
|||
((part) / OLDMAXPARTITIONS) * (__I386_MAXDISKS * OLDMAXPARTITIONS))
|
||||
|
||||
/* Pull in MBR partition definitions. */
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
#include <sys/dkbad.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile.booters,v 1.50 2003/05/05 20:49:10 fvdl Exp $
|
||||
# $NetBSD: Makefile.booters,v 1.51 2003/10/08 04:25:45 lukem Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
|
@ -23,7 +23,7 @@ COPTS+= -ffreestanding
|
|||
I386_STAND_DIR?= $S/arch/i386/stand
|
||||
|
||||
.PATH: ${I386_STAND_DIR}/lib/crt/bootsect ${I386_STAND_DIR}/lib
|
||||
# ensure the stuff we need to load all of 'biosboot' in in the first few
|
||||
# ensure the stuff we need to load all of 'boot' in in the first few
|
||||
# sectors, and that anything that goes to real mode is in the first 64k.
|
||||
# (prot_to_real will bleat if the return address is >64k)
|
||||
BSSTART= start_bootsect.o fraglist.o bootsectmain.o biosdisk_ll.o \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile.boot,v 1.8 2003/08/30 20:38:58 fvdl Exp $
|
||||
# $NetBSD: Makefile.boot,v 1.9 2003/10/08 04:25:45 lukem Exp $
|
||||
|
||||
S= ${.CURDIR}/../../../../../
|
||||
|
||||
|
@ -62,7 +62,7 @@ CPPFLAGS+= -DSUPPORT_SERIAL=boot_params.bp_consdev
|
|||
CPPFLAGS+= -DCONSPEED=boot_params.bp_conspeed
|
||||
|
||||
CPPFLAGS+= -DSUPPORT_USTARFS
|
||||
#CPPFLAGS+= -DSUPPORT_DOSFS
|
||||
CPPFLAGS+= -DSUPPORT_DOSFS
|
||||
CPPFLAGS+= -DPASS_BIOSGEOM
|
||||
CPPFLAGS+= -DPASS_MEMMAP
|
||||
#CPPFLAGS+= -DBOOTPASSWD
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: biosboot.S,v 1.1 2003/04/16 22:36:14 dsl Exp $ */
|
||||
/* $NetBSD: biosboot.S,v 1.2 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
/*
|
||||
* Code linked to 0x1000:0 and (usually) read from /boot by bootxx code
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# $NetBSD: Makefile,v 1.1 2003/04/16 22:36:15 dsl Exp $
|
||||
# $NetBSD: Makefile,v 1.2 2003/10/08 04:25:45 lukem Exp $
|
||||
|
||||
PROG=biosboot
|
||||
PROG= boot
|
||||
|
||||
.include <../Makefile.boot>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: boot2.c,v 1.3 2003/10/06 05:24:54 lukem Exp $ */
|
||||
/* $NetBSD: boot2.c,v 1.4 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003
|
||||
|
@ -59,7 +59,7 @@ int errno;
|
|||
extern int boot_biosdev;
|
||||
extern int boot_biossector; /* may be wrong... */
|
||||
|
||||
extern struct i386_boot_params boot_params;
|
||||
extern struct x86_boot_params boot_params;
|
||||
|
||||
extern const char bootprog_name[], bootprog_rev[], bootprog_date[],
|
||||
bootprog_maker[];
|
||||
|
@ -229,7 +229,7 @@ boot2(uint32_t boot_biosdev, uint32_t boot_biossector)
|
|||
#endif
|
||||
gateA20();
|
||||
|
||||
if (boot_params.bp_flags & I386_BP_FLAGS_RESET_VIDEO)
|
||||
if (boot_params.bp_flags & X86_BP_FLAGS_RESET_VIDEO)
|
||||
biosvideomode();
|
||||
|
||||
print_banner();
|
||||
|
@ -249,7 +249,7 @@ boot2(uint32_t boot_biosdev, uint32_t boot_biossector)
|
|||
|
||||
c = awaitkey(boot_params.bp_timeout, 1);
|
||||
if ((c != '\r') && (c != '\n') && (c != '\0') &&
|
||||
((boot_params.bp_flags & I386_BP_FLAGS_PASSWORD) == 0
|
||||
((boot_params.bp_flags & X86_BP_FLAGS_PASSWORD) == 0
|
||||
|| check_password(boot_params.bp_password))) {
|
||||
printf("type \"?\" or \"help\" for help.\n");
|
||||
bootmenu(); /* does not return */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$NetBSD: version,v 1.1 2003/04/16 22:36:14 dsl Exp $
|
||||
$NetBSD: version,v 1.2 2003/10/08 04:25:45 lukem Exp $
|
||||
|
||||
NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
|
||||
file is important - make sure the entries are appended on end, last item
|
||||
|
@ -18,16 +18,19 @@ is taken as the current.
|
|||
2.9: Recognize PS/2 L40 at runtime and use appropriate gate A20
|
||||
initialization (rather than using a compile flag).
|
||||
Recognize ESDI disks and identify them as ed(4) for COMPAT_OLDBOOT.
|
||||
2.10: g/c COMPAT_OLDBOOT
|
||||
2.10: g/c COMPAT_OLDBOOT.
|
||||
2.11: loadfile() update: ELF symbols no longer need backward seeks.
|
||||
2.12: loadfile() update to avoid backwards seeks for ELF Program Headers.
|
||||
2.13: Support boot from 1.44MB floppies in 2.88MB floppy drives.
|
||||
2.14: Add a quirk for BIOSes which report extended memory size
|
||||
in slightly nonstandard way in int15, function 0xE801
|
||||
in slightly nonstandard way in int15, function 0xE801.
|
||||
2.15: Use int15/0xc7 to get memory information on machines which support
|
||||
it, like later IBM PS/2 machines
|
||||
2.16: Move 16bit %ss to allow >64k for code, data and stack
|
||||
Default partition to that passed in by mbr code
|
||||
Support limited filename globbing in 'ls' command
|
||||
it, like later IBM PS/2 machines.
|
||||
2.16: Move 16bit %ss to allow >64k for code, data and stack.
|
||||
Default partition to that passed in by mbr code.
|
||||
Support limited filename globbing in 'ls' command.
|
||||
Use .code16 and .code32 directives
|
||||
3.0: Separate out into bootxx and boot
|
||||
3.1: Rename to /usr/mdec/boot.
|
||||
Leave space in bootxx for FAT32 BPB and MBR partition table.
|
||||
Keep MBR's existing BPB and partition table when installing bootxx.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# $NetBSD: Makefile,v 1.2 2003/06/24 09:38:36 tron Exp $
|
||||
# $NetBSD: Makefile,v 1.3 2003/10/08 04:25:45 lukem Exp $
|
||||
|
||||
SUBDIR= bootxx_ufs bootxx_ffsv1 bootxx_ffsv2 bootxx_lfsv1 bootxx_lfsv2
|
||||
SUBDIR+= bootxx_dosfs bootxx_ustarfs
|
||||
SUBDIR= bootxx_ffsv1 bootxx_ffsv2 bootxx_lfsv1 bootxx_lfsv2
|
||||
SUBDIR+=bootxx_msdos bootxx_ustarfs
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# $NetBSD: Makefile.bootxx,v 1.8 2003/08/30 18:25:07 fvdl Exp $
|
||||
# $NetBSD: Makefile.bootxx,v 1.9 2003/10/08 04:25:45 lukem Exp $
|
||||
|
||||
S= ${.CURDIR}/../../../../../
|
||||
|
||||
NOMAN=
|
||||
STRIPFLAG=
|
||||
PROG= bootxx_${FS}
|
||||
PROG?= bootxx_${FS}
|
||||
BINDIR= /usr/mdec
|
||||
BINMODE= 0444
|
||||
|
||||
|
@ -48,6 +48,8 @@ CPPFLAGS+= -DFS=${FS}
|
|||
# Make sure we override any optimization options specified by the user
|
||||
COPTS= -Os
|
||||
|
||||
CPPFLAGS+= -DTERSE_ERROR
|
||||
|
||||
.if ${MACHINE} == "amd64"
|
||||
LD+= -m elf_i386
|
||||
AFLAGS+= -m32
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bootxx.S,v 1.1 2003/04/16 22:17:44 dsl Exp $ */
|
||||
/* $NetBSD: bootxx.S,v 1.2 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
/*
|
||||
* Code linked to 0xa00 and copied to sectors 2+ of the netbsd boot
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.1 2003/04/16 22:27:35 dsl Exp $
|
||||
|
||||
FS=dosfs
|
||||
|
||||
.include <../Makefile.bootxx>
|
|
@ -0,0 +1,7 @@
|
|||
# $NetBSD: Makefile,v 1.1 2003/10/08 04:25:45 lukem Exp $
|
||||
|
||||
PROG= bootxx_msdos
|
||||
FS= dosfs
|
||||
CPPFLAGS=-DBOOT_FROM_FAT
|
||||
|
||||
.include <../Makefile.bootxx>
|
|
@ -1,5 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.1 2003/04/16 22:26:11 dsl Exp $
|
||||
|
||||
FS=ufs
|
||||
|
||||
.include <../Makefile.bootxx>
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pbr.S,v 1.7 2003/08/30 13:33:55 dsl Exp $ */
|
||||
/* $NetBSD: pbr.S,v 1.8 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -56,7 +56,7 @@
|
|||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#define OURADDR 0x7c00 /* our address */
|
||||
#define BOOTADDR PRIMARY_LOAD_ADDRESS
|
||||
|
@ -69,7 +69,7 @@
|
|||
#define errcod R(_errcod)
|
||||
#define newline R(_newline)
|
||||
|
||||
#define TABENTRYSIZE (PARTNAMESIZE + 1)
|
||||
#define TABENTRYSIZE (MBR_BS_PARTNAMESIZE + 1)
|
||||
#define NAMETABSIZE (4 * TABENTRYSIZE)
|
||||
|
||||
#ifdef TERSE_ERROR
|
||||
|
@ -94,7 +94,7 @@
|
|||
* and can load the subsequent blocks (that load boot) to an address
|
||||
* of our choosing. 0:600 is a not unreasonable choice.
|
||||
*
|
||||
* On entry the bios drive number is in %dl and %esi may contain the
|
||||
* On entry the BIOS drive number is in %dl and %esi may contain the
|
||||
* sector we were loaded from (if we were loaded by NetBSD mbr code).
|
||||
* In any case we have to re-read sector zero of the disk and hunt
|
||||
* through the BIOS partition table for the NetBSD partition.
|
||||
|
@ -104,18 +104,21 @@
|
|||
.code16
|
||||
ENTRY(start)
|
||||
/*
|
||||
* The PC BIOS architecture defines a 'Boot Parameter Block' here.
|
||||
* The actual format varies between different dos versions, but
|
||||
* The PC BIOS architecture defines a Boot Parameter Block (BPB) here.
|
||||
* The actual format varies between different MS-DOS versions, but
|
||||
* apparantly some system BIOS insist on patching this area
|
||||
* (especially on LS120 drives - which I thought had an mbr...).
|
||||
* (especially on LS120 drives - which I thought had an MBR...).
|
||||
* The initial jmp and nop are part of the standard and may be
|
||||
* tested for by the system BIOS.
|
||||
*/
|
||||
jmp start0
|
||||
nop
|
||||
.ascii "NetBSD20" /* OS name and version */
|
||||
.ascii "NetBSD20" /* oemname (8 bytes) */
|
||||
|
||||
. = start + 0x25 /* rest all zeros for now */
|
||||
. = start + MBR_BPB_OFFSET /* move to start of BPB */
|
||||
/* (ensures oemname doesn't overflow) */
|
||||
|
||||
. = start + MBR_BOOTCODE_OFFSET /* skip BPB */
|
||||
start0:
|
||||
xor %ax, %ax /* don't trust values of ds, es or ss */
|
||||
mov %ax, %ds
|
||||
|
@ -136,22 +139,37 @@ start0:
|
|||
/* See if this is our code, if so we have already loaded the next stage */
|
||||
|
||||
xorl %ebp, %ebp /* pass sector 0 to next stage */
|
||||
movl (%bx), %eax /* mbr code shouldn't even have ... */
|
||||
movl (%bx), %eax /* MBR code shouldn't even have ... */
|
||||
cmpl R(start), %eax /* ... a jmp at the start. */
|
||||
je pbr_read_ok1
|
||||
|
||||
/* Now scan the mbr partition table for a netbsd partition */
|
||||
/* Now scan the MBR partition table for a netbsd partition */
|
||||
|
||||
xorl %ebx, %ebx /* for base extended ptn chain */
|
||||
scan_ptn_tbl:
|
||||
xorl %ecx, %ecx /* for next extended ptn */
|
||||
movw $BOOTADDR + MBR_PARTOFF, %di
|
||||
1: movb 4(%di), %al /* mbrp_typ */
|
||||
movw $BOOTADDR + MBR_PART_OFFSET, %di
|
||||
1: movb 4(%di), %al /* mbrp_type */
|
||||
movl 8(%di), %ebp /* mbrp_start == LBA sector */
|
||||
addl lba_sector, %ebp /* add base of extended partition */
|
||||
#ifdef BOOT_FROM_FAT
|
||||
cmpb $MBR_PTYPE_FAT12, %al
|
||||
je 5f
|
||||
cmpb $MBR_PTYPE_FAT16S, %al
|
||||
je 5f
|
||||
cmpb $MBR_PTYPE_FAT16B, %al
|
||||
je 5f
|
||||
cmpb $MBR_PTYPE_FAT32, %al
|
||||
je 5f
|
||||
cmpb $MBR_PTYPE_FAT32L, %al
|
||||
je 5f
|
||||
cmpb $MBR_PTYPE_FAT16L, %al
|
||||
je 5f
|
||||
#else
|
||||
cmpb $MBR_PTYPE_NETBSD, %al
|
||||
#endif
|
||||
jne 10f
|
||||
testl %esi, %esi /* looking for a specific sector? */
|
||||
5: testl %esi, %esi /* looking for a specific sector? */
|
||||
je boot
|
||||
cmpl %ebp, %esi /* ptn we wanted? */
|
||||
je boot
|
||||
|
@ -164,7 +182,7 @@ scan_ptn_tbl:
|
|||
jne 20f
|
||||
15: movl 8(%di), %ecx /* sector of next ext. ptn */
|
||||
20: add $0x10, %di
|
||||
cmp $BOOTADDR + MBR_MAGICOFF, %di
|
||||
cmp $BOOTADDR + MBR_MAGIC_OFFSET, %di
|
||||
jne 1b
|
||||
|
||||
/* not in base partitions, check extended ones */
|
||||
|
@ -188,7 +206,7 @@ no_netbsd_ptn:
|
|||
/*
|
||||
* Sector below CHS limit
|
||||
* Do a cylinder-head-sector read instead
|
||||
* I believe the bios should do reads that cross track boundaries.
|
||||
* I believe the BIOS should do reads that cross track boundaries.
|
||||
* (but the read should start at the beginning of a track...)
|
||||
*/
|
||||
read_chs:
|
||||
|
@ -204,8 +222,8 @@ pbr_read_ok1:
|
|||
* We can either do a CHS (Cylinder Head Sector) or an LBA (Logical
|
||||
* Block Address) read. Always doing the LBA one
|
||||
* would be nice - unfortunately not all systems support it.
|
||||
* Also some may contain a separate (eg SCSI) bios that doesn't
|
||||
* support it even when the main bios does.
|
||||
* Also some may contain a separate (eg SCSI) BIOS that doesn't
|
||||
* support it even when the main BIOS does.
|
||||
*
|
||||
* The safest thing seems to be to find out whether the sector we
|
||||
* want is inside the CHS sector count. If it is we use CHS, if
|
||||
|
@ -220,7 +238,7 @@ boot:
|
|||
testl %ebx, %ebx /* was it an extended ptn? */
|
||||
jnz boot_lba /* yes - boot with LBA reads */
|
||||
|
||||
/* get maximum (bios) sector */
|
||||
/* get maximum (BIOS) sector */
|
||||
push %dx /* save drive number */
|
||||
movb $8, %ah
|
||||
int $0x13 /* chs info */
|
||||
|
@ -263,9 +281,9 @@ check_lba:
|
|||
* and the disk packet capability.
|
||||
*
|
||||
* This is actually relatively pointless:
|
||||
* 1) we only us LBA reads if CHS ones would fail
|
||||
* 2) the mbr code managed to read the same sectors
|
||||
* 3) the bios will (ok should) reject the LBA read as a bad bios call
|
||||
* 1) we onlye us LBA reads if CHS ones would fail
|
||||
* 2) the MBR code managed to read the same sectors
|
||||
* 3) the BIOS will (ok should) reject the LBA read as a bad BIOS call
|
||||
*/
|
||||
movw $0x55aa, %bx
|
||||
movb $0x41, %ah
|
||||
|
@ -373,18 +391,27 @@ _lba_sector:
|
|||
.long 0x0000
|
||||
|
||||
/*
|
||||
* Some people like to put this code into the mbr of a disk (this is not
|
||||
* a valid PC disk layout but...). To do this there must be space here
|
||||
* for a 64byte partition table. There isn't (quite) that much space
|
||||
* here, but provided the partition 0 entry is left blank it should be ok.
|
||||
*
|
||||
* Placate certain people by defining the last mbr partition active
|
||||
* and covering the start of the disk.
|
||||
* Provide empty MBR partition table.
|
||||
* If this is installed as an MBR, the user can use fdisk(8) to create
|
||||
* the correct partition table ...
|
||||
*/
|
||||
. = _C_LABEL(start) + MBR_PART_OFFSET
|
||||
_pbr_part0:
|
||||
.byte 0, 0, 0, 0, 0, 0, 0, 0
|
||||
.long 0, 0
|
||||
_pbr_part1:
|
||||
.byte 0, 0, 0, 0, 0, 0, 0, 0
|
||||
.long 0, 0
|
||||
_pbr_part2:
|
||||
.byte 0, 0, 0, 0, 0, 0, 0, 0
|
||||
.long 0, 0
|
||||
_pbr_part3:
|
||||
.byte 0, 0, 0, 0, 0, 0, 0, 0
|
||||
.long 0, 0
|
||||
|
||||
. = _C_LABEL(start) + MBR_MAGICOFF - 16
|
||||
.byte MBR_FLAGS_ACTIVE, 0, 0, 0, MBR_PTYPE_NETBSD, 0, 15, 0
|
||||
.long 0, 15
|
||||
. = _C_LABEL(start) + MBR_MAGICOFF
|
||||
/*
|
||||
* The magic comes last
|
||||
*/
|
||||
. = _C_LABEL(start) + MBR_MAGIC_OFFSET
|
||||
pbr_magic:
|
||||
.word MBR_MAGIC
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: biosdisk.c,v 1.17 2003/07/07 13:32:42 dsl Exp $ */
|
||||
/* $NetBSD: biosdisk.c,v 1.18 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1998
|
||||
|
@ -191,7 +191,7 @@ static int
|
|||
read_label(struct biosdisk *d)
|
||||
{
|
||||
struct disklabel dflt_lbl;
|
||||
struct mbr_partition mbr[NMBRPART];
|
||||
struct mbr_partition mbr[MBR_PART_COUNT];
|
||||
struct partition *p;
|
||||
int sector, i;
|
||||
int error;
|
||||
|
@ -225,10 +225,10 @@ read_label(struct biosdisk *d)
|
|||
#endif
|
||||
return EIO;
|
||||
}
|
||||
memcpy(&mbr, ((mbr_sector_t *)d->buf)->mbr_parts, sizeof mbr);
|
||||
memcpy(&mbr, ((struct mbr_sector *)d->buf)->mbr_parts, sizeof mbr);
|
||||
/* Look for NetBSD partition ID */
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
typ = mbr[i].mbrp_typ;
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
typ = mbr[i].mbrp_type;
|
||||
if (typ == 0)
|
||||
continue;
|
||||
sector = this_ext + mbr[i].mbrp_start;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bootinfo_biosgeom.c,v 1.11 2003/04/16 14:22:29 dsl Exp $ */
|
||||
/* $NetBSD: bootinfo_biosgeom.c,v 1.12 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997
|
||||
|
@ -174,7 +174,7 @@ void bi_getbiosgeom()
|
|||
for (j = 0, cksum = 0; j < BIOSDISK_SECSIZE; j++)
|
||||
cksum += buf[j];
|
||||
bibg->disk[nvalid].cksum = cksum;
|
||||
memcpy(bibg->disk[nvalid].dosparts, &buf[MBR_PARTOFF],
|
||||
memcpy(bibg->disk[nvalid].dosparts, &buf[MBR_PART_OFFSET],
|
||||
sizeof(bibg->disk[nvalid].dosparts));
|
||||
nvalid++;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: start_bootsect.S,v 1.20 2003/02/24 23:23:14 dsl Exp $ */
|
||||
/* $NetBSD: start_bootsect.S,v 1.21 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* BIOS bootsector startup
|
||||
|
@ -86,8 +86,8 @@ STACKOFF = 0xfffc
|
|||
LOADSZ = PRIM_LOADSZ # size of first loaded chunk
|
||||
|
||||
SIGNATURE = 0xaa55
|
||||
PARTSTART = MBR_PARTOFF # starting address of partition table
|
||||
NUMPART = NMBRPART # number of entries in partition table
|
||||
PARTSTART = MBR_PART_OFFSET # starting address of partition table
|
||||
NUMPART = MBR_PART_COUNT # number of entries in partition table
|
||||
PARTSZ = 16 # sizeof(struct dos_partition)
|
||||
NETBSDPART = MBR_PTYPE_NETBSD
|
||||
#ifdef COMPAT_386BSD_MBRPART
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pcio.c,v 1.14 2003/04/16 14:56:55 dsl Exp $ */
|
||||
/* $NetBSD: pcio.c,v 1.15 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997
|
||||
|
@ -47,7 +47,7 @@
|
|||
extern void conputc __P((int));
|
||||
extern int congetc __P((void));
|
||||
extern int coniskey __P((void));
|
||||
extern struct i386_boot_params boot_params;
|
||||
extern struct x86_boot_params boot_params;
|
||||
|
||||
struct btinfo_console btinfo_console;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mbr.S,v 1.3 2003/07/02 14:35:51 dsl Exp $ */
|
||||
/* $NetBSD: mbr.S,v 1.4 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999-2003 The NetBSD Foundation, Inc.
|
||||
|
@ -50,13 +50,18 @@
|
|||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#define BOOTADDR 0x7c00
|
||||
#define LOADADDR 0x0600 /* address were are linked to */
|
||||
|
||||
#define TABENTRYSIZE (PARTNAMESIZE + 1)
|
||||
#define NAMETABSIZE (NMBRPART * TABENTRYSIZE)
|
||||
#define TABENTRYSIZE (MBR_BS_PARTNAMESIZE + 1)
|
||||
#define NAMETABSIZE (MBR_PART_COUNT * TABENTRYSIZE)
|
||||
|
||||
/* Scan values for the various keys we use, as returned by the BIOS */
|
||||
#define SCAN_ENTER 0x1c
|
||||
#define SCAN_F1 0x3b
|
||||
#define SCAN_1 0x2
|
||||
|
||||
/*
|
||||
* Minimum and maximum drive number that is considered to be valid.
|
||||
|
@ -187,7 +192,7 @@ next_ptn:
|
|||
push %dx /* save drive */
|
||||
int $0x13
|
||||
jc wait_key /* abort menu on read fail */
|
||||
cmpw $MBR_MAGIC, LOADADDR + MBR_MAGICOFF
|
||||
cmpw $MBR_MAGIC, LOADADDR + MBR_MAGIC_OFFSET
|
||||
movw $nametab - LOADADDR + BOOTADDR, %bx
|
||||
je next_extended
|
||||
#endif
|
||||
|
@ -238,7 +243,7 @@ check_key:
|
|||
/*
|
||||
* Scan MBR for first active partition, and boot it.
|
||||
*/
|
||||
mov $NMBRPART, %cx
|
||||
mov $MBR_PART_COUNT, %cx
|
||||
mov $parttab, %si
|
||||
1:
|
||||
cmpb $0x80, (%si)
|
||||
|
@ -356,7 +361,7 @@ err_msg:
|
|||
boot_si:
|
||||
movl 8(%si), %ebp /* get sector # */
|
||||
|
||||
testb $BFL_READ_LBA, flags
|
||||
testb $MBR_BS_READ_LBA, flags
|
||||
jnz boot_lba /* fdisk forced LBA read */
|
||||
|
||||
pop %dx /* collect saved drive... */
|
||||
|
@ -433,7 +438,7 @@ do_read:
|
|||
movb BOOTADDR, %al /* first byte non-zero */
|
||||
test %al, %al
|
||||
jz 1f
|
||||
movw BOOTADDR + MBR_MAGICOFF, %ax
|
||||
movw BOOTADDR + MBR_MAGIC_OFFSET, %ax
|
||||
1: cmp $MBR_MAGIC, %ax
|
||||
set_err(ERR_NOOS)
|
||||
jnz err_msg
|
||||
|
@ -518,7 +523,7 @@ ERR_KEY: .asciz "bad key"
|
|||
* (Unfortunately I can't seem to get the value reported when it is -ve)
|
||||
*/
|
||||
mbr_space = defkey - .
|
||||
. = start + MBR_BOOTSELOFF
|
||||
. = start + MBR_BOOTSEL_OFFSET
|
||||
/*
|
||||
* Default action, as a keyvalue we'd normally read from the BIOS.
|
||||
*/
|
||||
|
@ -527,7 +532,7 @@ defkey:
|
|||
#ifndef BOOTSEL_FLAGS
|
||||
#define BOOTSEL_FLAGS 0
|
||||
#endif
|
||||
flags: .byte BFL_NEWMBR | BOOTSEL_FLAGS
|
||||
flags: .byte MBR_BS_NEWMBR | BOOTSEL_FLAGS
|
||||
/*
|
||||
* Timeout value. ~65536 ticks per hour, which is ~18.2 times per second.
|
||||
* 0xffff means never timeout.
|
||||
|
@ -538,16 +543,16 @@ timeout:
|
|||
* Space for name/select table and partition table.
|
||||
*/
|
||||
nametab:
|
||||
.fill NMBRPART * (PARTNAMESIZE + 1), 0x01, 0x00
|
||||
.fill MBR_PART_COUNT * (MBR_BS_PARTNAMESIZE + 1), 0x01, 0x00
|
||||
|
||||
. = start + MBR_PARTOFF - 2
|
||||
. = start + MBR_PART_OFFSET - 2
|
||||
.word MBR_MAGIC
|
||||
|
||||
. = start + MBR_PARTOFF
|
||||
. = start + MBR_PART_OFFSET
|
||||
parttab:
|
||||
.fill 0x40, 0x01, 0x00
|
||||
|
||||
. = start + MBR_MAGICOFF
|
||||
. = start + MBR_MAGIC_OFFSET
|
||||
.word MBR_MAGIC
|
||||
|
||||
/* zeroed data space */
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# $NetBSD: Makefile,v 1.1 2003/04/28 12:19:06 dsl Exp $
|
||||
# $NetBSD: Makefile,v 1.2 2003/10/08 04:25:45 lukem Exp $
|
||||
|
||||
PROG= mbr_bootsel
|
||||
AFLAGS+= -DBOOTSEL
|
||||
AFLAGS+= -DTERSE_ERROR
|
||||
AFLAGS+= -DBOOTSEL_FLAGS=BFL_SELACTIVE
|
||||
AFLAGS+= -DBOOTSEL_FLAGS=MBR_BS_ACTIVE
|
||||
|
||||
.include <../Makefile.mbr>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# $NetBSD: Makefile,v 1.1 2003/04/28 12:19:07 dsl Exp $
|
||||
# $NetBSD: Makefile,v 1.2 2003/10/08 04:25:45 lukem Exp $
|
||||
|
||||
PROG= mbr_ext
|
||||
AFLAGS+= -DBOOTSEL -DBOOT_EXTENDED
|
||||
AFLAGS+= -DTERSE_ERROR -DNO_CHS
|
||||
AFLAGS+= "-DBOOTSEL_FLAGS=BFL_SELACTIVE|BFL_EXTLBA"
|
||||
AFLAGS+= "-DBOOTSEL_FLAGS=MBR_BS_ACTIVE|MBR_BS_EXTLBA"
|
||||
|
||||
.include <../Makefile.mbr>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disksubr.c,v 1.47 2003/08/07 16:28:21 agc Exp $ */
|
||||
/* $NetBSD: disksubr.c,v 1.48 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
|
||||
|
@ -65,14 +65,14 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.47 2003/08/07 16:28:21 agc Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.48 2003/10/08 04:25:45 lukem Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/disk.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
#include <sys/syslog.h>
|
||||
|
||||
#include <machine/bswap.h>
|
||||
|
@ -350,16 +350,16 @@ read_mbr_label(dlbuf, lp, match)
|
|||
*match = 0;
|
||||
msg = NULL;
|
||||
|
||||
if (MBR_MAGIC != bswap16(*(u_int16_t *)(dlbuf + MBR_MAGICOFF)))
|
||||
if (MBR_MAGIC != bswap16(*(u_int16_t *)(dlbuf + MBR_MAGIC_OFFSET)))
|
||||
return msg;
|
||||
|
||||
/* Found MBR magic number; set up disklabel */
|
||||
*match = (-1);
|
||||
mbr_lbl_off = MBR_BBSECTOR * lp->d_secsize + MBR_PARTOFF;
|
||||
mbr_lbl_off = MBR_BBSECTOR * lp->d_secsize + MBR_PART_OFFSET;
|
||||
|
||||
dp = (struct mbr_partition *)(dlbuf + mbr_lbl_off);
|
||||
for (i = 0; i < NMBRPART; i++, dp++) {
|
||||
if (dp->mbrp_typ == 0)
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
|
||||
if (dp->mbrp_type == 0)
|
||||
continue;
|
||||
|
||||
slot = getFreeLabelEntry(lp);
|
||||
|
@ -371,7 +371,7 @@ read_mbr_label(dlbuf, lp, match)
|
|||
pp->p_size = bswap32(dp->mbrp_size);
|
||||
|
||||
for (ip = fat_types; *ip != -1; ip++) {
|
||||
if (dp->mbrp_typ == *ip) {
|
||||
if (dp->mbrp_type == *ip) {
|
||||
pp->p_fstype = FS_MSDOS;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disksubr.c,v 1.30 2003/08/07 16:28:24 agc Exp $ */
|
||||
/* $NetBSD: disksubr.c,v 1.31 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
|
||||
|
@ -106,7 +106,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.30 2003/08/07 16:28:24 agc Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.31 2003/10/08 04:25:45 lukem Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -114,7 +114,7 @@ __KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.30 2003/08/07 16:28:24 agc Exp $");
|
|||
#include <sys/conf.h>
|
||||
#include <sys/disk.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
#include <sys/syslog.h>
|
||||
|
||||
#include <machine/bswap.h>
|
||||
|
@ -438,10 +438,10 @@ read_dos_label(dev, strat, lp, osdep)
|
|||
goto done;
|
||||
}
|
||||
/* XXX */
|
||||
dp = (struct mbr_partition *)(bp->b_data + MBR_PARTOFF);
|
||||
dp = (struct mbr_partition *)(bp->b_data + MBR_PART_OFFSET);
|
||||
bsdp = NULL;
|
||||
for (i = 0; i < NMBRPART; i++, dp++) {
|
||||
switch (dp->mbrp_typ) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
|
||||
switch (dp->mbrp_type) {
|
||||
case MBR_PTYPE_NETBSD:
|
||||
bsdp = dp;
|
||||
break;
|
||||
|
@ -454,9 +454,9 @@ read_dos_label(dev, strat, lp, osdep)
|
|||
}
|
||||
if (!bsdp) {
|
||||
/* generate fake disklabel */
|
||||
dp = (struct mbr_partition *)(bp->b_data + MBR_PARTOFF);
|
||||
for (i = 0; i < NMBRPART; i++, dp++) {
|
||||
if (!dp->mbrp_typ)
|
||||
dp = (struct mbr_partition *)(bp->b_data + MBR_PART_OFFSET);
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
|
||||
if (!dp->mbrp_type)
|
||||
continue;
|
||||
slot = getFreeLabelEntry(lp);
|
||||
if (slot < 0)
|
||||
|
@ -467,7 +467,7 @@ read_dos_label(dev, strat, lp, osdep)
|
|||
lp->d_partitions[slot].p_offset = bswap32(dp->mbrp_start);
|
||||
lp->d_partitions[slot].p_size = bswap32(dp->mbrp_size);
|
||||
|
||||
switch (dp->mbrp_typ) {
|
||||
switch (dp->mbrp_type) {
|
||||
case MBR_PTYPE_FAT12:
|
||||
case MBR_PTYPE_FAT16S:
|
||||
case MBR_PTYPE_FAT16B:
|
||||
|
@ -608,7 +608,7 @@ readdisklabel(dev, strat, lp, osdep)
|
|||
/* it ignores labelsector/offset */
|
||||
msg = read_mac_label(dev, strat, lp, osdep);
|
||||
/* the disklabel is fictious */
|
||||
} else if (bswap16(*(u_int16_t *)(bp->b_data + MBR_MAGICOFF))
|
||||
} else if (bswap16(*(u_int16_t *)(bp->b_data + MBR_MAGIC_OFFSET))
|
||||
== MBR_MAGIC) {
|
||||
/* read_dos_label figures out labelsector/offset */
|
||||
msg = read_dos_label(dev, strat, lp, osdep);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ofdev.c,v 1.12 2003/07/11 23:38:08 aymeric Exp $ */
|
||||
/* $NetBSD: ofdev.c,v 1.13 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
|
@ -36,7 +36,7 @@
|
|||
|
||||
#include <sys/param.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
|
@ -210,16 +210,16 @@ search_label(devp, off, buf, lp, off0)
|
|||
|| read != DEV_BSIZE)
|
||||
return ERDLAB;
|
||||
|
||||
if (*(u_int16_t *)&buf[MBR_MAGICOFF] != sa_htole16(MBR_MAGIC))
|
||||
if (*(u_int16_t *)&buf[MBR_MAGIC_OFFSET] != sa_htole16(MBR_MAGIC))
|
||||
return ERDLAB;
|
||||
|
||||
if (recursion++ <= 1)
|
||||
off0 += off;
|
||||
for (p = (struct mbr_partition *)(buf + MBR_PARTOFF), i = 4;
|
||||
for (p = (struct mbr_partition *)(buf + MBR_PART_OFFSET), i = 4;
|
||||
--i >= 0; p++) {
|
||||
if (p->mbrp_typ == MBR_PTYPE_NETBSD
|
||||
if (p->mbrp_type == MBR_PTYPE_NETBSD
|
||||
#ifdef COMPAT_386BSD_MBRPART
|
||||
|| (p->mbrp_typ == MBR_PTYPE_386BSD &&
|
||||
|| (p->mbrp_type == MBR_PTYPE_386BSD &&
|
||||
(printf("WARNING: old BSD partition ID!\n"), 1)
|
||||
/* XXX XXX - libsa printf() is void */ )
|
||||
#endif
|
||||
|
@ -238,7 +238,7 @@ search_label(devp, off, buf, lp, off0)
|
|||
recursion--;
|
||||
return ERDLAB;
|
||||
}
|
||||
} else if (p->mbrp_typ == MBR_PTYPE_EXT) {
|
||||
} else if (p->mbrp_type == MBR_PTYPE_EXT) {
|
||||
poff = get_long(&p->mbrp_start);
|
||||
if (!search_label(devp, poff, buf, lp, off0)) {
|
||||
recursion--;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.3 2003/05/10 16:12:04 thorpej Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.4 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
|
@ -39,11 +39,11 @@
|
|||
#define RAW_PART 2 /* raw partition: xx?c */
|
||||
|
||||
/* Pull in MBR partition definitions. */
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#include <sys/dkbad.h>
|
||||
struct cpu_disklabel {
|
||||
struct mbr_partition dosparts[NMBRPART];
|
||||
struct mbr_partition dosparts[MBR_PART_COUNT];
|
||||
struct dkbad bad;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disksubr.c,v 1.8 2003/08/07 16:28:47 agc Exp $ */
|
||||
/* $NetBSD: disksubr.c,v 1.9 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.8 2003/08/07 16:28:47 agc Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.9 2003/10/08 04:25:45 lukem Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -71,16 +71,16 @@ mbr_findslice(dp, bp)
|
|||
int i;
|
||||
|
||||
/* Note: Magic number is little-endian. */
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGICOFF);
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGIC_OFFSET);
|
||||
if (*mbrmagicp != MBR_MAGIC)
|
||||
return (NO_MBR_SIGNATURE);
|
||||
|
||||
/* XXX how do we check veracity/bounds of this? */
|
||||
memcpy(dp, bp->b_data + MBR_PARTOFF, NMBRPART * sizeof(*dp));
|
||||
memcpy(dp, bp->b_data + MBR_PART_OFFSET, MBR_PART_COUNT * sizeof(*dp));
|
||||
|
||||
/* look for NetBSD partition */
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_NETBSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_NETBSD) {
|
||||
ourdp = &dp[i];
|
||||
break;
|
||||
}
|
||||
|
@ -89,8 +89,8 @@ mbr_findslice(dp, bp)
|
|||
#ifdef COMPAT_386BSD_MBRPART
|
||||
/* didn't find it -- look for 386BSD partition */
|
||||
if (!ourdp) {
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_386BSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_386BSD) {
|
||||
printf("WARNING: old BSD partition ID!\n");
|
||||
ourdp = &dp[i];
|
||||
/*
|
||||
|
@ -191,19 +191,19 @@ readdisklabel(dev, strat, lp, osdep)
|
|||
if (ourdp == NO_MBR_SIGNATURE)
|
||||
goto nombrpart;
|
||||
|
||||
for (i = 0; i < NMBRPART; i++, dp++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
|
||||
/* Install in partition e, f, g, or h. */
|
||||
pp = &lp->d_partitions[RAW_PART + 1 + i];
|
||||
pp->p_offset = dp->mbrp_start;
|
||||
pp->p_size = dp->mbrp_size;
|
||||
for (ip = fat_types; *ip != -1; ip++) {
|
||||
if (dp->mbrp_typ == *ip)
|
||||
if (dp->mbrp_type == *ip)
|
||||
pp->p_fstype = FS_MSDOS;
|
||||
}
|
||||
if (dp->mbrp_typ == MBR_PTYPE_LNXEXT2)
|
||||
if (dp->mbrp_type == MBR_PTYPE_LNXEXT2)
|
||||
pp->p_fstype = FS_EX2FS;
|
||||
|
||||
if (dp->mbrp_typ == MBR_PTYPE_NTFS)
|
||||
if (dp->mbrp_type == MBR_PTYPE_NTFS)
|
||||
pp->p_fstype = FS_NTFS;
|
||||
|
||||
/* is this ours? */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disksubr.c,v 1.15 2003/07/15 02:46:32 lukem Exp $ */
|
||||
/* $NetBSD: disksubr.c,v 1.16 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1996 Wolfgang Solfrank.
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.15 2003/07/15 02:46:32 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.16 2003/10/08 04:25:45 lukem Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/buf.h>
|
||||
|
@ -40,7 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.15 2003/07/15 02:46:32 lukem Exp $");
|
|||
#include <sys/device.h>
|
||||
#include <sys/disk.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/malloc.h>
|
||||
|
@ -161,16 +161,16 @@ mbr_to_label(dev_t dev, void (*strat)(struct buf *), daddr_t bno,
|
|||
if (biowait(bp))
|
||||
goto done;
|
||||
|
||||
if (get_short(bp->b_data + MBR_MAGICOFF) != MBR_MAGIC)
|
||||
if (get_short(bp->b_data + MBR_MAGIC_OFFSET) != MBR_MAGIC)
|
||||
goto done;
|
||||
|
||||
/* Extract info from MBR partition table */
|
||||
mp = (struct mbr_partition *)(bp->b_data + MBR_PARTOFF);
|
||||
for (i = 0; i < NMBRPART; i++, mp++) {
|
||||
mp = (struct mbr_partition *)(bp->b_data + MBR_PART_OFFSET);
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, mp++) {
|
||||
if (get_long(&mp->mbrp_size) == 0) {
|
||||
continue;
|
||||
}
|
||||
switch (mp->mbrp_typ) {
|
||||
switch (mp->mbrp_type) {
|
||||
case MBR_PTYPE_EXT:
|
||||
if (*pnpart < MAXPARTITIONS) {
|
||||
pp = lp->d_partitions + *pnpart;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ofdev.c,v 1.10 2003/10/08 01:30:40 simonb Exp $ */
|
||||
/* $NetBSD: ofdev.c,v 1.11 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include <sys/param.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
|
@ -221,16 +221,16 @@ search_label(struct of_dev *devp, u_long off, char *buf, struct disklabel *lp,
|
|||
|| read != DEV_BSIZE)
|
||||
return ERDLAB;
|
||||
|
||||
if (*(u_int16_t *)&buf[MBR_MAGICOFF] != sa_htole16(MBR_MAGIC))
|
||||
if (*(u_int16_t *)&buf[MBR_MAGIC_OFFSET] != sa_htole16(MBR_MAGIC))
|
||||
return ERDLAB;
|
||||
|
||||
if (recursion++ <= 1)
|
||||
off0 += off;
|
||||
for (p = (struct mbr_partition *)(buf + MBR_PARTOFF), i = 0;
|
||||
i < NMBRPART; i++, p++) {
|
||||
if (p->mbrp_typ == MBR_PTYPE_NETBSD
|
||||
for (p = (struct mbr_partition *)(buf + MBR_PART_OFFSET), i = 0;
|
||||
i < MBR_PART_COUNT; i++, p++) {
|
||||
if (p->mbrp_type == MBR_PTYPE_NETBSD
|
||||
#ifdef COMPAT_386BSD_MBRPART
|
||||
|| (p->mbrp_typ == MBR_PTYPE_386BSD &&
|
||||
|| (p->mbrp_type == MBR_PTYPE_386BSD &&
|
||||
(printf("WARNING: old BSD partition ID!\n"), 1)
|
||||
/* XXX XXX - libsa printf() is void */ )
|
||||
#endif
|
||||
|
@ -249,7 +249,7 @@ search_label(struct of_dev *devp, u_long off, char *buf, struct disklabel *lp,
|
|||
recursion--;
|
||||
return ERDLAB;
|
||||
}
|
||||
} else if (p->mbrp_typ == MBR_PTYPE_EXT) {
|
||||
} else if (p->mbrp_type == MBR_PTYPE_EXT) {
|
||||
poff = get_long(&p->mbrp_start);
|
||||
if (!search_label(devp, poff, buf, lp, off0)) {
|
||||
recursion--;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.3 2002/05/18 07:13:01 uch Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.4 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
|
@ -39,12 +39,12 @@
|
|||
#define RAW_PART 2
|
||||
|
||||
/* Pull in MBR partition definitions. */
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
#include <sys/dkbad.h>
|
||||
struct cpu_disklabel {
|
||||
struct mbr_partition dosparts[NMBRPART];
|
||||
struct mbr_partition dosparts[MBR_PART_COUNT];
|
||||
struct dkbad bad;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disksubr.c,v 1.8 2003/08/07 16:29:05 agc Exp $ */
|
||||
/* $NetBSD: disksubr.c,v 1.9 2003/10/08 04:25:45 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
|
||||
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.8 2003/08/07 16:29:05 agc Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.9 2003/10/08 04:25:45 lukem Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -57,16 +57,16 @@ mbr_findslice(struct mbr_partition *dp, struct buf *bp)
|
|||
int i;
|
||||
|
||||
/* Note: Magic number is little-endian. */
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGICOFF);
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGIC_OFFSET);
|
||||
if (*mbrmagicp != MBR_MAGIC)
|
||||
return (NO_MBR_SIGNATURE);
|
||||
|
||||
/* XXX how do we check veracity/bounds of this? */
|
||||
memcpy(dp, bp->b_data + MBR_PARTOFF, NMBRPART * sizeof(*dp));
|
||||
memcpy(dp, bp->b_data + MBR_PART_OFFSET, MBR_PART_COUNT * sizeof(*dp));
|
||||
|
||||
/* look for NetBSD partition */
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_NETBSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_NETBSD) {
|
||||
ourdp = &dp[i];
|
||||
break;
|
||||
}
|
||||
|
@ -155,15 +155,15 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
|
|||
if (ourdp == NO_MBR_SIGNATURE)
|
||||
goto nombrpart;
|
||||
|
||||
for (i = 0; i < NMBRPART; i++, dp++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
|
||||
/* Install in partition e, f, g, or h. */
|
||||
pp = &lp->d_partitions[RAW_PART + 1 + i];
|
||||
pp->p_offset = dp->mbrp_start;
|
||||
pp->p_size = dp->mbrp_size;
|
||||
if (dp->mbrp_typ == MBR_PTYPE_LNXEXT2)
|
||||
if (dp->mbrp_type == MBR_PTYPE_LNXEXT2)
|
||||
pp->p_fstype = FS_EX2FS;
|
||||
|
||||
if (dp->mbrp_typ == MBR_PTYPE_LNXSWAP)
|
||||
if (dp->mbrp_type == MBR_PTYPE_LNXSWAP)
|
||||
pp->p_fstype = FS_SWAP;
|
||||
|
||||
/* is this ours? */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.2 2003/05/10 16:12:05 thorpej Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.3 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
|
@ -39,11 +39,11 @@
|
|||
#define RAW_PART 2 /* raw partition: wdNc */
|
||||
|
||||
/* Pull in MBR partition definitions. */
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#include <sys/dkbad.h>
|
||||
struct cpu_disklabel {
|
||||
struct mbr_partition dosparts[NMBRPART];
|
||||
struct mbr_partition dosparts[MBR_PART_COUNT];
|
||||
struct dkbad bad;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disksubr.c,v 1.7 2003/08/07 16:29:17 agc Exp $ */
|
||||
/* $NetBSD: disksubr.c,v 1.8 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.7 2003/08/07 16:29:17 agc Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.8 2003/10/08 04:25:46 lukem Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -69,16 +69,16 @@ mbr_findslice(struct mbr_partition *dp, struct buf *bp)
|
|||
int i;
|
||||
|
||||
/* Note: Magic number is little-endian. */
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGICOFF);
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGIC_OFFSET);
|
||||
if (*mbrmagicp != MBR_MAGIC)
|
||||
return (NO_MBR_SIGNATURE);
|
||||
|
||||
/* XXX how do we check veracity/bounds of this? */
|
||||
memcpy(dp, bp->b_data + MBR_PARTOFF, NMBRPART * sizeof(*dp));
|
||||
memcpy(dp, bp->b_data + MBR_PART_OFFSET, MBR_PART_COUNT * sizeof(*dp));
|
||||
|
||||
/* look for NetBSD partition */
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_NETBSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_NETBSD) {
|
||||
ourdp = &dp[i];
|
||||
break;
|
||||
}
|
||||
|
@ -87,8 +87,8 @@ mbr_findslice(struct mbr_partition *dp, struct buf *bp)
|
|||
#ifdef COMPAT_386BSD_MBRPART
|
||||
/* didn't find it -- look for 386BSD partition */
|
||||
if (!ourdp) {
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_386BSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_386BSD) {
|
||||
printf("WARNING: old BSD partition ID!\n");
|
||||
ourdp = &dp[i];
|
||||
/*
|
||||
|
@ -188,19 +188,19 @@ readdisklabel(dev_t dev,
|
|||
if (ourdp == NO_MBR_SIGNATURE)
|
||||
goto nombrpart;
|
||||
|
||||
for (i = 0; i < NMBRPART; i++, dp++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
|
||||
/* Install in partition e, f, g, or h. */
|
||||
pp = &lp->d_partitions[RAW_PART + 1 + i];
|
||||
pp->p_offset = dp->mbrp_start;
|
||||
pp->p_size = dp->mbrp_size;
|
||||
for (ip = fat_types; *ip != -1; ip++) {
|
||||
if (dp->mbrp_typ == *ip)
|
||||
if (dp->mbrp_type == *ip)
|
||||
pp->p_fstype = FS_MSDOS;
|
||||
}
|
||||
if (dp->mbrp_typ == MBR_PTYPE_LNXEXT2)
|
||||
if (dp->mbrp_type == MBR_PTYPE_LNXEXT2)
|
||||
pp->p_fstype = FS_EX2FS;
|
||||
|
||||
if (dp->mbrp_typ == MBR_PTYPE_NTFS)
|
||||
if (dp->mbrp_type == MBR_PTYPE_NTFS)
|
||||
pp->p_fstype = FS_NTFS;
|
||||
|
||||
/* is this ours? */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.4 2003/05/10 16:12:05 thorpej Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.5 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
|
@ -39,11 +39,11 @@
|
|||
#define RAW_PART 2 /* raw partition: xx?c */
|
||||
|
||||
/* Pull in MBR partition definitions. */
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#include <sys/dkbad.h>
|
||||
struct cpu_disklabel {
|
||||
struct mbr_partition dosparts[NMBRPART];
|
||||
struct mbr_partition dosparts[MBR_PART_COUNT];
|
||||
struct dkbad bad;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disksubr.c,v 1.10 2003/08/07 16:29:21 agc Exp $ */
|
||||
/* $NetBSD: disksubr.c,v 1.11 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.10 2003/08/07 16:29:21 agc Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.11 2003/10/08 04:25:46 lukem Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -70,16 +70,16 @@ mbr_findslice(dp, bp)
|
|||
int i;
|
||||
|
||||
/* Note: Magic number is little-endian. */
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGICOFF);
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGIC_OFFSET);
|
||||
if (*mbrmagicp != le16toh(MBR_MAGIC))
|
||||
return (NO_MBR_SIGNATURE);
|
||||
|
||||
/* XXX how do we check veracity/bounds of this? */
|
||||
memcpy(dp, bp->b_data + MBR_PARTOFF, NMBRPART * sizeof(*dp));
|
||||
memcpy(dp, bp->b_data + MBR_PART_OFFSET, MBR_PART_COUNT * sizeof(*dp));
|
||||
|
||||
/* look for NetBSD partition */
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_NETBSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_NETBSD) {
|
||||
ourdp = &dp[i];
|
||||
break;
|
||||
}
|
||||
|
@ -88,8 +88,8 @@ mbr_findslice(dp, bp)
|
|||
#ifdef COMPAT_386BSD_MBRPART
|
||||
/* didn't find it -- look for 386BSD partition */
|
||||
if (!ourdp) {
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_386BSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_386BSD) {
|
||||
printf("WARNING: old BSD partition ID!\n");
|
||||
ourdp = &dp[i];
|
||||
/*
|
||||
|
@ -190,19 +190,19 @@ readdisklabel(dev, strat, lp, osdep)
|
|||
if (ourdp == NO_MBR_SIGNATURE)
|
||||
goto nombrpart;
|
||||
|
||||
for (i = 0; i < NMBRPART; i++, dp++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
|
||||
/* Install in partition e, f, g, or h. */
|
||||
pp = &lp->d_partitions[RAW_PART + 1 + i];
|
||||
pp->p_offset = le32toh(dp->mbrp_start);
|
||||
pp->p_size = le32toh(dp->mbrp_size);
|
||||
for (ip = fat_types; *ip != -1; ip++) {
|
||||
if (dp->mbrp_typ == *ip)
|
||||
if (dp->mbrp_type == *ip)
|
||||
pp->p_fstype = FS_MSDOS;
|
||||
}
|
||||
if (dp->mbrp_typ == MBR_PTYPE_LNXEXT2)
|
||||
if (dp->mbrp_type == MBR_PTYPE_LNXEXT2)
|
||||
pp->p_fstype = FS_EX2FS;
|
||||
|
||||
if (dp->mbrp_typ == MBR_PTYPE_NTFS)
|
||||
if (dp->mbrp_type == MBR_PTYPE_NTFS)
|
||||
pp->p_fstype = FS_NTFS;
|
||||
|
||||
/* is this ours? */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: installboot.c,v 1.4 2003/10/06 08:44:39 he Exp $ */
|
||||
/* $NetBSD: installboot.c,v 1.5 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 NONAKA Kimihiro (nonaka@netbsd.org).
|
||||
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <sys/param.h>
|
||||
#include <sys/exec_elf.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -188,17 +188,17 @@ load_prep_partition(int devfd, struct mbr_partition *ppp)
|
|||
|
||||
if (devread(devfd, mbr, MBR_BBSECTOR, DEV_BSIZE, "MBR") != 0)
|
||||
return 1;
|
||||
if (*(u_int16_t *)&mbr[MBR_MAGICOFF] != htole16(MBR_MAGIC)) {
|
||||
if (*(u_int16_t *)&mbr[MBR_MAGIC_OFFSET] != htole16(MBR_MAGIC)) {
|
||||
warn("no MBR_MAGIC");
|
||||
return 1;
|
||||
}
|
||||
|
||||
mbrp = (struct mbr_partition *)&mbr[MBR_PARTOFF];
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (mbrp[i].mbrp_typ == MBR_PTYPE_PREP)
|
||||
mbrp = (struct mbr_partition *)&mbr[MBR_PART_OFFSET];
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (mbrp[i].mbrp_type == MBR_PTYPE_PREP)
|
||||
break;
|
||||
}
|
||||
if (i == NMBRPART) {
|
||||
if (i == MBR_PART_COUNT) {
|
||||
warn("no PReP partition.");
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mkbootimage.c,v 1.5 2002/05/04 20:47:48 kleink Exp $ */
|
||||
/* $NetBSD: mkbootimage.c,v 1.6 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1999, 2000 NONAKA Kimihiro (nonaka@netbsd.org)
|
||||
|
@ -42,7 +42,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#include "byteorder.h"
|
||||
#include "magic.h"
|
||||
|
@ -51,8 +51,8 @@
|
|||
#define MBR_PTYPE_PREP 0x41
|
||||
#endif
|
||||
|
||||
#ifndef MBR_FLAGS_ACTIVE
|
||||
#define MBR_FLAGS_ACTIVE 0x80
|
||||
#ifndef MBR_PFLAG_ACTIVE
|
||||
#define MBR_PFLAG_ACTIVE 0x80
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -71,7 +71,7 @@ main(argc, argv)
|
|||
unsigned long length;
|
||||
Elf32_Ehdr hdr;
|
||||
Elf32_Phdr phdr;
|
||||
struct mbr_partition *mbrp = (struct mbr_partition *)&mbr[MBR_PARTOFF];
|
||||
struct mbr_partition *mbrp = (struct mbr_partition *)&mbr[MBR_PART_OFFSET];
|
||||
|
||||
switch (argc) {
|
||||
case 4:
|
||||
|
@ -152,14 +152,14 @@ main(argc, argv)
|
|||
/*
|
||||
* Set magic number for msdos partition
|
||||
*/
|
||||
*(unsigned short *)&mbr[MBR_MAGICOFF] = sa_htole16(MBR_MAGIC);
|
||||
*(unsigned short *)&mbr[MBR_MAGIC_OFFSET] = sa_htole16(MBR_MAGIC);
|
||||
|
||||
/*
|
||||
* Build a "PReP" partition table entry in the boot record
|
||||
* - "PReP" may only look at the system_indicator
|
||||
*/
|
||||
mbrp->mbrp_flag = MBR_FLAGS_ACTIVE;
|
||||
mbrp->mbrp_typ = MBR_PTYPE_PREP;
|
||||
mbrp->mbrp_flag = MBR_PFLAG_ACTIVE;
|
||||
mbrp->mbrp_type = MBR_PTYPE_PREP;
|
||||
|
||||
/*
|
||||
* The first block of the diskette is used by this "boot record" which
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.3 2003/05/10 16:12:05 thorpej Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.4 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
|
@ -39,11 +39,11 @@
|
|||
#define RAW_PART 2 /* raw partition: wdNc */
|
||||
|
||||
/* Pull in MBR partition definitions. */
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#include <sys/dkbad.h>
|
||||
struct cpu_disklabel {
|
||||
struct mbr_partition dosparts[NMBRPART];
|
||||
struct mbr_partition dosparts[MBR_PART_COUNT];
|
||||
struct dkbad bad;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disksubr.c,v 1.8 2003/08/07 16:29:23 agc Exp $ */
|
||||
/* $NetBSD: disksubr.c,v 1.9 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.8 2003/08/07 16:29:23 agc Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.9 2003/10/08 04:25:46 lukem Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -71,16 +71,16 @@ mbr_findslice(dp, bp)
|
|||
int i;
|
||||
|
||||
/* Note: Magic number is little-endian. */
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGICOFF);
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGIC_OFFSET);
|
||||
if (*mbrmagicp != MBR_MAGIC)
|
||||
return (NO_MBR_SIGNATURE);
|
||||
|
||||
/* XXX how do we check veracity/bounds of this? */
|
||||
memcpy(dp, bp->b_data + MBR_PARTOFF, NMBRPART * sizeof(*dp));
|
||||
memcpy(dp, bp->b_data + MBR_PART_OFFSET, MBR_PART_COUNT * sizeof(*dp));
|
||||
|
||||
/* look for NetBSD partition */
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_NETBSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_NETBSD) {
|
||||
ourdp = &dp[i];
|
||||
break;
|
||||
}
|
||||
|
@ -89,8 +89,8 @@ mbr_findslice(dp, bp)
|
|||
#ifdef COMPAT_386BSD_MBRPART
|
||||
/* didn't find it -- look for 386BSD partition */
|
||||
if (!ourdp) {
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_386BSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_386BSD) {
|
||||
printf("WARNING: old BSD partition ID!\n");
|
||||
ourdp = &dp[i];
|
||||
/*
|
||||
|
@ -191,19 +191,19 @@ readdisklabel(dev, strat, lp, osdep)
|
|||
if (ourdp == NO_MBR_SIGNATURE)
|
||||
goto nombrpart;
|
||||
|
||||
for (i = 0; i < NMBRPART; i++, dp++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
|
||||
/* Install in partition e, f, g, or h. */
|
||||
pp = &lp->d_partitions[RAW_PART + 1 + i];
|
||||
pp->p_offset = dp->mbrp_start;
|
||||
pp->p_size = dp->mbrp_size;
|
||||
for (ip = fat_types; *ip != -1; ip++) {
|
||||
if (dp->mbrp_typ == *ip)
|
||||
if (dp->mbrp_type == *ip)
|
||||
pp->p_fstype = FS_MSDOS;
|
||||
}
|
||||
if (dp->mbrp_typ == MBR_PTYPE_LNXEXT2)
|
||||
if (dp->mbrp_type == MBR_PTYPE_LNXEXT2)
|
||||
pp->p_fstype = FS_EX2FS;
|
||||
|
||||
if (dp->mbrp_typ == MBR_PTYPE_NTFS)
|
||||
if (dp->mbrp_type == MBR_PTYPE_NTFS)
|
||||
pp->p_fstype = FS_NTFS;
|
||||
|
||||
/* is this ours? */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.2 2003/02/07 17:46:12 cgd Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.3 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 2000, 2001
|
||||
|
@ -74,12 +74,12 @@
|
|||
|
||||
#ifdef __NetBSD__
|
||||
/* Pull in MBR partition definitions. */
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
#include <sys/dkbad.h>
|
||||
struct cpu_disklabel {
|
||||
struct mbr_partition dosparts[NMBRPART];
|
||||
struct mbr_partition dosparts[MBR_PART_COUNT];
|
||||
struct dkbad bad;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disksubr.c,v 1.8 2003/08/07 16:29:24 agc Exp $ */
|
||||
/* $NetBSD: disksubr.c,v 1.9 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
|
||||
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.8 2003/08/07 16:29:24 agc Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.9 2003/10/08 04:25:46 lukem Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -60,16 +60,16 @@ mbr_findslice(dp, bp)
|
|||
int i;
|
||||
|
||||
/* Note: Magic number is little-endian. */
|
||||
mbrmagicp = (uint16_t *)(bp->b_data + MBR_MAGICOFF);
|
||||
mbrmagicp = (uint16_t *)(bp->b_data + MBR_MAGIC_OFFSET);
|
||||
if (*mbrmagicp != MBR_MAGIC)
|
||||
return (NO_MBR_SIGNATURE);
|
||||
|
||||
/* XXX how do we check veracity/bounds of this? */
|
||||
memcpy(dp, bp->b_data + MBR_PARTOFF, NMBRPART * sizeof(*dp));
|
||||
memcpy(dp, bp->b_data + MBR_PART_OFFSET, MBR_PART_COUNT * sizeof(*dp));
|
||||
|
||||
/* look for NetBSD partition */
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_NETBSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_NETBSD) {
|
||||
ourdp = &dp[i];
|
||||
break;
|
||||
}
|
||||
|
@ -161,15 +161,15 @@ readdisklabel(dev, strat, lp, osdep)
|
|||
if (ourdp == NO_MBR_SIGNATURE)
|
||||
goto nombrpart;
|
||||
|
||||
for (i = 0; i < NMBRPART; i++, dp++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
|
||||
/* Install in partition e, f, g, or h. */
|
||||
pp = &lp->d_partitions[RAW_PART + 1 + i];
|
||||
pp->p_offset = dp->mbrp_start;
|
||||
pp->p_size = dp->mbrp_size;
|
||||
if (dp->mbrp_typ == MBR_PTYPE_LNXEXT2)
|
||||
if (dp->mbrp_type == MBR_PTYPE_LNXEXT2)
|
||||
pp->p_fstype = FS_EX2FS;
|
||||
|
||||
if (dp->mbrp_typ == MBR_PTYPE_LNXSWAP)
|
||||
if (dp->mbrp_type == MBR_PTYPE_LNXSWAP)
|
||||
pp->p_fstype = FS_SWAP;
|
||||
|
||||
/* is this ours? */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.4 2002/05/22 15:01:33 uch Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.5 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
|
@ -39,12 +39,12 @@
|
|||
#define RAW_PART 2
|
||||
|
||||
/* Pull in MBR partition definitions. */
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
#include <sys/dkbad.h>
|
||||
struct cpu_disklabel {
|
||||
struct mbr_partition dosparts[NMBRPART];
|
||||
struct mbr_partition dosparts[MBR_PART_COUNT];
|
||||
struct dkbad bad;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disksubr.c,v 1.15 2003/08/07 16:29:29 agc Exp $ */
|
||||
/* $NetBSD: disksubr.c,v 1.16 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.15 2003/08/07 16:29:29 agc Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.16 2003/10/08 04:25:46 lukem Exp $");
|
||||
|
||||
#include "opt_mbr.h"
|
||||
|
||||
|
@ -252,16 +252,16 @@ mbr_findslice(struct mbr_partition *dp, struct buf *bp)
|
|||
int i;
|
||||
|
||||
/* Note: Magic number is little-endian. */
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGICOFF);
|
||||
mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGIC_OFFSET);
|
||||
if (le16toh(*mbrmagicp) != MBR_MAGIC)
|
||||
return (NO_MBR_SIGNATURE);
|
||||
|
||||
/* XXX how do we check veracity/bounds of this? */
|
||||
memcpy(dp, bp->b_data + MBR_PARTOFF, NMBRPART * sizeof(*dp));
|
||||
memcpy(dp, bp->b_data + MBR_PART_OFFSET, MBR_PART_COUNT * sizeof(*dp));
|
||||
|
||||
/* look for NetBSD partition */
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (dp[i].mbrp_typ == MBR_PTYPE_NETBSD) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||
if (dp[i].mbrp_type == MBR_PTYPE_NETBSD) {
|
||||
ourdp = &dp[i];
|
||||
break;
|
||||
}
|
||||
|
@ -350,19 +350,19 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
|
|||
if (ourdp == NO_MBR_SIGNATURE)
|
||||
goto nombrpart;
|
||||
|
||||
for (i = 0; i < NMBRPART; i++, dp++) {
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
|
||||
/* Install in partition e, f, g, or h. */
|
||||
pp = &lp->d_partitions[RAW_PART + 1 + i];
|
||||
pp->p_offset = le32toh(dp->mbrp_start);
|
||||
pp->p_size = le32toh(dp->mbrp_size);
|
||||
for (ip = fat_types; *ip != -1; ip++) {
|
||||
if (dp->mbrp_typ == *ip)
|
||||
if (dp->mbrp_type == *ip)
|
||||
pp->p_fstype = FS_MSDOS;
|
||||
}
|
||||
if (dp->mbrp_typ == MBR_PTYPE_LNXEXT2)
|
||||
if (dp->mbrp_type == MBR_PTYPE_LNXEXT2)
|
||||
pp->p_fstype = FS_EX2FS;
|
||||
|
||||
if (dp->mbrp_typ == MBR_PTYPE_NTFS)
|
||||
if (dp->mbrp_type == MBR_PTYPE_NTFS)
|
||||
pp->p_fstype = FS_NTFS;
|
||||
|
||||
/* is this ours? */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.h,v 1.1 2002/07/05 13:31:57 scw Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.2 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
|
@ -44,12 +44,12 @@
|
|||
#define RAW_PART 2
|
||||
|
||||
/* Pull in MBR partition definitions. */
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
#include <sys/dkbad.h>
|
||||
struct cpu_disklabel {
|
||||
struct mbr_partition dosparts[NMBRPART];
|
||||
struct mbr_partition dosparts[MBR_PART_COUNT];
|
||||
struct dkbad bad;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ofdev.c,v 1.2 2002/06/18 00:37:26 itojun Exp $ */
|
||||
/* $NetBSD: ofdev.c,v 1.3 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
|
@ -36,7 +36,7 @@
|
|||
|
||||
#include <sys/param.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
|
@ -209,16 +209,16 @@ search_label(devp, off, buf, lp, off0)
|
|||
|| read != DEV_BSIZE)
|
||||
return ERDLAB;
|
||||
|
||||
if (*(u_int16_t *)&buf[MBR_MAGICOFF] != sa_htole16(MBR_MAGIC))
|
||||
if (*(u_int16_t *)&buf[MBR_MAGIC_OFFSET] != sa_htole16(MBR_MAGIC))
|
||||
return ERDLAB;
|
||||
|
||||
if (recursion++ <= 1)
|
||||
off0 += off;
|
||||
for (p = (struct mbr_partition *)(buf + MBR_PARTOFF), i = 4;
|
||||
for (p = (struct mbr_partition *)(buf + MBR_PART_OFFSET), i = 4;
|
||||
--i >= 0; p++) {
|
||||
if (p->mbrp_typ == MBR_PTYPE_NETBSD
|
||||
if (p->mbrp_type == MBR_PTYPE_NETBSD
|
||||
#ifdef COMPAT_386BSD_MBRPART
|
||||
|| (p->mbrp_typ == MBR_PTYPE_386BSD &&
|
||||
|| (p->mbrp_type == MBR_PTYPE_386BSD &&
|
||||
(printf("WARNING: old BSD partition ID!\n"), 1)
|
||||
/* XXX XXX - libsa printf() is void */ )
|
||||
#endif
|
||||
|
@ -237,7 +237,7 @@ search_label(devp, off, buf, lp, off0)
|
|||
recursion--;
|
||||
return ERDLAB;
|
||||
}
|
||||
} else if (p->mbrp_typ == MBR_PTYPE_EXT) {
|
||||
} else if (p->mbrp_type == MBR_PTYPE_EXT) {
|
||||
poff = get_long(&p->mbrp_start);
|
||||
if (!search_label(devp, poff, buf, lp, off0)) {
|
||||
recursion--;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bootinfo.h,v 1.2 2003/04/16 19:16:42 dsl Exp $ */
|
||||
/* $NetBSD: bootinfo.h,v 1.3 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997
|
||||
|
@ -106,7 +106,7 @@ struct btinfo_memmap {
|
|||
struct bi_memmap_entry entry[1]; /* var len */
|
||||
};
|
||||
|
||||
#include <sys/disklabel_mbr.h>
|
||||
#include <sys/bootblock.h>
|
||||
|
||||
/*
|
||||
* Structure describing disk info as seen by the BIOS.
|
||||
|
@ -139,7 +139,7 @@ struct bi_biosgeom_entry {
|
|||
unsigned int cksum; /* MBR checksum */
|
||||
int res0, res1, res2, res3; /* future expansion; 0 now */
|
||||
#endif
|
||||
struct mbr_partition dosparts[NMBRPART]; /* MBR itself */
|
||||
struct mbr_partition dosparts[MBR_PART_COUNT]; /* MBR itself */
|
||||
} __attribute__((packed));
|
||||
|
||||
struct btinfo_biosgeom {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: subr_disk_mbr.c,v 1.3 2003/08/19 11:49:24 dsl Exp $ */
|
||||
/* $NetBSD: subr_disk_mbr.c,v 1.4 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
|
||||
|
@ -54,7 +54,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_disk_mbr.c,v 1.3 2003/08/19 11:49:24 dsl Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_disk_mbr.c,v 1.4 2003/10/08 04:25:46 lukem Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -85,8 +85,8 @@ typedef struct mbr_args {
|
|||
#define UPDATE_LABEL 2
|
||||
#define WRITE_LABEL 3
|
||||
static int validate_label(mbr_args_t *, uint, int);
|
||||
static int look_netbsd_part(mbr_args_t *, mbr_partition_t *, int, uint);
|
||||
static int write_netbsd_label(mbr_args_t *, mbr_partition_t *, int, uint);
|
||||
static int look_netbsd_part(mbr_args_t *, struct mbr_partition *, int, uint);
|
||||
static int write_netbsd_label(mbr_args_t *, struct mbr_partition *, int, uint);
|
||||
|
||||
static int
|
||||
read_sector(mbr_args_t *a, uint sector)
|
||||
|
@ -110,11 +110,11 @@ read_sector(mbr_args_t *a, uint sector)
|
|||
*/
|
||||
|
||||
static int
|
||||
scan_mbr(mbr_args_t *a, int (*actn)(mbr_args_t *, mbr_partition_t *, int, uint))
|
||||
scan_mbr(mbr_args_t *a, int (*actn)(mbr_args_t *, struct mbr_partition *, int, uint))
|
||||
{
|
||||
mbr_partition_t ptns[NMBRPART];
|
||||
mbr_partition_t *dp;
|
||||
mbr_sector_t *mbr;
|
||||
struct mbr_partition ptns[MBR_PART_COUNT];
|
||||
struct mbr_partition *dp;
|
||||
struct mbr_sector *mbr;
|
||||
uint ext_base, this_ext, next_ext;
|
||||
int rval;
|
||||
int i;
|
||||
|
@ -132,7 +132,7 @@ scan_mbr(mbr_args_t *a, int (*actn)(mbr_args_t *, mbr_partition_t *, int, uint))
|
|||
|
||||
/* Note: Magic number is little-endian. */
|
||||
mbr = (void *)a->bp->b_data;
|
||||
if (mbr->mbr_signature != htole16(MBR_MAGIC))
|
||||
if (mbr->mbr_magic != htole16(MBR_MAGIC))
|
||||
return SCAN_CONTINUE;
|
||||
|
||||
/* Copy data out of buffer so action can use bp */
|
||||
|
@ -141,15 +141,15 @@ scan_mbr(mbr_args_t *a, int (*actn)(mbr_args_t *, mbr_partition_t *, int, uint))
|
|||
/* look for NetBSD partition */
|
||||
next_ext = 0;
|
||||
dp = ptns;
|
||||
for (i = 0; i < NMBRPART; i++, dp++) {
|
||||
if (dp->mbrp_typ == 0)
|
||||
for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
|
||||
if (dp->mbrp_type == 0)
|
||||
continue;
|
||||
if (MBR_IS_EXTENDED(dp->mbrp_typ)) {
|
||||
if (MBR_IS_EXTENDED(dp->mbrp_type)) {
|
||||
next_ext = le32toh(dp->mbrp_start);
|
||||
continue;
|
||||
}
|
||||
#ifdef COMPAT_386BSD_MBRPART
|
||||
if (dp->mbrp_typ == MBR_PTYPE_386BSD) {
|
||||
if (dp->mbrp_type == MBR_PTYPE_386BSD) {
|
||||
/*
|
||||
* If more than one matches, take last,
|
||||
* as NetBSD install tool does.
|
||||
|
@ -303,7 +303,7 @@ readdisklabel(dev, strat, lp, osdep)
|
|||
}
|
||||
|
||||
static int
|
||||
look_netbsd_part(mbr_args_t *a, mbr_partition_t *dp, int slot, uint ext_base)
|
||||
look_netbsd_part(mbr_args_t *a, struct mbr_partition *dp, int slot, uint ext_base)
|
||||
{
|
||||
struct partition *pp;
|
||||
int ptn_base = ext_base + le32toh(dp->mbrp_start);
|
||||
|
@ -311,9 +311,9 @@ look_netbsd_part(mbr_args_t *a, mbr_partition_t *dp, int slot, uint ext_base)
|
|||
|
||||
if (
|
||||
#ifdef COMPAT_386BSD_MBRPART
|
||||
dp->mbrp_typ == MBR_PTYPE_386BSD ||
|
||||
dp->mbrp_type == MBR_PTYPE_386BSD ||
|
||||
#endif
|
||||
dp->mbrp_typ == MBR_PTYPE_NETBSD) {
|
||||
dp->mbrp_type == MBR_PTYPE_NETBSD) {
|
||||
rval = validate_label(a, ptn_base + MBR_LABELSECTOR, READ_LABEL);
|
||||
|
||||
/* Put actual location where we found the label into ptn 2 */
|
||||
|
@ -332,7 +332,7 @@ look_netbsd_part(mbr_args_t *a, mbr_partition_t *dp, int slot, uint ext_base)
|
|||
if (ext_base == 0)
|
||||
slot += 4;
|
||||
else {
|
||||
slot = 4 + NMBRPART;
|
||||
slot = 4 + MBR_PART_COUNT;
|
||||
pp = &a->lp->d_partitions[slot];
|
||||
for (; slot < MAXPARTITIONS; pp++, slot++) {
|
||||
/* This gets called twice - avoid duplicates */
|
||||
|
@ -353,7 +353,7 @@ look_netbsd_part(mbr_args_t *a, mbr_partition_t *dp, int slot, uint ext_base)
|
|||
pp = &a->lp->d_partitions[slot];
|
||||
pp->p_offset = ptn_base;
|
||||
pp->p_size = le32toh(dp->mbrp_size);
|
||||
pp->p_fstype = xlat_mbr_fstype(dp->mbrp_typ);
|
||||
pp->p_fstype = xlat_mbr_fstype(dp->mbrp_type);
|
||||
|
||||
if (slot >= a->lp->d_npartitions)
|
||||
a->lp->d_npartitions = slot + 1;
|
||||
|
@ -520,11 +520,11 @@ writedisklabel(dev, strat, lp, osdep)
|
|||
}
|
||||
|
||||
static int
|
||||
write_netbsd_label(mbr_args_t *a, mbr_partition_t *dp, int slot, uint ext_base)
|
||||
write_netbsd_label(mbr_args_t *a, struct mbr_partition *dp, int slot, uint ext_base)
|
||||
{
|
||||
int ptn_base = ext_base + le32toh(dp->mbrp_start);
|
||||
|
||||
if (dp->mbrp_typ != MBR_PTYPE_NETBSD)
|
||||
if (dp->mbrp_type != MBR_PTYPE_NETBSD)
|
||||
return SCAN_CONTINUE;
|
||||
|
||||
return validate_label(a, ptn_base + MBR_LABELSECTOR, WRITE_LABEL);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.59 2003/10/01 01:37:13 christos Exp $
|
||||
# $NetBSD: Makefile,v 1.60 2003/10/08 04:25:46 lukem Exp $
|
||||
|
||||
INCSDIR= /usr/include/sys
|
||||
|
||||
|
@ -7,7 +7,7 @@ INCS= acct.h agpio.h ansi.h ataio.h audioio.h \
|
|||
callout.h cdefs.h cdefs_aout.h \
|
||||
cdefs_elf.h cdio.h chio.h clockctl.h conf.h core.h \
|
||||
device.h dir.h dirent.h disk.h disklabel.h disklabel_acorn.h \
|
||||
disklabel_mbr.h dkbad.h dkio.h dkstat.h domain.h dvdio.h \
|
||||
dkbad.h dkio.h dkstat.h domain.h dvdio.h \
|
||||
endian.h envsys.h errno.h event.h exec.h exec_aout.h \
|
||||
exec_coff.h exec_ecoff.h exec_elf.h exec_script.h extent.h \
|
||||
fcntl.h fdio.h featuretest.h file.h filedesc.h filio.h \
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: bootblock.h,v 1.15 2003/10/06 05:24:54 lukem Exp $ */
|
||||
/* $NetBSD: bootblock.h,v 1.16 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2002,2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -99,17 +99,214 @@
|
|||
#ifndef _SYS_BOOTBLOCK_H
|
||||
#define _SYS_BOOTBLOCK_H
|
||||
|
||||
#if !defined(__ASSEMBLER__)
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
#include <sys/stdint.h>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#endif /* !defined(__ASSEMBLER__) */
|
||||
|
||||
/* ------------------------------------------
|
||||
* MBR (Master Boot Record) --
|
||||
* definitions for systems that use MBRs
|
||||
*/
|
||||
|
||||
/*
|
||||
* MBR (Master Boot Record)
|
||||
*/
|
||||
#define MBR_BBSECTOR 0 /* MBR relative sector # */
|
||||
#define MBR_BPB_OFFSET 11 /* offsetof(mbr_sector, mbr_bpb) */
|
||||
#define MBR_BOOTCODE_OFFSET 90 /* offsetof(mbr_sector, mbr_bootcode) */
|
||||
#define MBR_BOOTSEL_OFFSET 404 /* offsetof(mbr_sector, mbr_bootsel) */
|
||||
#define MBR_PART_OFFSET 446 /* offsetof(mbr_sector, mbr_part[0]) */
|
||||
#define MBR_MAGIC_OFFSET 510 /* offsetof(mbr_sector, mbr_magic) */
|
||||
#define MBR_MAGIC 0xaa55 /* MBR magic number */
|
||||
#define MBR_PART_COUNT 4 /* Number of partitions in MBR */
|
||||
#define MBR_BS_PARTNAMESIZE 8 /* Size of name mbr_bootsel nametab */
|
||||
/* (excluding trailing NUL) */
|
||||
|
||||
/* values for mbr_partition.mbrp_flag */
|
||||
#define MBR_PFLAG_ACTIVE 0x80 /* The active partition */
|
||||
|
||||
/* values for mbr_partition.mbrp_type */
|
||||
#define MBR_PTYPE_FAT12 0x01 /* 12-bit FAT */
|
||||
#define MBR_PTYPE_FAT16S 0x04 /* 16-bit FAT, less than 32M */
|
||||
#define MBR_PTYPE_EXT 0x05 /* extended partition */
|
||||
#define MBR_PTYPE_FAT16B 0x06 /* 16-bit FAT, more than 32M */
|
||||
#define MBR_PTYPE_NTFS 0x07 /* OS/2 HPFS, NTFS, QNX2, Adv. UNIX */
|
||||
#define MBR_PTYPE_FAT32 0x0b /* 32-bit FAT */
|
||||
#define MBR_PTYPE_FAT32L 0x0c /* 32-bit FAT, LBA-mapped */
|
||||
#define MBR_PTYPE_FAT16L 0x0e /* 16-bit FAT, LBA-mapped */
|
||||
#define MBR_PTYPE_EXT_LBA 0x0f /* extended partition, LBA-mapped */
|
||||
#define MBR_PTYPE_ONTRACK 0x54
|
||||
#define MBR_PTYPE_LNXSWAP 0x82 /* Linux swap or Solaris */
|
||||
#define MBR_PTYPE_LNXEXT2 0x83 /* Linux native */
|
||||
#define MBR_PTYPE_EXT_LNX 0x85 /* Linux extended partition */
|
||||
#define MBR_PTYPE_NTFSVOL 0x87 /* NTFS volume set or HPFS mirrored */
|
||||
#define MBR_PTYPE_PREP 0x41 /* PReP */
|
||||
#define MBR_PTYPE_386BSD 0xa5 /* 386BSD partition type */
|
||||
#define MBR_PTYPE_APPLEUFS 0xa8 /* Apple UFS */
|
||||
#define MBR_PTYPE_NETBSD 0xa9 /* NetBSD partition type */
|
||||
#define MBR_PTYPE_OPENBSD 0xa6 /* OpenBSD partition type */
|
||||
|
||||
#define MBR_PSECT(s) ((s) & 0x3f)
|
||||
#define MBR_PCYL(c, s) ((c) + (((s) & 0xc0) << 2))
|
||||
|
||||
#define MBR_IS_EXTENDED(x) ((x) == MBR_PTYPE_EXT || \
|
||||
(x) == MBR_PTYPE_EXT_LBA || \
|
||||
(x) == MBR_PTYPE_EXT_LNX)
|
||||
|
||||
/* values for mbr_bootsel.mbrbs_flags */
|
||||
#define MBR_BS_ACTIVE 0x01 /* Bootselector active (or code present) */
|
||||
#define MBR_BS_EXTINT13 0x02 /* Set by fdisk if LBA needed (deprecated) */
|
||||
#define MBR_BS_READ_LBA 0x04 /* Force LBA reads - even for low numbers */
|
||||
#define MBR_BS_EXTLBA 0x08 /* Extended ptn capable (LBA reads) */
|
||||
#define MBR_BS_NEWMBR 0x80 /* New code: menu user 1..9 for ptns */
|
||||
|
||||
#if !defined(__ASSEMBLER__) /* { */
|
||||
|
||||
/*
|
||||
* (x86) BIOS Parameter Block for FAT12
|
||||
*/
|
||||
struct mbr_bpbFAT12 {
|
||||
uint16_t bpbBytesPerSec; /* bytes per sector */
|
||||
uint8_t bpbSecPerClust; /* sectors per cluster */
|
||||
uint16_t bpbResSectors; /* number of reserved sectors */
|
||||
uint8_t bpbFATs; /* number of FATs */
|
||||
uint16_t bpbRootDirEnts; /* number of root directory entries */
|
||||
uint16_t bpbSectors; /* total number of sectors */
|
||||
uint8_t bpbMedia; /* media descriptor */
|
||||
uint16_t bpbFATsecs; /* number of sectors per FAT */
|
||||
uint16_t bpbSecPerTrack; /* sectors per track */
|
||||
uint16_t bpbHeads; /* number of heads */
|
||||
uint16_t bpbHiddenSecs; /* # of hidden sectors */
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/*
|
||||
* (x86) BIOS Parameter Block for FAT16
|
||||
*/
|
||||
struct mbr_bpbFAT16 {
|
||||
uint16_t bpbBytesPerSec; /* bytes per sector */
|
||||
uint8_t bpbSecPerClust; /* sectors per cluster */
|
||||
uint16_t bpbResSectors; /* number of reserved sectors */
|
||||
uint8_t bpbFATs; /* number of FATs */
|
||||
uint16_t bpbRootDirEnts; /* number of root directory entries */
|
||||
uint16_t bpbSectors; /* total number of sectors */
|
||||
uint8_t bpbMedia; /* media descriptor */
|
||||
uint16_t bpbFATsecs; /* number of sectors per FAT */
|
||||
uint16_t bpbSecPerTrack; /* sectors per track */
|
||||
uint16_t bpbHeads; /* number of heads */
|
||||
uint32_t bpbHiddenSecs; /* # of hidden sectors */
|
||||
uint32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */
|
||||
uint8_t bsDrvNum; /* Int 0x13 drive number (e.g. 0x80) */
|
||||
uint8_t bsReserved1; /* Reserved; set to 0 */
|
||||
uint8_t bsBootSig; /* 0x29 if next 3 fields are present */
|
||||
uint8_t bsVolID[4]; /* Volume serial number */
|
||||
uint8_t bsVolLab[11]; /* Volume label */
|
||||
uint8_t bsFileSysType[8];
|
||||
/* "FAT12 ", "FAT16 ", "FAT " */
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/*
|
||||
* (x86) BIOS Parameter Block for FAT32
|
||||
*/
|
||||
struct mbr_bpbFAT32 {
|
||||
uint16_t bpbBytesPerSec; /* bytes per sector */
|
||||
uint8_t bpbSecPerClust; /* sectors per cluster */
|
||||
uint16_t bpbResSectors; /* number of reserved sectors */
|
||||
uint8_t bpbFATs; /* number of FATs */
|
||||
uint16_t bpbRootDirEnts; /* number of root directory entries */
|
||||
uint16_t bpbSectors; /* total number of sectors */
|
||||
uint8_t bpbMedia; /* media descriptor */
|
||||
uint16_t bpbFATsecs; /* number of sectors per FAT */
|
||||
uint16_t bpbSecPerTrack; /* sectors per track */
|
||||
uint16_t bpbHeads; /* number of heads */
|
||||
uint32_t bpbHiddenSecs; /* # of hidden sectors */
|
||||
uint32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */
|
||||
uint32_t bpbBigFATsecs; /* like bpbFATsecs for FAT32 */
|
||||
uint16_t bpbExtFlags; /* extended flags: */
|
||||
#define MBR_FAT32_FATNUM 0x0F /* mask for numbering active FAT */
|
||||
#define MBR_FAT32_FATMIRROR 0x80 /* FAT is mirrored (as previously) */
|
||||
uint16_t bpbFSVers; /* filesystem version */
|
||||
#define MBR_FAT32_FSVERS 0 /* currently only 0 is understood */
|
||||
uint32_t bpbRootClust; /* start cluster for root directory */
|
||||
uint16_t bpbFSInfo; /* filesystem info structure sector */
|
||||
uint16_t bpbBackup; /* backup boot sector */
|
||||
uint8_t bsReserved[12]; /* Reserved for future expansion */
|
||||
uint8_t bsDrvNum; /* Int 0x13 drive number (e.g. 0x80) */
|
||||
uint8_t bsReserved1; /* Reserved; set to 0 */
|
||||
uint8_t bsBootSig; /* 0x29 if next 3 fields are present */
|
||||
uint8_t bsVolID[4]; /* Volume serial number */
|
||||
uint8_t bsVolLab[11]; /* Volume label */
|
||||
uint8_t bsFileSysType[8]; /* "FAT32 " */
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/*
|
||||
* (x86) MBR boot selector
|
||||
*/
|
||||
struct mbr_bootsel {
|
||||
uint8_t mbrbs_defkey;
|
||||
uint8_t mbrbs_flags;
|
||||
uint16_t mbrbs_timeo;
|
||||
uint8_t mbrbs_nametab[MBR_PART_COUNT][MBR_BS_PARTNAMESIZE + 1];
|
||||
uint16_t mbrbs_magic;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/*
|
||||
* MBR partition
|
||||
*/
|
||||
struct mbr_partition {
|
||||
uint8_t mbrp_flag; /* MBR partition flags */
|
||||
uint8_t mbrp_shd; /* Starting head */
|
||||
uint8_t mbrp_ssect; /* Starting sector */
|
||||
uint8_t mbrp_scyl; /* Starting cylinder */
|
||||
uint8_t mbrp_type; /* Partition type (see below) */
|
||||
uint8_t mbrp_ehd; /* End head */
|
||||
uint8_t mbrp_esect; /* End sector */
|
||||
uint8_t mbrp_ecyl; /* End cylinder */
|
||||
uint32_t mbrp_start; /* Absolute starting sector number */
|
||||
uint32_t mbrp_size; /* Partition size in sectors */
|
||||
} __attribute__((__packed__));
|
||||
|
||||
int xlat_mbr_fstype(int); /* in sys/lib/libkern/xlat_mbr_fstype.c */
|
||||
|
||||
/*
|
||||
* MBR boot sector.
|
||||
* This is used by both the MBR (Master Boot Record) in sector 0 of the disk
|
||||
* and the PBR (Partition Boot Record) in sector 0 of an MBR partition.
|
||||
*/
|
||||
struct mbr_sector {
|
||||
/* Jump instruction to boot code. */
|
||||
/* Usually 0xE9nnnn or 0xEBnn90 */
|
||||
uint8_t mbr_jmpboot[3];
|
||||
/* OEM name and version */
|
||||
uint8_t mbr_oemname[8];
|
||||
union { /* BIOS Parameter Block */
|
||||
struct mbr_bpbFAT12 bpb12;
|
||||
struct mbr_bpbFAT16 bpb16;
|
||||
struct mbr_bpbFAT32 bpb32;
|
||||
} mbr_bpb;
|
||||
/* Boot code */
|
||||
uint8_t mbr_bootcode[314];
|
||||
/* Config for /usr/mdec/mbr_bootsel */
|
||||
struct mbr_bootsel mbr_bootsel;
|
||||
/* MBR partition table */
|
||||
struct mbr_partition mbr_parts[MBR_PART_COUNT];
|
||||
/* MBR magic (0xaa55) */
|
||||
uint16_t mbr_magic;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
#endif /* !defined(__ASSEMBLER__) */ /* } */
|
||||
|
||||
|
||||
/* ------------------------------------------
|
||||
* shared --
|
||||
* definintions shared by many platforms
|
||||
* definitions shared by many platforms
|
||||
*/
|
||||
|
||||
#if !defined(__ASSEMBLER__) /* { */
|
||||
|
||||
/* Maximum # of blocks in bbi_block_table, each bbi_block_size long */
|
||||
#define SHARED_BBINFO_MAXBLOCKS 118 /* so sizeof(shared_bbinfo) == 512 */
|
||||
|
||||
|
@ -120,7 +317,6 @@ struct shared_bbinfo {
|
|||
int32_t bbi_block_table[SHARED_BBINFO_MAXBLOCKS];
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------
|
||||
* alpha --
|
||||
* Alpha (disk, but also tape) Boot Block.
|
||||
|
@ -191,7 +387,7 @@ struct apple_drvr_map {
|
|||
uint16_t sbDrvrCount; /* number of driver descriptors */
|
||||
struct apple_drvr_descriptor sb_dd[APPLE_DRVR_MAP_MAX_DESCRIPTORS];
|
||||
uint16_t pad[3];
|
||||
} __attribute__ ((packed));
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/*
|
||||
* Partition map structure from Inside Macintosh: Devices, SCSI Manager
|
||||
|
@ -268,37 +464,41 @@ struct apple_blockzeroblock {
|
|||
#define APPLE_BZB_USRFS 0x4000
|
||||
|
||||
/* ------------------------------------------
|
||||
* i386
|
||||
* x86
|
||||
*
|
||||
*/
|
||||
|
||||
#define X86_BOOT_MAGIC_1 ('x' << 24 | 0x86b << 12 | 'm' << 4 | 1)
|
||||
#define X86_BOOT_MAGIC_2 ('x' << 24 | 0x86b << 12 | 'm' << 4 | 2)
|
||||
|
||||
/*
|
||||
* Parameters for NetBSD /boot written to start of pbr code by installboot
|
||||
*/
|
||||
|
||||
struct i386_boot_params {
|
||||
#define X86_BOOT_MAGIC_1 ('x' << 24 | 0x86b << 12 | 'm' << 4 | 1)
|
||||
#define X86_BOOT_MAGIC_2 ('x' << 24 | 0x86b << 12 | 'm' << 4 | 2)
|
||||
|
||||
struct x86_boot_params {
|
||||
uint32_t bp_length; /* length of patchable data */
|
||||
uint32_t bp_flags;
|
||||
#define I386_BP_FLAGS_RESET_VIDEO 1
|
||||
#define I386_BP_FLAGS_PASSWORD 2
|
||||
uint32_t bp_timeout; /* boot timeout in seconds */
|
||||
uint32_t bp_consdev;
|
||||
#define CONSDEV_PC 0
|
||||
#define CONSDEV_COM0 1
|
||||
#define CONSDEV_COM1 2
|
||||
#define CONSDEV_COM2 3
|
||||
#define CONSDEV_COM3 4
|
||||
#define CONSDEV_COM0KBD 5
|
||||
#define CONSDEV_COM1KBD 6
|
||||
#define CONSDEV_COM2KBD 7
|
||||
#define CONSDEV_COM3KBD 8
|
||||
uint32_t bp_conspeed;
|
||||
char bp_password[16]; /* md5 hash of password */
|
||||
};
|
||||
|
||||
/* values for bp_flags */
|
||||
#define X86_BP_FLAGS_RESET_VIDEO 1
|
||||
#define X86_BP_FLAGS_PASSWORD 2
|
||||
|
||||
/* values for bp_consdev */
|
||||
#define X86_BP_CONSDEV_PC 0
|
||||
#define X86_BP_CONSDEV_COM0 1
|
||||
#define X86_BP_CONSDEV_COM1 2
|
||||
#define X86_BP_CONSDEV_COM2 3
|
||||
#define X86_BP_CONSDEV_COM3 4
|
||||
#define X86_BP_CONSDEV_COM0KBD 5
|
||||
#define X86_BP_CONSDEV_COM1KBD 6
|
||||
#define X86_BP_CONSDEV_COM2KBD 7
|
||||
#define X86_BP_CONSDEV_COM3KBD 8
|
||||
|
||||
/* ------------------------------------------
|
||||
* macppc
|
||||
*/
|
||||
|
@ -451,4 +651,6 @@ struct vax_boot_block {
|
|||
/* Magic string -- 32 bytes long (including the NUL) */
|
||||
#define X68K_BBINFO_MAGIC "NetBSD/x68k bootxx 20020601"
|
||||
|
||||
#endif /* !defined(__ASSEMBLER__) */ /* } */
|
||||
|
||||
#endif /* !_SYS_BOOTBLOCK_H */
|
||||
|
|
|
@ -1,143 +0,0 @@
|
|||
/* $NetBSD: disklabel_mbr.h,v 1.11 2003/07/07 12:00:23 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1998 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.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_DISKLABEL_MBR_H_
|
||||
#define _SYS_DISKLABEL_MBR_H_
|
||||
|
||||
/*
|
||||
* From i386 disklabel.h rev 1.6, with cleanups and modifications to
|
||||
* make it easier to use as MI code.
|
||||
*
|
||||
* Note, all fields (including magic number) are little-endian!
|
||||
*/
|
||||
|
||||
/* MBR ("Master Boot Record"; DOS) partition table -- located in boot block */
|
||||
#define MBR_BBSECTOR 0 /* MBR relative sector # */
|
||||
#define MBR_BOOTSELOFF 404 /* offset of mbr_bootsel */
|
||||
#define MBR_PARTOFF 446 /* offset of MBR partition table */
|
||||
#define MBR_MAGICOFF 510 /* offset of magic number */
|
||||
#define MBR_MAGIC 0xaa55 /* MBR magic number */
|
||||
#define NMBRPART 4
|
||||
|
||||
/*
|
||||
* Each entry in the boot select table is a nul-terminated string
|
||||
* of 8 bytes (not including the 0). A zero-length string
|
||||
* (ie if the first char is 0) indicates an unused entry.
|
||||
*/
|
||||
#define PARTNAMESIZE 8 /* for bootselect menu */
|
||||
|
||||
#define DEFAULT_BOOTDIR "/usr/mdec"
|
||||
#define DEFAULT_BOOTCODE "mbr"
|
||||
#define DEFAULT_BOOTSELCODE "mbr_bootsel"
|
||||
#define DEFAULT_BOOTEXTCODE "mbr_ext"
|
||||
|
||||
/* flags for mbr_bootsel */
|
||||
#define BFL_SELACTIVE 0x01 /* Bootselector active (or code present) */
|
||||
#define BFL_EXTINT13 0x02 /* Set by fdisk if LBA needed (deprecated) */
|
||||
#define BFL_READ_LBA 0x04 /* Force LBA reads - even for low numbers */
|
||||
#define BFL_EXTLBA 0x08 /* Extended ptn capable (LBA reads) */
|
||||
#define BFL_NEWMBR 0x80 /* New code: menu user 1..9 for ptns */
|
||||
|
||||
/* Scan values for the various keys we use, as returned by the BIOS */
|
||||
#define SCAN_ENTER 0x1c
|
||||
#define SCAN_F1 0x3b
|
||||
#define SCAN_1 0x2
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
typedef struct mbr_partition mbr_partition_t;
|
||||
struct mbr_partition {
|
||||
u_int8_t mbrp_flag; /* bootstrap flags */
|
||||
u_int8_t mbrp_shd; /* starting head */
|
||||
u_int8_t mbrp_ssect; /* starting sector */
|
||||
u_int8_t mbrp_scyl; /* starting cylinder */
|
||||
u_int8_t mbrp_typ; /* partition type (see below) */
|
||||
u_int8_t mbrp_ehd; /* end head */
|
||||
u_int8_t mbrp_esect; /* end sector */
|
||||
u_int8_t mbrp_ecyl; /* end cylinder */
|
||||
u_int32_t mbrp_start; /* absolute starting sector number */
|
||||
u_int32_t mbrp_size; /* partition size in sectors */
|
||||
} __attribute__((__packed__));
|
||||
|
||||
typedef struct mbr_bootsel mbr_bootsel_t;
|
||||
struct mbr_bootsel {
|
||||
uint8_t mbrb_defkey;
|
||||
uint8_t mbrb_flags;
|
||||
uint16_t mbrb_timeo;
|
||||
char mbrb_nametab[NMBRPART][PARTNAMESIZE + 1];
|
||||
uint16_t mbrb_magic;
|
||||
};
|
||||
|
||||
typedef struct mbr_sector mbr_sector_t;
|
||||
struct mbr_sector {
|
||||
uint8_t mbr_bootinst[MBR_BOOTSELOFF];
|
||||
mbr_bootsel_t mbr_bootsel;
|
||||
mbr_partition_t mbr_parts[NMBRPART];
|
||||
uint16_t mbr_signature;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
int xlat_mbr_fstype(int);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Known MBR flags: */
|
||||
#define MBR_FLAGS_ACTIVE 0x80 /* This is the boot partition */
|
||||
|
||||
/* Known MBR partition types: */
|
||||
#define MBR_PTYPE_NETBSD 0xa9 /* NetBSD partition type */
|
||||
#define MBR_PTYPE_OPENBSD 0xa6 /* OpenBSD partition type */
|
||||
#define MBR_PTYPE_386BSD 0xa5 /* 386BSD partition type */
|
||||
#define MBR_PTYPE_FAT12 0x01 /* 12-bit FAT */
|
||||
#define MBR_PTYPE_FAT16S 0x04 /* 16-bit FAT, less than 32M */
|
||||
#define MBR_PTYPE_EXT 0x05 /* extended partition */
|
||||
#define MBR_PTYPE_FAT16B 0x06 /* 16-bit FAT, more than 32M */
|
||||
#define MBR_PTYPE_NTFS 0x07 /* OS/2 HPFS, NTFS, QNX2, Adv. UNIX */
|
||||
#define MBR_PTYPE_FAT32 0x0b /* 32-bit FAT */
|
||||
#define MBR_PTYPE_FAT32L 0x0c /* 32-bit FAT, LBA-mapped */
|
||||
#define MBR_PTYPE_FAT16L 0x0e /* 16-bit FAT, LBA-mapped */
|
||||
#define MBR_PTYPE_EXT_LBA 0x0f /* extended partition, LBA-mapped */
|
||||
#define MBR_PTYPE_LNXSWAP 0x82 /* Linux swap or Solaris */
|
||||
#define MBR_PTYPE_LNXEXT2 0x83 /* Linux native */
|
||||
#define MBR_PTYPE_EXT_LNX 0x85 /* Linux extended partition */
|
||||
#define MBR_PTYPE_NTFSVOL 0x87 /* NTFS volume set or HPFS mirrored */
|
||||
#define MBR_PTYPE_PREP 0x41 /* PReP */
|
||||
#define MBR_PTYPE_APPLEUFS 0xa8 /* Apple UFS */
|
||||
|
||||
/* Isolate the relevant bits to get sector and cylinder. */
|
||||
#define MBR_PSECT(s) ((s) & 0x3f)
|
||||
#define MBR_PCYL(c, s) ((c) + (((s) & 0xc0) << 2))
|
||||
|
||||
#define MBR_IS_EXTENDED(x) ((x) == MBR_PTYPE_EXT || \
|
||||
(x) == MBR_PTYPE_EXT_LBA || \
|
||||
(x) == MBR_PTYPE_EXT_LNX)
|
||||
|
||||
#endif /* _SYS_DISKLABEL_MBR_H_ */
|
|
@ -1,3 +0,0 @@
|
|||
/* $NetBSD: disklabel_mbr.h,v 1.1 2002/05/12 12:30:10 bjh21 Exp $ */
|
||||
|
||||
#include "../../../sys/sys/disklabel_mbr.h"
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: i386.c,v 1.8 2003/10/06 05:24:54 lukem Exp $ */
|
||||
/* $NetBSD: i386.c,v 1.9 2003/10/08 04:25:46 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(__lint)
|
||||
__RCSID("$NetBSD: i386.c,v 1.8 2003/10/06 05:24:54 lukem Exp $");
|
||||
__RCSID("$NetBSD: i386.c,v 1.9 2003/10/08 04:25:46 lukem Exp $");
|
||||
#endif /* __RCSID && !__lint */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
|
@ -61,13 +61,13 @@ __RCSID("$NetBSD: i386.c,v 1.8 2003/10/06 05:24:54 lukem Exp $");
|
|||
int
|
||||
i386_setboot(ib_params *params)
|
||||
{
|
||||
int retval;
|
||||
int retval, i;
|
||||
char *bootstrapbuf;
|
||||
uint bootstrapsize;
|
||||
ssize_t rv;
|
||||
uint32_t magic;
|
||||
struct i386_boot_params *bp;
|
||||
int i;
|
||||
struct x86_boot_params *bp;
|
||||
struct mbr_sector mbr;
|
||||
|
||||
assert(params != NULL);
|
||||
assert(params->fsfd != -1);
|
||||
|
@ -85,8 +85,29 @@ i386_setboot(ib_params *params)
|
|||
if (params->s1stat.st_size > 8192) {
|
||||
warnx("stage1 bootstrap `%s' is larger than 8192 bytes",
|
||||
params->stage1);
|
||||
return 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read in the existing MBR.
|
||||
*/
|
||||
rv = pread(params->fsfd, &mbr, sizeof(mbr), MBR_BBSECTOR);
|
||||
if (rv == -1) {
|
||||
warn("Reading `%s'", params->filesystem);
|
||||
goto done;
|
||||
} else if (rv != sizeof(mbr)) {
|
||||
warnx("Reading `%s': short read", params->filesystem);
|
||||
goto done;
|
||||
}
|
||||
if (mbr.mbr_magic != le32toh(MBR_MAGIC)) {
|
||||
if (params->flags & IB_VERBOSE) {
|
||||
printf(
|
||||
"Ignoring MBR with invalid magic in sector 0 of `%s'\n",
|
||||
params->filesystem);
|
||||
}
|
||||
memset(&mbr, 0, sizeof(mbr));
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a buffer, with space to round up the input file
|
||||
* to the next block size boundary, and with space for the boot
|
||||
|
@ -101,14 +122,16 @@ i386_setboot(ib_params *params)
|
|||
}
|
||||
memset(bootstrapbuf, 0, bootstrapsize);
|
||||
|
||||
/* read the file into the buffer */
|
||||
/*
|
||||
* Read the file into the buffer.
|
||||
*/
|
||||
rv = pread(params->s1fd, bootstrapbuf, params->s1stat.st_size, 0);
|
||||
if (rv == -1) {
|
||||
warn("Reading `%s'", params->stage1);
|
||||
return 0;
|
||||
goto done;
|
||||
} else if (rv != params->s1stat.st_size) {
|
||||
warnx("Reading `%s': short read", params->stage1);
|
||||
return 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
magic = *(uint32_t *)(bootstrapbuf + 512 * 2 + 4);
|
||||
|
@ -118,7 +141,38 @@ i386_setboot(ib_params *params)
|
|||
goto done;
|
||||
}
|
||||
|
||||
/* Fill in any user-specified options */
|
||||
/*
|
||||
* Ensure bootxx hasn't got code (i.e, non-zero bytes) in
|
||||
* the BIOS Parameter Block (BPB) or the partition table.
|
||||
*/
|
||||
for (i = 0; i < sizeof(mbr.mbr_bpb); i++) {
|
||||
if (*(uint8_t *)(bootstrapbuf + MBR_BPB_OFFSET + i) != 0) {
|
||||
warnx("BPB has non-zero byte at offset %d in `%s'",
|
||||
MBR_BPB_OFFSET + i, params->stage1);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < sizeof(mbr.mbr_parts); i++) {
|
||||
if (*(uint8_t *)(bootstrapbuf + MBR_PART_OFFSET + i) != 0) {
|
||||
warnx(
|
||||
"Partition table has non-zero byte at offset %d in `%s'",
|
||||
MBR_PART_OFFSET + i, params->stage1);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy the BPB and the partition table from the original MBR to the
|
||||
* temporary buffer so that they're written back to the fs.
|
||||
*/
|
||||
memcpy(bootstrapbuf + MBR_BPB_OFFSET, &mbr.mbr_bpb,
|
||||
sizeof(mbr.mbr_bpb));
|
||||
memcpy(bootstrapbuf + MBR_PART_OFFSET, &mbr.mbr_parts,
|
||||
sizeof(mbr.mbr_parts));
|
||||
|
||||
/*
|
||||
* Fill in any user-specified options.
|
||||
*/
|
||||
bp = (void *)(bootstrapbuf + 512 * 2 + 8);
|
||||
if (le32toh(bp->bp_length) < sizeof *bp) {
|
||||
warnx("Patch area in stage1 bootstrap is too small");
|
||||
|
@ -127,7 +181,7 @@ i386_setboot(ib_params *params)
|
|||
if (params->flags & IB_TIMEOUT)
|
||||
bp->bp_timeout = htole32(params->timeout);
|
||||
if (params->flags & IB_RESETVIDEO)
|
||||
bp->bp_flags |= htole32(I386_BP_FLAGS_RESET_VIDEO);
|
||||
bp->bp_flags |= htole32(X86_BP_FLAGS_RESET_VIDEO);
|
||||
if (params->flags & IB_CONSPEED)
|
||||
bp->bp_conspeed = htole32(params->conspeed);
|
||||
if (params->flags & IB_CONSOLE) {
|
||||
|
@ -154,7 +208,7 @@ i386_setboot(ib_params *params)
|
|||
MD5Init(&md5ctx);
|
||||
MD5Update(&md5ctx, params->password, strlen(params->password));
|
||||
MD5Final(bp->bp_password, &md5ctx);
|
||||
bp->bp_flags |= htole32(I386_BP_FLAGS_PASSWORD);
|
||||
bp->bp_flags |= htole32(X86_BP_FLAGS_PASSWORD);
|
||||
}
|
||||
|
||||
if (params->flags & IB_NOWRITE) {
|
||||
|
@ -162,7 +216,9 @@ i386_setboot(ib_params *params)
|
|||
goto done;
|
||||
}
|
||||
|
||||
/* Write pbr code to sector zero */
|
||||
/*
|
||||
* Write MBR code to sector zero.
|
||||
*/
|
||||
rv = pwrite(params->fsfd, bootstrapbuf, 512, 0);
|
||||
if (rv == -1) {
|
||||
warn("Writing `%s'", params->filesystem);
|
||||
|
@ -172,7 +228,9 @@ i386_setboot(ib_params *params)
|
|||
goto done;
|
||||
}
|
||||
|
||||
/* Skip disklabel and write bootxx to sectors 2 + */
|
||||
/*
|
||||
* Skip disklabel in sector 1 and write bootxx to sectors 2..N.
|
||||
*/
|
||||
rv = pwrite(params->fsfd, bootstrapbuf + 512 * 2,
|
||||
bootstrapsize - 512 * 2, 512 * 2);
|
||||
if (rv == -1) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: installboot.8,v 1.30 2003/10/03 13:43:34 lukem Exp $
|
||||
.\" $NetBSD: installboot.8,v 1.31 2003/10/08 04:25:46 lukem Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
|
@ -34,7 +34,7 @@
|
|||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd October 3, 2003
|
||||
.Dd October 7, 2003
|
||||
.Dt INSTALLBOOT 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -377,12 +377,6 @@ Primary bootstrap for file system type
|
|||
Installed into the bootstrap area of the file system by
|
||||
.Nm .
|
||||
.
|
||||
.It Pa /usr/mdec/bootxx_dos
|
||||
Primary bootstrap for
|
||||
.Tn MS-DOS
|
||||
.Sy FAT
|
||||
file systems.
|
||||
.
|
||||
.It Pa /usr/mdec/bootxx_ffsv1
|
||||
Primary bootstrap for
|
||||
.Sy FFSv1
|
||||
|
@ -405,9 +399,11 @@ Primary bootstrap for
|
|||
file systems
|
||||
(the default LFS version).
|
||||
.
|
||||
.It Pa /usr/mdec/bootxx_ufs
|
||||
Synonym for
|
||||
.Pa /usr/mdec/bootxx_ffsv1 .
|
||||
.It Pa /usr/mdec/bootxx_msdos
|
||||
Primary bootstrap for
|
||||
.Tn MS-DOS
|
||||
.Sy FAT
|
||||
file systems.
|
||||
.
|
||||
.It Pa /usr/mdec/bootxx_ustarfs
|
||||
Primary bootstrap for
|
||||
|
@ -438,18 +434,6 @@ is not found.
|
|||
.
|
||||
.El
|
||||
.
|
||||
.Ss NetBSD/i386 files
|
||||
.
|
||||
.Bl -tag -width /usr/mdec/bootxx_ustarfs
|
||||
.
|
||||
.It Pa /usr/mdec/biosboot
|
||||
Secondary bootstrap.
|
||||
This should be installed into the file system before
|
||||
.Nm
|
||||
is run.
|
||||
.
|
||||
.El
|
||||
.
|
||||
.Ss NetBSD/sparc64 files
|
||||
.
|
||||
.Bl -tag -width /usr/mdec/bootxx_ustarfs
|
||||
|
@ -488,7 +472,7 @@ the ustarfs file system):
|
|||
Ignore the warnings this spews (it can not write a disklabel, which is no
|
||||
problem for a floppy disk)
|
||||
.Dl Ic mount /dev/fd0a /mnt
|
||||
.Dl Ic cp /usr/mdec/biosboot /mnt/boot
|
||||
.Dl Ic cp /usr/mdec/boot /mnt/boot
|
||||
.Dl Ic gzip -9 < sys/arch/i386/compile/mykernel/netbsd > /mnt/netbsd.gz
|
||||
.Dl Ic umount /mnt
|
||||
.Dl Ic installboot -v /dev/rfd0a /usr/mdec/bootxx_ufs
|
||||
|
|
Loading…
Reference in New Issue