ecma_167.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  1. /*
  2. * ecma_167.h
  3. *
  4. * This file is based on ECMA-167 3rd edition (June 1997)
  5. * http://www.ecma.ch
  6. *
  7. * Copyright (c) 2001-2002 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 <linux/types.h>
  35. #ifndef _ECMA_167_H
  36. #define _ECMA_167_H 1
  37. /* Character set specification (ECMA 167r3 1/7.2.1) */
  38. struct charspec {
  39. uint8_t charSetType;
  40. uint8_t charSetInfo[63];
  41. } __attribute__ ((packed));
  42. /* Character Set Type (ECMA 167r3 1/7.2.1.1) */
  43. #define CHARSPEC_TYPE_CS0 0x00 /* (1/7.2.2) */
  44. #define CHARSPEC_TYPE_CS1 0x01 /* (1/7.2.3) */
  45. #define CHARSPEC_TYPE_CS2 0x02 /* (1/7.2.4) */
  46. #define CHARSPEC_TYPE_CS3 0x03 /* (1/7.2.5) */
  47. #define CHARSPEC_TYPE_CS4 0x04 /* (1/7.2.6) */
  48. #define CHARSPEC_TYPE_CS5 0x05 /* (1/7.2.7) */
  49. #define CHARSPEC_TYPE_CS6 0x06 /* (1/7.2.8) */
  50. #define CHARSPEC_TYPE_CS7 0x07 /* (1/7.2.9) */
  51. #define CHARSPEC_TYPE_CS8 0x08 /* (1/7.2.10) */
  52. typedef uint8_t dstring;
  53. /* Timestamp (ECMA 167r3 1/7.3) */
  54. struct timestamp {
  55. __le16 typeAndTimezone;
  56. __le16 year;
  57. uint8_t month;
  58. uint8_t day;
  59. uint8_t hour;
  60. uint8_t minute;
  61. uint8_t second;
  62. uint8_t centiseconds;
  63. uint8_t hundredsOfMicroseconds;
  64. uint8_t microseconds;
  65. } __attribute__ ((packed));
  66. /* Type and Time Zone (ECMA 167r3 1/7.3.1) */
  67. #define TIMESTAMP_TYPE_MASK 0xF000
  68. #define TIMESTAMP_TYPE_CUT 0x0000
  69. #define TIMESTAMP_TYPE_LOCAL 0x1000
  70. #define TIMESTAMP_TYPE_AGREEMENT 0x2000
  71. #define TIMESTAMP_TIMEZONE_MASK 0x0FFF
  72. /* Entity identifier (ECMA 167r3 1/7.4) */
  73. struct regid {
  74. uint8_t flags;
  75. uint8_t ident[23];
  76. uint8_t identSuffix[8];
  77. } __attribute__ ((packed));
  78. /* Flags (ECMA 167r3 1/7.4.1) */
  79. #define ENTITYID_FLAGS_DIRTY 0x00
  80. #define ENTITYID_FLAGS_PROTECTED 0x01
  81. /* Volume Structure Descriptor (ECMA 167r3 2/9.1) */
  82. #define VSD_STD_ID_LEN 5
  83. struct volStructDesc {
  84. uint8_t structType;
  85. uint8_t stdIdent[VSD_STD_ID_LEN];
  86. uint8_t structVersion;
  87. uint8_t structData[2041];
  88. } __attribute__ ((packed));
  89. /* Standard Identifier (EMCA 167r2 2/9.1.2) */
  90. #define VSD_STD_ID_NSR02 "NSR02" /* (3/9.1) */
  91. /* Standard Identifier (ECMA 167r3 2/9.1.2) */
  92. #define VSD_STD_ID_BEA01 "BEA01" /* (2/9.2) */
  93. #define VSD_STD_ID_BOOT2 "BOOT2" /* (2/9.4) */
  94. #define VSD_STD_ID_CD001 "CD001" /* (ECMA-119) */
  95. #define VSD_STD_ID_CDW02 "CDW02" /* (ECMA-168) */
  96. #define VSD_STD_ID_NSR03 "NSR03" /* (3/9.1) */
  97. #define VSD_STD_ID_TEA01 "TEA01" /* (2/9.3) */
  98. /* Beginning Extended Area Descriptor (ECMA 167r3 2/9.2) */
  99. struct beginningExtendedAreaDesc {
  100. uint8_t structType;
  101. uint8_t stdIdent[VSD_STD_ID_LEN];
  102. uint8_t structVersion;
  103. uint8_t structData[2041];
  104. } __attribute__ ((packed));
  105. /* Terminating Extended Area Descriptor (ECMA 167r3 2/9.3) */
  106. struct terminatingExtendedAreaDesc {
  107. uint8_t structType;
  108. uint8_t stdIdent[VSD_STD_ID_LEN];
  109. uint8_t structVersion;
  110. uint8_t structData[2041];
  111. } __attribute__ ((packed));
  112. /* Boot Descriptor (ECMA 167r3 2/9.4) */
  113. struct bootDesc {
  114. uint8_t structType;
  115. uint8_t stdIdent[VSD_STD_ID_LEN];
  116. uint8_t structVersion;
  117. uint8_t reserved1;
  118. struct regid archType;
  119. struct regid bootIdent;
  120. __le32 bootExtLocation;
  121. __le32 bootExtLength;
  122. __le64 loadAddress;
  123. __le64 startAddress;
  124. struct timestamp descCreationDateAndTime;
  125. __le16 flags;
  126. uint8_t reserved2[32];
  127. uint8_t bootUse[1906];
  128. } __attribute__ ((packed));
  129. /* Flags (ECMA 167r3 2/9.4.12) */
  130. #define BOOT_FLAGS_ERASE 0x01
  131. /* Extent Descriptor (ECMA 167r3 3/7.1) */
  132. struct extent_ad {
  133. __le32 extLength;
  134. __le32 extLocation;
  135. } __attribute__ ((packed));
  136. struct kernel_extent_ad {
  137. uint32_t extLength;
  138. uint32_t extLocation;
  139. };
  140. /* Descriptor Tag (ECMA 167r3 3/7.2) */
  141. struct tag {
  142. __le16 tagIdent;
  143. __le16 descVersion;
  144. uint8_t tagChecksum;
  145. uint8_t reserved;
  146. __le16 tagSerialNum;
  147. __le16 descCRC;
  148. __le16 descCRCLength;
  149. __le32 tagLocation;
  150. } __attribute__ ((packed));
  151. /* Tag Identifier (ECMA 167r3 3/7.2.1) */
  152. #define TAG_IDENT_PVD 0x0001
  153. #define TAG_IDENT_AVDP 0x0002
  154. #define TAG_IDENT_VDP 0x0003
  155. #define TAG_IDENT_IUVD 0x0004
  156. #define TAG_IDENT_PD 0x0005
  157. #define TAG_IDENT_LVD 0x0006
  158. #define TAG_IDENT_USD 0x0007
  159. #define TAG_IDENT_TD 0x0008
  160. #define TAG_IDENT_LVID 0x0009
  161. /* NSR Descriptor (ECMA 167r3 3/9.1) */
  162. struct NSRDesc {
  163. uint8_t structType;
  164. uint8_t stdIdent[VSD_STD_ID_LEN];
  165. uint8_t structVersion;
  166. uint8_t reserved;
  167. uint8_t structData[2040];
  168. } __attribute__ ((packed));
  169. /* Primary Volume Descriptor (ECMA 167r3 3/10.1) */
  170. struct primaryVolDesc {
  171. struct tag descTag;
  172. __le32 volDescSeqNum;
  173. __le32 primaryVolDescNum;
  174. dstring volIdent[32];
  175. __le16 volSeqNum;
  176. __le16 maxVolSeqNum;
  177. __le16 interchangeLvl;
  178. __le16 maxInterchangeLvl;
  179. __le32 charSetList;
  180. __le32 maxCharSetList;
  181. dstring volSetIdent[128];
  182. struct charspec descCharSet;
  183. struct charspec explanatoryCharSet;
  184. struct extent_ad volAbstract;
  185. struct extent_ad volCopyright;
  186. struct regid appIdent;
  187. struct timestamp recordingDateAndTime;
  188. struct regid impIdent;
  189. uint8_t impUse[64];
  190. __le32 predecessorVolDescSeqLocation;
  191. __le16 flags;
  192. uint8_t reserved[22];
  193. } __attribute__ ((packed));
  194. /* Flags (ECMA 167r3 3/10.1.21) */
  195. #define PVD_FLAGS_VSID_COMMON 0x0001
  196. /* Anchor Volume Descriptor Pointer (ECMA 167r3 3/10.2) */
  197. struct anchorVolDescPtr {
  198. struct tag descTag;
  199. struct extent_ad mainVolDescSeqExt;
  200. struct extent_ad reserveVolDescSeqExt;
  201. uint8_t reserved[480];
  202. } __attribute__ ((packed));
  203. /* Volume Descriptor Pointer (ECMA 167r3 3/10.3) */
  204. struct volDescPtr {
  205. struct tag descTag;
  206. __le32 volDescSeqNum;
  207. struct extent_ad nextVolDescSeqExt;
  208. uint8_t reserved[484];
  209. } __attribute__ ((packed));
  210. /* Implementation Use Volume Descriptor (ECMA 167r3 3/10.4) */
  211. struct impUseVolDesc {
  212. struct tag descTag;
  213. __le32 volDescSeqNum;
  214. struct regid impIdent;
  215. uint8_t impUse[460];
  216. } __attribute__ ((packed));
  217. /* Partition Descriptor (ECMA 167r3 3/10.5) */
  218. struct partitionDesc {
  219. struct tag descTag;
  220. __le32 volDescSeqNum;
  221. __le16 partitionFlags;
  222. __le16 partitionNumber;
  223. struct regid partitionContents;
  224. uint8_t partitionContentsUse[128];
  225. __le32 accessType;
  226. __le32 partitionStartingLocation;
  227. __le32 partitionLength;
  228. struct regid impIdent;
  229. uint8_t impUse[128];
  230. uint8_t reserved[156];
  231. } __attribute__ ((packed));
  232. /* Partition Flags (ECMA 167r3 3/10.5.3) */
  233. #define PD_PARTITION_FLAGS_ALLOC 0x0001
  234. /* Partition Contents (ECMA 167r2 3/10.5.3) */
  235. #define PD_PARTITION_CONTENTS_NSR02 "+NSR02"
  236. /* Partition Contents (ECMA 167r3 3/10.5.5) */
  237. #define PD_PARTITION_CONTENTS_FDC01 "+FDC01"
  238. #define PD_PARTITION_CONTENTS_CD001 "+CD001"
  239. #define PD_PARTITION_CONTENTS_CDW02 "+CDW02"
  240. #define PD_PARTITION_CONTENTS_NSR03 "+NSR03"
  241. /* Access Type (ECMA 167r3 3/10.5.7) */
  242. #define PD_ACCESS_TYPE_NONE 0x00000000
  243. #define PD_ACCESS_TYPE_READ_ONLY 0x00000001
  244. #define PD_ACCESS_TYPE_WRITE_ONCE 0x00000002
  245. #define PD_ACCESS_TYPE_REWRITABLE 0x00000003
  246. #define PD_ACCESS_TYPE_OVERWRITABLE 0x00000004
  247. /* Logical Volume Descriptor (ECMA 167r3 3/10.6) */
  248. struct logicalVolDesc {
  249. struct tag descTag;
  250. __le32 volDescSeqNum;
  251. struct charspec descCharSet;
  252. dstring logicalVolIdent[128];
  253. __le32 logicalBlockSize;
  254. struct regid domainIdent;
  255. uint8_t logicalVolContentsUse[16];
  256. __le32 mapTableLength;
  257. __le32 numPartitionMaps;
  258. struct regid impIdent;
  259. uint8_t impUse[128];
  260. struct extent_ad integritySeqExt;
  261. uint8_t partitionMaps[0];
  262. } __attribute__ ((packed));
  263. /* Generic Partition Map (ECMA 167r3 3/10.7.1) */
  264. struct genericPartitionMap {
  265. uint8_t partitionMapType;
  266. uint8_t partitionMapLength;
  267. uint8_t partitionMapping[0];
  268. } __attribute__ ((packed));
  269. /* Partition Map Type (ECMA 167r3 3/10.7.1.1) */
  270. #define GP_PARTITION_MAP_TYPE_UNDEF 0x00
  271. #define GP_PARTIITON_MAP_TYPE_1 0x01
  272. #define GP_PARTITION_MAP_TYPE_2 0x02
  273. /* Type 1 Partition Map (ECMA 167r3 3/10.7.2) */
  274. struct genericPartitionMap1 {
  275. uint8_t partitionMapType;
  276. uint8_t partitionMapLength;
  277. __le16 volSeqNum;
  278. __le16 partitionNum;
  279. } __attribute__ ((packed));
  280. /* Type 2 Partition Map (ECMA 167r3 3/10.7.3) */
  281. struct genericPartitionMap2 {
  282. uint8_t partitionMapType;
  283. uint8_t partitionMapLength;
  284. uint8_t partitionIdent[62];
  285. } __attribute__ ((packed));
  286. /* Unallocated Space Descriptor (ECMA 167r3 3/10.8) */
  287. struct unallocSpaceDesc {
  288. struct tag descTag;
  289. __le32 volDescSeqNum;
  290. __le32 numAllocDescs;
  291. struct extent_ad allocDescs[0];
  292. } __attribute__ ((packed));
  293. /* Terminating Descriptor (ECMA 167r3 3/10.9) */
  294. struct terminatingDesc {
  295. struct tag descTag;
  296. uint8_t reserved[496];
  297. } __attribute__ ((packed));
  298. /* Logical Volume Integrity Descriptor (ECMA 167r3 3/10.10) */
  299. struct logicalVolIntegrityDesc {
  300. struct tag descTag;
  301. struct timestamp recordingDateAndTime;
  302. __le32 integrityType;
  303. struct extent_ad nextIntegrityExt;
  304. uint8_t logicalVolContentsUse[32];
  305. __le32 numOfPartitions;
  306. __le32 lengthOfImpUse;
  307. __le32 freeSpaceTable[0];
  308. __le32 sizeTable[0];
  309. uint8_t impUse[0];
  310. } __attribute__ ((packed));
  311. /* Integrity Type (ECMA 167r3 3/10.10.3) */
  312. #define LVID_INTEGRITY_TYPE_OPEN 0x00000000
  313. #define LVID_INTEGRITY_TYPE_CLOSE 0x00000001
  314. /* Recorded Address (ECMA 167r3 4/7.1) */
  315. struct lb_addr {
  316. __le32 logicalBlockNum;
  317. __le16 partitionReferenceNum;
  318. } __attribute__ ((packed));
  319. /* ... and its in-core analog */
  320. struct kernel_lb_addr {
  321. uint32_t logicalBlockNum;
  322. uint16_t partitionReferenceNum;
  323. };
  324. /* Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */
  325. struct short_ad {
  326. __le32 extLength;
  327. __le32 extPosition;
  328. } __attribute__ ((packed));
  329. /* Long Allocation Descriptor (ECMA 167r3 4/14.14.2) */
  330. struct long_ad {
  331. __le32 extLength;
  332. struct lb_addr extLocation;
  333. uint8_t impUse[6];
  334. } __attribute__ ((packed));
  335. struct kernel_long_ad {
  336. uint32_t extLength;
  337. struct kernel_lb_addr extLocation;
  338. uint8_t impUse[6];
  339. };
  340. /* Extended Allocation Descriptor (ECMA 167r3 4/14.14.3) */
  341. struct ext_ad {
  342. __le32 extLength;
  343. __le32 recordedLength;
  344. __le32 informationLength;
  345. struct lb_addr extLocation;
  346. } __attribute__ ((packed));
  347. struct kernel_ext_ad {
  348. uint32_t extLength;
  349. uint32_t recordedLength;
  350. uint32_t informationLength;
  351. struct kernel_lb_addr extLocation;
  352. };
  353. /* Descriptor Tag (ECMA 167r3 4/7.2 - See 3/7.2) */
  354. /* Tag Identifier (ECMA 167r3 4/7.2.1) */
  355. #define TAG_IDENT_FSD 0x0100
  356. #define TAG_IDENT_FID 0x0101
  357. #define TAG_IDENT_AED 0x0102
  358. #define TAG_IDENT_IE 0x0103
  359. #define TAG_IDENT_TE 0x0104
  360. #define TAG_IDENT_FE 0x0105
  361. #define TAG_IDENT_EAHD 0x0106
  362. #define TAG_IDENT_USE 0x0107
  363. #define TAG_IDENT_SBD 0x0108
  364. #define TAG_IDENT_PIE 0x0109
  365. #define TAG_IDENT_EFE 0x010A
  366. /* File Set Descriptor (ECMA 167r3 4/14.1) */
  367. struct fileSetDesc {
  368. struct tag descTag;
  369. struct timestamp recordingDateAndTime;
  370. __le16 interchangeLvl;
  371. __le16 maxInterchangeLvl;
  372. __le32 charSetList;
  373. __le32 maxCharSetList;
  374. __le32 fileSetNum;
  375. __le32 fileSetDescNum;
  376. struct charspec logicalVolIdentCharSet;
  377. dstring logicalVolIdent[128];
  378. struct charspec fileSetCharSet;
  379. dstring fileSetIdent[32];
  380. dstring copyrightFileIdent[32];
  381. dstring abstractFileIdent[32];
  382. struct long_ad rootDirectoryICB;
  383. struct regid domainIdent;
  384. struct long_ad nextExt;
  385. struct long_ad streamDirectoryICB;
  386. uint8_t reserved[32];
  387. } __attribute__ ((packed));
  388. /* Partition Header Descriptor (ECMA 167r3 4/14.3) */
  389. struct partitionHeaderDesc {
  390. struct short_ad unallocSpaceTable;
  391. struct short_ad unallocSpaceBitmap;
  392. struct short_ad partitionIntegrityTable;
  393. struct short_ad freedSpaceTable;
  394. struct short_ad freedSpaceBitmap;
  395. uint8_t reserved[88];
  396. } __attribute__ ((packed));
  397. /* File Identifier Descriptor (ECMA 167r3 4/14.4) */
  398. struct fileIdentDesc {
  399. struct tag descTag;
  400. __le16 fileVersionNum;
  401. uint8_t fileCharacteristics;
  402. uint8_t lengthFileIdent;
  403. struct long_ad icb;
  404. __le16 lengthOfImpUse;
  405. uint8_t impUse[0];
  406. uint8_t fileIdent[0];
  407. uint8_t padding[0];
  408. } __attribute__ ((packed));
  409. /* File Characteristics (ECMA 167r3 4/14.4.3) */
  410. #define FID_FILE_CHAR_HIDDEN 0x01
  411. #define FID_FILE_CHAR_DIRECTORY 0x02
  412. #define FID_FILE_CHAR_DELETED 0x04
  413. #define FID_FILE_CHAR_PARENT 0x08
  414. #define FID_FILE_CHAR_METADATA 0x10
  415. /* Allocation Ext Descriptor (ECMA 167r3 4/14.5) */
  416. struct allocExtDesc {
  417. struct tag descTag;
  418. __le32 previousAllocExtLocation;
  419. __le32 lengthAllocDescs;
  420. } __attribute__ ((packed));
  421. /* ICB Tag (ECMA 167r3 4/14.6) */
  422. struct icbtag {
  423. __le32 priorRecordedNumDirectEntries;
  424. __le16 strategyType;
  425. __le16 strategyParameter;
  426. __le16 numEntries;
  427. uint8_t reserved;
  428. uint8_t fileType;
  429. struct lb_addr parentICBLocation;
  430. __le16 flags;
  431. } __attribute__ ((packed));
  432. /* Strategy Type (ECMA 167r3 4/14.6.2) */
  433. #define ICBTAG_STRATEGY_TYPE_UNDEF 0x0000
  434. #define ICBTAG_STRATEGY_TYPE_1 0x0001
  435. #define ICBTAG_STRATEGY_TYPE_2 0x0002
  436. #define ICBTAG_STRATEGY_TYPE_3 0x0003
  437. #define ICBTAG_STRATEGY_TYPE_4 0x0004
  438. /* File Type (ECMA 167r3 4/14.6.6) */
  439. #define ICBTAG_FILE_TYPE_UNDEF 0x00
  440. #define ICBTAG_FILE_TYPE_USE 0x01
  441. #define ICBTAG_FILE_TYPE_PIE 0x02
  442. #define ICBTAG_FILE_TYPE_IE 0x03
  443. #define ICBTAG_FILE_TYPE_DIRECTORY 0x04
  444. #define ICBTAG_FILE_TYPE_REGULAR 0x05
  445. #define ICBTAG_FILE_TYPE_BLOCK 0x06
  446. #define ICBTAG_FILE_TYPE_CHAR 0x07
  447. #define ICBTAG_FILE_TYPE_EA 0x08
  448. #define ICBTAG_FILE_TYPE_FIFO 0x09
  449. #define ICBTAG_FILE_TYPE_SOCKET 0x0A
  450. #define ICBTAG_FILE_TYPE_TE 0x0B
  451. #define ICBTAG_FILE_TYPE_SYMLINK 0x0C
  452. #define ICBTAG_FILE_TYPE_STREAMDIR 0x0D
  453. /* Flags (ECMA 167r3 4/14.6.8) */
  454. #define ICBTAG_FLAG_AD_MASK 0x0007
  455. #define ICBTAG_FLAG_AD_SHORT 0x0000
  456. #define ICBTAG_FLAG_AD_LONG 0x0001
  457. #define ICBTAG_FLAG_AD_EXTENDED 0x0002
  458. #define ICBTAG_FLAG_AD_IN_ICB 0x0003
  459. #define ICBTAG_FLAG_SORTED 0x0008
  460. #define ICBTAG_FLAG_NONRELOCATABLE 0x0010
  461. #define ICBTAG_FLAG_ARCHIVE 0x0020
  462. #define ICBTAG_FLAG_SETUID 0x0040
  463. #define ICBTAG_FLAG_SETGID 0x0080
  464. #define ICBTAG_FLAG_STICKY 0x0100
  465. #define ICBTAG_FLAG_CONTIGUOUS 0x0200
  466. #define ICBTAG_FLAG_SYSTEM 0x0400
  467. #define ICBTAG_FLAG_TRANSFORMED 0x0800
  468. #define ICBTAG_FLAG_MULTIVERSIONS 0x1000
  469. #define ICBTAG_FLAG_STREAM 0x2000
  470. /* Indirect Entry (ECMA 167r3 4/14.7) */
  471. struct indirectEntry {
  472. struct tag descTag;
  473. struct icbtag icbTag;
  474. struct long_ad indirectICB;
  475. } __attribute__ ((packed));
  476. /* Terminal Entry (ECMA 167r3 4/14.8) */
  477. struct terminalEntry {
  478. struct tag descTag;
  479. struct icbtag icbTag;
  480. } __attribute__ ((packed));
  481. /* File Entry (ECMA 167r3 4/14.9) */
  482. struct fileEntry {
  483. struct tag descTag;
  484. struct icbtag icbTag;
  485. __le32 uid;
  486. __le32 gid;
  487. __le32 permissions;
  488. __le16 fileLinkCount;
  489. uint8_t recordFormat;
  490. uint8_t recordDisplayAttr;
  491. __le32 recordLength;
  492. __le64 informationLength;
  493. __le64 logicalBlocksRecorded;
  494. struct timestamp accessTime;
  495. struct timestamp modificationTime;
  496. struct timestamp attrTime;
  497. __le32 checkpoint;
  498. struct long_ad extendedAttrICB;
  499. struct regid impIdent;
  500. __le64 uniqueID;
  501. __le32 lengthExtendedAttr;
  502. __le32 lengthAllocDescs;
  503. uint8_t extendedAttr[0];
  504. uint8_t allocDescs[0];
  505. } __attribute__ ((packed));
  506. /* Permissions (ECMA 167r3 4/14.9.5) */
  507. #define FE_PERM_O_EXEC 0x00000001U
  508. #define FE_PERM_O_WRITE 0x00000002U
  509. #define FE_PERM_O_READ 0x00000004U
  510. #define FE_PERM_O_CHATTR 0x00000008U
  511. #define FE_PERM_O_DELETE 0x00000010U
  512. #define FE_PERM_G_EXEC 0x00000020U
  513. #define FE_PERM_G_WRITE 0x00000040U
  514. #define FE_PERM_G_READ 0x00000080U
  515. #define FE_PERM_G_CHATTR 0x00000100U
  516. #define FE_PERM_G_DELETE 0x00000200U
  517. #define FE_PERM_U_EXEC 0x00000400U
  518. #define FE_PERM_U_WRITE 0x00000800U
  519. #define FE_PERM_U_READ 0x00001000U
  520. #define FE_PERM_U_CHATTR 0x00002000U
  521. #define FE_PERM_U_DELETE 0x00004000U
  522. /* Record Format (ECMA 167r3 4/14.9.7) */
  523. #define FE_RECORD_FMT_UNDEF 0x00
  524. #define FE_RECORD_FMT_FIXED_PAD 0x01
  525. #define FE_RECORD_FMT_FIXED 0x02
  526. #define FE_RECORD_FMT_VARIABLE8 0x03
  527. #define FE_RECORD_FMT_VARIABLE16 0x04
  528. #define FE_RECORD_FMT_VARIABLE16_MSB 0x05
  529. #define FE_RECORD_FMT_VARIABLE32 0x06
  530. #define FE_RECORD_FMT_PRINT 0x07
  531. #define FE_RECORD_FMT_LF 0x08
  532. #define FE_RECORD_FMT_CR 0x09
  533. #define FE_RECORD_FMT_CRLF 0x0A
  534. #define FE_RECORD_FMT_LFCR 0x0B
  535. /* Record Display Attributes (ECMA 167r3 4/14.9.8) */
  536. #define FE_RECORD_DISPLAY_ATTR_UNDEF 0x00
  537. #define FE_RECORD_DISPLAY_ATTR_1 0x01
  538. #define FE_RECORD_DISPLAY_ATTR_2 0x02
  539. #define FE_RECORD_DISPLAY_ATTR_3 0x03
  540. /* Extended Attribute Header Descriptor (ECMA 167r3 4/14.10.1) */
  541. struct extendedAttrHeaderDesc {
  542. struct tag descTag;
  543. __le32 impAttrLocation;
  544. __le32 appAttrLocation;
  545. } __attribute__ ((packed));
  546. /* Generic Format (ECMA 167r3 4/14.10.2) */
  547. struct genericFormat {
  548. __le32 attrType;
  549. uint8_t attrSubtype;
  550. uint8_t reserved[3];
  551. __le32 attrLength;
  552. uint8_t attrData[0];
  553. } __attribute__ ((packed));
  554. /* Character Set Information (ECMA 167r3 4/14.10.3) */
  555. struct charSetInfo {
  556. __le32 attrType;
  557. uint8_t attrSubtype;
  558. uint8_t reserved[3];
  559. __le32 attrLength;
  560. __le32 escapeSeqLength;
  561. uint8_t charSetType;
  562. uint8_t escapeSeq[0];
  563. } __attribute__ ((packed));
  564. /* Alternate Permissions (ECMA 167r3 4/14.10.4) */
  565. struct altPerms {
  566. __le32 attrType;
  567. uint8_t attrSubtype;
  568. uint8_t reserved[3];
  569. __le32 attrLength;
  570. __le16 ownerIdent;
  571. __le16 groupIdent;
  572. __le16 permission;
  573. } __attribute__ ((packed));
  574. /* File Times Extended Attribute (ECMA 167r3 4/14.10.5) */
  575. struct fileTimesExtAttr {
  576. __le32 attrType;
  577. uint8_t attrSubtype;
  578. uint8_t reserved[3];
  579. __le32 attrLength;
  580. __le32 dataLength;
  581. __le32 fileTimeExistence;
  582. uint8_t fileTimes;
  583. } __attribute__ ((packed));
  584. /* FileTimeExistence (ECMA 167r3 4/14.10.5.6) */
  585. #define FTE_CREATION 0x00000001
  586. #define FTE_DELETION 0x00000004
  587. #define FTE_EFFECTIVE 0x00000008
  588. #define FTE_BACKUP 0x00000002
  589. /* Information Times Extended Attribute (ECMA 167r3 4/14.10.6) */
  590. struct infoTimesExtAttr {
  591. __le32 attrType;
  592. uint8_t attrSubtype;
  593. uint8_t reserved[3];
  594. __le32 attrLength;
  595. __le32 dataLength;
  596. __le32 infoTimeExistence;
  597. uint8_t infoTimes[0];
  598. } __attribute__ ((packed));
  599. /* Device Specification (ECMA 167r3 4/14.10.7) */
  600. struct deviceSpec {
  601. __le32 attrType;
  602. uint8_t attrSubtype;
  603. uint8_t reserved[3];
  604. __le32 attrLength;
  605. __le32 impUseLength;
  606. __le32 majorDeviceIdent;
  607. __le32 minorDeviceIdent;
  608. uint8_t impUse[0];
  609. } __attribute__ ((packed));
  610. /* Implementation Use Extended Attr (ECMA 167r3 4/14.10.8) */
  611. struct impUseExtAttr {
  612. __le32 attrType;
  613. uint8_t attrSubtype;
  614. uint8_t reserved[3];
  615. __le32 attrLength;
  616. __le32 impUseLength;
  617. struct regid impIdent;
  618. uint8_t impUse[0];
  619. } __attribute__ ((packed));
  620. /* Application Use Extended Attribute (ECMA 167r3 4/14.10.9) */
  621. struct appUseExtAttr {
  622. __le32 attrType;
  623. uint8_t attrSubtype;
  624. uint8_t reserved[3];
  625. __le32 attrLength;
  626. __le32 appUseLength;
  627. struct regid appIdent;
  628. uint8_t appUse[0];
  629. } __attribute__ ((packed));
  630. #define EXTATTR_CHAR_SET 1
  631. #define EXTATTR_ALT_PERMS 3
  632. #define EXTATTR_FILE_TIMES 5
  633. #define EXTATTR_INFO_TIMES 6
  634. #define EXTATTR_DEV_SPEC 12
  635. #define EXTATTR_IMP_USE 2048
  636. #define EXTATTR_APP_USE 65536
  637. /* Unallocated Space Entry (ECMA 167r3 4/14.11) */
  638. struct unallocSpaceEntry {
  639. struct tag descTag;
  640. struct icbtag icbTag;
  641. __le32 lengthAllocDescs;
  642. uint8_t allocDescs[0];
  643. } __attribute__ ((packed));
  644. /* Space Bitmap Descriptor (ECMA 167r3 4/14.12) */
  645. struct spaceBitmapDesc {
  646. struct tag descTag;
  647. __le32 numOfBits;
  648. __le32 numOfBytes;
  649. uint8_t bitmap[0];
  650. } __attribute__ ((packed));
  651. /* Partition Integrity Entry (ECMA 167r3 4/14.13) */
  652. struct partitionIntegrityEntry {
  653. struct tag descTag;
  654. struct icbtag icbTag;
  655. struct timestamp recordingDateAndTime;
  656. uint8_t integrityType;
  657. uint8_t reserved[175];
  658. struct regid impIdent;
  659. uint8_t impUse[256];
  660. } __attribute__ ((packed));
  661. /* Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */
  662. /* Extent Length (ECMA 167r3 4/14.14.1.1) */
  663. #define EXT_RECORDED_ALLOCATED 0x00000000
  664. #define EXT_NOT_RECORDED_ALLOCATED 0x40000000
  665. #define EXT_NOT_RECORDED_NOT_ALLOCATED 0x80000000
  666. #define EXT_NEXT_EXTENT_ALLOCDECS 0xC0000000
  667. /* Long Allocation Descriptor (ECMA 167r3 4/14.14.2) */
  668. /* Extended Allocation Descriptor (ECMA 167r3 4/14.14.3) */
  669. /* Logical Volume Header Descriptor (ECMA 167r3 4/14.15) */
  670. struct logicalVolHeaderDesc {
  671. __le64 uniqueID;
  672. uint8_t reserved[24];
  673. } __attribute__ ((packed));
  674. /* Path Component (ECMA 167r3 4/14.16.1) */
  675. struct pathComponent {
  676. uint8_t componentType;
  677. uint8_t lengthComponentIdent;
  678. __le16 componentFileVersionNum;
  679. dstring componentIdent[0];
  680. } __attribute__ ((packed));
  681. /* File Entry (ECMA 167r3 4/14.17) */
  682. struct extendedFileEntry {
  683. struct tag descTag;
  684. struct icbtag icbTag;
  685. __le32 uid;
  686. __le32 gid;
  687. __le32 permissions;
  688. __le16 fileLinkCount;
  689. uint8_t recordFormat;
  690. uint8_t recordDisplayAttr;
  691. __le32 recordLength;
  692. __le64 informationLength;
  693. __le64 objectSize;
  694. __le64 logicalBlocksRecorded;
  695. struct timestamp accessTime;
  696. struct timestamp modificationTime;
  697. struct timestamp createTime;
  698. struct timestamp attrTime;
  699. __le32 checkpoint;
  700. __le32 reserved;
  701. struct long_ad extendedAttrICB;
  702. struct long_ad streamDirectoryICB;
  703. struct regid impIdent;
  704. __le64 uniqueID;
  705. __le32 lengthExtendedAttr;
  706. __le32 lengthAllocDescs;
  707. uint8_t extendedAttr[0];
  708. uint8_t allocDescs[0];
  709. } __attribute__ ((packed));
  710. #endif /* _ECMA_167_H */