osta_udf.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. #include "ecma_167.h"
  35. #ifndef _OSTA_UDF_H
  36. #define _OSTA_UDF_H 1
  37. /* OSTA CS0 Charspec (UDF 2.50 2.1.2) */
  38. #define UDF_CHAR_SET_TYPE 0
  39. #define UDF_CHAR_SET_INFO "OSTA Compressed Unicode"
  40. /* Entity Identifier (UDF 2.50 2.1.5) */
  41. /* Identifiers (UDF 2.50 2.1.5.2) */
  42. #define UDF_ID_DEVELOPER "*Linux UDFFS"
  43. #define UDF_ID_COMPLIANT "*OSTA UDF Compliant"
  44. #define UDF_ID_LV_INFO "*UDF LV Info"
  45. #define UDF_ID_FREE_EA "*UDF FreeEASpace"
  46. #define UDF_ID_FREE_APP_EA "*UDF FreeAppEASpace"
  47. #define UDF_ID_DVD_CGMS "*UDF DVD CGMS Info"
  48. #define UDF_ID_OS2_EA "*UDF OS/2 EA"
  49. #define UDF_ID_OS2_EA_LENGTH "*UDF OS/2 EALength"
  50. #define UDF_ID_MAC_VOLUME "*UDF Mac VolumeInfo"
  51. #define UDF_ID_MAC_FINDER "*UDF Mac FinderInfo"
  52. #define UDF_ID_MAC_UNIQUE "*UDF Mac UniqueIDTable"
  53. #define UDF_ID_MAC_RESOURCE "*UDF Mac ResourceFork"
  54. #define UDF_ID_VIRTUAL "*UDF Virtual Partition"
  55. #define UDF_ID_SPARABLE "*UDF Sparable Partition"
  56. #define UDF_ID_ALLOC "*UDF Virtual Alloc Tbl"
  57. #define UDF_ID_SPARING "*UDF Sparing Table"
  58. #define UDF_ID_METADATA "*UDF Metadata Partition"
  59. /* Identifier Suffix (UDF 2.50 2.1.5.3) */
  60. #define IS_DF_HARD_WRITE_PROTECT 0x01
  61. #define IS_DF_SOFT_WRITE_PROTECT 0x02
  62. struct UDFIdentSuffix {
  63. __le16 UDFRevision;
  64. uint8_t OSClass;
  65. uint8_t OSIdentifier;
  66. uint8_t reserved[4];
  67. } __packed;
  68. struct impIdentSuffix {
  69. uint8_t OSClass;
  70. uint8_t OSIdentifier;
  71. uint8_t reserved[6];
  72. } __packed;
  73. struct appIdentSuffix {
  74. uint8_t impUse[8];
  75. } __packed;
  76. /* Logical Volume Integrity Descriptor (UDF 2.50 2.2.6) */
  77. /* Implementation Use (UDF 2.50 2.2.6.4) */
  78. struct logicalVolIntegrityDescImpUse {
  79. struct regid impIdent;
  80. __le32 numFiles;
  81. __le32 numDirs;
  82. __le16 minUDFReadRev;
  83. __le16 minUDFWriteRev;
  84. __le16 maxUDFWriteRev;
  85. uint8_t impUse[0];
  86. } __packed;
  87. /* Implementation Use Volume Descriptor (UDF 2.50 2.2.7) */
  88. /* Implementation Use (UDF 2.50 2.2.7.2) */
  89. struct impUseVolDescImpUse {
  90. struct charspec LVICharset;
  91. dstring logicalVolIdent[128];
  92. dstring LVInfo1[36];
  93. dstring LVInfo2[36];
  94. dstring LVInfo3[36];
  95. struct regid impIdent;
  96. uint8_t impUse[128];
  97. } __packed;
  98. struct udfPartitionMap2 {
  99. uint8_t partitionMapType;
  100. uint8_t partitionMapLength;
  101. uint8_t reserved1[2];
  102. struct regid partIdent;
  103. __le16 volSeqNum;
  104. __le16 partitionNum;
  105. } __packed;
  106. /* Virtual Partition Map (UDF 2.50 2.2.8) */
  107. struct virtualPartitionMap {
  108. uint8_t partitionMapType;
  109. uint8_t partitionMapLength;
  110. uint8_t reserved1[2];
  111. struct regid partIdent;
  112. __le16 volSeqNum;
  113. __le16 partitionNum;
  114. uint8_t reserved2[24];
  115. } __packed;
  116. /* Sparable Partition Map (UDF 2.50 2.2.9) */
  117. struct sparablePartitionMap {
  118. uint8_t partitionMapType;
  119. uint8_t partitionMapLength;
  120. uint8_t reserved1[2];
  121. struct regid partIdent;
  122. __le16 volSeqNum;
  123. __le16 partitionNum;
  124. __le16 packetLength;
  125. uint8_t numSparingTables;
  126. uint8_t reserved2[1];
  127. __le32 sizeSparingTable;
  128. __le32 locSparingTable[4];
  129. } __packed;
  130. /* Metadata Partition Map (UDF 2.4.0 2.2.10) */
  131. struct metadataPartitionMap {
  132. uint8_t partitionMapType;
  133. uint8_t partitionMapLength;
  134. uint8_t reserved1[2];
  135. struct regid partIdent;
  136. __le16 volSeqNum;
  137. __le16 partitionNum;
  138. __le32 metadataFileLoc;
  139. __le32 metadataMirrorFileLoc;
  140. __le32 metadataBitmapFileLoc;
  141. __le32 allocUnitSize;
  142. __le16 alignUnitSize;
  143. uint8_t flags;
  144. uint8_t reserved2[5];
  145. } __packed;
  146. /* Virtual Allocation Table (UDF 1.5 2.2.10) */
  147. struct virtualAllocationTable15 {
  148. __le32 VirtualSector[0];
  149. struct regid vatIdent;
  150. __le32 previousVATICBLoc;
  151. } __packed;
  152. #define ICBTAG_FILE_TYPE_VAT15 0x00U
  153. /* Virtual Allocation Table (UDF 2.50 2.2.11) */
  154. struct virtualAllocationTable20 {
  155. __le16 lengthHeader;
  156. __le16 lengthImpUse;
  157. dstring logicalVolIdent[128];
  158. __le32 previousVATICBLoc;
  159. __le32 numFiles;
  160. __le32 numDirs;
  161. __le16 minReadRevision;
  162. __le16 minWriteRevision;
  163. __le16 maxWriteRevision;
  164. __le16 reserved;
  165. uint8_t impUse[0];
  166. __le32 vatEntry[0];
  167. } __packed;
  168. #define ICBTAG_FILE_TYPE_VAT20 0xF8U
  169. /* Sparing Table (UDF 2.50 2.2.12) */
  170. struct sparingEntry {
  171. __le32 origLocation;
  172. __le32 mappedLocation;
  173. } __packed;
  174. struct sparingTable {
  175. struct tag descTag;
  176. struct regid sparingIdent;
  177. __le16 reallocationTableLen;
  178. __le16 reserved;
  179. __le32 sequenceNum;
  180. struct sparingEntry
  181. mapEntry[0];
  182. } __packed;
  183. /* Metadata File (and Metadata Mirror File) (UDF 2.50 2.2.13.1) */
  184. #define ICBTAG_FILE_TYPE_MAIN 0xFA
  185. #define ICBTAG_FILE_TYPE_MIRROR 0xFB
  186. #define ICBTAG_FILE_TYPE_BITMAP 0xFC
  187. /* struct struct long_ad ICB - ADImpUse (UDF 2.50 2.2.4.3) */
  188. struct allocDescImpUse {
  189. __le16 flags;
  190. uint8_t impUse[4];
  191. } __packed;
  192. #define AD_IU_EXT_ERASED 0x0001
  193. /* Real-Time Files (UDF 2.50 6.11) */
  194. #define ICBTAG_FILE_TYPE_REALTIME 0xF9U
  195. /* Implementation Use Extended Attribute (UDF 2.50 3.3.4.5) */
  196. /* FreeEASpace (UDF 2.50 3.3.4.5.1.1) */
  197. struct freeEaSpace {
  198. __le16 headerChecksum;
  199. uint8_t freeEASpace[0];
  200. } __packed;
  201. /* DVD Copyright Management Information (UDF 2.50 3.3.4.5.1.2) */
  202. struct DVDCopyrightImpUse {
  203. __le16 headerChecksum;
  204. uint8_t CGMSInfo;
  205. uint8_t dataType;
  206. uint8_t protectionSystemInfo[4];
  207. } __packed;
  208. /* Application Use Extended Attribute (UDF 2.50 3.3.4.6) */
  209. /* FreeAppEASpace (UDF 2.50 3.3.4.6.1) */
  210. struct freeAppEASpace {
  211. __le16 headerChecksum;
  212. uint8_t freeEASpace[0];
  213. } __packed;
  214. /* UDF Defined System Stream (UDF 2.50 3.3.7) */
  215. #define UDF_ID_UNIQUE_ID "*UDF Unique ID Mapping Data"
  216. #define UDF_ID_NON_ALLOC "*UDF Non-Allocatable Space"
  217. #define UDF_ID_POWER_CAL "*UDF Power Cal Table"
  218. #define UDF_ID_BACKUP "*UDF Backup"
  219. /* Operating System Identifiers (UDF 2.50 6.3) */
  220. #define UDF_OS_CLASS_UNDEF 0x00U
  221. #define UDF_OS_CLASS_DOS 0x01U
  222. #define UDF_OS_CLASS_OS2 0x02U
  223. #define UDF_OS_CLASS_MAC 0x03U
  224. #define UDF_OS_CLASS_UNIX 0x04U
  225. #define UDF_OS_CLASS_WIN9X 0x05U
  226. #define UDF_OS_CLASS_WINNT 0x06U
  227. #define UDF_OS_CLASS_OS400 0x07U
  228. #define UDF_OS_CLASS_BEOS 0x08U
  229. #define UDF_OS_CLASS_WINCE 0x09U
  230. #define UDF_OS_ID_UNDEF 0x00U
  231. #define UDF_OS_ID_DOS 0x00U
  232. #define UDF_OS_ID_OS2 0x00U
  233. #define UDF_OS_ID_MAC 0x00U
  234. #define UDF_OS_ID_MAX_OSX 0x01U
  235. #define UDF_OS_ID_UNIX 0x00U
  236. #define UDF_OS_ID_AIX 0x01U
  237. #define UDF_OS_ID_SOLARIS 0x02U
  238. #define UDF_OS_ID_HPUX 0x03U
  239. #define UDF_OS_ID_IRIX 0x04U
  240. #define UDF_OS_ID_LINUX 0x05U
  241. #define UDF_OS_ID_MKLINUX 0x06U
  242. #define UDF_OS_ID_FREEBSD 0x07U
  243. #define UDF_OS_ID_WIN9X 0x00U
  244. #define UDF_OS_ID_WINNT 0x00U
  245. #define UDF_OS_ID_OS400 0x00U
  246. #define UDF_OS_ID_BEOS 0x00U
  247. #define UDF_OS_ID_WINCE 0x00U
  248. #endif /* _OSTA_UDF_H */