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