ecma_167.h 22 KB

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