osta_udf.h 9.0 KB

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