1 /** $MirOS: src/sbin/fdisk/mbr.h,v 1.3 2008/04/07 05:57:16 tg Exp $ */ 2 /* $OpenBSD: mbr.h,v 1.11 2003/06/03 01:13:19 weingart Exp $ */ 3 4 /* 5 * Copyright (c) 1997 Tobias Weingartner 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef _MBR_H 30 #define _MBR_H 31 32 #include "part.h" 33 34 /* Various constants */ 35 #define MBR_CODE_SIZE 0x1BE /* all of boot code */ 36 #define MBR_SMALLCODE_SIZE 0x1B7 /* not the fdef flag and NT magic */ 37 #define MBR_PART_SIZE 0x10 /* size of one PTBL entry */ 38 #define MBR_FORCE_DEFPART 0x1B7 /* offset of the fdef flag */ 39 #define MBR_DISKSIG_OFF 0x1B8 /* offset of the disc signature */ 40 #define MBR_PART_OFF 0x1BE /* offset of first PTBL entry */ 41 #define MBR_SIG_OFF 0x1FE /* offset of the 55AA signature */ 42 43 /* MBR type */ 44 typedef struct _mbr_t { 45 off_t reloffset; 46 off_t offset; 47 unsigned char code[MBR_CODE_SIZE]; 48 prt_t part[NDOSPART]; 49 unsigned short signature; 50 } mbr_t; 51 52 /* Prototypes */ 53 void MBR_print_disk(char *); 54 void MBR_print(mbr_t *, char *); 55 void MBR_parse(disk_t *, char *, off_t, off_t, mbr_t *); 56 void MBR_make(mbr_t *, char *); 57 void MBR_init(disk_t *, mbr_t *); 58 int MBR_read(int, off_t, char *); 59 int MBR_write(int, off_t, char *); 60 void MBR_pcopy(disk_t *, mbr_t *); 61 62 /* Sanity check */ 63 #include <machine/param.h> 64 #if (DEV_BSIZE != 512) 65 #error "DEV_BSIZE != 512, somebody better fix me!" 66 #endif 67 68 #endif /* _MBR_H */ 69