1 ////////////////////////////////////////////////////////////////////
2 // Copyright (C) Alexander Telyatnikov, Ivan Keliukh, Yegor Anchishkin, SKIF Software, 1999-2013. Kiev, Ukraine
3 // All rights reserved
4 // This file was released under the GPLv2 on June 2015.
5 ////////////////////////////////////////////////////////////////////
6 /*
7     Module name:
8 
9    ecma_167.h
10 
11     Abstract:
12 
13    This file contains ECMA-167 definitions
14 
15 */
16 
17 #ifndef __ECMA_167_H__
18 #define __ECMA_167_H__
19 
20 typedef uint8   dstring;
21 
22 #define UDF_COMP_ID_8    0x08
23 #define UDF_COMP_ID_16   0x10
24 
25 /* make sure all structures are packed! */
26 #pragma pack(push, 1)
27 
28 /* CS0 Charspec (ECMA 167 1/7.2.1) */
29 typedef struct {
30     uint8 charSetType;
31     uint8 charSetInfo[63];
32 } charspec;
33 
34 /* Timestamp (ECMA 167 1/7.3) */
35 typedef struct {
36     uint16 typeAndTimezone;
37     uint16 year;
38     uint8 month;
39     uint8 day;
40     uint8 hour;
41     uint8 minute;
42     uint8 second;
43     uint8 centiseconds;
44     uint8 hundredsOfMicroseconds;
45     uint8 microseconds;
46 } timestamp;
47 
48 typedef timestamp       UDF_TIME_STAMP;
49 typedef UDF_TIME_STAMP* PUDF_TIME_STAMP;
50 
51 /* Timestamp types (ECMA 167 1/7.3.1) */
52 #define TIMESTAMP_TYPE_CUT          0x0000U
53 #define TIMESTAMP_TYPE_LOCAL        0x0001U
54 #define TIMESTAMP_TYPE_AGREEMENT    0x0002U
55 #define TIMESTAMP_OFFSET_MASK       0x0FFFU
56 #define TIMESTAMP_NO_OFFSET         0x0800U
57 
58 /* Entity Identifier (ECMA 167 1/7.4) */
59 typedef struct {
60     uint8 flags;
61     uint8 ident[23];
62     uint8 identSuffix[8];
63 } EntityID;
64 #define regid EntityID
65 
66 /* Entity identifier flags (ECMA 167 1/7.4.1) */
67 #define ENTITYID_FLAGS_DIRTY        0x01U
68 #define ENTITYID_FLAGS_PROTECTED    0x02U
69 
70 /* Volume Structure Descriptor (ECMA 167 2/9.1) */
71 #define STD_ID_LEN  5
72 struct VolStructDesc {
73     uint8 structType;
74     uint8 stdIdent[STD_ID_LEN];
75     uint8 structVersion;
76     uint8 structData[2041];
77 };
78 
79 /* Std structure identifiers (ECMA 167 2/9.1.2) */
80 #define STD_ID_BEA01    "BEA01"
81 #define STD_ID_BOOT2    "BOOT2"
82 #define STD_ID_CD001    "CD001"
83 #define STD_ID_CDW02    "CDW02"
84 #define STD_ID_NSR02    "NSR02"
85 #define STD_ID_NSR03    "NSR03"
86 #define STD_ID_TEA01    "TEA01"
87 
88 /* Beginning Extended Area Descriptor (ECMA 167 2/9.2) */
89 struct BeginningExtendedAreaDesc {
90     uint8 structType;
91     uint8 stdIdent[STD_ID_LEN];
92     uint8 structVersion;
93     uint8 structData[2041];
94 };
95 
96 /* Terminating Extended Area Descriptor (ECMA 167 2/9.3) */
97 struct TerminatingExtendedAreaDesc {
98     uint8 structType;
99     uint8 stdIdent[STD_ID_LEN];
100     uint8 structVersion;
101     uint8 structData[2041];
102 };
103 
104 /* Boot Descriptor (ECMA 167 2/9.4) */
105 typedef struct _BootDesc {
106     uint8 structType;
107     uint8 stdIdent[STD_ID_LEN];
108     uint8 structVersion;
109     uint8 reserved1;
110     EntityID architectureType;
111     EntityID bootIdent;
112     uint32 bootExtLocation;
113     uint32 bootExtLength;
114     uint64 loadAddress;
115     uint64 startAddress;
116     timestamp descCreationDateAndTime;
117     uint16 flags;
118     uint8 reserved2[32];
119     uint8 bootUse[1906];
120 } BootDesc, *PBootDesc;
121 
122 /* Boot flags (ECMA 167 2/9.4.12) */
123 #define BOOT_FLAGS_ERASE    1
124 
125 /* Extent Descriptor (ECMA 167 3/7.1) */
126 
127 typedef struct _EXTENT_AD {
128     uint32 extLength;
129     uint32 extLocation;   // Lba
130 } EXTENT_AD, *PEXTENT_AD;
131 
132 typedef EXTENT_AD   extent_ad;
133 
134 typedef EXTENT_AD   EXTENT_MAP;
135 typedef PEXTENT_AD  PEXTENT_MAP;
136 
137 /* Descriptor Tag (ECMA 167 3/7.2) */
138 typedef struct {
139     uint16 tagIdent;
140     uint16 descVersion;
141     uint8 tagChecksum;
142     uint8 reserved;
143     uint16 tagSerialNum;
144     uint16 descCRC;
145     uint16 descCRCLength;
146     uint32 tagLocation;
147 } tag;
148 
149 typedef tag       DESC_TAG;
150 typedef DESC_TAG* PDESC_TAG;
151 
152 /* Tag Identifiers (ECMA 167 3/7.2.1) */
153 #define TID_UNUSED_DESC                 0x0000U
154 #define TID_PRIMARY_VOL_DESC            0x0001U
155 #define TID_ANCHOR_VOL_DESC_PTR         0x0002U
156 #define TID_VOL_DESC_PTR                0x0003U
157 #define TID_IMP_USE_VOL_DESC            0x0004U
158 #define TID_PARTITION_DESC              0x0005U
159 #define TID_LOGICAL_VOL_DESC            0x0006U
160 #define TID_UNALLOC_SPACE_DESC          0x0007U
161 #define TID_TERMINATING_DESC            0x0008U
162 #define TID_LOGICAL_VOL_INTEGRITY_DESC  0x0009U
163 
164 /* Tag Identifiers (ECMA 167 4/7.2.1) */
165 #define TID_FILE_SET_DESC               0x0100U
166 #define TID_FILE_IDENT_DESC             0x0101U
167 #define TID_ALLOC_EXTENT_DESC           0x0102U
168 #define TID_INDIRECT_ENTRY              0x0103U
169 #define TID_TERMINAL_ENTRY              0x0104U
170 #define TID_FILE_ENTRY                  0x0105U
171 #define TID_EXTENDED_ATTRE_HEADER_DESC  0x0106U
172 #define TID_UNALLOCATED_SPACE_ENTRY     0x0107U
173 #define TID_SPACE_BITMAP_DESC           0x0108U
174 #define TID_PARTITION_INTEGRITY_ENTRY   0x0109U
175 #define TID_EXTENDED_FILE_ENTRY         0x010AU
176 
177 /* NSR Descriptor (ECMA 167 3/9.1) */
178 struct NSRDesc {
179     uint8 structType;
180     uint8 stdIdent[STD_ID_LEN];
181     uint8 structVersion;
182     uint8 reserved;
183     uint8 structData[2040];
184 };
185 
186 /* Primary Volume Descriptor (ECMA 167 3/10.1) */
187 struct PrimaryVolDesc {
188     tag descTag;
189     uint32 volDescSeqNum;
190     uint32 primaryVolDescNum;
191     dstring volIdent[32];
192     uint16 volSeqNum;
193     uint16 maxVolSeqNum;
194     uint16 interchangeLvl;
195     uint16 maxInterchangeLvl;
196     uint32 charSetList;
197     uint32 maxCharSetList;
198     dstring volSetIdent[128];
199     charspec descCharSet;
200     charspec explanatoryCharSet;
201     extent_ad volAbstract;
202     extent_ad volCopyright;
203     EntityID appIdent;
204     timestamp recordingDateAndTime;
205     EntityID impIdent;
206     uint8 impUse[64];
207     uint32 predecessorVolDescSeqLocation;
208     uint16 flags;
209     uint8 reserved[22];
210 };
211 
212 /* Primary volume descriptor flags (ECMA 167 3/10.1.21) */
213 #define VOL_SET_IDENT   1
214 
215 /* Anchor Volume Descriptor Pointer (ECMA 167 3/10.2) */
216 struct AnchorVolDescPtr {
217     tag descTag;
218     extent_ad mainVolDescSeqExt;
219     extent_ad reserveVolDescSeqExt;
220     uint8 reserved[480];
221 };
222 
223 /* Volume Descriptor Pointer (ECMA 167 3/10.3) */
224 struct VolDescPtr {
225     tag descTag;
226     uint32 volDescSeqNum;
227     extent_ad nextVolDescSeqExt;
228     uint8 reserved[484];
229 };
230 
231 #define MAX_VDS_PARTS  32
232 
233 /* Implementation Use Volume Descriptor (ECMA 167 3/10.4) */
234 struct ImpUseVolDesc {
235     tag descTag;
236     uint32 volDescSeqNum;
237     EntityID impIdent;
238     uint8 impUse[460];
239 };
240 
241 /* Partition Descriptor (ECMA 167 3/10.5) */
242 struct PartitionDesc {
243     tag descTag;
244     uint32 volDescSeqNum;
245     uint16 partitionFlags;
246     uint16 partitionNumber;
247     EntityID partitionContents;
248     uint8 partitionContentsUse[128];
249     uint32 accessType;
250     uint32 partitionStartingLocation;
251     uint32 partitionLength;
252     EntityID impIdent;
253     uint8 impUse[128];
254     uint8 reserved[156];
255 };
256 
257 /* Partition Flags (ECMA 167 3/10.5.3) */
258 #define PARTITION_FLAGS_ALLOC   1
259 
260 /* Partition Contents (ECMA 167 3/10.5.5) */
261 #define PARTITION_CONTENTS_FDC01    "+FDC01"
262 #define PARTITION_CONTENTS_CD001    "+CD001"
263 #define PARTITION_CONTENTS_CDW02    "+CDW02"
264 #define PARTITION_CONTENTS_NSR02    "+NSR02"
265 #define PARTITION_CONTENTS_NSR03    "+NSR03"
266 
267 /* Partition Access Types (ECMA 167 3/10.5.7) */
268 #define PARTITION_ACCESS_NONE       0
269 #define PARTITION_ACCESS_R          1
270 #define PARTITION_ACCESS_WO         2
271 #define PARTITION_ACCESS_RW         3
272 #define PARTITION_ACCESS_OW         4
273 #define PARTITION_ACCESS_MAX_KNOWN  PARTITION_ACCESS_OW
274 
275 /* Logical Volume Descriptor (ECMA 167 3/10.6) */
276 struct LogicalVolDesc {
277     tag descTag;
278     uint32 volDescSeqNum;
279     charspec descCharSet;
280     dstring logicalVolIdent[128];
281     uint32 logicalBlockSize;
282     EntityID domainIdent;
283     uint8 logicalVolContentsUse[16]; /* used to find fileset */
284     uint32 mapTableLength;
285     uint32 numPartitionMaps;
286     EntityID impIdent;
287     uint8 impUse[128];
288     extent_ad integritySeqExt;
289 //  uint8 partitionMaps[0];
290 };
291 
292 /* Generic Partition Map (ECMA 167 3/10.7.1) */
293 struct GenericPartitionMap {
294     uint8 partitionMapType;
295     uint8 partitionMapLength;
296 //  uint8 partitionMapping[0];
297 };
298 
299 /* Partition Map Type (ECMA 167 3/10.7.1.1) */
300 #define PARTITION_MAP_TYPE_NONE     0
301 #define PARTITION_MAP_TYPE_1        1
302 #define PARTITION_MAP_TYPE_2        2
303 
304 /* Type 1 Partition Map (ECMA 167 3/10.7.2) */
305 struct GenericPartitionMap1 {
306     uint8 partitionMapType;
307     uint8 partitionMapLength;
308     uint16 volSeqNum;
309     uint16 partitionNum;
310 };
311 
312 /* Type 2 Partition Map (ECMA 167 3/10.7.3) */
313 struct GenericPartitionMap2 {
314     uint8 partitionMapType; /* 2 */
315     uint8 partitionMapLength;
316     uint8 partitionIdent[62];
317 };
318 
319 /* Unallocated Space Descriptor (ECMA 167 3/10.8) */
320 typedef struct _UNALLOC_SPACE_DESC {
321     tag descTag;
322     uint32 volDescSeqNum;
323     uint32 numAllocDescs;
324 //  extent_ad allocDescs[0];
325 } UNALLOC_SPACE_DESC, *PUNALLOC_SPACE_DESC;
326 
327 typedef UNALLOC_SPACE_DESC UnallocatedSpaceDesc;
328 
329 /* Terminating Descriptor (ECMA 3/10.9) */
330 struct TerminatingDesc {
331     tag descTag;
332     uint8 reserved[496];
333 };
334 
335 struct GenericDesc
336 {
337         tag descTag;
338         uint32 volDescSeqNum;
339 };
340 
341 /* Logical Volume Integrity Descriptor (ECMA 167 3/10.10) */
342 
343 struct LogicalVolIntegrityDesc {
344     tag descTag;
345     timestamp recordingDateAndTime;
346     uint32 integrityType;
347     extent_ad nextIntegrityExt;
348     uint8 logicalVolContentsUse[32];
349     uint32 numOfPartitions;
350     uint32 lengthOfImpUse;
351 //  uint32 freeSpaceTable[0];
352 //  uint32 sizeTable[0];
353 //  uint8 impUse[0];
354 };
355 
356 /* Integrity Types (ECMA 167 3/10.10.3) */
357 #define INTEGRITY_TYPE_OPEN     0
358 #define INTEGRITY_TYPE_CLOSE    1
359 
360 /* Recorded Address (ECMA 167 4/7.1) */
361 typedef struct {
362     uint32 logicalBlockNum;
363     uint16 partitionReferenceNum;
364 } lb_addr;
365 
366 /* Extent interpretation (ECMA 167 4/14.14.1.1) */
367 #define EXTENT_RECORDED_ALLOCATED               0x00
368 #define EXTENT_NOT_RECORDED_ALLOCATED           0x01
369 #define EXTENT_NOT_RECORDED_NOT_ALLOCATED       0x02
370 #define EXTENT_NEXT_EXTENT_ALLOCDESC            0x03
371 
372 /* Long Allocation Descriptor (ECMA 167 4/14.14.2) */
373 typedef struct {
374     uint32 extLength;
375     lb_addr extLocation;
376     uint8 impUse[6];
377 } long_ad;
378     /* upper 2 bits of extLength indicate type */
379 typedef long_ad  LONG_AD;
380 typedef LONG_AD* PLONG_AD;
381 
382 /* File Set Descriptor (ECMA 167 4/14.1) */
383 typedef struct _FILE_SET_DESC {
384     tag descTag;
385     timestamp recordingDateAndTime;
386     uint16 interchangeLvl;
387     uint16 maxInterchangeLvl;
388     uint32 charSetList;
389     uint32 maxCharSetList;
390     uint32 fileSetNum;
391     uint32 fileSetDescNum;
392     charspec logicalVolIdentCharSet;
393     dstring logicalVolIdent[128];
394     charspec fileSetCharSet;
395     dstring fileSetIdent[32];
396     dstring copyrightFileIdent[32];
397     dstring abstractFileIdent[32];
398     long_ad rootDirectoryICB;        //points to Allocation Ext Descriptor
399     EntityID domainIdent;
400     long_ad nextExt;
401     long_ad streamDirectoryICB;
402     uint8 reserved[32];
403 } FILE_SET_DESC, *PFILE_SET_DESC;
404 
405 /* Short Allocation Descriptor (ECMA 167 4/14.14.1) */
406 typedef struct _SHORT_AD {
407     uint32 extLength;
408     uint32 extPosition;
409 } SHORT_AD, *PSHORT_AD;
410 
411 typedef SHORT_AD short_ad;
412 
413 /* Partition Header Descriptor (ECMA 167 4/14.3) */
414 typedef struct _PARTITION_HEADER_DESC {
415     short_ad unallocatedSpaceTable;
416     short_ad unallocatedSpaceBitmap;             // 0 - allocated, 1 - free
417     short_ad partitionIntegrityTable;
418     short_ad freedSpaceTable;
419     short_ad freedSpaceBitmap;                   // 0 - ????       1 - freed
420     uint8 reserved[88];
421 } PARTITION_HEADER_DESC, *PPARTITION_HEADER_DESC;
422 
423 /* File Identifier Descriptor (ECMA 167 4/14.4) */
424 
425 typedef struct _FILE_IDENT_DESC {
426     tag descTag;
427     uint16 fileVersionNum;
428     uint8 fileCharacteristics;
429     uint8 lengthFileIdent;
430     long_ad icb;
431     uint16 lengthOfImpUse;
432 //  uint8 impUse[0];
433 //  uint8 fileIdent[0];
434 //  uint8 padding[0];
435 } FILE_IDENT_DESC, *PFILE_IDENT_DESC;
436 
437 /* File Characteristics (ECMA 167 4/14.4.3) */
438 #define FILE_HIDDEN     0x01
439 #define FILE_DIRECTORY  0x02
440 #define FILE_DELETED    0x04
441 #define FILE_PARENT     0x08
442 #define FILE_METADATA   0x10 /* UDF 2.0 */
443 
444 /* Allocation Ext Descriptor (ECMA 167 4/14.5) */
445 typedef struct _ALLOC_EXT_DESC {
446     tag descTag;
447     uint32 previousAllocExtLocation;
448     uint32 lengthAllocDescs;
449 } ALLOC_EXT_DESC, *PALLOC_EXT_DESC;
450 
451 /* ICB Tag (ECMA 167 4/14.6) */
452 typedef struct {
453     uint32 priorRecordedNumDirectEntries;
454     uint16 strategyType;
455     uint16 strategyParameter;
456     uint16 numEntries;
457     uint8 reserved;
458     uint8 fileType;
459     lb_addr parentICBLocation;
460     uint16 flags;
461 } icbtag;
462 
463 /* ICB File Type (ECMA 167 4/14.6.6) */
464 #define UDF_FILE_TYPE_NONE      0x00U
465 #define UDF_FILE_TYPE_UNALLOC   0x01U
466 #define UDF_FILE_TYPE_INTEGRITY 0x02U
467 #define UDF_FILE_TYPE_INDIRECT  0x03U
468 #define UDF_FILE_TYPE_DIRECTORY 0x04U
469 #define UDF_FILE_TYPE_REGULAR   0x05U
470 #define UDF_FILE_TYPE_BLOCK     0x06U
471 #define UDF_FILE_TYPE_CHAR      0x07U
472 #define UDF_FILE_TYPE_EXTENDED  0x08U
473 #define UDF_FILE_TYPE_FIFO      0x09U
474 #define UDF_FILE_TYPE_SOCKET    0x0aU
475 #define UDF_FILE_TYPE_TERMINAL  0x0bU
476 #define UDF_FILE_TYPE_SYMLINK   0x0cU
477 #define UDF_FILE_TYPE_STREAMDIR 0x0dU /* ECMA 167 4/13 */
478 
479 /* ICB Flags (ECMA 167 4/14.6.8) */
480 #define ICB_FLAG_ALLOC_MASK     0x0007U
481 #define ICB_FLAG_SORTED         0x0008U
482 #define ICB_FLAG_NONRELOCATABLE 0x0010U
483 #define ICB_FLAG_ARCHIVE        0x0020U
484 #define ICB_FLAG_SETUID         0x0040U
485 #define ICB_FLAG_SETGID         0x0080U
486 #define ICB_FLAG_STICKY         0x0100U
487 #define ICB_FLAG_CONTIGUOUS     0x0200U
488 #define ICB_FLAG_SYSTEM         0x0400U
489 #define ICB_FLAG_TRANSFORMED    0x0800U
490 #define ICB_FLAG_MULTIVERSIONS  0x1000U
491 
492 /* ICB Flags Allocation type(ECMA 167 4/14.6.8) */
493 #define ICB_FLAG_AD_SHORT    0
494 #define ICB_FLAG_AD_LONG     1
495 #define ICB_FLAG_AD_EXTENDED 2
496 #define ICB_FLAG_AD_IN_ICB   3
497 
498 /* Indirect Entry (ECMA 167 4/14.7) */
499 struct IndirectEntry {
500     tag descTag;
501     icbtag icbTag;
502     long_ad indirectICB;
503 };
504 
505 /* Terminal Entry (ECMA 167 4/14.8) */
506 struct TerminalEntry {
507     tag descTag;
508     icbtag icbTag;
509 };
510 
511 /* File Entry (ECMA 167 4/14.9) */
512 
513 typedef struct _FILE_ENTRY {
514     tag         descTag;
515     icbtag      icbTag;
516     uint32      uid;
517     uint32      gid;
518     uint32      permissions;
519     uint16      fileLinkCount;
520     uint8       recordFormat;
521     uint8       recordDisplayAttr;
522     uint32      recordLength;
523     uint64      informationLength;
524     uint64      logicalBlocksRecorded;
525     timestamp   accessTime;
526     timestamp   modificationTime;
527     timestamp   attrTime;
528     uint32      checkpoint;
529     long_ad     extendedAttrICB;
530     EntityID    impIdent;
531     uint64      uniqueID; /* 0= root, 16- (2^32-1) */
532 
533     uint32      lengthExtendedAttr;
534     uint32      lengthAllocDescs;
535 //  uint8       extendedAttr[0];
536 //  uint8       allocDescs[0];
537 } FILE_ENTRY, *PFILE_ENTRY;
538 
539 /* File Permissions (ECMA 167 4/14.9.5) */
540 #define PERM_O_EXEC     0x00000001U
541 #define PERM_O_WRITE    0x00000002U
542 #define PERM_O_READ     0x00000004U
543 #define PERM_O_CHATTR   0x00000008U
544 #define PERM_O_DELETE   0x00000010U
545 #define PERM_G_EXEC     0x00000020U
546 #define PERM_G_WRITE    0x00000040U
547 #define PERM_G_READ     0x00000080U
548 #define PERM_G_CHATTR   0x00000100U
549 #define PERM_G_DELETE   0x00000200U
550 #define PERM_U_EXEC     0x00000400U
551 #define PERM_U_WRITE    0x00000800U
552 #define PERM_U_READ     0x00001000U
553 #define PERM_U_CHATTR   0x00002000U
554 #define PERM_U_DELETE   0x00004000U
555 
556 /* File Record Format (ECMA 167 4/14.9.7) */
557 #define RECORD_FMT_NONE             0
558 #define RECORD_FMT_FIXED_PAD        1
559 #define RECORD_FMT_FIXED            2
560 #define RECORD_FMT_VARIABLE8        3
561 #define RECORD_FMT_VARIABLE16       4
562 #define RECORD_FMT_VARIABLE16_MSB   5
563 #define RECORD_FMT_VARIABLE32       6
564 #define RECORD_FMT_PRINT            7
565 #define RECORD_FMT_LF               8
566 #define RECORD_FMT_CR               9
567 #define RECORD_FMT_CRLF             10
568 #define RECORD_FMT_LFCR             10
569 
570 /* Extended Attribute Header Descriptor (ECMA 167 4/14.10.1) */
571 struct ExtendedAttrHeaderDesc {
572     tag descTag;
573     uint32 impAttrLocation;
574     uint32 appAttrLocation;
575 };
576 
577 /* Generic Attribute Format (ECMA 4/14.10.2) */
578 struct GenericAttrFormat {
579     uint32 attrType;
580     uint8 attrSubtype;
581     uint8 reserved[3];
582     uint32 attrLength;
583 //  uint8 attrData[0];
584 };
585 
586 /* Character Set Attribute Format (ECMA 4/14.10.3) */
587 struct CharSetAttrFormat {
588     uint32 attrType;        /* 1 */
589     uint8 attrSubtype;      /* 1 */
590     uint8 reserved[3];
591     uint32 attrLength;
592     uint32 escapeSeqLength;
593     uint8 charSetType;
594 //  uint8 escapeSeq[0];
595 };
596 
597 /* Alternate Permissions (ECMA 167 4/14.10.4) */
598 struct AlternatePermissionsExtendedAttr {
599     uint32 attrType;        /* 3 */
600     uint8 attrSubtype;      /* 1 */
601     uint8 reserved[3];
602     uint32 attrLength;
603     uint16 ownerIdent;
604     uint16 groupIdent;
605     uint16 permission;
606 };
607 
608 /* File Times Extended Attribute (ECMA 167 4/14.10.5) */
609 struct FileTimesExtendedAttr {
610     uint32 attrType;        /* 5 */
611     uint8 attrSubtype;      /* 1 */
612     uint8 reserved[3];
613     uint32 attrLength;
614     uint32 dataLength;
615     uint32 fileTimeExistence;
616 //    timestamp fileTimes[0];
617 };
618 
619 /* FileTimeExistence (ECMA 167 4/14.10.5.6) */
620 #define FTE_CREATION    0
621 #define FTE_DELETION    2
622 #define FTE_EFFECTIVE   3
623 #define FTE_BACKUP  5
624 
625 /* Information Times Extended Attribute (ECMA 167 4/14.10.6) */
626 struct InfoTimesExtendedAttr {
627     uint32 attrType;        /* 6 */
628     uint8 attrSubtype;      /* 1 */
629     uint8 reserved[3];
630     uint32 attrLength;
631     uint32 dataLength;
632     uint32 infoTimeExistence;
633 //  uint8 infoTimes[0];
634 };
635 
636 /* Device Specification Extended Attribute (ECMA 167 4/14.10.7) */
637 struct DeviceSpecificationExtendedAttr {
638     uint32 attrType;        /* 12 */
639     uint8 attrSubtype;      /* 1 */
640     uint8 reserved[3];
641     uint32 attrLength;
642     uint32 impUseLength;
643     uint32 majorDeviceIdent;
644     uint32 minorDeviceIdent;
645 //  uint8 impUse[0];
646 };
647 
648 /* Implementation Use Extended Attr (ECMA 167 4/14.10.8) */
649 struct ImpUseExtendedAttr {
650     uint32 attrType;        /* 2048 */
651     uint8 attrSubtype;      /* 1 */
652     uint8 reserved[3];
653     uint32 attrLength;
654     uint32 impUseLength;
655     EntityID impIdent;
656 //  uint8 impUse[0];
657 };
658 
659 /* Application Use Extended Attribute (ECMA 167 4/14.10.9) */
660 struct AppUseExtendedAttr {
661     uint32 attrType;        /* 65536 */
662     uint8 attrSubtype;      /* 1 */
663     uint8 reserved[3];
664     uint32 attrLength;
665     uint32 appUseLength;
666     EntityID appIdent;
667 //  uint8 appUse[0];
668 };
669 
670 #define EXTATTR_CHAR_SET    1
671 #define EXTATTR_ALT_PERMS   3
672 #define EXTATTR_FILE_TIMES  5
673 #define EXTATTR_INFO_TIMES  6
674 #define EXTATTR_DEV_SPEC    12
675 #define EXTATTR_IMP_USE     2048
676 #define EXTATTR_APP_USE     65536
677 
678 
679 /* Unallocated Space Entry (ECMA 167 4/14.11) */
680 struct UnallocatedSpaceEntry {
681     tag descTag;
682     icbtag icbTag;
683     uint32 lengthAllocDescs;
684 //  uint8 allocDescs[0];
685 };
686 
687 /* Space Bitmap Descriptor (ECMA 167 4/14.12) */
688 typedef struct _SPACE_BITMAP_DESC {
689     tag descTag;
690     uint32 numOfBits;
691     uint32 numOfBytes;
692 //  uint8 bitmap[0]; // describes blocks from Lba=0 to Lba=LAST_LBA
693 } SPACE_BITMAP_DESC, *PSPACE_BITMAP_DESC;
694 
695 typedef SPACE_BITMAP_DESC SpaceBitmapDesc;
696 
697 /* Partition Integrity Entry (ECMA 167 4/14.13) */
698 struct PartitionIntegrityEntry {
699     tag descTag;
700     icbtag icbTag;
701     timestamp recordingDateAndTime;
702     uint8 integrityType;
703     uint8 reserved[175];
704     EntityID impIdent;
705     uint8 impUse[256];
706 };
707 
708 #define INTEGRITY_TYPE_STABLE    2
709 
710 /* Extended Allocation Descriptor (ECMA 167 4/14.14.3) */
711 typedef struct _EXT_AD { /* ECMA 167 4/14.14.3 */
712     uint32 extLength;
713     uint32 recordedLength;
714     uint32 informationLength;
715     lb_addr extLocation;
716 } EXT_AD, *PEXT_AD;
717 
718 typedef EXT_AD ext_ad;
719 
720 /* Logical Volume Header Descriptor (ECMA 167 4/14.5) */
721 struct LogicalVolHeaderDesc {
722     uint64 uniqueID;
723     uint8 reserved[24];
724 };
725 
726 /* Path Component (ECMA 167 4/14.16.1) */
727 struct PathComponent {
728     uint8 componentType;
729     uint8 lengthComponentIdent;
730     uint16 componentFileVersionNum;
731 //  dstring componentIdent[0];
732 };
733 
734 #define COMPONENT_TYPE_ROOT_X  0x01 /* originator & recipient know its value */
735 #define COMPONENT_TYPE_ROOT    0x02 /* root of the volume */
736 #define COMPONENT_TYPE_PARENT  0x03 /* predecessor's parent dir */
737 #define COMPONENT_TYPE_CURENT  0x04 /* same as predecessor's dir */
738 #define COMPONENT_TYPE_OBJECT  0x05 /* terminal entry */
739 
740 /* File Entry (ECMA 167 4/14.17) */
741 
742 typedef struct _EXTENDED_FILE_ENTRY {
743     tag         descTag;
744     icbtag      icbTag;
745     uint32      uid;
746     uint32      gid;
747     uint32      permissions;
748     uint16      fileLinkCount;
749     uint8       recordFormat;
750     uint8       recordDisplayAttr;
751     uint32      recordLength;
752     uint64      informationLength;
753     uint64      objectSize;
754     uint64      logicalBlocksRecorded;
755     timestamp   accessTime;
756     timestamp   modificationTime;
757     timestamp   createTime;
758     timestamp   attrTime;
759     uint32      checkpoint;
760     uint32      reserved;
761     long_ad     extendedAttrICB;
762     long_ad     streamDirectoryICB;
763     EntityID    impIdent;
764     uint64      uniqueID;
765     uint32      lengthExtendedAttr;
766     uint32      lengthAllocDescs;
767 //  uint8       extendedAttr[0];
768 //  uint8       allocDescs[0];
769 } EXTENDED_FILE_ENTRY, *PEXTENDED_FILE_ENTRY;
770 
771 typedef EXTENDED_FILE_ENTRY ExtendedFileEntry;
772 
773 #pragma pack(pop)
774 
775 #endif /* __ECMA_167_H__ */
776 
777