1 /*
2  * osta_udf.h
3  *
4  * This file is based on OSTA UDF(tm) 2.01 (March 15, 2000)
5  * http://www.osta.org
6  *
7  * Copyright (c) 2001-2002  Ben Fennema <bfennema@falcon.csc.calpoly.edu>
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions, and the following disclaimer,
15  *    without modification.
16  * 2. The name of the author may not be used to endorse or promote products
17  *    derived from this software without specific prior written permission.
18  *
19  * Alternatively, this software may be distributed under the terms of the
20  * GNU Public License ("GPL").
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
26  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  */
34 
35 #include "ecma_167.h"
36 
37 #ifndef _OSTA_UDF_H
38 #define _OSTA_UDF_H 1
39 
40 /* OSTA CS0 Charspec (UDF 2.01 2.1.2) */
41 #define UDF_CHAR_SET_TYPE		0
42 #define UDF_CHAR_SET_INFO		"OSTA Compressed Unicode"
43 
44 /* Entity Identifier (UDF 2.01 2.1.5) */
45 /* Identifiers (UDF 2.01 2.1.5.2) */
46 #define UDF_ID_DEVELOPER		"*Linux UDFFS"
47 #define	UDF_ID_COMPLIANT		"*OSTA UDF Compliant"
48 #define UDF_ID_LV_INFO			"*UDF LV Info"
49 #define UDF_ID_FREE_EA			"*UDF FreeEASpace"
50 #define UDF_ID_FREE_APP_EA		"*UDF FreeAppEASpace"
51 #define UDF_ID_DVD_CGMS			"*UDF DVD CGMS Info"
52 #define UDF_ID_OS2_EA			"*UDF OS/2 EA"
53 #define UDF_ID_OS2_EA_LENGTH		"*UDF OS/2 EALength"
54 #define UDF_ID_MAC_VOLUME		"*UDF Mac VolumeInfo"
55 #define UDF_ID_MAC_FINDER		"*UDF Mac FinderInfo"
56 #define UDF_ID_MAC_UNIQUE		"*UDF Mac UniqueIDTable"
57 #define UDF_ID_MAC_RESOURCE		"*UDF Mac ResourceFork"
58 #define UDF_ID_VIRTUAL			"*UDF Virtual Partition"
59 #define UDF_ID_SPARABLE			"*UDF Sparable Partition"
60 #define UDF_ID_ALLOC			"*UDF Virtual Alloc Tbl"
61 #define UDF_ID_SPARING			"*UDF Sparing Table"
62 
63 /* Identifier Suffix (UDF 2.01 2.1.5.3) */
64 #define IS_DF_HARD_WRITE_PROTECT	0x01
65 #define IS_DF_SOFT_WRITE_PROTECT	0x02
66 
67 struct UDFIdentSuffix
68 {
69 	uint16_t	UDFRevision;
70 	uint8_t		OSClass;
71 	uint8_t		OSIdentifier;
72 	uint8_t		reserved[4];
73 } __attribute__ ((packed));
74 
75 struct impIdentSuffix
76 {
77 	uint8_t		OSClass;
78 	uint8_t		OSIdentifier;
79 	uint8_t		reserved[6];
80 } __attribute__ ((packed));
81 
82 struct appIdentSuffix
83 {
84 	uint8_t		impUse[8];
85 } __attribute__ ((packed));
86 
87 /* Logical Volume Integrity Descriptor (UDF 2.01 2.2.6) */
88 /* Implementation Use (UDF 2.01 2.2.6.4) */
89 struct logicalVolIntegrityDescImpUse
90 {
91 	regid		impIdent;
92 	uint32_t	numFiles;
93 	uint32_t	numDirs;
94 	uint16_t	minUDFReadRev;
95 	uint16_t	minUDFWriteRev;
96 	uint16_t	maxUDFWriteRev;
97 	uint8_t		impUse[0];
98 } __attribute__ ((packed));
99 
100 /* Implementation Use Volume Descriptor (UDF 2.01 2.2.7) */
101 /* Implementation Use (UDF 2.01 2.2.7.2) */
102 struct impUseVolDescImpUse
103 {
104 	charspec	LVICharset;
105 	dstring		logicalVolIdent[128];
106 	dstring		LVInfo1[36];
107 	dstring		LVInfo2[36];
108 	dstring		LVInfo3[36];
109 	regid		impIdent;
110 	uint8_t		impUse[128];
111 } __attribute__ ((packed));
112 
113 struct udfPartitionMap2
114 {
115 	uint8_t		partitionMapType;
116 	uint8_t		partitionMapLength;
117 	uint8_t		reserved1[2];
118 	regid		partIdent;
119 	uint16_t	volSeqNum;
120 	uint16_t	partitionNum;
121 } __attribute__ ((packed));
122 
123 /* Virtual Partition Map (UDF 2.01 2.2.8) */
124 struct virtualPartitionMap
125 {
126 	uint8_t		partitionMapType;
127 	uint8_t		partitionMapLength;
128 	uint8_t		reserved1[2];
129 	regid		partIdent;
130 	uint16_t	volSeqNum;
131 	uint16_t	partitionNum;
132 	uint8_t		reserved2[24];
133 } __attribute__ ((packed));
134 
135 /* Sparable Partition Map (UDF 2.01 2.2.9) */
136 struct sparablePartitionMap
137 {
138 	uint8_t		partitionMapType;
139 	uint8_t		partitionMapLength;
140 	uint8_t		reserved1[2];
141 	regid		partIdent;
142 	uint16_t	volSeqNum;
143 	uint16_t	partitionNum;
144 	uint16_t	packetLength;
145 	uint8_t		numSparingTables;
146 	uint8_t		reserved2[1];
147 	uint32_t	sizeSparingTable;
148 	uint32_t	locSparingTable[4];
149 } __attribute__ ((packed));
150 
151 /* Virtual Allocation Table (UDF 1.5 2.2.10) */
152 struct virtualAllocationTable15
153 {
154 	uint32_t	VirtualSector[0];
155 	regid		ident;
156 	uint32_t	previousVATICB;
157 } __attribute__ ((packed));
158 
159 #define ICBTAG_FILE_TYPE_VAT15		0x00U
160 
161 /* Virtual Allocation Table (UDF 2.01 2.2.10) */
162 struct virtualAllocationTable20
163 {
164 	uint16_t	lengthHeader;
165 	uint16_t	lengthImpUse;
166 	dstring		logicalVolIdent[128];
167 	uint32_t	previousVatICBLoc;
168 	uint32_t	numFIDSFiles;
169 	uint32_t	numFIDSDirectories;
170 	uint16_t	minReadRevision;
171 	uint16_t	minWriteRevision;
172 	uint16_t	maxWriteRevision;
173 	uint16_t	reserved;
174 	uint8_t		impUse[0];
175 	uint32_t	vatEntry[0];
176 } __attribute__ ((packed));
177 
178 #define ICBTAG_FILE_TYPE_VAT20		0xF8U
179 
180 /* Sparing Table (UDF 2.01 2.2.11) */
181 struct sparingEntry
182 {
183 	uint32_t	origLocation;
184 	uint32_t	mappedLocation;
185 } __attribute__ ((packed));
186 
187 struct sparingTable
188 {
189 	tag 		descTag;
190 	regid		sparingIdent;
191 	uint16_t	reallocationTableLen;
192 	uint16_t	reserved;
193 	uint32_t	sequenceNum;
194 	struct sparingEntry
195 			mapEntry[0];
196 } __attribute__ ((packed));
197 
198 /* struct long_ad ICB - ADImpUse (UDF 2.01 2.2.4.3) */
199 struct allocDescImpUse
200 {
201 	uint16_t	flags;
202 	uint8_t		impUse[4];
203 } __attribute__ ((packed));
204 
205 #define AD_IU_EXT_ERASED		0x0001
206 
207 /* Real-Time Files (UDF 2.01 6.11) */
208 #define ICBTAG_FILE_TYPE_REALTIME	0xF9U
209 
210 /* Implementation Use Extended Attribute (UDF 2.01 3.3.4.5) */
211 /* FreeEASpace (UDF 2.01 3.3.4.5.1.1) */
212 struct freeEaSpace
213 {
214 	uint16_t	headerChecksum;
215 	uint8_t		freeEASpace[0];
216 } __attribute__ ((packed));
217 
218 /* DVD Copyright Management Information (UDF 2.01 3.3.4.5.1.2) */
219 struct DVDCopyrightImpUse
220 {
221 	uint16_t	headerChecksum;
222 	uint8_t		CGMSInfo;
223 	uint8_t		dataType;
224 	uint8_t		protectionSystemInfo[4];
225 } __attribute__ ((packed));
226 
227 /* Application Use Extended Attribute (UDF 2.01 3.3.4.6) */
228 /* FreeAppEASpace (UDF 2.01 3.3.4.6.1) */
229 struct freeAppEASpace
230 {
231 	uint16_t	headerChecksum;
232 	uint8_t		freeEASpace[0];
233 } __attribute__ ((packed));
234 
235 /* UDF Defined System Stream (UDF 2.01 3.3.7) */
236 #define UDF_ID_UNIQUE_ID		"*UDF Unique ID Mapping Data"
237 #define UDF_ID_NON_ALLOC		"*UDF Non-Allocatable Space"
238 #define UDF_ID_POWER_CAL		"*UDF Power Cal Table"
239 #define UDF_ID_BACKUP			"*UDF Backup"
240 
241 /* Operating System Identifiers (UDF 2.01 6.3) */
242 #define UDF_OS_CLASS_UNDEF		0x00U
243 #define UDF_OS_CLASS_DOS		0x01U
244 #define UDF_OS_CLASS_OS2		0x02U
245 #define UDF_OS_CLASS_MAC		0x03U
246 #define UDF_OS_CLASS_UNIX		0x04U
247 #define UDF_OS_CLASS_WIN9X		0x05U
248 #define UDF_OS_CLASS_WINNT		0x06U
249 #define UDF_OS_CLASS_OS400		0x07U
250 #define UDF_OS_CLASS_BEOS		0x08U
251 #define UDF_OS_CLASS_WINCE		0x09U
252 
253 #define UDF_OS_ID_UNDEF			0x00U
254 #define UDF_OS_ID_DOS			0x00U
255 #define UDF_OS_ID_OS2			0x00U
256 #define UDF_OS_ID_MAC			0x00U
257 #define UDF_OS_ID_UNIX			0x00U
258 #define UDF_OS_ID_AIX			0x01U
259 #define UDF_OS_ID_SOLARIS		0x02U
260 #define UDF_OS_ID_HPUX			0x03U
261 #define UDF_OS_ID_IRIX			0x04U
262 #define UDF_OS_ID_LINUX			0x05U
263 #define UDF_OS_ID_MKLINUX		0x06U
264 #define UDF_OS_ID_FREEBSD		0x07U
265 #define UDF_OS_ID_WIN9X			0x00U
266 #define UDF_OS_ID_WINNT			0x00U
267 #define UDF_OS_ID_OS400			0x00U
268 #define UDF_OS_ID_BEOS			0x00U
269 #define UDF_OS_ID_WINCE			0x00U
270 
271 #endif /* _OSTA_UDF_H */
272