Remove unused libahdi.
It will be replaced in the future with a more generic libdisklabel.
This commit is contained in:
parent
a519c15410
commit
70b32a2849
@ -1,16 +1,10 @@
|
||||
# $NetBSD: md.atari,v 1.38 2000/02/05 20:59:05 jdc Exp $
|
||||
# $NetBSD: md.atari,v 1.39 2000/03/07 20:55:06 veego Exp $
|
||||
./dev/mouse
|
||||
./sbin/binpatch
|
||||
./sbin/edahdi
|
||||
./sbin/edlabel
|
||||
./usr/bin/fdformat
|
||||
./usr/bin/msconfig
|
||||
./usr/include/libahdi.h
|
||||
./usr/lib/libahdi.a
|
||||
./usr/lib/libahdi_p.a
|
||||
./usr/lib/libahdi_pic.a
|
||||
./usr/lib/libahdi.so.0.0
|
||||
./usr/libdata/lint/llib-lahdi.ln
|
||||
./usr/mdec/bootxx
|
||||
./usr/mdec/fdboot
|
||||
./usr/mdec/installboot
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: md_share,v 1.82 2000/02/27 17:20:02 augustss Exp $
|
||||
# $NetBSD: md_share,v 1.83 2000/03/07 20:55:06 veego Exp $
|
||||
./usr/share/man/cat1/atari/edahdi.0
|
||||
./usr/share/man/cat1/atari/msconfig.0
|
||||
./usr/share/man/cat1/grfinfo.0
|
||||
@ -19,11 +19,6 @@
|
||||
./usr/share/man/cat1/x68k/loadkmap.0
|
||||
./usr/share/man/cat1/x68k/palette.0
|
||||
./usr/share/man/cat1/x68k/tvctrl.0
|
||||
./usr/share/man/cat3/atari/ahdi_buildlabel.0
|
||||
./usr/share/man/cat3/atari/ahdi_checklabel.0
|
||||
./usr/share/man/cat3/atari/ahdi_readlabel.0
|
||||
./usr/share/man/cat3/atari/ahdi_writedisktab.0
|
||||
./usr/share/man/cat3/atari/ahdi_writelabel.0
|
||||
./usr/share/man/cat3/i386/keycap.0
|
||||
./usr/share/man/cat4/amiga/afsc.0
|
||||
./usr/share/man/cat4/amiga/ahsc.0
|
||||
@ -75,7 +70,6 @@
|
||||
./usr/share/man/cat4/arm32/ptsc.0
|
||||
./usr/share/man/cat4/arm32/quadmouse.0
|
||||
./usr/share/man/cat4/arm32/wd.0
|
||||
./usr/share/man/cat4/atari/ahdi.0
|
||||
./usr/share/man/cat4/atari/et.0
|
||||
./usr/share/man/cat4/atari/floppy.0
|
||||
./usr/share/man/cat4/atari/intro.0
|
||||
@ -360,11 +354,6 @@
|
||||
./usr/share/man/man1/x68k/loadkmap.1
|
||||
./usr/share/man/man1/x68k/palette.1
|
||||
./usr/share/man/man1/x68k/tvctrl.1
|
||||
./usr/share/man/man3/atari/ahdi_buildlabel.3
|
||||
./usr/share/man/man3/atari/ahdi_checklabel.3
|
||||
./usr/share/man/man3/atari/ahdi_readlabel.3
|
||||
./usr/share/man/man3/atari/ahdi_writedisktab.3
|
||||
./usr/share/man/man3/atari/ahdi_writelabel.3
|
||||
./usr/share/man/man3/i386/keycap.3
|
||||
./usr/share/man/man4/amiga/afsc.4
|
||||
./usr/share/man/man4/amiga/ahsc.4
|
||||
@ -416,7 +405,6 @@
|
||||
./usr/share/man/man4/arm32/ptsc.4
|
||||
./usr/share/man/man4/arm32/quadmouse.4
|
||||
./usr/share/man/man4/arm32/wd.4
|
||||
./usr/share/man/man4/atari/ahdi.4
|
||||
./usr/share/man/man4/atari/et.4
|
||||
./usr/share/man/man4/atari/floppy.4
|
||||
./usr/share/man/man4/atari/intro.4
|
||||
|
@ -1,10 +1,10 @@
|
||||
# $NetBSD: Makefile,v 1.57 2000/02/05 20:57:13 jdc Exp $
|
||||
# $NetBSD: Makefile,v 1.58 2000/03/07 20:54:57 veego Exp $
|
||||
# from: @(#)Makefile 5.25.1.1 (Berkeley) 5/7/91
|
||||
|
||||
SRCTOP= ..
|
||||
.include <bsd.crypto.mk>
|
||||
|
||||
SUBDIR= csu libahdi libarch libbz2 libc libcompat libcrypt libcurses libedit \
|
||||
SUBDIR= csu libarch libbz2 libc libcompat libcrypt libcurses libedit \
|
||||
libkvm libl libm libmenu libntp libossaudio libpcap libposix \
|
||||
libresolv librmt librpcsvc libskey libterm libusb libutil libwrap \
|
||||
liby libz
|
||||
|
@ -1,19 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.1 2000/02/05 20:40:35 jdc Exp $
|
||||
|
||||
.if ${MACHINE} == "atari"
|
||||
LIB= ahdi
|
||||
SRCS= build.c check.c cksum.c magic.c openraw.c read.c write.c writedtab.c
|
||||
INCS= libahdi.h
|
||||
INCSDIR=/usr/include
|
||||
.endif
|
||||
|
||||
MAN= ahdi_buildlabel.3 ahdi_checklabel.3 ahdi_readlabel.3 \
|
||||
ahdi_writedisktab.3 ahdi_writelabel.3 ahdi.4
|
||||
MANSUBDIR= /atari
|
||||
|
||||
.if ${MACHINE} == "atari"
|
||||
.include <bsd.lib.mk>
|
||||
.else
|
||||
.include <bsd.man.mk>
|
||||
.endif
|
||||
.include <bsd.subdir.mk>
|
@ -1,135 +0,0 @@
|
||||
.\" $NetBSD: ahdi.4,v 1.1 2000/02/05 20:40:36 jdc Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to The NetBSD Foundation
|
||||
.\" by Julian Coleman.
|
||||
.\"
|
||||
.\" 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 the NetBSD
|
||||
.\" Foundation, Inc. and its contributors.
|
||||
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
.\" contributors may be used to endorse or promote products derived
|
||||
.\" from this software without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
.\" ``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 FOUNDATION OR CONTRIBUTORS
|
||||
.\" 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.
|
||||
.\"
|
||||
.Dd January 5, 2000
|
||||
.Dt ahdi 4
|
||||
.Sh NAME
|
||||
.Nm ahdi
|
||||
.Nd format of AHDI partitioned disk
|
||||
.Sh DESCRIPTION
|
||||
The AHDI disk format consists of a root sector (sector 0) containing:
|
||||
.Bl -column "Offset" "Contents" -offset indent
|
||||
.It Em Offset Ta Em Contents
|
||||
.It Li 0x000 Ta
|
||||
Boot code (can be empty)
|
||||
.It Li 0x1c2 Ta
|
||||
Size of hard disk in sectors
|
||||
.It Li 0x1c6 Ta
|
||||
First partition information
|
||||
.It Li 0x1d2 Ta
|
||||
Second partition information
|
||||
.It Li 0x1de Ta
|
||||
Third partition information
|
||||
.It Li 0x1ea Ta
|
||||
Fourth partition information
|
||||
.It Li 0x1f6 Ta
|
||||
Sector containing start of bad sector list (usually 1)
|
||||
.It Li 0x1fa Ta
|
||||
Length of bad sector list, in sectors (usually 1)
|
||||
.It Li 0x1fe Ta
|
||||
Root sector checksum
|
||||
.El
|
||||
.Pp
|
||||
The format of the partition information is:
|
||||
.Bl -column "Offset" "Contents" -offset indent
|
||||
.It Li Em Offset Ta Em Contents
|
||||
.It Li 0x00 Ta
|
||||
Partition flag (0x1 if partition is valid, 0x0 otherwise)
|
||||
.It Li 0x01 Ta
|
||||
Partition ID (e.g. NBD, GEM)
|
||||
.It Li 0x04 Ta
|
||||
Partition start sector
|
||||
.It Li 0x08 Ta
|
||||
Partition size in sectors
|
||||
.El
|
||||
.Pp
|
||||
The offsets are in bytes from the start of the sector.
|
||||
.Pp
|
||||
If the partition ID is
|
||||
.Em XGM ,
|
||||
the partition is a pointer to an extended partition, where the start
|
||||
sector is the sector containing the auxiliary root and the size is the
|
||||
size of the auxiliary root and any partitions it references.
|
||||
.Pp
|
||||
The format of the auxiliary root sector is the same as that of the root
|
||||
sector. However, the only valid fields are at most two of the partition
|
||||
structures. Only one of these can reference to a non-XGM partition. The
|
||||
start sector in the partition structure contains the offset of the partition
|
||||
from the start of the
|
||||
.Em first
|
||||
auxiliary partition.
|
||||
.Pp
|
||||
Partitions referenced from the root sector (sector 0) are known as
|
||||
.Em primary partitions ,
|
||||
while those referenced from auxiliary root sectors are known as
|
||||
.Em extended partitions .
|
||||
.Pp
|
||||
The bad sector list consists of 3-byte entries. The first entry contains
|
||||
the number of vendor bad sectors recorded. The first byte of the second
|
||||
entry contains a checksum byte which causes the bytewise sum of the whole
|
||||
bad sector list to be 0xa5. The remaining entries are vendor bad sectors
|
||||
followed by user bad sectors.
|
||||
.Pp
|
||||
The
|
||||
.Nx
|
||||
disklabel is written in the first partition with ID
|
||||
.Em NBD
|
||||
or
|
||||
.Em RAW .
|
||||
If neither of these partition ID's is present on the disk, no
|
||||
.Nx
|
||||
disklabel will exist on the disk. In this case, an in-core disklabel is
|
||||
automatically generated by the
|
||||
.Nx
|
||||
kernel.
|
||||
.Sh NOTES
|
||||
The AHDI disk format only supports media with a 512 byte sector size.
|
||||
.Pp
|
||||
It is only possible to boot from a
|
||||
.Em primary partition .
|
||||
.Sh SEE ALSO
|
||||
.Xr ahdi_buildlabel 3 ,
|
||||
.Xr ahdi_checklabel 3 ,
|
||||
.Xr ahdi_readlabel 3 ,
|
||||
.Xr ahdi_writedisktab 3 ,
|
||||
.Xr ahdi_writelabel 3
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm libahdi
|
||||
package appeared in
|
||||
.Nx 1.5 .
|
||||
.Sh AUTHORS
|
||||
.An Julian Coleman, Waldi Ravens, Leo Weppelman
|
@ -1,85 +0,0 @@
|
||||
.\" $NetBSD: ahdi_buildlabel.3,v 1.1 2000/02/05 20:40:36 jdc Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to The NetBSD Foundation
|
||||
.\" by Julian Coleman.
|
||||
.\"
|
||||
.\" 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 the NetBSD
|
||||
.\" Foundation, Inc. and its contributors.
|
||||
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
.\" contributors may be used to endorse or promote products derived
|
||||
.\" from this software without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
.\" ``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 FOUNDATION OR CONTRIBUTORS
|
||||
.\" 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.
|
||||
.\"
|
||||
.Dd January 5, 2000
|
||||
.Dt ahdi_buildlabel 3
|
||||
.Sh NAME
|
||||
.Nm ahdi_buildlabel
|
||||
.Nd build AHDI partition label
|
||||
.Sh LIBRARY
|
||||
.Lb libahdi
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <libahdi.h>
|
||||
.Ft int
|
||||
.Fn ahdi_buildlabel "struct ahdi_ptable *ptable"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
function builds a label suitable for use on AHDI partitioned disk. If the
|
||||
total number of partitions is greater than four, it will make the first
|
||||
three partitions primary partitions and the others extended partitions.
|
||||
If the total number of partitions is four or less, the function will make
|
||||
all the partitions primary partitions.
|
||||
.Pp
|
||||
If passed a partition table containing primary and/or extended partitions,
|
||||
these will be modified, if necessary, to conform to the above specifications.
|
||||
If there are no primary or extended partitions in the partition table, they
|
||||
will be created. In both cases, the start sector of partitions may be
|
||||
modified in order to leave space for any auxiliary root sectors.
|
||||
.Sh DIAGNOSTICS
|
||||
The
|
||||
.Nm
|
||||
function returns the following codes:
|
||||
.Bl -column "Code" "Meaning" -offset indent
|
||||
.It Em Code Ta Em Meaning
|
||||
.It Li 1 Ta
|
||||
Partition table was modified.
|
||||
.It Li 0 Ta
|
||||
Partition table was not modified.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr ahdi_checklabel 3 ,
|
||||
.Xr ahdi_readlabel 3 ,
|
||||
.Xr ahdi_writedisktab 3 ,
|
||||
.Xr ahdi_writelabel 3 ,
|
||||
.Xr ahdi 4
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm libahdi
|
||||
package appeared in
|
||||
.Nx 1.5 .
|
||||
.Sh AUTHORS
|
||||
.An Julian Coleman, Waldi Ravens, Leo Weppelman
|
@ -1,96 +0,0 @@
|
||||
.\" $NetBSD: ahdi_checklabel.3,v 1.1 2000/02/05 20:40:37 jdc Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to The NetBSD Foundation
|
||||
.\" by Julian Coleman.
|
||||
.\"
|
||||
.\" 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 the NetBSD
|
||||
.\" Foundation, Inc. and its contributors.
|
||||
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
.\" contributors may be used to endorse or promote products derived
|
||||
.\" from this software without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
.\" ``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 FOUNDATION OR CONTRIBUTORS
|
||||
.\" 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.
|
||||
.\"
|
||||
.Dd January 5, 2000
|
||||
.Dt ahdi_checklabel 3
|
||||
.Sh NAME
|
||||
.Nm ahdi_checklabel
|
||||
.Nd check AHDI partition label
|
||||
.Sh LIBRARY
|
||||
.Lb libahdi
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <libahdi.h>
|
||||
.Vt extern int errp1;
|
||||
.Vt extern int errp2;
|
||||
.Ft int
|
||||
.Fn ahdi_checklabel "struct ahdi_ptable *ptable"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
function checks an AHDI partition label for consistency.
|
||||
.Sh DIAGNOSTICS
|
||||
The
|
||||
.Nm
|
||||
function returns the following codes:
|
||||
.Bl -column "Code" "Meaning" -offset indent
|
||||
.It Em Code Ta Em Meaning
|
||||
.It Li 1 Ta
|
||||
Partition label is OK
|
||||
.It Li -2 Ta
|
||||
Number of partitions is greater than MAXPARTITIONS or less than 1
|
||||
.It Li -3 Ta
|
||||
GEM partition should be BGM or BGM partition should be GEM
|
||||
.It Li -4 Ta
|
||||
Partition overlaps root sector or bad sector list (starts before sector 2)
|
||||
.It Li -5 Ta
|
||||
Partition extends beyond end of disk
|
||||
.It Li -6 Ta
|
||||
Partitions overlap
|
||||
.It Li -7 Ta
|
||||
Partition overlaps auxilliary root
|
||||
.It Li -8 Ta
|
||||
More than 4 partitions in root sector
|
||||
.It Li -9 Ta
|
||||
More than 1 partition in an auxiliary root
|
||||
.El
|
||||
.Pp
|
||||
The partitions which have errors are returned in the variables
|
||||
.Em errp1
|
||||
and
|
||||
.Em errp2 .
|
||||
.Sh SEE ALSO
|
||||
.Xr ahdi_buildlabel 3 ,
|
||||
.Xr ahdi_readlabel 3 ,
|
||||
.Xr ahdi_writedisktab 3 ,
|
||||
.Xr ahdi_writelabel 3 ,
|
||||
.Xr ahdi 4
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm libahdi
|
||||
package appeared in
|
||||
.Nx 1.5 .
|
||||
.Sh AUTHORS
|
||||
.An Julian Coleman, Waldi Ravens, Leo Weppelman
|
@ -1,122 +0,0 @@
|
||||
.\" $NetBSD: ahdi_readlabel.3,v 1.1 2000/02/05 20:40:38 jdc Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to The NetBSD Foundation
|
||||
.\" by Julian Coleman.
|
||||
.\"
|
||||
.\" 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 the NetBSD
|
||||
.\" Foundation, Inc. and its contributors.
|
||||
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
.\" contributors may be used to endorse or promote products derived
|
||||
.\" from this software without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
.\" ``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 FOUNDATION OR CONTRIBUTORS
|
||||
.\" 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.
|
||||
.\"
|
||||
.Dd January 5, 2000
|
||||
.Dt ahdi_readlabel 3
|
||||
.Sh NAME
|
||||
.Nm ahdi_readlabel
|
||||
.Nd read AHDI partition label from disk
|
||||
.Sh LIBRARY
|
||||
.Lb libahdi
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <libahdi.h>
|
||||
.Ft int
|
||||
.Fn ahdi_readlabel "struct ahdi_ptable *ptable" "char *diskname" "int flags"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
function reads an AHDI partitioned disk and places the AHDI partition label
|
||||
into
|
||||
.Em ptable .
|
||||
Partition letters are first assigned sequentially to partitions that have
|
||||
the id `NBD' and then sequentially to other partitions. Partition `b' will
|
||||
only be assigned if a partition with the id `SWP' exists. Partition `c' is
|
||||
reserved for the whole disk.
|
||||
.Pp
|
||||
The function takes the following flags:
|
||||
.Bl -column "AHDI_IGN_EXISTS" "Result" -offset indent
|
||||
.It Em Flag Ta Em Result
|
||||
.It Li FORCE_AHDI Ta
|
||||
Read AHDI label even if NetBSD label exists
|
||||
.It Li AHDI_IGN_EXISTS Ta
|
||||
Ignore partition exists flag and assume all partitions are real
|
||||
.It Li AHDI_IGN_EXT Ta
|
||||
Ignore final extended partition pointer
|
||||
.It Li AHDI_IGN_CKSUM Ta
|
||||
Ignore mismatch between on-disk and calculated checksums
|
||||
.It Li AHDI_IGN_SPU Ta
|
||||
Ignore total sectors from root sector if different from that reported by the disk
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
function will try to open
|
||||
.Em diskname ,
|
||||
.Li then r Ns Em diskname Ns c,
|
||||
.Li then /dev/r Ns Em diskname Ns c .
|
||||
.Sh DIAGNOSTICS
|
||||
The
|
||||
.Nm
|
||||
function returns the following codes:
|
||||
.Bl -column "Code" "Meaning" -offset indent
|
||||
.It Em Code Ta Em Meaning
|
||||
.It Li 1 Ta
|
||||
OK
|
||||
.It Li -1 Ta
|
||||
System call error (see value of errno)
|
||||
.It Li -2 Ta
|
||||
Device is not 512 bytes/sector
|
||||
.It Li -3 Ta
|
||||
No AHDI partitions found (or disk has valid NetBSD partitions)
|
||||
.It Li -4 Ta
|
||||
AHDI checksum error (on disk different from calculated)
|
||||
.It Li -5 Ta
|
||||
Bogus final extended partition (does not point to auxiliary root)
|
||||
.It Li -6 Ta
|
||||
AHDI total sectors does not match device total sectors
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr errno 2 ,
|
||||
.Xr ahdi_buildlabel 3 ,
|
||||
.Xr ahdi_checklabel 3 ,
|
||||
.Xr ahdi_writedisktab 3 ,
|
||||
.Xr ahdi_writelabel 3 ,
|
||||
.Xr ahdi 4
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm libahdi
|
||||
package appeared in
|
||||
.Nx 1.5 .
|
||||
.Sh AUTHORS
|
||||
.An Julian Coleman, Waldi Ravens, Leo Weppelman
|
||||
.Sh BUGS
|
||||
The
|
||||
.Nm
|
||||
function does not recognise the (deprecated) partition ID's
|
||||
.Em NBR ,
|
||||
.Em NBU
|
||||
or
|
||||
.Em NBS .
|
@ -1,114 +0,0 @@
|
||||
.\" $NetBSD: ahdi_writedisktab.3,v 1.1 2000/02/05 20:40:41 jdc Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to The NetBSD Foundation
|
||||
.\" by Julian Coleman.
|
||||
.\"
|
||||
.\" 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 the NetBSD
|
||||
.\" Foundation, Inc. and its contributors.
|
||||
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
.\" contributors may be used to endorse or promote products derived
|
||||
.\" from this software without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
.\" ``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 FOUNDATION OR CONTRIBUTORS
|
||||
.\" 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.
|
||||
.\"
|
||||
.Dd January 5, 2000
|
||||
.Dt ahdi_writedisktab 3
|
||||
.Sh NAME
|
||||
.Nm ahdi_writedisktab
|
||||
.Nd write AHDI partition label in disktab form
|
||||
.Sh LIBRARY
|
||||
.Lb libahdi
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <libahdi.h>
|
||||
.Ft int
|
||||
.Fn ahdi_writedisktab "struct ahdi_ptable *ptable" "char *disktype" "char *disktab" "char *dtype"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
function takes an AHDI label and writes it out in
|
||||
.Xr disktab 5
|
||||
format. The
|
||||
.Em disktype
|
||||
parameter is the name given to the entry and can be passed as the
|
||||
.Em disktype
|
||||
to
|
||||
.Xr disklabel 8 .
|
||||
The
|
||||
.Em disktab
|
||||
parameter is the name of the disktab file to append the disktab to. If this
|
||||
parameter is empty, the default /etc/disktab is used. The
|
||||
.Em dtype
|
||||
parameter, if not empty, is used as the `dt' paramter in the disktab. It should
|
||||
be one of the dktypenames defined in /usr/include/sys/disklabel.h.
|
||||
.Pp
|
||||
If an AHDI label has been written to the disk using the
|
||||
.Fn ahdi_writedisktab
|
||||
function, the partition letters on the disk may not be consistent with those
|
||||
in the ptable variable until a NetBSD dislabel
|
||||
has been written with the
|
||||
.Xr disklabel
|
||||
command, using the disklabel generated by this function.
|
||||
.Sh DIAGNOSTICS
|
||||
The
|
||||
.Nm
|
||||
function returns the following codes:
|
||||
.Bl -column "Code" "Meaning" -offset indent
|
||||
.It Em Code Ta Em Meaning
|
||||
.It Li 1 Ta
|
||||
OK
|
||||
.It Li -1 Ta
|
||||
System call error (see value of errno)
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr errno 2 ,
|
||||
.Xr ahdi_buildlabel 3 ,
|
||||
.Xr ahdi_checklabel 3 ,
|
||||
.Xr ahdi_readlabel 3 ,
|
||||
.Xr ahdi_writelabel 3 ,
|
||||
.Xr ahdi 4 ,
|
||||
.Xr disktab 5 ,
|
||||
.Xr disklabel 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm libahdi
|
||||
package appeared in
|
||||
.Nx 1.5 .
|
||||
.Sh AUTHORS
|
||||
.An Julian Coleman, Waldi Ravens, Leo Weppelman
|
||||
.Sh BUGS
|
||||
The
|
||||
.Nm
|
||||
function does not recognise the (deprecated) partition ID's
|
||||
.Em NBR ,
|
||||
.Em NBU
|
||||
or
|
||||
.Em NBS .
|
||||
.Pp
|
||||
If no partition of type
|
||||
.Em NBD
|
||||
or
|
||||
.Em RAW
|
||||
exist, no NetBSD disklabel can be written to the disk.
|
@ -1,120 +0,0 @@
|
||||
.\" $NetBSD: ahdi_writelabel.3,v 1.1 2000/02/05 20:40:42 jdc Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to The NetBSD Foundation
|
||||
.\" by Julian Coleman.
|
||||
.\"
|
||||
.\" 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 the NetBSD
|
||||
.\" Foundation, Inc. and its contributors.
|
||||
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
.\" contributors may be used to endorse or promote products derived
|
||||
.\" from this software without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
.\" ``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 FOUNDATION OR CONTRIBUTORS
|
||||
.\" 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.
|
||||
.\"
|
||||
.Dd January 5, 2000
|
||||
.Dt ahdi_writelabel 3
|
||||
.Sh NAME
|
||||
.Nm ahdi_writelabel
|
||||
.Nd write AHDI partition label to disk
|
||||
.Sh LIBRARY
|
||||
.Lb libahdi
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <libahdi.h>
|
||||
.Ft int
|
||||
.Fn ahdi_writelabel "struct ahdi_ptable *ptable" "char *diskname" "int flags"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
function writes an AHDI format disk from an AHDI label. The root sector
|
||||
that is written contains no boot code and the bad sector list contains no
|
||||
entries. Any existing NetBSD disklabel for this disk will be invalidated.
|
||||
.Nm
|
||||
calls
|
||||
.Xr ahdi_checklabel
|
||||
and will not write the information if
|
||||
.Xr ahdi_checklabel
|
||||
returns an error.
|
||||
.Pp
|
||||
The function takes the following flags:
|
||||
.Bl -column "AHDI_IGN_EXISTS" "Result" -offset indent
|
||||
.It Em Flag Ta Em Result
|
||||
.It Li AHDI_KEEP_BOOT Ta
|
||||
Keep the existing boot code in the root sector
|
||||
.It Li AHDI_KEEP_BSL Ta
|
||||
Keep the existing bad sector list
|
||||
.It Li AHDI_KEEP_NBDA Ta
|
||||
Keep the existing NetBSD disk label
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
function will try to open
|
||||
.Em diskname ,
|
||||
.Li then r Ns Em diskname Ns c,
|
||||
.Li then /dev/r Ns Em diskname Ns c .
|
||||
.Sh DIAGNOSTICS
|
||||
The
|
||||
.Nm
|
||||
function returns the following codes:
|
||||
.Bl -column "Code" "Meaning" -offset indent
|
||||
.It Em Code Ta Em Meaning
|
||||
.It Li 1 Ta
|
||||
OK
|
||||
.It Li -1 Ta
|
||||
System call error (see value of errno)
|
||||
.It Li <-1 Ta
|
||||
.Xr ahdi_checklabel
|
||||
returned an error
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr errno
|
||||
.Xr ahdi_buildlabel 3 ,
|
||||
.Xr ahdi_checklabel 3 ,
|
||||
.Xr ahdi_readlabel 3 ,
|
||||
.Xr ahdi_writedisktab 3 ,
|
||||
.Xr ahdi 4 ,
|
||||
.Xr installboot 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm libahdi
|
||||
package appeared in
|
||||
.Nx 1.5 .
|
||||
.Sh AUTHORS
|
||||
.An Julian Coleman, Waldi Ravens, Leo Weppelman
|
||||
.Sh BUGS
|
||||
The
|
||||
.Nm
|
||||
function does not recognise the (deprecated) partition ID's
|
||||
.Em NBR ,
|
||||
.Em NBU
|
||||
or
|
||||
.Em NBS .
|
||||
.Pp
|
||||
If no partition of type
|
||||
.Em NBD
|
||||
or
|
||||
.Em RAW
|
||||
exist, no NetBSD disklabel can be written to the disk.
|
@ -1,87 +0,0 @@
|
||||
/* $NetBSD: build.c,v 1.1 2000/02/05 20:40:42 jdc Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Julian Coleman, Waldi Ravens and Leo Weppelman.
|
||||
*
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``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 FOUNDATION OR CONTRIBUTORS
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "privahdi.h"
|
||||
|
||||
/*
|
||||
* Build AHDI auxillary roots (extended partitions).
|
||||
* Always make first 3 partitions real.
|
||||
*/
|
||||
int
|
||||
ahdi_buildlabel (ptable)
|
||||
struct ahdi_ptable *ptable;
|
||||
{
|
||||
int i, j;
|
||||
struct ahdi_ptable old_table;
|
||||
|
||||
/* Copy original ptable */
|
||||
bcopy (ptable, &old_table, sizeof (struct ahdi_ptable));
|
||||
|
||||
/*
|
||||
* Adjust partition starts. Do this first because some
|
||||
* partitioning tools (ICD) change the relative ordering of
|
||||
* auxiliary roots vs. partitions.
|
||||
*/
|
||||
for (i = 0; i < ptable->nparts; i++)
|
||||
for (j = 0; j < ptable->nparts; j++)
|
||||
if (ptable->parts[j].start ==
|
||||
ptable->parts[i].root + 1) {
|
||||
ptable->parts[j].start--;
|
||||
ptable->parts[j].size++;
|
||||
}
|
||||
for (i = 0; i < ptable->nparts; i++) {
|
||||
/* Remove auxiliary roots for first 3 (or all) partitions */
|
||||
if (i < 3 || (i < 4 && ptable->nparts < 5)) {
|
||||
ptable->parts[i].root = 0;
|
||||
/* Create auxiliary roots for other partitions */
|
||||
} else {
|
||||
ptable->parts[i].root = ptable->parts[i].start;
|
||||
ptable->parts[i].start++;
|
||||
ptable->parts[i].size--;
|
||||
}
|
||||
}
|
||||
|
||||
/* Compare old and new */
|
||||
for (i = 0; i < ptable->nparts; i++)
|
||||
if (ptable->parts[i].root != old_table.parts[i].root ||
|
||||
ptable->parts[i].start != old_table.parts[i].start ||
|
||||
ptable->parts[i].size != old_table.parts[i].size)
|
||||
return (1);
|
||||
|
||||
return (0);
|
||||
}
|
@ -1,143 +0,0 @@
|
||||
/* $NetBSD: check.c,v 1.1 2000/02/05 20:40:43 jdc Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Julian Coleman, Waldi Ravens and Leo Weppelman.
|
||||
*
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``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 FOUNDATION OR CONTRIBUTORS
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "privahdi.h"
|
||||
|
||||
/* Partitions which have errors */
|
||||
int errp1 = -1;
|
||||
int errp2 = -1;
|
||||
|
||||
/*
|
||||
* Check partitions for consistency :
|
||||
* GEM vs BGM
|
||||
* Start sector > 2
|
||||
* End sector < secperunit
|
||||
* other partition overlap
|
||||
* auxiliary root overlap
|
||||
* Number of partitions in root/auxiliary root
|
||||
*/
|
||||
int
|
||||
ahdi_checklabel (ptable)
|
||||
struct ahdi_ptable *ptable;
|
||||
{
|
||||
int i, j, rcount, acount;
|
||||
u_int32_t i_end, j_end;
|
||||
|
||||
if (ptable->nparts < 1 || ptable->nparts > MAXPARTITIONS)
|
||||
return (-2);
|
||||
|
||||
rcount = 0;
|
||||
acount = 0;
|
||||
|
||||
for (i = 0; i < ptable->nparts; i++) {
|
||||
|
||||
/* GEM vs BGM */
|
||||
if (ptable->parts[i].size > 32768) {
|
||||
if (AHDI_MKPID (ptable->parts[i].id[0],
|
||||
ptable->parts[i].id[1], ptable->parts[i].id[2])
|
||||
== AHDI_PID_GEM) {
|
||||
errp1 = i;
|
||||
return (-3);
|
||||
}
|
||||
} else {
|
||||
if (AHDI_MKPID (ptable->parts[i].id[0],
|
||||
ptable->parts[i].id[1], ptable->parts[i].id[2])
|
||||
== AHDI_PID_BGM) {
|
||||
errp1 = i;
|
||||
return (-3);
|
||||
}
|
||||
}
|
||||
|
||||
/* Need 2 free sectors at start for root and bad sector list */
|
||||
if (ptable->parts[i].start < 2) {
|
||||
errp1 = i;
|
||||
return (-4);
|
||||
}
|
||||
|
||||
i_end = ptable->parts[i].start + ptable->parts[i].size - 1;
|
||||
|
||||
/* Check partition does not extend past end of disk */
|
||||
if (i_end > ptable->secperunit) {
|
||||
errp1 = i;
|
||||
return (-5);
|
||||
}
|
||||
|
||||
for (j = i + 1; j < ptable->nparts; j++) {
|
||||
/* Check for overlap with other partitions */
|
||||
j_end = ptable->parts[j].start + ptable->parts[j].size
|
||||
- 1;
|
||||
if ((ptable->parts[j].start >= ptable->parts[i].start
|
||||
&& ptable->parts[j].start <= i_end) ||
|
||||
(j_end >= ptable->parts[i].start &&
|
||||
j_end <= i_end)) {
|
||||
errp1 = i;
|
||||
errp2 = j;
|
||||
return (-6);
|
||||
}
|
||||
/* Check number of partitions in auxiliary root */
|
||||
if (ptable->parts[i].root &&
|
||||
ptable->parts[i].root == ptable->parts[j].root) {
|
||||
errp1 = i;
|
||||
errp2 = j;
|
||||
return (-9);
|
||||
}
|
||||
}
|
||||
|
||||
for (j = i; j < ptable->nparts; j++)
|
||||
/* Check for overlap with auxiliary root(s) */
|
||||
if (ptable->parts[j].root >= ptable->parts[i].start &&
|
||||
ptable->parts[j].root <= i_end) {
|
||||
errp1 = i;
|
||||
return (-7);
|
||||
}
|
||||
|
||||
/* Count partitions in root/auxiliary roots */
|
||||
if (ptable->parts[i].root)
|
||||
acount ++;
|
||||
else
|
||||
rcount ++;
|
||||
|
||||
}
|
||||
/* Check number of partitions in root sector */
|
||||
if (acount)
|
||||
rcount++;
|
||||
if (rcount > 4)
|
||||
return (-8);
|
||||
else
|
||||
return (1);
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
/* $NetBSD: cksum.c,v 1.1 2000/02/05 20:40:44 jdc Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Julian Coleman, Waldi Ravens and Leo Weppelman.
|
||||
*
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``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 FOUNDATION OR CONTRIBUTORS
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "privahdi.h"
|
||||
|
||||
/*
|
||||
* Disklabel checksum.
|
||||
*/
|
||||
|
||||
int
|
||||
dkcksum (dl)
|
||||
struct disklabel *dl;
|
||||
{
|
||||
u_short *start, *end, sum = 0;
|
||||
|
||||
start = (u_short *)dl;
|
||||
end = (u_short *)&dl->d_partitions[dl->d_npartitions];
|
||||
while (start < end)
|
||||
sum ^= *start++;
|
||||
return (sum);
|
||||
}
|
||||
|
||||
/*
|
||||
* AHDI root sector checksum.
|
||||
*/
|
||||
|
||||
u_int16_t
|
||||
ahdi_cksum (buf)
|
||||
void *buf;
|
||||
{
|
||||
u_int16_t *p = (u_int16_t *)buf;
|
||||
u_int16_t csum = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
csum += *p++;
|
||||
return ((0x1234 - csum) & 0xffff);
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
/* $NetBSD: libahdi.h,v 1.1 2000/02/05 20:40:44 jdc Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Julian Coleman, Waldi Ravens and Leo Weppelman.
|
||||
*
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``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 FOUNDATION OR CONTRIBUTORS
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <machine/ahdilabel.h>
|
||||
|
||||
/* Flags for ahdi_readlabel() */
|
||||
#define FORCE_AHDI 0x01 /* Read AHDI label when NetBSD label exists */
|
||||
#define AHDI_IGN_EXISTS 0x02 /* Ignore partition exists flag (ICD tools) */
|
||||
#define AHDI_IGN_EXT 0x04 /* Ignore last extended parition (HDDriver) */
|
||||
#define AHDI_IGN_CKSUM 0x08 /* Ignore checksum mismatch on root sector */
|
||||
#define AHDI_IGN_SPU 0x10 /* Ignore total sectors mismatch */
|
||||
|
||||
/* Flags for ahdi_writelabel() */
|
||||
#define AHDI_KEEP_BOOT 0x01 /* Keep boot sector */
|
||||
#define AHDI_KEEP_BSL 0x02 /* Keep bad sector list */
|
||||
#define AHDI_KEEP_NBDA 0x04 /* Keep NetBSD label */
|
||||
|
||||
struct ptable_part {
|
||||
u_int8_t flag; /* partition flag */
|
||||
u_int8_t id[3]; /* id: GEM, BGM, NBD, ... */
|
||||
u_int32_t root; /* root sector */
|
||||
u_int32_t start; /* start sector */
|
||||
u_int32_t size; /* size in sectors */
|
||||
int letter; /* partition letter */
|
||||
};
|
||||
|
||||
struct ahdi_ptable {
|
||||
u_int32_t nsectors; /* number of sectors/track */
|
||||
u_int32_t ntracks; /* number of tracks/cylinder */
|
||||
u_int32_t ncylinders; /* number of cylinders */
|
||||
u_int32_t secpercyl; /* number of sectors/cylinder */
|
||||
u_int32_t secperunit; /* number of total sectors */
|
||||
int nparts; /* number of partitions */
|
||||
struct ptable_part parts[MAXPARTITIONS];
|
||||
};
|
||||
|
||||
int ahdi_buildlabel __P((struct ahdi_ptable *));
|
||||
int ahdi_checklabel __P((struct ahdi_ptable *));
|
||||
int ahdi_readlabel __P((struct ahdi_ptable *, char *, int));
|
||||
int ahdi_writedisktab __P((struct ahdi_ptable *, char *, char *, char *));
|
||||
int ahdi_writelabel __P((struct ahdi_ptable *, char *, int));
|
||||
|
||||
extern int errp1, errp2;
|
@ -1,80 +0,0 @@
|
||||
/* $NetBSD: magic.c,v 1.1 2000/02/05 20:40:45 jdc Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Julian Coleman, Waldi Ravens and Leo Weppelman.
|
||||
*
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``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 FOUNDATION OR CONTRIBUTORS
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "privahdi.h"
|
||||
|
||||
/*
|
||||
* Check label magic numbers for AHDI partitions
|
||||
*/
|
||||
int
|
||||
check_magic(fd, offset, flags)
|
||||
int fd;
|
||||
u_int offset;
|
||||
int flags;
|
||||
{
|
||||
u_char *bblk;
|
||||
u_int nsec;
|
||||
int rv = 1;
|
||||
|
||||
nsec = (BBMINSIZE + (DEV_BSIZE - 1)) / DEV_BSIZE;
|
||||
bblk = disk_read(fd, offset, nsec);
|
||||
if (bblk != NULL) {
|
||||
u_int *end, *p;
|
||||
|
||||
end = (u_int *)&bblk[BBMINSIZE - sizeof(struct disklabel)];
|
||||
for (p = (u_int *)bblk; p < end; ++p) {
|
||||
struct disklabel *dl = (struct disklabel *)&p[1];
|
||||
if (((p[0] == NBDAMAGIC && offset == 0 &&
|
||||
!(flags & FORCE_AHDI)) ||
|
||||
(p[0] == AHDIMAGIC && offset != 0) ||
|
||||
(u_char *)dl - bblk == 7168) &&
|
||||
dl->d_npartitions <= MAXPARTITIONS &&
|
||||
dl->d_magic2 == DISKMAGIC &&
|
||||
dl->d_magic == DISKMAGIC &&
|
||||
dkcksum(dl) == 0) {
|
||||
rv = -3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(bblk);
|
||||
}
|
||||
else
|
||||
rv = -1;
|
||||
|
||||
return (rv);
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/* $NetBSD: openraw.c,v 1.1 2000/02/05 20:40:45 jdc Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Julian Coleman, Waldi Ravens and Leo Weppelman.
|
||||
*
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``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 FOUNDATION OR CONTRIBUTORS
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "privahdi.h"
|
||||
#include <paths.h>
|
||||
#include <machine/disklabel.h>
|
||||
|
||||
/*
|
||||
* Open raw disk partition.
|
||||
*/
|
||||
int
|
||||
openraw (name, flags)
|
||||
const char *name;
|
||||
int flags;
|
||||
{
|
||||
char buf[MAXPATHLEN];
|
||||
int f;
|
||||
|
||||
if ((f = open (name, flags)) != -1)
|
||||
return (f);
|
||||
|
||||
snprintf (buf, MAXPATHLEN, "r%s%c", name, RAW_PART + 'a');
|
||||
if ((f = open (buf, flags)) != -1)
|
||||
return (f);
|
||||
|
||||
snprintf (buf, MAXPATHLEN, "%sr%s%c", _PATH_DEV, name, RAW_PART + 'a');
|
||||
if ((f = open (buf, flags)) != -1)
|
||||
return (f);
|
||||
|
||||
return (0);
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/* $NetBSD: privahdi.h,v 1.1 2000/02/05 20:40:46 jdc Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Julian Coleman, Waldi Ravens and Leo Weppelman.
|
||||
*
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``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 FOUNDATION OR CONTRIBUTORS
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "libahdi.h"
|
||||
|
||||
/*
|
||||
* Functions internal to libahdi.
|
||||
*/
|
||||
|
||||
u_int16_t ahdi_cksum __P((void *));
|
||||
void assign_letters __P((struct ahdi_ptable *));
|
||||
int check_magic __P((int, u_int, int));
|
||||
int dkcksum __P((struct disklabel *));
|
||||
void *disk_read __P((int, u_int, u_int));
|
||||
int disk_write __P((int, u_int, u_int, void *));
|
||||
int invalidate_netbsd_label __P((int, u_int32_t));
|
||||
int openraw __P((const char *, int));
|
||||
struct disklabel *read_dl __P((int));
|
||||
int read_rsec __P((int, struct ahdi_ptable *, u_int,
|
||||
u_int, int));
|
||||
int write_bsl __P((int));
|
@ -1,272 +0,0 @@
|
||||
/* $NetBSD: read.c,v 1.1 2000/02/05 20:40:47 jdc Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Julian Coleman, Waldi Ravens and Leo Weppelman.
|
||||
*
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``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 FOUNDATION OR CONTRIBUTORS
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "privahdi.h"
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/dkio.h>
|
||||
|
||||
/*
|
||||
* Read AHDI partitions from disk.
|
||||
*/
|
||||
int
|
||||
ahdi_readlabel (ptable, diskname, flags)
|
||||
struct ahdi_ptable *ptable;
|
||||
char *diskname;
|
||||
int flags;
|
||||
{
|
||||
int fd, rv;
|
||||
struct disklabel *dl;
|
||||
|
||||
if (!(fd = openraw (diskname, O_RDONLY)))
|
||||
return (-1);
|
||||
|
||||
if ((dl = read_dl (fd)) == NULL) {
|
||||
close (fd);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (dl->d_secsize != AHDI_BSIZE) {
|
||||
close (fd);
|
||||
return (-2);
|
||||
}
|
||||
|
||||
if ((rv = check_magic(fd, LABELSECTOR, flags)) < 0) {
|
||||
close (fd);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
bzero ((void *) ptable, sizeof (struct ahdi_ptable));
|
||||
|
||||
if ((rv = read_rsec (fd, ptable, AHDI_BBLOCK, AHDI_BBLOCK, flags))
|
||||
< 0) {
|
||||
close (fd);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
if (dl->d_secperunit != ptable->secperunit) {
|
||||
if (flags & AHDI_IGN_SPU)
|
||||
ptable->secperunit = dl->d_secperunit;
|
||||
else {
|
||||
close (fd);
|
||||
return (-6);
|
||||
}
|
||||
}
|
||||
|
||||
ptable->nsectors = dl->d_nsectors;
|
||||
ptable->ntracks = dl->d_ntracks;
|
||||
ptable->ncylinders = dl->d_ncylinders;
|
||||
ptable->secpercyl = dl->d_secpercyl;
|
||||
|
||||
assign_letters (ptable);
|
||||
|
||||
close (fd);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read AHDI partitions from root sector/auxillary root sector.
|
||||
*/
|
||||
int
|
||||
read_rsec (fd, ptable, rsec, esec, flags)
|
||||
int fd;
|
||||
struct ahdi_ptable *ptable;
|
||||
u_int rsec, esec;
|
||||
int flags;
|
||||
{
|
||||
struct ahdi_part *part, *end;
|
||||
struct ahdi_root *root;
|
||||
u_int16_t cksum, newcksum;
|
||||
int rv;
|
||||
|
||||
if ((root = disk_read (fd, rsec, 1)) == NULL) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (rsec == AHDI_BBLOCK) {
|
||||
end = &root->ar_parts[AHDI_MAXRPD];
|
||||
if (root->ar_checksum) {
|
||||
cksum = root->ar_checksum;
|
||||
root->ar_checksum = 0;
|
||||
newcksum = ahdi_cksum (root);
|
||||
if ((cksum != newcksum) && !(flags & AHDI_IGN_CKSUM)) {
|
||||
free (root);
|
||||
return (-4);
|
||||
}
|
||||
}
|
||||
ptable->secperunit=root->ar_hdsize;
|
||||
} else
|
||||
end = &root->ar_parts[AHDI_MAXARPD];
|
||||
for (part = root->ar_parts; part < end; ++part) {
|
||||
#ifdef DEBUG
|
||||
printf ("Found partitions at sector %u:\n", rsec);
|
||||
printf (" flags : %02x\n", part->ap_flg);
|
||||
printf (" id : %c%c%c\n", part->ap_id[0], part->ap_id[1],
|
||||
part->ap_id[2]);
|
||||
printf (" start : %u\n", part->ap_st);
|
||||
printf (" size : %u\n", part->ap_size);
|
||||
#endif
|
||||
if (!(part->ap_flg & 0x01))
|
||||
if ((part->ap_id[0] || part->ap_id[1] ||
|
||||
part->ap_id[2]) && (flags & AHDI_IGN_EXISTS))
|
||||
part->ap_flg &= 0x01;
|
||||
else
|
||||
continue;
|
||||
|
||||
if (AHDI_MKPID (part->ap_id[0], part->ap_id[1],
|
||||
part->ap_id[2]) == AHDI_PID_XGM) {
|
||||
u_int offs = part->ap_st + esec;
|
||||
if ((rv = read_rsec (fd, ptable, offs,
|
||||
esec == AHDI_BBLOCK ? offs : esec, flags)) < 0) {
|
||||
free (root);
|
||||
return (rv);
|
||||
}
|
||||
} else {
|
||||
/* Attempt to check for junk values */
|
||||
if (((part->ap_st + rsec) > ptable->secperunit ||
|
||||
(part->ap_st + rsec + part->ap_size -1) >
|
||||
ptable->secperunit)) {
|
||||
if (flags & AHDI_IGN_EXT) {
|
||||
/* Fake previous partition */
|
||||
ptable->parts[ptable->nparts].id[0] =
|
||||
part->ap_id[0];
|
||||
ptable->parts[ptable->nparts].id[1] =
|
||||
part->ap_id[1];
|
||||
ptable->parts[ptable->nparts].id[2] =
|
||||
part->ap_id[2];
|
||||
} else {
|
||||
free (root);
|
||||
return (-5);
|
||||
}
|
||||
}
|
||||
ptable->parts[ptable->nparts].flag = part->ap_flg;
|
||||
ptable->parts[ptable->nparts].id[0] = part->ap_id[0];
|
||||
ptable->parts[ptable->nparts].id[1] = part->ap_id[1];
|
||||
ptable->parts[ptable->nparts].id[2] = part->ap_id[2];
|
||||
ptable->parts[ptable->nparts].root = rsec;
|
||||
ptable->parts[ptable->nparts].start =
|
||||
part->ap_st + rsec;
|
||||
ptable->parts[ptable->nparts].size = part->ap_size;
|
||||
ptable->nparts++;
|
||||
}
|
||||
}
|
||||
free (root);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a sector from the disk.
|
||||
*/
|
||||
void *
|
||||
disk_read (fd, start, count)
|
||||
int fd;
|
||||
u_int start,
|
||||
count;
|
||||
{
|
||||
void *buffer;
|
||||
off_t offset;
|
||||
size_t size;
|
||||
|
||||
|
||||
size = count * DEV_BSIZE;
|
||||
offset = start * DEV_BSIZE;
|
||||
|
||||
if ((buffer = malloc (size)) == NULL)
|
||||
return (NULL);
|
||||
|
||||
if (lseek (fd, offset, SEEK_SET) != offset) {
|
||||
free (buffer);
|
||||
return (NULL);
|
||||
}
|
||||
if (read (fd, buffer, size) != size) {
|
||||
free (buffer);
|
||||
return (NULL);
|
||||
}
|
||||
return (buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Assign NetBSD drive letters to partitions
|
||||
*/
|
||||
void
|
||||
assign_letters (ptable)
|
||||
struct ahdi_ptable *ptable;
|
||||
{
|
||||
int i, have_root, pno;
|
||||
u_int32_t pid;
|
||||
|
||||
#define ROOT_PART 0
|
||||
|
||||
have_root = 0;
|
||||
pno = 0;
|
||||
|
||||
for (i = 0; i < ptable->nparts; i++) {
|
||||
while (pno == ROOT_PART || pno == SWAP_PART || pno == RAW_PART)
|
||||
pno++;
|
||||
pid = AHDI_MKPID (ptable->parts[i].id[0],
|
||||
ptable->parts[i].id[1], ptable->parts[i].id[2]);
|
||||
if (!have_root && pid == AHDI_PID_NBD) {
|
||||
ptable->parts[i].letter = ROOT_PART;
|
||||
have_root = 1;
|
||||
} else if (pid == AHDI_PID_SWP)
|
||||
ptable->parts[i].letter = SWAP_PART;
|
||||
else {
|
||||
ptable->parts[i].letter = pno;
|
||||
pno++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Read disklabel for disk.
|
||||
*/
|
||||
struct disklabel *
|
||||
read_dl (fd)
|
||||
int fd;
|
||||
{
|
||||
struct disklabel *dl;
|
||||
|
||||
if ((dl = malloc (sizeof (struct disklabel))) == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (ioctl (fd, DIOCGDINFO, dl) < 0) {
|
||||
return (NULL);
|
||||
}
|
||||
return (dl);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
# $NetBSD: shlib_version,v 1.1 2000/02/05 20:40:47 jdc Exp $
|
||||
# Remember to update distrib/sets/lists/base/md.atari when changing
|
||||
#
|
||||
major=0
|
||||
minor=0
|
||||
|
@ -1,348 +0,0 @@
|
||||
/* $NetBSD: write.c,v 1.1 2000/02/05 20:40:48 jdc Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Julian Coleman, Waldi Ravens and Leo Weppelman.
|
||||
*
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``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 FOUNDATION OR CONTRIBUTORS
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "privahdi.h"
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/dkio.h>
|
||||
|
||||
#define BSL_MAGIC 0xa5
|
||||
#define BSL_OFFSET 1
|
||||
#define BSL_SIZE 1
|
||||
|
||||
/*
|
||||
* Write AHDI partitions to disk
|
||||
*/
|
||||
|
||||
int
|
||||
ahdi_writelabel (ptable, diskname, flags)
|
||||
struct ahdi_ptable *ptable;
|
||||
char *diskname;
|
||||
int flags;
|
||||
{
|
||||
int fd, i, j, k, firstxgm, keep;
|
||||
struct ahdi_root *root;
|
||||
u_int rsec;
|
||||
u_int32_t xgmsec, nbdsec;
|
||||
|
||||
if (!(fd = openraw (diskname, O_RDWR)))
|
||||
return (-1);
|
||||
|
||||
if (ahdi_checklabel (ptable) < 0) {
|
||||
close (fd);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (flags & AHDI_KEEP_BOOT) {
|
||||
if ((root = disk_read (fd, AHDI_BBLOCK, 1)) == NULL) {
|
||||
return (-1);
|
||||
}
|
||||
bzero ((void *) root->ar_parts,
|
||||
sizeof (struct ahdi_part) * AHDI_MAXRPD);
|
||||
} else {
|
||||
if ((root = malloc (sizeof (struct ahdi_root))) == NULL) {
|
||||
close (fd);
|
||||
return (-1);
|
||||
}
|
||||
bzero ((void *) root, sizeof (struct ahdi_root));
|
||||
}
|
||||
|
||||
nbdsec = 0;
|
||||
#ifdef DEBUG
|
||||
printf ("Writing root sector\n");
|
||||
#endif
|
||||
|
||||
/* All partitions in root sector (including first XGM) */
|
||||
j = 0;
|
||||
firstxgm = 0;
|
||||
for (i = 0; i < ptable->nparts; i++) {
|
||||
if (ptable->parts[i].root == 0) {
|
||||
#ifdef DEBUG
|
||||
printf (" Partition %d - ", j);
|
||||
#endif
|
||||
root->ar_parts[j].ap_flg = 0x01;
|
||||
for (k = 0; k < 3; k++) {
|
||||
root->ar_parts[j].ap_id[k] =
|
||||
ptable->parts[i].id[k];
|
||||
#ifdef DEBUG
|
||||
printf ("%c", root->ar_parts[j].ap_id[k]);
|
||||
#endif
|
||||
}
|
||||
root->ar_parts[j].ap_st = ptable->parts[i].start;
|
||||
root->ar_parts[j].ap_size = ptable->parts[i].size;
|
||||
#ifdef DEBUG
|
||||
printf ("/%u/%u\n", root->ar_parts[j].ap_st,
|
||||
root->ar_parts[j].ap_size);
|
||||
#endif
|
||||
|
||||
j++;
|
||||
} else if (!firstxgm) {
|
||||
root->ar_parts[j].ap_flg = 0x01;
|
||||
root->ar_parts[j].ap_id[0] = 'X';
|
||||
root->ar_parts[j].ap_id[1] = 'G';
|
||||
root->ar_parts[j].ap_id[2] = 'M';
|
||||
root->ar_parts[j].ap_st = ptable->parts[i].root;
|
||||
root->ar_parts[j].ap_size = ptable->parts[i].size + 1;
|
||||
firstxgm = i;
|
||||
xgmsec = ptable->parts[i].root;
|
||||
#ifdef DEBUG
|
||||
printf (" Partition %d - XGM/%u/%u\n", j,
|
||||
root->ar_parts[j].ap_st,
|
||||
root->ar_parts[j].ap_size);
|
||||
#endif
|
||||
j++;
|
||||
}
|
||||
/*
|
||||
* Note first netbsd partition for invalidate_netbsd_label().
|
||||
*/
|
||||
if (!nbdsec && AHDI_MKPID (ptable->parts[i].id[0],
|
||||
ptable->parts[i].id[1], ptable->parts[i].id[2])
|
||||
== AHDI_PID_NBD) {
|
||||
nbdsec = ptable->parts[i].start;
|
||||
}
|
||||
}
|
||||
|
||||
root->ar_hdsize = ptable->secperunit;
|
||||
if (!(flags & AHDI_KEEP_BSL)) {
|
||||
root->ar_bslst = (u_int32_t) BSL_OFFSET;
|
||||
root->ar_bslsize = (u_int32_t) BSL_SIZE;
|
||||
}
|
||||
root->ar_checksum = ahdi_cksum (root);
|
||||
|
||||
if (!disk_write (fd, AHDI_BBLOCK, 1, root)) {
|
||||
free (root);
|
||||
close (fd);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* Auxiliary roots */
|
||||
for (i = firstxgm; i < ptable->nparts; i++) {
|
||||
j = 0;
|
||||
if (ptable->parts[i].root == 0)
|
||||
continue;
|
||||
#ifdef DEBUG
|
||||
printf ("Writing auxiliary root at sector %u\n",
|
||||
ptable->parts[i].root);
|
||||
#endif
|
||||
bzero ((void *) root, sizeof (struct ahdi_root));
|
||||
rsec = ptable->parts[i].root;
|
||||
#ifdef DEBUG
|
||||
printf (" Partition %d - ", j);
|
||||
#endif
|
||||
root->ar_parts[j].ap_flg = 0x01;
|
||||
for (k = 0; k < 3; k++) {
|
||||
root->ar_parts[j].ap_id[k] =
|
||||
ptable->parts[i].id[k];
|
||||
#ifdef DEBUG
|
||||
printf ("%c", root->ar_parts[j].ap_id[k]);
|
||||
#endif
|
||||
}
|
||||
root->ar_parts[j].ap_st = ptable->parts[i].start -
|
||||
rsec;
|
||||
root->ar_parts[j].ap_size = ptable->parts[i].size;
|
||||
#ifdef DEBUG
|
||||
printf ("/%u/%u\n", root->ar_parts[j].ap_st,
|
||||
root->ar_parts[j].ap_size);
|
||||
#endif
|
||||
j++;
|
||||
if (i < ptable->nparts - 1) {
|
||||
/* Need an XGM? */
|
||||
if (ptable->parts[i].root != ptable->parts[i+1].root &&
|
||||
ptable->parts[i+1].root != 0) {
|
||||
root->ar_parts[j].ap_flg = 0x01;
|
||||
root->ar_parts[j].ap_id[0] = 'X';
|
||||
root->ar_parts[j].ap_id[1] = 'G';
|
||||
root->ar_parts[j].ap_id[2] = 'M';
|
||||
root->ar_parts[j].ap_st =
|
||||
ptable->parts[i+1].root - xgmsec;
|
||||
root->ar_parts[j].ap_size =
|
||||
ptable->parts[i+1].size + 1;
|
||||
#ifdef DEBUG
|
||||
printf (" Partition %d - XGM/%u/%u\n", j,
|
||||
root->ar_parts[j].ap_st,
|
||||
root->ar_parts[j].ap_size);
|
||||
#endif
|
||||
root->ar_parts[j].ap_size = 0;
|
||||
}
|
||||
if (ptable->parts[i].root == ptable->parts[i+1].root) {
|
||||
/* Next partition has same auxiliary root */
|
||||
#ifdef DEBUG
|
||||
printf (" Partition %d - ", j);
|
||||
#endif
|
||||
root->ar_parts[j].ap_flg = 0x01;
|
||||
for (k = 0; k < 3; k++) {
|
||||
root->ar_parts[j].ap_id[k] =
|
||||
ptable->parts[i+1].id[k];
|
||||
#ifdef DEBUG
|
||||
printf ("%c", root->ar_parts[j].ap_id[k]);
|
||||
#endif
|
||||
}
|
||||
root->ar_parts[j].ap_st =
|
||||
ptable->parts[i+1].start - rsec;
|
||||
root->ar_parts[j].ap_size =
|
||||
ptable->parts[i+1].size;
|
||||
#ifdef DEBUG
|
||||
printf ("/%u/%u\n", root->ar_parts[j].ap_st,
|
||||
root->ar_parts[j].ap_size);
|
||||
#endif
|
||||
i++;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
|
||||
if (!disk_write (fd, rsec, 1, root)) {
|
||||
close (fd);
|
||||
free (root);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Note first netbsd partition for invalidate_netbsd_label().
|
||||
*/
|
||||
if (!nbdsec && AHDI_MKPID (ptable->parts[i].id[0],
|
||||
ptable->parts[i].id[1], ptable->parts[i].id[2])
|
||||
== AHDI_PID_NBD) {
|
||||
nbdsec = ptable->parts[i].start;
|
||||
}
|
||||
}
|
||||
|
||||
free (root);
|
||||
|
||||
if (!(flags & AHDI_KEEP_BSL) && !write_bsl (fd)) {
|
||||
close (fd);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (!(flags & AHDI_KEEP_NBDA) && !invalidate_netbsd_label(fd, nbdsec)) {
|
||||
close (fd);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf ("Forcing disk label re-read\n");
|
||||
#endif
|
||||
keep = 0;
|
||||
if (ioctl (fd, DIOCKLABEL, &keep) < 0) {
|
||||
close (fd);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
close (fd);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a bad sector list (empty).
|
||||
*/
|
||||
int
|
||||
write_bsl (fd)
|
||||
int fd;
|
||||
{
|
||||
u_int8_t *bsl;
|
||||
|
||||
if ((bsl = malloc (sizeof (u_int8_t) * BSL_SIZE * DEV_BSIZE)) == NULL)
|
||||
return (0);
|
||||
bzero ((void *) bsl, sizeof (u_int8_t) * DEV_BSIZE);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf ("Writing bad sector list\n");
|
||||
#endif
|
||||
bsl[3] = BSL_MAGIC;
|
||||
if (!disk_write (fd, (u_int) BSL_OFFSET, (u_int) BSL_SIZE, bsl)) {
|
||||
free (bsl);
|
||||
return (0);
|
||||
}
|
||||
free (bsl);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Invalidate any previous AHDI/NBDA disklabel.
|
||||
* Otherwise this make take precedence when we next open the disk.
|
||||
*/
|
||||
int
|
||||
invalidate_netbsd_label (fd, nbdsec)
|
||||
int fd;
|
||||
u_int32_t nbdsec;
|
||||
{
|
||||
struct bootblock *bb;
|
||||
u_int nsec;
|
||||
|
||||
nsec = (BBMINSIZE + (DEV_BSIZE - 1)) / DEV_BSIZE;
|
||||
|
||||
if ((bb = disk_read (fd, nbdsec, nsec)) == NULL) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (bb->bb_magic == NBDAMAGIC || bb->bb_magic == AHDIMAGIC) {
|
||||
bb->bb_magic = bb->bb_magic & 0xffffff00;
|
||||
bb->bb_magic = bb->bb_magic | 0x5f;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf ("Invalidating old NBDA/AHDI label (sector %u)\n",
|
||||
nbdsec);
|
||||
#endif
|
||||
if (!disk_write (fd, nbdsec, nsec, bb)) {
|
||||
free (bb);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
free (bb);
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
disk_write (fd, start, count, buf)
|
||||
int fd;
|
||||
u_int start,
|
||||
count;
|
||||
void *buf;
|
||||
{
|
||||
off_t offset;
|
||||
size_t size;
|
||||
|
||||
size = count * DEV_BSIZE;
|
||||
offset = start * DEV_BSIZE;
|
||||
|
||||
if (lseek (fd, offset, SEEK_SET) != offset)
|
||||
return (0);
|
||||
if (write (fd, buf, size) != size)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
/* $NetBSD: writedtab.c,v 1.1 2000/02/05 20:40:48 jdc Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Julian Coleman, Waldi Ravens and Leo Weppelman.
|
||||
*
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``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 FOUNDATION OR CONTRIBUTORS
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "privahdi.h"
|
||||
#include <disktab.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* Write AHDI partitions to disk
|
||||
*/
|
||||
int
|
||||
ahdi_writedisktab (ptable, disktype, disktab, dtype)
|
||||
struct ahdi_ptable *ptable;
|
||||
char *disktype, *disktab, *dtype;
|
||||
{
|
||||
FILE *fd;
|
||||
int pid, i, j, todo;
|
||||
|
||||
if ((fd = fopen (strlen (disktab) ? disktab : _PATH_DISKTAB, "a"))
|
||||
== NULL)
|
||||
return (-1);
|
||||
|
||||
fprintf (fd, "%s disk|%s:\\\n",
|
||||
strlen (dtype) ? dtype : "SCSI", disktype);
|
||||
fprintf (fd, "\t:ty#winchester:dt=%s:ns#%u:nt#%u:nc#%u:sc#%u:su#%u",
|
||||
strlen (dtype) ? dtype : "SCSI", ptable->nsectors,
|
||||
ptable->ntracks, ptable->ncylinders, ptable->secpercyl,
|
||||
ptable->secperunit);
|
||||
|
||||
todo = ptable->nparts;
|
||||
j = 0;
|
||||
while (todo) {
|
||||
for (i = 0; i < ptable->nparts; i++) {
|
||||
if (j == RAW_PART) {
|
||||
fprintf (fd,
|
||||
"\\\n\t:p%c#%u:o%c#0:t%c=unknown:",
|
||||
RAW_PART + 'a', ptable->secperunit,
|
||||
RAW_PART + 'a', RAW_PART + 'a');
|
||||
break;
|
||||
}
|
||||
if (ptable->parts[i].letter == j) {
|
||||
fprintf (fd, "\\\n\t:p%c#%u:o%c#%u:t%c=",
|
||||
ptable->parts[i].letter + 'a',
|
||||
ptable->parts[i].size,
|
||||
ptable->parts[i].letter + 'a',
|
||||
ptable->parts[i].start,
|
||||
ptable->parts[i].letter + 'a');
|
||||
pid = AHDI_MKPID (ptable->parts[i].id[0],
|
||||
ptable->parts[i].id[1],
|
||||
ptable->parts[i].id[2]);
|
||||
switch (pid) {
|
||||
case AHDI_PID_NBD:
|
||||
fprintf (fd, "4.2BSD:");
|
||||
break;
|
||||
case AHDI_PID_SWP:
|
||||
fprintf (fd, "swap:");
|
||||
break;
|
||||
case AHDI_PID_GEM:
|
||||
case AHDI_PID_BGM:
|
||||
fprintf (fd, "MSDOS:");
|
||||
break;
|
||||
default:
|
||||
fprintf (fd, "unknown:" );
|
||||
}
|
||||
todo--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if (j <= RAW_PART) {
|
||||
fprintf (fd, "\\\n\t:p%c#%u:o%c#0:t%c=unknown:",
|
||||
RAW_PART + 'a', ptable->secperunit,
|
||||
RAW_PART + 'a', RAW_PART + 'a');
|
||||
}
|
||||
fprintf (fd, "\n\n");
|
||||
|
||||
fclose (fd);
|
||||
return (1);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: bsd.README,v 1.60 2000/02/05 20:54:12 jdc Exp $
|
||||
# $NetBSD: bsd.README,v 1.61 2000/03/07 20:55:05 veego Exp $
|
||||
# @(#)bsd.README 8.2 (Berkeley) 4/2/94
|
||||
|
||||
This is the README file for the new make "include" files for the BSD
|
||||
@ -354,7 +354,6 @@ DPADD Additional dependencies for the program. Usually used for
|
||||
The following libraries are predefined for DPADD:
|
||||
|
||||
LIBCRT0?= ${DESTDIR}/usr/lib/crt0.o
|
||||
LIBAHDI?= ${DESTDIR}/usr/lib/libahdi.a
|
||||
LIBC?= ${DESTDIR}/usr/lib/libc.a
|
||||
LIBC_PIC?= ${DESTDIR}/usr/lib/libc_pic.a
|
||||
LIBCOMPAT?= ${DESTDIR}/usr/lib/libcompat.a
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: bsd.hostprog.mk,v 1.6 2000/02/05 20:54:12 jdc Exp $
|
||||
# $NetBSD: bsd.hostprog.mk,v 1.7 2000/03/07 20:55:05 veego Exp $
|
||||
# @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94
|
||||
|
||||
.if !target(__initialized__)
|
||||
@ -17,7 +17,6 @@ clean cleandir distclean: cleanprog
|
||||
|
||||
CFLAGS+= ${COPTS}
|
||||
|
||||
LIBAHDI?= /usr/lib/libahdi.a
|
||||
LIBBZ2?= /usr/lib/libbz2.a
|
||||
LIBC?= /usr/lib/libc.a
|
||||
LIBC_PIC?= /usr/lib/libc_pic.a
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: bsd.prog.mk,v 1.109 2000/02/05 20:54:12 jdc Exp $
|
||||
# $NetBSD: bsd.prog.mk,v 1.110 2000/03/07 20:55:05 veego Exp $
|
||||
# @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94
|
||||
|
||||
.if !target(__initialized__)
|
||||
@ -29,7 +29,6 @@ LIBCRTEND?=
|
||||
|
||||
LIBCRT0?= ${DESTDIR}/usr/lib/crt0.o
|
||||
|
||||
LIBAHDI?= ${DESTDIR}/usr/lib/libahdi.a
|
||||
LIBBZ2?= ${DESTDIR}/usr/lib/libbz2.a
|
||||
LIBC?= ${DESTDIR}/usr/lib/libc.a
|
||||
LIBC_PIC?= ${DESTDIR}/usr/lib/libc_pic.a
|
||||
|
Loading…
Reference in New Issue
Block a user