ReactOS 0.4.15-dev-8127-g6338913
sunlabel.h
Go to the documentation of this file.
1/* @(#)sunlabel.h 1.5 03/12/28 Copyright 1999-2003 J. Schilling */
2/*
3 * Support for Sun disk label
4 *
5 * Copyright (c) 1999-2003 J. Schilling
6 */
7/*
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; see the file COPYING. If not, write to the Free Software
19 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#ifndef howmany
23#define howmany(x, y) (((x)+((y)-1))/(y))
24#endif
25#ifndef roundup
26#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
27#endif
28
29#define NDKMAP 8 /* # of sparc partitions */
30#define NX86MAP 16 /* # if x86 partitions */
31#define DKL_MAGIC 0xDABE /* magic number */
32#define DKL_MAGIC_0 0xDA /* magic number high byte */
33#define DKL_MAGIC_1 0xBE /* magic number low byte */
34
35#define CD_DEFLABEL "CD-ROM Disc with Sun sparc boot created by mkisofs"
36#define CD_X86LABEL "CD-ROM Disc with Sun x86 boot created by mkisofs"
37
38/*
39 * Define a virtual geometry for the CD disk label.
40 * The current values are stolen from Sun install disks and do not seem to be
41 * a good idea as they limit the size of the CD to 327680 sectors which is less
42 * than 74 minutes.
43 * There are 84 minute CD's with 378000 sectors and there will be DVD's with
44 * even more.
45 */
46#define CD_RPM 350
47#define CD_PCYL 2048
48#define CD_APC 0
49#define CD_INTRLV 1
50#define CD_NCYL 2048
51#define CD_ACYL 0
52#define CD_NHEAD 1
53#define CD_NSECT 640
54
55/*
56 * NOTE: The virtual cylinder size on CD must be a mutiple of 2048.
57 * This is true if CD_NSECT is a multiple of 4.
58 */
59#define CD_CYLSIZE (CD_NSECT*CD_NHEAD*512)
60
61#define V_VERSION 1 /* The VTOC version */
62#define VTOC_SANE 0x600DDEEE /* Indicates a sane VTOC */
63
64#define V_ROOT 0x02 /* Root partiton */
65#define V_USR 0x04 /* Usr partiton */
66
67#define V_RONLY 0x10 /* Read only */
68
69/*
70 * The Sun sparc disk label (at offset 0 on a disk)
71 */
72struct sun_label {
73 char dkl_ascilabel[128];
74 struct dk_vtoc {
75 Uchar v_version[4]; /* layout version */
76 char v_volume[8]; /* volume name */
77 Uchar v_nparts[2]; /* number of partitions */
78 struct dk_map2 {
79 Uchar p_tag[2]; /* ID tag of partition */
80 Uchar p_flag[2]; /* permission flag */
81
83 Uchar v_xxpad[2]; /* To come over Sun's alignement problem */
84 Uchar v_bootinfo[3*4]; /* info for mboot */
85 Uchar v_sanity[4]; /* to verify vtoc sanity */
88
89 } dkl_vtoc; /* vtoc inclusions from AT&T SVr4 */
90 char dkl_pad[512-(128+sizeof (struct dk_vtoc)+NDKMAP*8+14*2)];
91 Uchar dkl_rpm[2]; /* rotations per minute */
92 Uchar dkl_pcyl[2]; /* # physical cylinders */
93 Uchar dkl_apc[2]; /* alternates per cylinder */
94 Uchar dkl_obs1[2]; /* obsolete */
95 Uchar dkl_obs2[2]; /* obsolete */
96 Uchar dkl_intrlv[2]; /* interleave factor */
97 Uchar dkl_ncyl[2]; /* # of data cylinders */
98 Uchar dkl_acyl[2]; /* # of alternate cylinders */
99 Uchar dkl_nhead[2]; /* # of heads in this partition */
100 Uchar dkl_nsect[2]; /* # of 512 byte sectors per track */
101 Uchar dkl_obs3[2]; /* obsolete */
102 Uchar dkl_obs4[2]; /* obsolete */
103
104 struct dk_map { /* logical partitions */
105 Uchar dkl_cylno[4]; /* starting cylinder */
106 Uchar dkl_nblk[4]; /* number of blocks */
107 } dkl_map[NDKMAP]; /* logical partition headers */
108
109 Uchar dkl_magic[2]; /* identifies this label format */
110 Uchar dkl_cksum[2]; /* xor checksum of sector */
111};
112
113/*
114 * The Sun x86 / AT&T disk label (at offset 512 on a fdisk partition)
115 */
116struct x86_label {
117 struct x86_vtoc {
118 Uchar v_bootinfo[3*4]; /* unsupported */
119 Uchar v_sanity[4]; /* to verify vtoc sanity */
120 Uchar v_version[4]; /* layout version */
121 char v_volume[8]; /* volume name */
122 Uchar v_sectorsz[2]; /* # of bytes in a sector */
123 Uchar v_nparts[2]; /* # of partitions */
126 Uchar p_tag[2]; /* ID tag of partition */
127 Uchar p_flag[2]; /* permission flag */
128 Uchar p_start[4]; /* starting sector */
129 Uchar p_size[4]; /* number of blocks */
132 char v_asciilabel[128];
133 } dkl_vtoc; /* vtoc inclusions from AT&T SVr4 */
134 Uchar dkl_pcyl[4]; /* # physical cylinders */
135 Uchar dkl_ncyl[4]; /* # of data cylinders */
136 Uchar dkl_acyl[2]; /* # of alternate cylinders */
138 Uchar dkl_nhead[4]; /* # of heads in this partition */
139 Uchar dkl_nsect[4]; /* # of 512 byte sectors per track */
140 Uchar dkl_intrlv[2]; /* interleave factor */
142 Uchar dkl_apc[2]; /* alternates per cylinder */
143 Uchar dkl_rpm[2]; /* rotations per minute */
146 Uchar dkl_extra[4*2]; /* for later expansions */
147 char dkl_pad[512-(sizeof (struct x86_vtoc)+4*4+14*2)];
148 Uchar dkl_magic[2]; /* identifies this label format */
149 Uchar dkl_cksum[2]; /* xor checksum of sector */
150};
151
152/*
153 * One x86 PC fdisk partition record.
154 */
155struct pc_pr {
156 Uchar pr_status; /* Boot status */
157 Uchar pr_head; /* Starting head # */
158 char pr_sec_cyl[2]; /* Starting sec+cyl # */
159 Uchar pr_type; /* Partition type */
160 Uchar pr_e_head; /* Ending head # */
161 char pr_e_sec_cyl[2]; /* Ending sec+cyl # */
162 char pr_partoff[4]; /* Partition start sector # */
163 char pr_nsect[4]; /* # of sectors in partition */
164};
165
166/*
167 * Flags and macros for above partition record.
168 */
169#define SEC_MASK 0x3F
170#define GET_SEC(a) ((a) & SEC_MASK)
171#define GET_CYL(a) ((((a) & 0xFF) >> 8) | (((a) & 0xC0) << 2))
172
173#define STATUS_INACT 0 /* Marked non bootable */
174#define STATUS_ACTIVE 0x80 /* Marked as bootable */
175
176#define TYPE_FREE 0 /* Unused partition */
177#define TYPE_DOS12 0x01 /* FAT12 fileystem */
178#define TYPE_XENIX 0x02 /* XENIX root */
179#define TYPE_XENIX2 0x03 /* XENIX usr */
180#define TYPE_DOS16 0x04 /* FAT16 filesystem */
181#define TYPE_XDOS 0x05 /* Extended DOS part */
182#define TYPE_DOS4 0x06 /* FAT16 >= 32 MB */
183#define TYPE_SOLARIS 0x82 /* Solaris x86 */
184#define TYPE_SOLARIS_BOOT 0xBE /* Solaris boot */
185#define TYPE_CDOS4 0xDB /* CPM */
186
187/*
188 * The first sector on a disk from a x86 PC (at offset 0 on a disk)
189 */
190struct pc_part {
191 char bootcode[0x1BE]; /* Master boot record */
192 struct pc_pr part[4]; /* The 4 primary partitions */
193 Uchar magic[2]; /* Fixed at 0x55 0xAA */
194};
struct pc_pr part[4]
Definition: sunlabel.h:192
char bootcode[0x1BE]
Definition: sunlabel.h:191
Uchar magic[2]
Definition: sunlabel.h:193
char pr_nsect[4]
Definition: sunlabel.h:163
char pr_partoff[4]
Definition: sunlabel.h:162
Uchar pr_e_head
Definition: sunlabel.h:160
Uchar pr_type
Definition: sunlabel.h:159
Uchar pr_status
Definition: sunlabel.h:156
char pr_sec_cyl[2]
Definition: sunlabel.h:158
char pr_e_sec_cyl[2]
Definition: sunlabel.h:161
Uchar pr_head
Definition: sunlabel.h:157
Uchar dkl_cylno[4]
Definition: sunlabel.h:105
Uchar dkl_nblk[4]
Definition: sunlabel.h:106
char v_volume[8]
Definition: sunlabel.h:76
Uchar v_timestamp[NDKMAP *4]
Definition: sunlabel.h:87
struct sun_label::dk_vtoc::dk_map2 v_part[NDKMAP]
Uchar v_version[4]
Definition: sunlabel.h:75
Uchar v_sanity[4]
Definition: sunlabel.h:85
Uchar v_bootinfo[3 *4]
Definition: sunlabel.h:84
Uchar v_reserved[10 *4]
Definition: sunlabel.h:86
Uchar v_nparts[2]
Definition: sunlabel.h:77
Uchar v_xxpad[2]
Definition: sunlabel.h:83
Uchar dkl_rpm[2]
Definition: sunlabel.h:91
struct sun_label::dk_map dkl_map[NDKMAP]
Uchar dkl_apc[2]
Definition: sunlabel.h:93
Uchar dkl_pcyl[2]
Definition: sunlabel.h:92
char dkl_ascilabel[128]
Definition: sunlabel.h:73
Uchar dkl_nhead[2]
Definition: sunlabel.h:99
Uchar dkl_magic[2]
Definition: sunlabel.h:109
Uchar dkl_intrlv[2]
Definition: sunlabel.h:96
Uchar dkl_acyl[2]
Definition: sunlabel.h:98
struct sun_label::dk_vtoc dkl_vtoc
Uchar dkl_ncyl[2]
Definition: sunlabel.h:97
Uchar dkl_cksum[2]
Definition: sunlabel.h:110
Uchar dkl_nsect[2]
Definition: sunlabel.h:100
Uchar dkl_obs1[2]
Definition: sunlabel.h:94
Uchar dkl_obs2[2]
Definition: sunlabel.h:95
Uchar dkl_obs3[2]
Definition: sunlabel.h:101
char dkl_pad[512-(128+sizeof(struct dk_vtoc)+NDKMAP *8+14 *2)]
Definition: sunlabel.h:90
Uchar dkl_obs4[2]
Definition: sunlabel.h:102
Uchar v_nparts[2]
Definition: sunlabel.h:123
Uchar v_version[4]
Definition: sunlabel.h:120
Uchar v_sanity[4]
Definition: sunlabel.h:119
Uchar v_reserved[10 *4]
Definition: sunlabel.h:124
Uchar v_bootinfo[3 *4]
Definition: sunlabel.h:118
struct x86_label::x86_vtoc::dkl_partition v_part[NX86MAP]
Uchar v_sectorsz[2]
Definition: sunlabel.h:122
char v_asciilabel[128]
Definition: sunlabel.h:132
struct x86_label::x86_vtoc dkl_vtoc
Uchar dkl_intrlv[2]
Definition: sunlabel.h:140
Uchar dkl_ncyl[4]
Definition: sunlabel.h:135
Uchar dkl_nhead[4]
Definition: sunlabel.h:138
Uchar dkl_nsect[4]
Definition: sunlabel.h:139
Uchar dkl_extra[4 *2]
Definition: sunlabel.h:146
Uchar dkl_cksum[2]
Definition: sunlabel.h:149
Uchar dkl_magic[2]
Definition: sunlabel.h:148
Uchar dkl_rpm[2]
Definition: sunlabel.h:143
char dkl_pad[512-(sizeof(struct x86_vtoc)+4 *4+14 *2)]
Definition: sunlabel.h:147
Uchar dkl_read_reinstruct[2]
Definition: sunlabel.h:145
Uchar dkl_bcyl[2]
Definition: sunlabel.h:137
Uchar dkl_pcyl[4]
Definition: sunlabel.h:134
Uchar dkl_write_reinstruct[2]
Definition: sunlabel.h:144
Uchar dkl_apc[2]
Definition: sunlabel.h:142
Uchar dkl_skew[2]
Definition: sunlabel.h:141
Uchar dkl_acyl[2]
Definition: sunlabel.h:136
#define NX86MAP
Definition: sunlabel.h:30
#define NDKMAP
Definition: sunlabel.h:29
unsigned char Uchar
Definition: utypes.h:45