ecma_167.h 22 KB

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