osta_udf.h 8.1 KB

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