patch genisoimage multi extent
[platform/upstream/cdrkit.git] / genisoimage / mac_label.h
1 /*
2  * This file has been modified for the cdrkit suite.
3  *
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).
6  *
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.
10  *
11  */
12
13 /* @(#)mac_label.h      1.3 04/03/01 joerg, Copyright 1997, 1998, 1999, 2000 James Pearson */
14 /*
15  *      Copyright (c) 1997, 1998, 1999, 2000 James Pearson
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation; either version 2, or (at your option)
20  * any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; see the file COPYING.  If not, write to
29  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
30  */
31
32 /*
33  *      mac_label.h: defines Macintosh partition maps and label
34  *
35  *      Taken from "genisoimage 1.05 PLUS" by Andy Polyakov <appro@fy.chalmers.se>
36  *      (see http://fy.chalmers.se/~appro/genisoimage_plus.html for details)
37  *
38  *      Much of this is already defined in the libhfs code, but to keep
39  *      things simple we stick with these.
40  */
41
42 #ifndef _MAC_LABEL_H
43 #define _MAC_LABEL_H
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49 #ifdef PREP_BOOT
50 struct fdiskPartition {
51 #define prepPartType 0x41
52 #define chrpPartType 0x96
53         unsigned char   boot;           /* bootable flag; not used */
54         unsigned char   CHSstart[3];    /* start CHS; not used */
55         unsigned char   type;           /* Partition type, = 0x41 (PReP bootable) */
56         unsigned char   CHSend[3];      /* end CHS; not used */
57         unsigned char   startSect[4];   /* start sector (really start of boot image on CD */
58         unsigned char   size[4];        /* size of partition (or boot image ;) ) */
59 };
60 typedef struct fdiskPartition fdiskPartition;
61 #endif
62
63 /* Driver Descriptor Map */
64 #define sbSigMagic      "ER"
65 struct MacLabel {
66         unsigned char   sbSig[2];       /* unique value for SCSI block 0 */
67         unsigned char   sbBlkSize[2];   /* block size of device */
68         unsigned char   sbBlkCount[4];  /* number of blocks on device */
69         unsigned char   sbDevType[2];   /* device type */
70         unsigned char   sbDevId[2];     /* device id */
71         unsigned char   sbData[4];      /* not used */
72         unsigned char   sbDrvrCount[2]; /* driver descriptor count */
73         unsigned char   ddBlock[4];     /* 1st driver's starting block */
74         unsigned char   ddSize[2];      /* size of 1st driver (512-byte blks) */
75         unsigned char   ddType[2];      /* system type (1 for Mac+) */
76 #ifndef PREP_BOOT
77         unsigned char   ddPad[486];     /* ARRAY[0..242] OF INTEGER; not used */
78 #else
79 #define fdiskMagic0 0x55
80 #define fdiskMagic1 0xAA
81         unsigned char   pad1[420];      /* not used */
82         fdiskPartition  image[4];       /* heh heh heh, we can have up to 4 */
83                                         /* different boot images */
84         unsigned char   fdiskMagic[2];  /* PReP uses fdisk partition map */
85 #endif /* PREP_BOOT */
86 };
87 typedef struct MacLabel MacLabel;
88
89 #define IS_MAC_LABEL(d)         (((MacLabel*)(d))->sbSig[0] == 'E' && \
90                                 ((MacLabel*)(d))->sbSig[1] == 'R')
91
92 /* Partition Map Entry */
93 #define pmSigMagic      "PM"
94
95 #define pmPartType_1    "Apple_partition_map"
96 #define pmPartName_11   "Apple"
97
98 #define pmPartType_2    "Apple_Driver"
99 #define pmPartType_21   "Apple_Driver43"
100
101 #define pmPartType_3    "Apple_UNIX_SVR2"
102 #define pmPartName_31   "A/UX Root"
103 #define pmPartName_32   "A/UX Usr"
104 #define pmPartName_33   "Random A/UX fs"
105 #define pmPartName_34   "Swap"
106
107 #define pmPartType_4    "Apple_HFS"
108 #define pmPartName_41   "MacOS"
109
110 #define pmPartType_5    "Apple_Free"
111 #define pmPartName_51   "Extra"
112
113 #define PM2     2
114 #define PM4     4
115
116 struct MacPart {
117         unsigned char   pmSig[2];       /* unique value for map entry blk */
118         unsigned char   pmSigPad[2];    /* currently unused */
119         unsigned char   pmMapBlkCnt[4]; /* # of blks in partition map */
120         unsigned char   pmPyPartStart[4]; /* physical start blk of partition */
121         unsigned char   pmPartBlkCnt[4];  /* # of blks in this partition */
122         unsigned char   pmPartName[32];   /* ASCII partition name */
123         unsigned char   pmPartType[32];   /* ASCII partition type */
124         unsigned char   pmLgDataStart[4]; /* log. # of partition's 1st data blk */
125         unsigned char   pmDataCnt[4];     /* # of blks in partition's data area */
126         unsigned char   pmPartStatus[4];  /* bit field for partition status */
127         unsigned char   pmLgBootStart[4]; /* log. blk of partition's boot code */
128         unsigned char   pmBootSize[4];  /* number of bytes in boot code */
129         unsigned char   pmBootAddr[4];  /* memory load address of boot code */
130         unsigned char   pmBootAddr2[4]; /* currently unused */
131         unsigned char   pmBootEntry[4]; /* entry point of boot code */
132         unsigned char   pmBootEntry2[4]; /* currently unused */
133         unsigned char   pmBootCksum[4];  /* checksum of boot code */
134         unsigned char   pmProcessor[16]; /* ASCII for the processor type */
135         unsigned char   pmPad[376];      /* ARRAY[0..187] OF INTEGER; not used */
136 };
137 typedef struct MacPart MacPart;
138
139 #define IS_MAC_PART(d)          (((MacPart*)(d))->pmSig[0] == 'P' && \
140                                 ((MacPart*)(d))->pmSig[1] == 'M')
141
142 #define PM_STAT_VALID           0x01    /* Set if a valid partition map entry */
143 #define PM_STAT_ALLOC           0x02    /* Set if partition is already allocated; clear if available */
144 #define PM_STAT_INUSE           0x04    /* Set if partition is in use; may be cleared after a system reset */
145 #define PM_STAT_BOOTABLE        0x08    /* Set if partition contains valid boot information */
146 #define PM_STAT_READABLE        0x10    /* Set if partition allows reading */
147 #define PM_STAT_WRITABLE        0x20    /* Set if partition allows writing */
148 #define PM_STAT_BOOT_PIC        0x40    /* Set if boot code is position-independent */
149 #define PM_STAT_UNUSED          0x80    /* Unused */
150 #define PM_STAT_DEFAULT         PM_STAT_VALID|PM_STAT_ALLOC|PM_STAT_READABLE|PM_STAT_WRITABLE
151
152 typedef struct {
153         char *name;                     /* Partition name */
154         char *type;                     /* Partition type */
155         int   ntype;                    /* Partition type (numeric) */
156         int   start;                    /* start extent (SECTOR_SIZE blocks) */
157         int   size;                     /* extents (SECTOR_SIZE blocks) */
158 } mac_partition_table;
159
160 /* from libhfs */
161 #define HFS_BB_SIGWORD          0x4c4b
162
163 typedef struct deferred_write defer;
164
165 #ifdef __cplusplus
166 }
167 #endif
168
169 #endif /* _MAC_LABEL_H */