1139825Simp/*-
21541Srgrimes * Copyright (c) 1987, 1988, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes *
51541Srgrimes * Redistribution and use in source and binary forms, with or without
61541Srgrimes * modification, are permitted provided that the following conditions
71541Srgrimes * are met:
81541Srgrimes * 1. Redistributions of source code must retain the above copyright
91541Srgrimes *    notice, this list of conditions and the following disclaimer.
101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111541Srgrimes *    notice, this list of conditions and the following disclaimer in the
121541Srgrimes *    documentation and/or other materials provided with the distribution.
131541Srgrimes * 4. Neither the name of the University nor the names of its contributors
141541Srgrimes *    may be used to endorse or promote products derived from this software
151541Srgrimes *    without specific prior written permission.
161541Srgrimes *
171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271541Srgrimes * SUCH DAMAGE.
281541Srgrimes *
2914478Shsu *	@(#)disklabel.h	8.2 (Berkeley) 7/10/94
3050477Speter * $FreeBSD$
311541Srgrimes */
321541Srgrimes
33104314Sphk#ifndef _SYS_DISKMBR_H_
34104314Sphk#define	_SYS_DISKMBR_H_
352165Spaul
36108392Sphk#include <sys/ioccom.h>
37108392Sphk
3816363Sasami#define	DOSBBSECTOR	0	/* DOS boot block relative sector number */
39223587Sae#define	DOSDSNOFF	440	/* WinNT/2K/XP Drive Serial Number offset */
4093582Sphk#define	DOSPARTOFF	446
41113452Sphk#define	DOSPARTSIZE	16
4293582Sphk#define	NDOSPART	4
43109556Sphk#define	NEXTDOSPART	32
44113452Sphk#define	DOSMAGICOFFSET	510
45113452Sphk#define	DOSMAGIC	0xAA55
46113452Sphk
47218014Sae#define	DOSPTYP_EXT	0x05	/* DOS extended partition */
48247961Sgavin#define	DOSPTYP_FAT16	0x06	/* FAT16 partition */
49218014Sae#define	DOSPTYP_NTFS	0x07	/* NTFS partition */
50218014Sae#define	DOSPTYP_FAT32	0x0b	/* FAT32 partition */
51218014Sae#define	DOSPTYP_EXTLBA	0x0f	/* DOS extended partition */
52230522Snwhitehorn#define	DOSPTYP_PPCBOOT	0x41	/* PReP/CHRP boot partition */
53231367Sae#define	DOSPTYP_LDM	0x42	/* Win2k dynamic extended partition */
5459771Sjlemon#define	DOSPTYP_LINSWP	0x82	/* Linux swap partition */
5559771Sjlemon#define	DOSPTYP_LINUX	0x83	/* Linux partition */
56218014Sae#define	DOSPTYP_LINLVM	0x8e	/* Linux LVM partition */
57282861Sae#define	DOSPTYP_386BSD	0xa5	/* 386BSD partition type */
58282861Sae#define	DOSPTYP_APPLE_UFS	0xa8	/* Apple Mac OS X boot */
59282861Sae#define	DOSPTYP_APPLE_BOOT	0xab	/* Apple Mac OS X UFS */
60282861Sae#define	DOSPTYP_HFS	0xaf	/* HFS/HFS+ partition type */
61113030Sphk#define	DOSPTYP_PMBR	0xee	/* GPT Protective MBR */
62234417Smarck#define	DOSPTYP_VMFS	0xfb	/* VMware VMFS partition */
63234417Smarck#define	DOSPTYP_VMKDIAG	0xfc	/* VMware vmkDiagnostic partition */
64218014Sae#define	DOSPTYP_LINRAID	0xfd	/* Linux raid partition */
651549Srgrimes
661549Srgrimesstruct dos_partition {
671549Srgrimes	unsigned char	dp_flag;	/* bootstrap flags */
681549Srgrimes	unsigned char	dp_shd;		/* starting head */
691549Srgrimes	unsigned char	dp_ssect;	/* starting sector */
701549Srgrimes	unsigned char	dp_scyl;	/* starting cylinder */
711549Srgrimes	unsigned char	dp_typ;		/* partition type */
721549Srgrimes	unsigned char	dp_ehd;		/* end head */
731549Srgrimes	unsigned char	dp_esect;	/* end sector */
741549Srgrimes	unsigned char	dp_ecyl;	/* end cylinder */
7537466Sbde	u_int32_t	dp_start;	/* absolute starting sector number */
7637466Sbde	u_int32_t	dp_size;	/* partition size in sectors */
771549Srgrimes};
7893773Sphk#ifdef CTASSERT
79113452SphkCTASSERT(sizeof (struct dos_partition) == DOSPARTSIZE);
8016363Sasami#endif
811549Srgrimes
82113394Sphkvoid dos_partition_dec(void const *pp, struct dos_partition *d);
83113394Sphkvoid dos_partition_enc(void *pp, struct dos_partition *d);
84113394Sphk
8593582Sphk#define	DPSECT(s) ((s) & 0x3f)		/* isolate relevant bits of sector */
8693582Sphk#define	DPCYL(c, s) ((c) + (((s) & 0xc0)<<2)) /* and those that are cylinder */
871549Srgrimes
88108392Sphk#define DIOCSMBR 	_IOW('M', 129, u_char[512])
89108392Sphk
90104314Sphk#endif /* !_SYS_DISKMBR_H_ */
91