osta_udf.h 8.8 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3
/*
 * osta_udf.h
 *
4
 * This file is based on OSTA UDF(tm) 2.60 (March 1, 2005)
L
Linus Torvalds 已提交
5 6
 * http://www.osta.org
 *
7
 * Copyright (c) 2001-2004  Ben Fennema
8
 * Copyright (c) 2017-2019  Pali Rohár <pali@kernel.org>
L
Linus Torvalds 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions, and the following disclaimer,
 *    without modification.
 * 2. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * Alternatively, this software may be distributed under the terms of the
 * GNU Public License ("GPL").
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

36 37 38 39 40
/**
 * @file
 * OSTA-UDF defines and structure definitions
 */

L
Linus Torvalds 已提交
41 42 43 44 45
#include "ecma_167.h"

#ifndef _OSTA_UDF_H
#define _OSTA_UDF_H 1

46
/* OSTA CS0 Charspec (UDF 2.60 2.1.2) */
L
Linus Torvalds 已提交
47 48 49
#define UDF_CHAR_SET_TYPE		0
#define UDF_CHAR_SET_INFO		"OSTA Compressed Unicode"

50 51 52 53 54 55 56 57
/* Entity Identifier (UDF 2.60 2.1.5) */
/* Identifiers (UDF 2.60 2.1.5.2) */
/* Implementation Use Extended Attribute (UDF 2.60 3.3.4.5) */
/* Virtual Allocation Table (UDF 1.50 2.2.10) */
/* Logical Volume Extended Information (UDF 1.50 Errata, DCN 5003, 3.3.4.5.1.3) */
/* OS2EA (UDF 1.50 3.3.4.5.3.1) */
/* MacUniqueIDTable (UDF 1.50 3.3.4.5.4.3) */
/* MacResourceFork (UDF 1.50 3.3.4.5.4.4) */
L
Linus Torvalds 已提交
58 59 60 61 62 63
#define UDF_ID_DEVELOPER		"*Linux UDFFS"
#define	UDF_ID_COMPLIANT		"*OSTA UDF Compliant"
#define UDF_ID_LV_INFO			"*UDF LV Info"
#define UDF_ID_FREE_EA			"*UDF FreeEASpace"
#define UDF_ID_FREE_APP_EA		"*UDF FreeAppEASpace"
#define UDF_ID_DVD_CGMS			"*UDF DVD CGMS Info"
64
#define UDF_ID_VAT_LVEXTENSION		"*UDF VAT LVExtension"
L
Linus Torvalds 已提交
65 66 67 68 69 70
#define UDF_ID_OS2_EA			"*UDF OS/2 EA"
#define UDF_ID_OS2_EA_LENGTH		"*UDF OS/2 EALength"
#define UDF_ID_MAC_VOLUME		"*UDF Mac VolumeInfo"
#define UDF_ID_MAC_FINDER		"*UDF Mac FinderInfo"
#define UDF_ID_MAC_UNIQUE		"*UDF Mac UniqueIDTable"
#define UDF_ID_MAC_RESOURCE		"*UDF Mac ResourceFork"
71
#define UDF_ID_OS400_DIRINFO		"*UDF OS/400 DirInfo"
L
Linus Torvalds 已提交
72 73 74 75 76 77
#define UDF_ID_VIRTUAL			"*UDF Virtual Partition"
#define UDF_ID_SPARABLE			"*UDF Sparable Partition"
#define UDF_ID_ALLOC			"*UDF Virtual Alloc Tbl"
#define UDF_ID_SPARING			"*UDF Sparing Table"
#define UDF_ID_METADATA			"*UDF Metadata Partition"

78
/* Identifier Suffix (UDF 2.60 2.1.5.3) */
79 80 81 82 83 84 85 86
#define DOMAIN_FLAGS_HARD_WRITE_PROTECT	0x01
#define DOMAIN_FLAGS_SOFT_WRITE_PROTECT	0x02

struct domainIdentSuffix {
	__le16		UDFRevision;
	uint8_t		domainFlags;
	uint8_t		reserved[5];
} __packed;
L
Linus Torvalds 已提交
87

88
struct UDFIdentSuffix {
89 90 91 92
	__le16		UDFRevision;
	uint8_t		OSClass;
	uint8_t		OSIdentifier;
	uint8_t		reserved[4];
93
} __packed;
L
Linus Torvalds 已提交
94

95
struct impIdentSuffix {
96 97
	uint8_t		OSClass;
	uint8_t		OSIdentifier;
98
	uint8_t		impUse[6];
99
} __packed;
L
Linus Torvalds 已提交
100

101
struct appIdentSuffix {
102
	uint8_t		impUse[8];
103
} __packed;
L
Linus Torvalds 已提交
104

105 106
/* Logical Volume Integrity Descriptor (UDF 2.60 2.2.6) */
/* Implementation Use (UDF 2.60 2.2.6.4) */
107
struct logicalVolIntegrityDescImpUse {
108
	struct regid	impIdent;
109 110 111 112 113
	__le32		numFiles;
	__le32		numDirs;
	__le16		minUDFReadRev;
	__le16		minUDFWriteRev;
	__le16		maxUDFWriteRev;
J
Jan Kara 已提交
114
	uint8_t		impUse[];
115
} __packed;
L
Linus Torvalds 已提交
116

117 118
/* Implementation Use Volume Descriptor (UDF 2.60 2.2.7) */
/* Implementation Use (UDF 2.60 2.2.7.2) */
119
struct impUseVolDescImpUse {
120
	struct charspec	LVICharset;
121 122 123 124
	dstring		logicalVolIdent[128];
	dstring		LVInfo1[36];
	dstring		LVInfo2[36];
	dstring		LVInfo3[36];
125
	struct regid	impIdent;
126
	uint8_t		impUse[128];
127
} __packed;
L
Linus Torvalds 已提交
128

129
struct udfPartitionMap2 {
130 131 132
	uint8_t		partitionMapType;
	uint8_t		partitionMapLength;
	uint8_t		reserved1[2];
133
	struct regid	partIdent;
134 135
	__le16		volSeqNum;
	__le16		partitionNum;
136
} __packed;
L
Linus Torvalds 已提交
137

138
/* Virtual Partition Map (UDF 2.60 2.2.8) */
139
struct virtualPartitionMap {
140 141 142
	uint8_t		partitionMapType;
	uint8_t		partitionMapLength;
	uint8_t		reserved1[2];
143
	struct regid	partIdent;
144 145 146
	__le16		volSeqNum;
	__le16		partitionNum;
	uint8_t		reserved2[24];
147
} __packed;
L
Linus Torvalds 已提交
148

149
/* Sparable Partition Map (UDF 2.60 2.2.9) */
150 151 152 153
struct sparablePartitionMap {
	uint8_t partitionMapType;
	uint8_t partitionMapLength;
	uint8_t reserved1[2];
154
	struct regid partIdent;
155 156 157 158 159 160 161
	__le16 volSeqNum;
	__le16 partitionNum;
	__le16 packetLength;
	uint8_t numSparingTables;
	uint8_t reserved2[1];
	__le32 sizeSparingTable;
	__le32 locSparingTable[4];
162
} __packed;
L
Linus Torvalds 已提交
163

164
/* Metadata Partition Map (UDF 2.60 2.2.10) */
165
struct metadataPartitionMap {
166 167 168
	uint8_t		partitionMapType;
	uint8_t		partitionMapLength;
	uint8_t		reserved1[2];
169
	struct regid	partIdent;
170 171 172 173 174 175 176 177 178
	__le16		volSeqNum;
	__le16		partitionNum;
	__le32		metadataFileLoc;
	__le32		metadataMirrorFileLoc;
	__le32		metadataBitmapFileLoc;
	__le32		allocUnitSize;
	__le16		alignUnitSize;
	uint8_t		flags;
	uint8_t		reserved2[5];
179
} __packed;
L
Linus Torvalds 已提交
180

181
/* Virtual Allocation Table (UDF 2.60 2.2.11) */
182
struct virtualAllocationTable20 {
183 184 185 186 187 188
	__le16		lengthHeader;
	__le16		lengthImpUse;
	dstring		logicalVolIdent[128];
	__le32		previousVATICBLoc;
	__le32		numFiles;
	__le32		numDirs;
189 190 191
	__le16		minUDFReadRev;
	__le16		minUDFWriteRev;
	__le16		maxUDFWriteRev;
192
	__le16		reserved;
J
Jan Kara 已提交
193 194
	uint8_t		impUse[];
	/* __le32	vatEntry[]; */
195
} __packed;
L
Linus Torvalds 已提交
196 197 198

#define ICBTAG_FILE_TYPE_VAT20		0xF8U

199
/* Sparing Table (UDF 2.60 2.2.12) */
200
struct sparingEntry {
201 202
	__le32		origLocation;
	__le32		mappedLocation;
203
} __packed;
L
Linus Torvalds 已提交
204

205
struct sparingTable {
206 207
	struct tag	descTag;
	struct regid	sparingIdent;
208 209 210
	__le16		reallocationTableLen;
	__le16		reserved;
	__le32		sequenceNum;
J
Jan Kara 已提交
211
	struct sparingEntry mapEntry[];
212
} __packed;
L
Linus Torvalds 已提交
213

214
/* Metadata File (and Metadata Mirror File) (UDF 2.60 2.2.13.1) */
L
Linus Torvalds 已提交
215 216 217 218
#define ICBTAG_FILE_TYPE_MAIN		0xFA
#define ICBTAG_FILE_TYPE_MIRROR		0xFB
#define ICBTAG_FILE_TYPE_BITMAP		0xFC

219
/* struct long_ad ICB - ADImpUse (UDF 2.60 2.2.4.3) */
220
struct allocDescImpUse {
221 222
	__le16		flags;
	uint8_t		impUse[4];
223
} __packed;
L
Linus Torvalds 已提交
224 225 226

#define AD_IU_EXT_ERASED		0x0001

227
/* Real-Time Files (UDF 2.60 6.11) */
L
Linus Torvalds 已提交
228 229
#define ICBTAG_FILE_TYPE_REALTIME	0xF9U

230 231
/* Implementation Use Extended Attribute (UDF 2.60 3.3.4.5) */
/* FreeEASpace (UDF 2.60 3.3.4.5.1.1) */
232
struct freeEaSpace {
233
	__le16		headerChecksum;
J
Jan Kara 已提交
234
	uint8_t		freeEASpace[];
235
} __packed;
L
Linus Torvalds 已提交
236

237
/* DVD Copyright Management Information (UDF 2.60 3.3.4.5.1.2) */
238
struct DVDCopyrightImpUse {
239 240 241 242
	__le16		headerChecksum;
	uint8_t		CGMSInfo;
	uint8_t		dataType;
	uint8_t		protectionSystemInfo[4];
243
} __packed;
L
Linus Torvalds 已提交
244

245 246 247 248 249 250 251 252 253 254 255
/* Logical Volume Extended Information (UDF 1.50 Errata, DCN 5003, 3.3.4.5.1.3) */
struct LVExtensionEA {
	__le16		headerChecksum;
	__le64		verificationID;
	__le32		numFiles;
	__le32		numDirs;
	dstring		logicalVolIdent[128];
} __packed;

/* Application Use Extended Attribute (UDF 2.60 3.3.4.6) */
/* FreeAppEASpace (UDF 2.60 3.3.4.6.1) */
256
struct freeAppEASpace {
257
	__le16		headerChecksum;
J
Jan Kara 已提交
258
	uint8_t		freeEASpace[];
259
} __packed;
L
Linus Torvalds 已提交
260

261
/* UDF Defined System Stream (UDF 2.60 3.3.7) */
L
Linus Torvalds 已提交
262 263 264 265 266
#define UDF_ID_UNIQUE_ID		"*UDF Unique ID Mapping Data"
#define UDF_ID_NON_ALLOC		"*UDF Non-Allocatable Space"
#define UDF_ID_POWER_CAL		"*UDF Power Cal Table"
#define UDF_ID_BACKUP			"*UDF Backup"

267 268 269 270 271 272 273
/* UDF Defined Non-System Streams (UDF 2.60 3.3.8) */
#define UDF_ID_MAC_RESOURCE_FORK_STREAM	"*UDF Macintosh Resource Fork"
/* #define UDF_ID_OS2_EA		"*UDF OS/2 EA" */
#define UDF_ID_NT_ACL			"*UDF NT ACL"
#define UDF_ID_UNIX_ACL			"*UDF UNIX ACL"

/* Operating System Identifiers (UDF 2.60 6.3) */
L
Linus Torvalds 已提交
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
#define UDF_OS_CLASS_UNDEF		0x00U
#define UDF_OS_CLASS_DOS		0x01U
#define UDF_OS_CLASS_OS2		0x02U
#define UDF_OS_CLASS_MAC		0x03U
#define UDF_OS_CLASS_UNIX		0x04U
#define UDF_OS_CLASS_WIN9X		0x05U
#define UDF_OS_CLASS_WINNT		0x06U
#define UDF_OS_CLASS_OS400		0x07U
#define UDF_OS_CLASS_BEOS		0x08U
#define UDF_OS_CLASS_WINCE		0x09U

#define UDF_OS_ID_UNDEF			0x00U
#define UDF_OS_ID_DOS			0x00U
#define UDF_OS_ID_OS2			0x00U
#define UDF_OS_ID_MAC			0x00U
#define UDF_OS_ID_MAX_OSX		0x01U
#define UDF_OS_ID_UNIX			0x00U
#define UDF_OS_ID_AIX			0x01U
#define UDF_OS_ID_SOLARIS		0x02U
#define UDF_OS_ID_HPUX			0x03U
#define UDF_OS_ID_IRIX			0x04U
#define UDF_OS_ID_LINUX			0x05U
#define UDF_OS_ID_MKLINUX		0x06U
#define UDF_OS_ID_FREEBSD		0x07U
298
#define UDF_OS_ID_NETBSD		0x08U
L
Linus Torvalds 已提交
299 300 301 302 303 304
#define UDF_OS_ID_WIN9X			0x00U
#define UDF_OS_ID_WINNT			0x00U
#define UDF_OS_ID_OS400			0x00U
#define UDF_OS_ID_BEOS			0x00U
#define UDF_OS_ID_WINCE			0x00U

305
#endif /* _OSTA_UDF_H */