ecma_167.h 22 KB

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