Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * ecma_167.h
0003  *
0004  * This file is based on ECMA-167 3rd edition (June 1997)
0005  * https://www.ecma.ch
0006  *
0007  * Copyright (c) 2001-2002  Ben Fennema
0008  * Copyright (c) 2017-2019  Pali Rohár <pali@kernel.org>
0009  * All rights reserved.
0010  *
0011  * Redistribution and use in source and binary forms, with or without
0012  * modification, are permitted provided that the following conditions
0013  * are met:
0014  * 1. Redistributions of source code must retain the above copyright
0015  *    notice, this list of conditions, and the following disclaimer,
0016  *    without modification.
0017  * 2. The name of the author may not be used to endorse or promote products
0018  *    derived from this software without specific prior written permission.
0019  *
0020  * Alternatively, this software may be distributed under the terms of the
0021  * GNU Public License ("GPL").
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
0024  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
0027  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0028  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
0029  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
0030  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
0031  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
0032  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0033  * SUCH DAMAGE.
0034  */
0035 
0036 /**
0037  * @file
0038  * ECMA-167r3 defines and structure definitions
0039  */
0040 
0041 #include <linux/types.h>
0042 
0043 #ifndef _ECMA_167_H
0044 #define _ECMA_167_H 1
0045 
0046 /* Character sets and coding - d-characters (ECMA 167r3 1/7.2) */
0047 typedef uint8_t     dchars;
0048 
0049 /* Character set specification (ECMA 167r3 1/7.2.1) */
0050 struct charspec {
0051     uint8_t     charSetType;
0052     uint8_t     charSetInfo[63];
0053 } __packed;
0054 
0055 /* Character Set Type (ECMA 167r3 1/7.2.1.1) */
0056 #define CHARSPEC_TYPE_CS0       0x00    /* (1/7.2.2) */
0057 #define CHARSPEC_TYPE_CS1       0x01    /* (1/7.2.3) */
0058 #define CHARSPEC_TYPE_CS2       0x02    /* (1/7.2.4) */
0059 #define CHARSPEC_TYPE_CS3       0x03    /* (1/7.2.5) */
0060 #define CHARSPEC_TYPE_CS4       0x04    /* (1/7.2.6) */
0061 #define CHARSPEC_TYPE_CS5       0x05    /* (1/7.2.7) */
0062 #define CHARSPEC_TYPE_CS6       0x06    /* (1/7.2.8) */
0063 #define CHARSPEC_TYPE_CS7       0x07    /* (1/7.2.9) */
0064 #define CHARSPEC_TYPE_CS8       0x08    /* (1/7.2.10) */
0065 
0066 /* Fixed-length character fields - d-string (EMCA 167r3 1/7.2.12) */
0067 typedef uint8_t     dstring;
0068 
0069 /* Timestamp (ECMA 167r3 1/7.3) */
0070 struct timestamp {
0071     __le16      typeAndTimezone;
0072     __le16      year;
0073     uint8_t     month;
0074     uint8_t     day;
0075     uint8_t     hour;
0076     uint8_t     minute;
0077     uint8_t     second;
0078     uint8_t     centiseconds;
0079     uint8_t     hundredsOfMicroseconds;
0080     uint8_t     microseconds;
0081 } __packed;
0082 
0083 /* Type and Time Zone (ECMA 167r3 1/7.3.1) */
0084 #define TIMESTAMP_TYPE_MASK     0xF000
0085 #define TIMESTAMP_TYPE_CUT      0x0000
0086 #define TIMESTAMP_TYPE_LOCAL        0x1000
0087 #define TIMESTAMP_TYPE_AGREEMENT    0x2000
0088 #define TIMESTAMP_TIMEZONE_MASK     0x0FFF
0089 
0090 /* Entity identifier (ECMA 167r3 1/7.4) */
0091 struct regid {
0092     uint8_t     flags;
0093     uint8_t     ident[23];
0094     uint8_t     identSuffix[8];
0095 } __packed;
0096 
0097 /* Flags (ECMA 167r3 1/7.4.1) */
0098 #define ENTITYID_FLAGS_DIRTY        0x01
0099 #define ENTITYID_FLAGS_PROTECTED    0x02
0100 
0101 /* Volume Structure Descriptor (ECMA 167r3 2/9.1) */
0102 #define VSD_STD_ID_LEN          5
0103 struct volStructDesc {
0104     uint8_t     structType;
0105     uint8_t     stdIdent[VSD_STD_ID_LEN];
0106     uint8_t     structVersion;
0107     uint8_t     structData[2041];
0108 } __packed;
0109 
0110 /* Standard Identifier (EMCA 167r2 2/9.1.2) */
0111 #define VSD_STD_ID_NSR02        "NSR02" /* (3/9.1) */
0112 
0113 /* Standard Identifier (ECMA 167r3 2/9.1.2) */
0114 #define VSD_STD_ID_BEA01        "BEA01" /* (2/9.2) */
0115 #define VSD_STD_ID_BOOT2        "BOOT2" /* (2/9.4) */
0116 #define VSD_STD_ID_CD001        "CD001" /* (ECMA-119) */
0117 #define VSD_STD_ID_CDW02        "CDW02" /* (ECMA-168) */
0118 #define VSD_STD_ID_NSR03        "NSR03" /* (3/9.1) */
0119 #define VSD_STD_ID_TEA01        "TEA01" /* (2/9.3) */
0120 
0121 /* Beginning Extended Area Descriptor (ECMA 167r3 2/9.2) */
0122 struct beginningExtendedAreaDesc {
0123     uint8_t     structType;
0124     uint8_t     stdIdent[VSD_STD_ID_LEN];
0125     uint8_t     structVersion;
0126     uint8_t     structData[2041];
0127 } __packed;
0128 
0129 /* Terminating Extended Area Descriptor (ECMA 167r3 2/9.3) */
0130 struct terminatingExtendedAreaDesc {
0131     uint8_t     structType;
0132     uint8_t     stdIdent[VSD_STD_ID_LEN];
0133     uint8_t     structVersion;
0134     uint8_t     structData[2041];
0135 } __packed;
0136 
0137 /* Boot Descriptor (ECMA 167r3 2/9.4) */
0138 struct bootDesc {
0139     uint8_t         structType;
0140     uint8_t         stdIdent[VSD_STD_ID_LEN];
0141     uint8_t         structVersion;
0142     uint8_t         reserved1;
0143     struct regid        archType;
0144     struct regid        bootIdent;
0145     __le32          bootExtLocation;
0146     __le32          bootExtLength;
0147     __le64          loadAddress;
0148     __le64          startAddress;
0149     struct timestamp    descCreationDateAndTime;
0150     __le16          flags;
0151     uint8_t         reserved2[32];
0152     uint8_t         bootUse[1906];
0153 } __packed;
0154 
0155 /* Flags (ECMA 167r3 2/9.4.12) */
0156 #define BOOT_FLAGS_ERASE        0x01
0157 
0158 /* Extent Descriptor (ECMA 167r3 3/7.1) */
0159 struct extent_ad {
0160     __le32      extLength;
0161     __le32      extLocation;
0162 } __packed;
0163 
0164 struct kernel_extent_ad {
0165     uint32_t    extLength;
0166     uint32_t    extLocation;
0167 };
0168 
0169 /* Descriptor Tag (ECMA 167r3 3/7.2) */
0170 struct tag {
0171     __le16      tagIdent;
0172     __le16      descVersion;
0173     uint8_t     tagChecksum;
0174     uint8_t     reserved;
0175     __le16      tagSerialNum;
0176     __le16      descCRC;
0177     __le16      descCRCLength;
0178     __le32      tagLocation;
0179 } __packed;
0180 
0181 /* Tag Identifier (ECMA 167r3 3/7.2.1) */
0182 #define TAG_IDENT_PVD           0x0001
0183 #define TAG_IDENT_AVDP          0x0002
0184 #define TAG_IDENT_VDP           0x0003
0185 #define TAG_IDENT_IUVD          0x0004
0186 #define TAG_IDENT_PD            0x0005
0187 #define TAG_IDENT_LVD           0x0006
0188 #define TAG_IDENT_USD           0x0007
0189 #define TAG_IDENT_TD            0x0008
0190 #define TAG_IDENT_LVID          0x0009
0191 
0192 /* NSR Descriptor (ECMA 167r3 3/9.1) */
0193 struct NSRDesc {
0194     uint8_t     structType;
0195     uint8_t     stdIdent[VSD_STD_ID_LEN];
0196     uint8_t     structVersion;
0197     uint8_t     reserved;
0198     uint8_t     structData[2040];
0199 } __packed;
0200 
0201 /* Generic Descriptor */
0202 struct genericDesc {
0203     struct tag  descTag;
0204     __le32      volDescSeqNum;
0205     uint8_t     reserved[492];
0206 } __packed;
0207 
0208 /* Primary Volume Descriptor (ECMA 167r3 3/10.1) */
0209 struct primaryVolDesc {
0210     struct tag      descTag;
0211     __le32          volDescSeqNum;
0212     __le32          primaryVolDescNum;
0213     dstring         volIdent[32];
0214     __le16          volSeqNum;
0215     __le16          maxVolSeqNum;
0216     __le16          interchangeLvl;
0217     __le16          maxInterchangeLvl;
0218     __le32          charSetList;
0219     __le32          maxCharSetList;
0220     dstring         volSetIdent[128];
0221     struct charspec     descCharSet;
0222     struct charspec     explanatoryCharSet;
0223     struct extent_ad    volAbstract;
0224     struct extent_ad    volCopyright;
0225     struct regid        appIdent;
0226     struct timestamp    recordingDateAndTime;
0227     struct regid        impIdent;
0228     uint8_t         impUse[64];
0229     __le32          predecessorVolDescSeqLocation;
0230     __le16          flags;
0231     uint8_t         reserved[22];
0232 } __packed;
0233 
0234 /* Flags (ECMA 167r3 3/10.1.21) */
0235 #define PVD_FLAGS_VSID_COMMON       0x0001
0236 
0237 /* Anchor Volume Descriptor Pointer (ECMA 167r3 3/10.2) */
0238 struct anchorVolDescPtr {
0239     struct tag      descTag;
0240     struct extent_ad    mainVolDescSeqExt;
0241     struct extent_ad    reserveVolDescSeqExt;
0242     uint8_t         reserved[480];
0243 } __packed;
0244 
0245 /* Volume Descriptor Pointer (ECMA 167r3 3/10.3) */
0246 struct volDescPtr {
0247     struct tag      descTag;
0248     __le32          volDescSeqNum;
0249     struct extent_ad    nextVolDescSeqExt;
0250     uint8_t         reserved[484];
0251 } __packed;
0252 
0253 /* Implementation Use Volume Descriptor (ECMA 167r3 3/10.4) */
0254 struct impUseVolDesc {
0255     struct tag  descTag;
0256     __le32      volDescSeqNum;
0257     struct regid    impIdent;
0258     uint8_t     impUse[460];
0259 } __packed;
0260 
0261 /* Partition Descriptor (ECMA 167r3 3/10.5) */
0262 struct partitionDesc {
0263     struct tag descTag;
0264     __le32 volDescSeqNum;
0265     __le16 partitionFlags;
0266     __le16 partitionNumber;
0267     struct regid partitionContents;
0268     uint8_t partitionContentsUse[128];
0269     __le32 accessType;
0270     __le32 partitionStartingLocation;
0271     __le32 partitionLength;
0272     struct regid impIdent;
0273     uint8_t impUse[128];
0274     uint8_t reserved[156];
0275 } __packed;
0276 
0277 /* Partition Flags (ECMA 167r3 3/10.5.3) */
0278 #define PD_PARTITION_FLAGS_ALLOC    0x0001
0279 
0280 /* Partition Contents (ECMA 167r2 3/10.5.3) */
0281 #define PD_PARTITION_CONTENTS_NSR02 "+NSR02"
0282 
0283 /* Partition Contents (ECMA 167r3 3/10.5.5) */
0284 #define PD_PARTITION_CONTENTS_FDC01 "+FDC01"
0285 #define PD_PARTITION_CONTENTS_CD001 "+CD001"
0286 #define PD_PARTITION_CONTENTS_CDW02 "+CDW02"
0287 #define PD_PARTITION_CONTENTS_NSR03 "+NSR03"
0288 
0289 /* Access Type (ECMA 167r3 3/10.5.7) */
0290 #define PD_ACCESS_TYPE_NONE     0x00000000
0291 #define PD_ACCESS_TYPE_READ_ONLY    0x00000001
0292 #define PD_ACCESS_TYPE_WRITE_ONCE   0x00000002
0293 #define PD_ACCESS_TYPE_REWRITABLE   0x00000003
0294 #define PD_ACCESS_TYPE_OVERWRITABLE 0x00000004
0295 
0296 /* Logical Volume Descriptor (ECMA 167r3 3/10.6) */
0297 struct logicalVolDesc {
0298     struct tag      descTag;
0299     __le32          volDescSeqNum;
0300     struct charspec     descCharSet;
0301     dstring         logicalVolIdent[128];
0302     __le32          logicalBlockSize;
0303     struct regid        domainIdent;
0304     uint8_t         logicalVolContentsUse[16];
0305     __le32          mapTableLength;
0306     __le32          numPartitionMaps;
0307     struct regid        impIdent;
0308     uint8_t         impUse[128];
0309     struct extent_ad    integritySeqExt;
0310     uint8_t         partitionMaps[];
0311 } __packed;
0312 
0313 /* Generic Partition Map (ECMA 167r3 3/10.7.1) */
0314 struct genericPartitionMap {
0315     uint8_t     partitionMapType;
0316     uint8_t     partitionMapLength;
0317     uint8_t     partitionMapping[];
0318 } __packed;
0319 
0320 /* Partition Map Type (ECMA 167r3 3/10.7.1.1) */
0321 #define GP_PARTITION_MAP_TYPE_UNDEF 0x00
0322 #define GP_PARTITION_MAP_TYPE_1     0x01
0323 #define GP_PARTITION_MAP_TYPE_2     0x02
0324 
0325 /* Type 1 Partition Map (ECMA 167r3 3/10.7.2) */
0326 struct genericPartitionMap1 {
0327     uint8_t     partitionMapType;
0328     uint8_t     partitionMapLength;
0329     __le16      volSeqNum;
0330     __le16      partitionNum;
0331 } __packed;
0332 
0333 /* Type 2 Partition Map (ECMA 167r3 3/10.7.3) */
0334 struct genericPartitionMap2 {
0335     uint8_t     partitionMapType;
0336     uint8_t     partitionMapLength;
0337     uint8_t     partitionIdent[62];
0338 } __packed;
0339 
0340 /* Unallocated Space Descriptor (ECMA 167r3 3/10.8) */
0341 struct unallocSpaceDesc {
0342     struct tag      descTag;
0343     __le32          volDescSeqNum;
0344     __le32          numAllocDescs;
0345     struct extent_ad    allocDescs[];
0346 } __packed;
0347 
0348 /* Terminating Descriptor (ECMA 167r3 3/10.9) */
0349 struct terminatingDesc {
0350     struct tag  descTag;
0351     uint8_t     reserved[496];
0352 } __packed;
0353 
0354 /* Logical Volume Integrity Descriptor (ECMA 167r3 3/10.10) */
0355 struct logicalVolIntegrityDesc {
0356     struct tag      descTag;
0357     struct timestamp    recordingDateAndTime;
0358     __le32          integrityType;
0359     struct extent_ad    nextIntegrityExt;
0360     uint8_t         logicalVolContentsUse[32];
0361     __le32          numOfPartitions;
0362     __le32          lengthOfImpUse;
0363     __le32          freeSpaceTable[];
0364     /* __le32       sizeTable[]; */
0365     /* uint8_t      impUse[]; */
0366 } __packed;
0367 
0368 /* Integrity Type (ECMA 167r3 3/10.10.3) */
0369 #define LVID_INTEGRITY_TYPE_OPEN    0x00000000
0370 #define LVID_INTEGRITY_TYPE_CLOSE   0x00000001
0371 
0372 /* Recorded Address (ECMA 167r3 4/7.1) */
0373 struct lb_addr {
0374     __le32      logicalBlockNum;
0375     __le16      partitionReferenceNum;
0376 } __packed;
0377 
0378 /* ... and its in-core analog */
0379 struct kernel_lb_addr {
0380     uint32_t        logicalBlockNum;
0381     uint16_t        partitionReferenceNum;
0382 };
0383 
0384 /* Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */
0385 struct short_ad {
0386         __le32      extLength;
0387         __le32      extPosition;
0388 } __packed;
0389 
0390 /* Long Allocation Descriptor (ECMA 167r3 4/14.14.2) */
0391 struct long_ad {
0392     __le32      extLength;
0393     struct lb_addr  extLocation;
0394     uint8_t     impUse[6];
0395 } __packed;
0396 
0397 struct kernel_long_ad {
0398     uint32_t        extLength;
0399     struct kernel_lb_addr   extLocation;
0400     uint8_t         impUse[6];
0401 };
0402 
0403 /* Extended Allocation Descriptor (ECMA 167r3 4/14.14.3) */
0404 struct ext_ad {
0405     __le32      extLength;
0406     __le32      recordedLength;
0407     __le32      informationLength;
0408     struct lb_addr  extLocation;
0409 } __packed;
0410 
0411 struct kernel_ext_ad {
0412     uint32_t        extLength;
0413     uint32_t        recordedLength;
0414     uint32_t        informationLength;
0415     struct kernel_lb_addr   extLocation;
0416 };
0417 
0418 /* Descriptor Tag (ECMA 167r3 4/7.2 - See 3/7.2) */
0419 
0420 /* Tag Identifier (ECMA 167r3 4/7.2.1) */
0421 #define TAG_IDENT_FSD           0x0100
0422 #define TAG_IDENT_FID           0x0101
0423 #define TAG_IDENT_AED           0x0102
0424 #define TAG_IDENT_IE            0x0103
0425 #define TAG_IDENT_TE            0x0104
0426 #define TAG_IDENT_FE            0x0105
0427 #define TAG_IDENT_EAHD          0x0106
0428 #define TAG_IDENT_USE           0x0107
0429 #define TAG_IDENT_SBD           0x0108
0430 #define TAG_IDENT_PIE           0x0109
0431 #define TAG_IDENT_EFE           0x010A
0432 
0433 /* File Set Descriptor (ECMA 167r3 4/14.1) */
0434 struct fileSetDesc {
0435     struct tag      descTag;
0436     struct timestamp    recordingDateAndTime;
0437     __le16          interchangeLvl;
0438     __le16          maxInterchangeLvl;
0439     __le32          charSetList;
0440     __le32          maxCharSetList;
0441     __le32          fileSetNum;
0442     __le32          fileSetDescNum;
0443     struct charspec     logicalVolIdentCharSet;
0444     dstring         logicalVolIdent[128];
0445     struct charspec     fileSetCharSet;
0446     dstring         fileSetIdent[32];
0447     dstring         copyrightFileIdent[32];
0448     dstring         abstractFileIdent[32];
0449     struct long_ad      rootDirectoryICB;
0450     struct regid        domainIdent;
0451     struct long_ad      nextExt;
0452     struct long_ad      streamDirectoryICB;
0453     uint8_t         reserved[32];
0454 } __packed;
0455 
0456 /* Partition Header Descriptor (ECMA 167r3 4/14.3) */
0457 struct partitionHeaderDesc {
0458     struct short_ad unallocSpaceTable;
0459     struct short_ad unallocSpaceBitmap;
0460     struct short_ad partitionIntegrityTable;
0461     struct short_ad freedSpaceTable;
0462     struct short_ad freedSpaceBitmap;
0463     uint8_t     reserved[88];
0464 } __packed;
0465 
0466 /* File Identifier Descriptor (ECMA 167r3 4/14.4) */
0467 struct fileIdentDesc {
0468     struct tag  descTag;
0469     __le16      fileVersionNum;
0470     uint8_t     fileCharacteristics;
0471     uint8_t     lengthFileIdent;
0472     struct long_ad  icb;
0473     __le16      lengthOfImpUse;
0474     uint8_t     impUse[];
0475     /* uint8_t  fileIdent[]; */
0476     /* uint8_t  padding[]; */
0477 } __packed;
0478 
0479 /* File Characteristics (ECMA 167r3 4/14.4.3) */
0480 #define FID_FILE_CHAR_HIDDEN        0x01
0481 #define FID_FILE_CHAR_DIRECTORY     0x02
0482 #define FID_FILE_CHAR_DELETED       0x04
0483 #define FID_FILE_CHAR_PARENT        0x08
0484 #define FID_FILE_CHAR_METADATA      0x10
0485 
0486 /* Allocation Ext Descriptor (ECMA 167r3 4/14.5) */
0487 struct allocExtDesc {
0488     struct tag  descTag;
0489     __le32      previousAllocExtLocation;
0490     __le32      lengthAllocDescs;
0491 } __packed;
0492 
0493 /* ICB Tag (ECMA 167r3 4/14.6) */
0494 struct icbtag {
0495     __le32      priorRecordedNumDirectEntries;
0496     __le16      strategyType;
0497     __le16      strategyParameter;
0498     __le16      numEntries;
0499     uint8_t     reserved;
0500     uint8_t     fileType;
0501     struct lb_addr  parentICBLocation;
0502     __le16      flags;
0503 } __packed;
0504 
0505 /* Strategy Type (ECMA 167r3 4/14.6.2) */
0506 #define ICBTAG_STRATEGY_TYPE_UNDEF  0x0000
0507 #define ICBTAG_STRATEGY_TYPE_1      0x0001
0508 #define ICBTAG_STRATEGY_TYPE_2      0x0002
0509 #define ICBTAG_STRATEGY_TYPE_3      0x0003
0510 #define ICBTAG_STRATEGY_TYPE_4      0x0004
0511 
0512 /* File Type (ECMA 167r3 4/14.6.6) */
0513 #define ICBTAG_FILE_TYPE_UNDEF      0x00
0514 #define ICBTAG_FILE_TYPE_USE        0x01
0515 #define ICBTAG_FILE_TYPE_PIE        0x02
0516 #define ICBTAG_FILE_TYPE_IE     0x03
0517 #define ICBTAG_FILE_TYPE_DIRECTORY  0x04
0518 #define ICBTAG_FILE_TYPE_REGULAR    0x05
0519 #define ICBTAG_FILE_TYPE_BLOCK      0x06
0520 #define ICBTAG_FILE_TYPE_CHAR       0x07
0521 #define ICBTAG_FILE_TYPE_EA     0x08
0522 #define ICBTAG_FILE_TYPE_FIFO       0x09
0523 #define ICBTAG_FILE_TYPE_SOCKET     0x0A
0524 #define ICBTAG_FILE_TYPE_TE     0x0B
0525 #define ICBTAG_FILE_TYPE_SYMLINK    0x0C
0526 #define ICBTAG_FILE_TYPE_STREAMDIR  0x0D
0527 
0528 /* Flags (ECMA 167r3 4/14.6.8) */
0529 #define ICBTAG_FLAG_AD_MASK     0x0007
0530 #define ICBTAG_FLAG_AD_SHORT        0x0000
0531 #define ICBTAG_FLAG_AD_LONG     0x0001
0532 #define ICBTAG_FLAG_AD_EXTENDED     0x0002
0533 #define ICBTAG_FLAG_AD_IN_ICB       0x0003
0534 #define ICBTAG_FLAG_SORTED      0x0008
0535 #define ICBTAG_FLAG_NONRELOCATABLE  0x0010
0536 #define ICBTAG_FLAG_ARCHIVE     0x0020
0537 #define ICBTAG_FLAG_SETUID      0x0040
0538 #define ICBTAG_FLAG_SETGID      0x0080
0539 #define ICBTAG_FLAG_STICKY      0x0100
0540 #define ICBTAG_FLAG_CONTIGUOUS      0x0200
0541 #define ICBTAG_FLAG_SYSTEM      0x0400
0542 #define ICBTAG_FLAG_TRANSFORMED     0x0800
0543 #define ICBTAG_FLAG_MULTIVERSIONS   0x1000
0544 #define ICBTAG_FLAG_STREAM      0x2000
0545 
0546 /* Indirect Entry (ECMA 167r3 4/14.7) */
0547 struct indirectEntry {
0548     struct tag  descTag;
0549     struct icbtag   icbTag;
0550     struct long_ad  indirectICB;
0551 } __packed;
0552 
0553 /* Terminal Entry (ECMA 167r3 4/14.8) */
0554 struct terminalEntry {
0555     struct tag  descTag;
0556     struct icbtag   icbTag;
0557 } __packed;
0558 
0559 /* File Entry (ECMA 167r3 4/14.9) */
0560 struct fileEntry {
0561     struct tag      descTag;
0562     struct icbtag       icbTag;
0563     __le32          uid;
0564     __le32          gid;
0565     __le32          permissions;
0566     __le16          fileLinkCount;
0567     uint8_t         recordFormat;
0568     uint8_t         recordDisplayAttr;
0569     __le32          recordLength;
0570     __le64          informationLength;
0571     __le64          logicalBlocksRecorded;
0572     struct timestamp    accessTime;
0573     struct timestamp    modificationTime;
0574     struct timestamp    attrTime;
0575     __le32          checkpoint;
0576     struct long_ad      extendedAttrICB;
0577     struct regid        impIdent;
0578     __le64          uniqueID;
0579     __le32          lengthExtendedAttr;
0580     __le32          lengthAllocDescs;
0581     uint8_t         extendedAttr[];
0582     /* uint8_t      allocDescs[]; */
0583 } __packed;
0584 
0585 /* Permissions (ECMA 167r3 4/14.9.5) */
0586 #define FE_PERM_O_EXEC          0x00000001U
0587 #define FE_PERM_O_WRITE         0x00000002U
0588 #define FE_PERM_O_READ          0x00000004U
0589 #define FE_PERM_O_CHATTR        0x00000008U
0590 #define FE_PERM_O_DELETE        0x00000010U
0591 #define FE_PERM_G_EXEC          0x00000020U
0592 #define FE_PERM_G_WRITE         0x00000040U
0593 #define FE_PERM_G_READ          0x00000080U
0594 #define FE_PERM_G_CHATTR        0x00000100U
0595 #define FE_PERM_G_DELETE        0x00000200U
0596 #define FE_PERM_U_EXEC          0x00000400U
0597 #define FE_PERM_U_WRITE         0x00000800U
0598 #define FE_PERM_U_READ          0x00001000U
0599 #define FE_PERM_U_CHATTR        0x00002000U
0600 #define FE_PERM_U_DELETE        0x00004000U
0601 
0602 /* Record Format (ECMA 167r3 4/14.9.7) */
0603 #define FE_RECORD_FMT_UNDEF     0x00
0604 #define FE_RECORD_FMT_FIXED_PAD     0x01
0605 #define FE_RECORD_FMT_FIXED     0x02
0606 #define FE_RECORD_FMT_VARIABLE8     0x03
0607 #define FE_RECORD_FMT_VARIABLE16    0x04
0608 #define FE_RECORD_FMT_VARIABLE16_MSB    0x05
0609 #define FE_RECORD_FMT_VARIABLE32    0x06
0610 #define FE_RECORD_FMT_PRINT     0x07
0611 #define FE_RECORD_FMT_LF        0x08
0612 #define FE_RECORD_FMT_CR        0x09
0613 #define FE_RECORD_FMT_CRLF      0x0A
0614 #define FE_RECORD_FMT_LFCR      0x0B
0615 
0616 /* Record Display Attributes (ECMA 167r3 4/14.9.8) */
0617 #define FE_RECORD_DISPLAY_ATTR_UNDEF    0x00
0618 #define FE_RECORD_DISPLAY_ATTR_1    0x01
0619 #define FE_RECORD_DISPLAY_ATTR_2    0x02
0620 #define FE_RECORD_DISPLAY_ATTR_3    0x03
0621 
0622 /* Extended Attribute Header Descriptor (ECMA 167r3 4/14.10.1) */
0623 struct extendedAttrHeaderDesc {
0624     struct tag  descTag;
0625     __le32      impAttrLocation;
0626     __le32      appAttrLocation;
0627 } __packed;
0628 
0629 /* Generic Format (ECMA 167r3 4/14.10.2) */
0630 struct genericFormat {
0631     __le32      attrType;
0632     uint8_t     attrSubtype;
0633     uint8_t     reserved[3];
0634     __le32      attrLength;
0635     uint8_t     attrData[];
0636 } __packed;
0637 
0638 /* Character Set Information (ECMA 167r3 4/14.10.3) */
0639 struct charSetInfo {
0640     __le32      attrType;
0641     uint8_t     attrSubtype;
0642     uint8_t     reserved[3];
0643     __le32      attrLength;
0644     __le32      escapeSeqLength;
0645     uint8_t     charSetType;
0646     uint8_t     escapeSeq[];
0647 } __packed;
0648 
0649 /* Alternate Permissions (ECMA 167r3 4/14.10.4) */
0650 struct altPerms {
0651     __le32      attrType;
0652     uint8_t     attrSubtype;
0653     uint8_t     reserved[3];
0654     __le32      attrLength;
0655     __le16      ownerIdent;
0656     __le16      groupIdent;
0657     __le16      permission;
0658 } __packed;
0659 
0660 /* File Times Extended Attribute (ECMA 167r3 4/14.10.5) */
0661 struct fileTimesExtAttr {
0662     __le32      attrType;
0663     uint8_t     attrSubtype;
0664     uint8_t     reserved[3];
0665     __le32      attrLength;
0666     __le32      dataLength;
0667     __le32      fileTimeExistence;
0668     uint8_t     fileTimes;
0669 } __packed;
0670 
0671 /* FileTimeExistence (ECMA 167r3 4/14.10.5.6) */
0672 #define FTE_CREATION            0x00000001
0673 #define FTE_DELETION            0x00000004
0674 #define FTE_EFFECTIVE           0x00000008
0675 #define FTE_BACKUP          0x00000002
0676 
0677 /* Information Times Extended Attribute (ECMA 167r3 4/14.10.6) */
0678 struct infoTimesExtAttr {
0679     __le32      attrType;
0680     uint8_t     attrSubtype;
0681     uint8_t     reserved[3];
0682     __le32      attrLength;
0683     __le32      dataLength;
0684     __le32      infoTimeExistence;
0685     uint8_t     infoTimes[];
0686 } __packed;
0687 
0688 /* Device Specification (ECMA 167r3 4/14.10.7) */
0689 struct deviceSpec {
0690     __le32      attrType;
0691     uint8_t     attrSubtype;
0692     uint8_t     reserved[3];
0693     __le32      attrLength;
0694     __le32      impUseLength;
0695     __le32      majorDeviceIdent;
0696     __le32      minorDeviceIdent;
0697     uint8_t     impUse[];
0698 } __packed;
0699 
0700 /* Implementation Use Extended Attr (ECMA 167r3 4/14.10.8) */
0701 struct impUseExtAttr {
0702     __le32      attrType;
0703     uint8_t     attrSubtype;
0704     uint8_t     reserved[3];
0705     __le32      attrLength;
0706     __le32      impUseLength;
0707     struct regid    impIdent;
0708     uint8_t     impUse[];
0709 } __packed;
0710 
0711 /* Application Use Extended Attribute (ECMA 167r3 4/14.10.9) */
0712 struct appUseExtAttr {
0713     __le32      attrType;
0714     uint8_t     attrSubtype;
0715     uint8_t     reserved[3];
0716     __le32      attrLength;
0717     __le32      appUseLength;
0718     struct regid    appIdent;
0719     uint8_t     appUse[];
0720 } __packed;
0721 
0722 #define EXTATTR_CHAR_SET        1
0723 #define EXTATTR_ALT_PERMS       3
0724 #define EXTATTR_FILE_TIMES      5
0725 #define EXTATTR_INFO_TIMES      6
0726 #define EXTATTR_DEV_SPEC        12
0727 #define EXTATTR_IMP_USE         2048
0728 #define EXTATTR_APP_USE         65536
0729 #define EXTATTR_SUBTYPE         1
0730 
0731 /* Unallocated Space Entry (ECMA 167r3 4/14.11) */
0732 struct unallocSpaceEntry {
0733     struct tag  descTag;
0734     struct icbtag   icbTag;
0735     __le32      lengthAllocDescs;
0736     uint8_t     allocDescs[];
0737 } __packed;
0738 
0739 /* Space Bitmap Descriptor (ECMA 167r3 4/14.12) */
0740 struct spaceBitmapDesc {
0741     struct tag  descTag;
0742     __le32      numOfBits;
0743     __le32      numOfBytes;
0744     uint8_t     bitmap[];
0745 } __packed;
0746 
0747 /* Partition Integrity Entry (ECMA 167r3 4/14.13) */
0748 struct partitionIntegrityEntry {
0749     struct tag      descTag;
0750     struct icbtag       icbTag;
0751     struct timestamp    recordingDateAndTime;
0752     uint8_t         integrityType;
0753     uint8_t         reserved[175];
0754     struct regid        impIdent;
0755     uint8_t         impUse[256];
0756 } __packed;
0757 
0758 /* Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */
0759 
0760 /* Extent Length (ECMA 167r3 4/14.14.1.1) */
0761 #define EXT_LENGTH_MASK         0x3FFFFFFF
0762 #define EXT_TYPE_MASK           0xC0000000
0763 #define EXT_RECORDED_ALLOCATED      0x00000000
0764 #define EXT_NOT_RECORDED_ALLOCATED  0x40000000
0765 #define EXT_NOT_RECORDED_NOT_ALLOCATED  0x80000000
0766 #define EXT_NEXT_EXTENT_ALLOCDESCS  0xC0000000
0767 
0768 /* Long Allocation Descriptor (ECMA 167r3 4/14.14.2) */
0769 
0770 /* Extended Allocation Descriptor (ECMA 167r3 4/14.14.3) */
0771 
0772 /* Logical Volume Header Descriptor (ECMA 167r3 4/14.15) */
0773 struct logicalVolHeaderDesc {
0774     __le64      uniqueID;
0775     uint8_t     reserved[24];
0776 } __packed;
0777 
0778 /* Path Component (ECMA 167r3 4/14.16.1) */
0779 struct pathComponent {
0780     uint8_t     componentType;
0781     uint8_t     lengthComponentIdent;
0782     __le16      componentFileVersionNum;
0783     dchars      componentIdent[];
0784 } __packed;
0785 
0786 /* File Entry (ECMA 167r3 4/14.17) */
0787 struct extendedFileEntry {
0788     struct tag      descTag;
0789     struct icbtag       icbTag;
0790     __le32          uid;
0791     __le32          gid;
0792     __le32          permissions;
0793     __le16          fileLinkCount;
0794     uint8_t         recordFormat;
0795     uint8_t         recordDisplayAttr;
0796     __le32          recordLength;
0797     __le64          informationLength;
0798     __le64          objectSize;
0799     __le64          logicalBlocksRecorded;
0800     struct timestamp    accessTime;
0801     struct timestamp    modificationTime;
0802     struct timestamp    createTime;
0803     struct timestamp    attrTime;
0804     __le32          checkpoint;
0805     __le32          reserved;
0806     struct long_ad      extendedAttrICB;
0807     struct long_ad      streamDirectoryICB;
0808     struct regid        impIdent;
0809     __le64          uniqueID;
0810     __le32          lengthExtendedAttr;
0811     __le32          lengthAllocDescs;
0812     uint8_t         extendedAttr[];
0813     /* uint8_t      allocDescs[]; */
0814 } __packed;
0815 
0816 #endif /* _ECMA_167_H */