1*f6aac1c3SLionel Sambuc /* $NetBSD: disklabel.h,v 1.16 2011/08/30 12:39:55 bouyer Exp $ */ 2*f6aac1c3SLionel Sambuc 3*f6aac1c3SLionel Sambuc /* 4*f6aac1c3SLionel Sambuc * Copyright (c) 1994 Christopher G. Demetriou 5*f6aac1c3SLionel Sambuc * All rights reserved. 6*f6aac1c3SLionel Sambuc * 7*f6aac1c3SLionel Sambuc * Redistribution and use in source and binary forms, with or without 8*f6aac1c3SLionel Sambuc * modification, are permitted provided that the following conditions 9*f6aac1c3SLionel Sambuc * are met: 10*f6aac1c3SLionel Sambuc * 1. Redistributions of source code must retain the above copyright 11*f6aac1c3SLionel Sambuc * notice, this list of conditions and the following disclaimer. 12*f6aac1c3SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright 13*f6aac1c3SLionel Sambuc * notice, this list of conditions and the following disclaimer in the 14*f6aac1c3SLionel Sambuc * documentation and/or other materials provided with the distribution. 15*f6aac1c3SLionel Sambuc * 3. All advertising materials mentioning features or use of this software 16*f6aac1c3SLionel Sambuc * must display the following acknowledgement: 17*f6aac1c3SLionel Sambuc * This product includes software developed by Christopher G. Demetriou. 18*f6aac1c3SLionel Sambuc * 4. The name of the author may not be used to endorse or promote products 19*f6aac1c3SLionel Sambuc * derived from this software without specific prior written permission 20*f6aac1c3SLionel Sambuc * 21*f6aac1c3SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22*f6aac1c3SLionel Sambuc * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23*f6aac1c3SLionel Sambuc * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24*f6aac1c3SLionel Sambuc * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25*f6aac1c3SLionel Sambuc * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26*f6aac1c3SLionel Sambuc * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27*f6aac1c3SLionel Sambuc * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28*f6aac1c3SLionel Sambuc * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29*f6aac1c3SLionel Sambuc * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30*f6aac1c3SLionel Sambuc * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31*f6aac1c3SLionel Sambuc */ 32*f6aac1c3SLionel Sambuc 33*f6aac1c3SLionel Sambuc #ifndef _I386_DISKLABEL_H_ 34*f6aac1c3SLionel Sambuc #define _I386_DISKLABEL_H_ 35*f6aac1c3SLionel Sambuc 36*f6aac1c3SLionel Sambuc #define LABELUSESMBR 1 /* use MBR partitionning */ 37*f6aac1c3SLionel Sambuc #define LABELSECTOR 1 /* sector containing label */ 38*f6aac1c3SLionel Sambuc #define LABELOFFSET 0 /* offset of label in sector */ 39*f6aac1c3SLionel Sambuc #define MAXPARTITIONS 16 /* number of partitions */ 40*f6aac1c3SLionel Sambuc #define OLDMAXPARTITIONS 8 /* number of partitions before 1.6 */ 41*f6aac1c3SLionel Sambuc #define RAW_PART 3 /* raw partition: XX?d (XXX) */ 42*f6aac1c3SLionel Sambuc 43*f6aac1c3SLionel Sambuc /* 44*f6aac1c3SLionel Sambuc * We use the highest bit of the minor number for the partition number. 45*f6aac1c3SLionel Sambuc * This maintains backward compatibility with device nodes created before 46*f6aac1c3SLionel Sambuc * MAXPARTITIONS was increased. 47*f6aac1c3SLionel Sambuc */ 48*f6aac1c3SLionel Sambuc #define __I386_MAXDISKS ((1 << 20) / MAXPARTITIONS) 49*f6aac1c3SLionel Sambuc #define DISKUNIT(dev) ((minor(dev) / OLDMAXPARTITIONS) % __I386_MAXDISKS) 50*f6aac1c3SLionel Sambuc #define DISKPART(dev) ((minor(dev) % OLDMAXPARTITIONS) + \ 51*f6aac1c3SLionel Sambuc ((minor(dev) / (__I386_MAXDISKS * OLDMAXPARTITIONS)) * OLDMAXPARTITIONS)) 52*f6aac1c3SLionel Sambuc #define DISKMINOR(unit, part) \ 53*f6aac1c3SLionel Sambuc (((unit) * OLDMAXPARTITIONS) + ((part) % OLDMAXPARTITIONS) + \ 54*f6aac1c3SLionel Sambuc ((part) / OLDMAXPARTITIONS) * (__I386_MAXDISKS * OLDMAXPARTITIONS)) 55*f6aac1c3SLionel Sambuc 56*f6aac1c3SLionel Sambuc /* Pull in MBR partition definitions. */ 57*f6aac1c3SLionel Sambuc #if HAVE_NBTOOL_CONFIG_H 58*f6aac1c3SLionel Sambuc #include <nbinclude/sys/bootblock.h> 59*f6aac1c3SLionel Sambuc #else 60*f6aac1c3SLionel Sambuc #include <sys/bootblock.h> 61*f6aac1c3SLionel Sambuc #endif /* HAVE_NBTOOL_CONFIG_H */ 62*f6aac1c3SLionel Sambuc 63*f6aac1c3SLionel Sambuc #ifndef __ASSEMBLER__ 64*f6aac1c3SLionel Sambuc #if HAVE_NBTOOL_CONFIG_H 65*f6aac1c3SLionel Sambuc #include <nbinclude/sys/dkbad.h> 66*f6aac1c3SLionel Sambuc #else 67*f6aac1c3SLionel Sambuc #include <sys/dkbad.h> 68*f6aac1c3SLionel Sambuc #endif /* HAVE_NBTOOL_CONFIG_H */ 69*f6aac1c3SLionel Sambuc struct cpu_disklabel { 70*f6aac1c3SLionel Sambuc #define __HAVE_DISKLABEL_DKBAD 71*f6aac1c3SLionel Sambuc struct dkbad bad; 72*f6aac1c3SLionel Sambuc }; 73*f6aac1c3SLionel Sambuc #endif 74*f6aac1c3SLionel Sambuc 75*f6aac1c3SLionel Sambuc #endif /* _I386_DISKLABEL_H_ */ 76