1/*
2 * osta_udf.h
3 *
4 * This file is based on OSTA UDF(tm) 2.50 (April 30, 2003)
5 * http://www.osta.org
6 *
7 * Copyright (c) 2001-2004  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.50 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.50 2.1.5) */
45/* Identifiers (UDF 2.50 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#define UDF_ID_METADATA			"*UDF Metadata Partition"
63
64/* Identifier Suffix (UDF 2.50 2.1.5.3) */
65#define IS_DF_HARD_WRITE_PROTECT	0x01
66#define IS_DF_SOFT_WRITE_PROTECT	0x02
67
68struct UDFIdentSuffix
69{
70	__le16		UDFRevision;
71	uint8_t		OSClass;
72	uint8_t		OSIdentifier;
73	uint8_t		reserved[4];
74} __attribute__ ((packed));
75
76struct impIdentSuffix
77{
78	uint8_t		OSClass;
79	uint8_t		OSIdentifier;
80	uint8_t		reserved[6];
81} __attribute__ ((packed));
82
83struct appIdentSuffix
84{
85	uint8_t		impUse[8];
86} __attribute__ ((packed));
87
88/* Logical Volume Integrity Descriptor (UDF 2.50 2.2.6) */
89/* Implementation Use (UDF 2.50 2.2.6.4) */
90struct logicalVolIntegrityDescImpUse
91{
92	regid		impIdent;
93	__le32		numFiles;
94	__le32		numDirs;
95	__le16		minUDFReadRev;
96	__le16		minUDFWriteRev;
97	__le16		maxUDFWriteRev;
98	uint8_t		impUse[0];
99} __attribute__ ((packed));
100
101/* Implementation Use Volume Descriptor (UDF 2.50 2.2.7) */
102/* Implementation Use (UDF 2.50 2.2.7.2) */
103struct impUseVolDescImpUse
104{
105	charspec	LVICharset;
106	dstring		logicalVolIdent[128];
107	dstring		LVInfo1[36];
108	dstring		LVInfo2[36];
109	dstring		LVInfo3[36];
110	regid		impIdent;
111	uint8_t		impUse[128];
112} __attribute__ ((packed));
113
114struct udfPartitionMap2
115{
116	uint8_t		partitionMapType;
117	uint8_t		partitionMapLength;
118	uint8_t		reserved1[2];
119	regid		partIdent;
120	__le16		volSeqNum;
121	__le16		partitionNum;
122} __attribute__ ((packed));
123
124/* Virtual Partition Map (UDF 2.50 2.2.8) */
125struct virtualPartitionMap
126{
127	uint8_t		partitionMapType;
128	uint8_t		partitionMapLength;
129	uint8_t		reserved1[2];
130	regid		partIdent;
131	__le16		volSeqNum;
132	__le16		partitionNum;
133	uint8_t		reserved2[24];
134} __attribute__ ((packed));
135
136/* Sparable Partition Map (UDF 2.50 2.2.9) */
137struct sparablePartitionMap
138{
139	uint8_t		partitionMapType;
140	uint8_t		partitionMapLength;
141	uint8_t		reserved1[2];
142	regid		partIdent;
143	__le16		volSeqNum;
144	__le16		partitionNum;
145	__le16		packetLength;
146	uint8_t		numSparingTables;
147	uint8_t		reserved2[1];
148	__le32		sizeSparingTable;
149	__le32		locSparingTable[4];
150} __attribute__ ((packed));
151
152/* Metadata Partition Map (UDF 2.4.0 2.2.10) */
153struct metadataPartitionMap
154{
155	uint8_t		partitionMapType;
156	uint8_t		partitionMapLength;
157	uint8_t		reserved1[2];
158	regid		partIdent;
159	__le16		volSeqNum;
160	__le16		partitionNum;
161	__le32		metadataFileLoc;
162	__le32		metadataMirrorFileLoc;
163	__le32		metadataBitmapFileLoc;
164	__le32		allocUnitSize;
165	__le16		alignUnitSize;
166	uint8_t		flags;
167	uint8_t		reserved2[5];
168} __attribute__ ((packed));
169
170/* Virtual Allocation Table (UDF 1.5 2.2.10) */
171struct virtualAllocationTable15
172{
173	__le32		VirtualSector[0];
174	regid		vatIdent;
175	__le32		previousVATICBLoc;
176} __attribute__ ((packed));
177
178#define ICBTAG_FILE_TYPE_VAT15		0x00U
179
180/* Virtual Allocation Table (UDF 2.50 2.2.11) */
181struct virtualAllocationTable20
182{
183	__le16		lengthHeader;
184	__le16		lengthImpUse;
185	dstring		logicalVolIdent[128];
186	__le32		previousVATICBLoc;
187	__le32		numFiles;
188	__le32		numDirs;
189	__le16		minReadRevision;
190	__le16		minWriteRevision;
191	__le16		maxWriteRevision;
192	__le16		reserved;
193	uint8_t		impUse[0];
194	__le32		vatEntry[0];
195} __attribute__ ((packed));
196
197#define ICBTAG_FILE_TYPE_VAT20		0xF8U
198
199/* Sparing Table (UDF 2.50 2.2.12) */
200struct sparingEntry
201{
202	__le32		origLocation;
203	__le32		mappedLocation;
204} __attribute__ ((packed));
205
206struct sparingTable
207{
208	tag 		descTag;
209	regid		sparingIdent;
210	__le16		reallocationTableLen;
211	__le16		reserved;
212	__le32		sequenceNum;
213	struct sparingEntry
214			mapEntry[0];
215} __attribute__ ((packed));
216
217/* Metadata File (and Metadata Mirror File) (UDF 2.50 2.2.13.1) */
218#define ICBTAG_FILE_TYPE_MAIN		0xFA
219#define ICBTAG_FILE_TYPE_MIRROR		0xFB
220#define ICBTAG_FILE_TYPE_BITMAP		0xFC
221
222/* struct long_ad ICB - ADImpUse (UDF 2.50 2.2.4.3) */
223struct allocDescImpUse
224{
225	__le16		flags;
226	uint8_t		impUse[4];
227} __attribute__ ((packed));
228
229#define AD_IU_EXT_ERASED		0x0001
230
231/* Real-Time Files (UDF 2.50 6.11) */
232#define ICBTAG_FILE_TYPE_REALTIME	0xF9U
233
234/* Implementation Use Extended Attribute (UDF 2.50 3.3.4.5) */
235/* FreeEASpace (UDF 2.50 3.3.4.5.1.1) */
236struct freeEaSpace
237{
238	__le16		headerChecksum;
239	uint8_t		freeEASpace[0];
240} __attribute__ ((packed));
241
242/* DVD Copyright Management Information (UDF 2.50 3.3.4.5.1.2) */
243struct DVDCopyrightImpUse
244{
245	__le16		headerChecksum;
246	uint8_t		CGMSInfo;
247	uint8_t		dataType;
248	uint8_t		protectionSystemInfo[4];
249} __attribute__ ((packed));
250
251/* Application Use Extended Attribute (UDF 2.50 3.3.4.6) */
252/* FreeAppEASpace (UDF 2.50 3.3.4.6.1) */
253struct freeAppEASpace
254{
255	__le16		headerChecksum;
256	uint8_t		freeEASpace[0];
257} __attribute__ ((packed));
258
259/* UDF Defined System Stream (UDF 2.50 3.3.7) */
260#define UDF_ID_UNIQUE_ID		"*UDF Unique ID Mapping Data"
261#define UDF_ID_NON_ALLOC		"*UDF Non-Allocatable Space"
262#define UDF_ID_POWER_CAL		"*UDF Power Cal Table"
263#define UDF_ID_BACKUP			"*UDF Backup"
264
265/* Operating System Identifiers (UDF 2.50 6.3) */
266#define UDF_OS_CLASS_UNDEF		0x00U
267#define UDF_OS_CLASS_DOS		0x01U
268#define UDF_OS_CLASS_OS2		0x02U
269#define UDF_OS_CLASS_MAC		0x03U
270#define UDF_OS_CLASS_UNIX		0x04U
271#define UDF_OS_CLASS_WIN9X		0x05U
272#define UDF_OS_CLASS_WINNT		0x06U
273#define UDF_OS_CLASS_OS400		0x07U
274#define UDF_OS_CLASS_BEOS		0x08U
275#define UDF_OS_CLASS_WINCE		0x09U
276
277#define UDF_OS_ID_UNDEF			0x00U
278#define UDF_OS_ID_DOS			0x00U
279#define UDF_OS_ID_OS2			0x00U
280#define UDF_OS_ID_MAC			0x00U
281#define UDF_OS_ID_MAX_OSX		0x01U
282#define UDF_OS_ID_UNIX			0x00U
283#define UDF_OS_ID_AIX			0x01U
284#define UDF_OS_ID_SOLARIS		0x02U
285#define UDF_OS_ID_HPUX			0x03U
286#define UDF_OS_ID_IRIX			0x04U
287#define UDF_OS_ID_LINUX			0x05U
288#define UDF_OS_ID_MKLINUX		0x06U
289#define UDF_OS_ID_FREEBSD		0x07U
290#define UDF_OS_ID_WIN9X			0x00U
291#define UDF_OS_ID_WINNT			0x00U
292#define UDF_OS_ID_OS400			0x00U
293#define UDF_OS_ID_BEOS			0x00U
294#define UDF_OS_ID_WINCE			0x00U
295
296#endif /* _OSTA_UDF_H */
297