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