libcdio  0.90
ecma_167.h
Go to the documentation of this file.
00001 /* 
00002     Copyright (c) 2005, 2006, 2008, 2012 Rocky Bernstein <rocky@cpan.org>
00003     Copyright (c) 2001-2002  Ben Fennema <bfennema@falcon.csc.calpoly.edu>
00004 
00005     This program is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 /*
00019  * Some portions taken from FreeBSD ecma167-udf.h which states:
00020  * Copyright (c) 2001, 2002 Scott Long <scottl@freebsd.org>
00021  * All rights reserved.
00022  *
00023  * Redistribution and use in source and binary forms, with or without
00024  * modification, are permitted provided that the following conditions
00025  * are met:
00026  * 1. Redistributions of source code must retain the above copyright
00027  *    notice, this list of conditions and the following disclaimer.
00028  * 2. Redistributions in binary form must reproduce the above copyright
00029  *    notice, this list of conditions and the following disclaimer in the
00030  *    documentation and/or other materials provided with the distribution.
00031  *
00032  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
00033  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00034  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00035  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
00036  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00037  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00038  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00039  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00040  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00041  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00042  * SUCH DAMAGE.
00043  */
00044 
00052 #ifndef CDIO_ECMA_167_H
00053 #define CDIO_ECMA_167_H 1
00054 
00055 #include <cdio/types.h>
00056 
00061 typedef enum {
00062   VSD_STD_ID_SIZE    =    5, 
00064   UDF_REGID_ID_SIZE  =   23, 
00065   UDF_VOLID_SIZE     =   32,
00066   UDF_FID_SIZE       =   38,
00067   UDF_VOLSET_ID_SIZE =  128
00068 } ecma_167_enum1_t ;
00069 
00072 typedef enum {
00073   TAGID_PRI_VOL          = 0x0001,
00074   TAGID_ANCHOR           = 0x0002,
00075   TAGID_VOL              = 0x0003,
00076   TAGID_IMP_VOL          = 0x0004,
00077   TAGID_PARTITION        = 0x0005,
00078   TAGID_LOGVOL           = 0x0006,
00079   TAGID_UNALLOC_SPACE    = 0x0007,
00080   TAGID_TERM             = 0x0008,
00081   TAGID_LOGVOL_INTEGRITY = 0x0009,
00082   TAGID_FSD              = 0x0100,
00083   TAGID_FID              = 0x0101,
00084   TAGID_AED              = 0x0102,
00085   TAGID_IE               = 0x0103,
00086   TAGID_TE               = 0x0104,
00087   TAGID_FILE_ENTRY       = 0x0105,
00088   TAGID_EAHD             = 0x0106,
00089   TAGID_USE              = 0x0107,
00090   TAGID_SBD              = 0x0108,
00091   TAGID_PIE              = 0x0109,
00092   TAGID_EFE              = 0x010A,
00093 } tag_id_t ;
00094 
00096 typedef enum {
00097   CHARSPEC_TYPE_CS0 = 0x00,     
00098   CHARSPEC_TYPE_CS1 = 0x01,     
00099   CHARSPEC_TYPE_CS2 = 0x02,     
00100   CHARSPEC_TYPE_CS3 = 0x03,     
00101   CHARSPEC_TYPE_CS4 = 0x04,     
00102   CHARSPEC_TYPE_CS5 = 0x05,     
00103   CHARSPEC_TYPE_CS6 = 0x06,     
00104   CHARSPEC_TYPE_CS7 = 0x07,     
00106   CHARSPEC_TYPE_CS8 = 0x08,     
00107 } udf_charspec_enum_t;
00108   
00109 typedef uint8_t  udf_Uint8_t;  
00110 typedef uint16_t udf_Uint16_t; 
00111 typedef uint32_t udf_Uint32_t; 
00112 typedef uint64_t udf_Uint64_t; 
00113 typedef char     udf_dstring;  
00115 #define UDF_LENGTH_MASK 0x3fffffff
00116 
00117 PRAGMA_BEGIN_PACKED
00118 
00120 struct udf_charspec_s
00121 {
00122   udf_Uint8_t   charset_type;
00123   udf_Uint8_t   charset_info[63];
00124 } GNUC_PACKED;
00125 
00126 typedef struct udf_charspec_s udf_charspec_t;
00127 
00129 struct udf_timestamp_s
00130 {
00131   udf_Uint16_t          type_tz;
00132   udf_Uint16_t          year;
00133   udf_Uint8_t           month;
00134   udf_Uint8_t           day;
00135   udf_Uint8_t           hour;
00136   udf_Uint8_t           minute;
00137   udf_Uint8_t           second;
00138   udf_Uint8_t           centiseconds;
00139   udf_Uint8_t           hundreds_of_microseconds;
00140   udf_Uint8_t           microseconds;
00141 } GNUC_PACKED;
00142 
00143 typedef struct udf_timestamp_s udf_timestamp_t;
00144 
00150 typedef enum { 
00151   TIMESTAMP_TYPE_CUT        =   0x0000,
00152   TIMESTAMP_TYPE_LOCAL      =   0x1000,
00153   TIMESTAMP_TYPE_AGREEMENT  =   0x2000,
00154   TIMESTAMP_TYPE_MASK       =   0xF000,
00155   TIMESTAMP_TIMEZONE_MASK   =   0x0FFF,
00156 } ecma_167_timezone_enum_t ;
00157 
00158 
00159 #define TIMESTAMP_TYPE_MASK             0xF000
00160 #define TIMESTAMP_TYPE_CUT              0x0000
00161 #define TIMESTAMP_TYPE_LOCAL            0x1000
00162 #define TIMESTAMP_TYPE_AGREEMENT        0x2000
00163 #define TIMESTAMP_TIMEZONE_MASK         0x0FFF
00164 
00165 struct udf_id_suffix_s
00166 {
00167   udf_Uint16_t  udf_revision;
00168   udf_Uint8_t   os_class;
00169   udf_Uint8_t   os_identifier;
00170   udf_Uint8_t   reserved[4];
00171 } GNUC_PACKED;
00172 
00173 typedef struct udf_id_suffix_s udf_id_suffix_t;
00174 
00176 struct udf_regid_s
00177 {
00178   udf_Uint8_t           flags;
00179   udf_Uint8_t           id[UDF_REGID_ID_SIZE];
00180   udf_id_suffix_t       id_suffix;
00181 } GNUC_PACKED;
00182 
00183 typedef struct udf_regid_s udf_regid_t;
00184 
00186 #define ENTITYID_FLAGS_DIRTY            0x00
00187 #define ENTITYID_FLAGS_PROTECTED        0x01
00188 
00190 struct vol_struct_desc_s
00191 {
00192   udf_Uint8_t           struct_type;
00193   udf_Uint8_t           std_id[VSD_STD_ID_SIZE];
00194   udf_Uint8_t           struct_version;
00195   udf_Uint8_t           struct_data[2041];
00196 } GNUC_PACKED;
00197 
00199 #define VSD_STD_ID_NSR02                "NSR02" /* (3/9.1) */
00200 
00203 /* The below const definitions are to faciltate debugging of the
00204    values #define'd below. */
00205 extern const char VSD_STD_ID_BEA01[sizeof("BEA01")-1];
00206 extern const char VSD_STD_ID_BOOT2[sizeof("BOOT2")-1];
00207 extern const char VSD_STD_ID_CD001[sizeof("CD001")-1];
00208 extern const char VSD_STD_ID_CDW01[sizeof("CDW02")-1];
00209 extern const char VSD_STD_ID_NSR03[sizeof("NSR03")-1];
00210 extern const char VSD_STD_ID_TEA01[sizeof("TEA01")-1];
00211 
00212 #define VSD_STD_ID_BEA01                "BEA01" 
00213 #define VSD_STD_ID_BOOT2                "BOOT2" 
00214 #define VSD_STD_ID_CD001                "CD001" 
00215 #define VSD_STD_ID_CDW02                "CDW02" 
00216 #define VSD_STD_ID_NSR02                "NSR02" 
00218 #define VSD_STD_ID_NSR03                "NSR03" 
00219 #define VSD_STD_ID_TEA01                "TEA01" 
00222 struct beginning_extended_area_desc_s
00223 {
00224   udf_Uint8_t           struct_type;
00225   udf_Uint8_t           std_id[VSD_STD_ID_SIZE];
00226   udf_Uint8_t           struct_version;
00227   udf_Uint8_t           struct_data[2041];
00228 } GNUC_PACKED;
00229 
00231 struct terminating_extended_area_desc_s
00232 {
00233   udf_Uint8_t           struct_type;
00234   udf_Uint8_t           std_id[VSD_STD_ID_SIZE];
00235   udf_Uint8_t           struct_version;
00236   udf_Uint8_t           struct_data[2041];
00237 } GNUC_PACKED;
00238 
00240 struct boot_desc_s
00241 {
00242   udf_Uint8_t           struct_type;
00243   udf_Uint8_t           std_ident[VSD_STD_ID_SIZE];
00244   udf_Uint8_t           struct_version;
00245   udf_Uint8_t           reserved1;
00246   udf_regid_t           arch_type;
00247   udf_regid_t           boot_ident;
00248   udf_Uint32_t          bool_ext_location;
00249   udf_Uint32_t          bool_ext_length;
00250   udf_Uint64_t          load_address;
00251   udf_Uint64_t          start_address;
00252   udf_timestamp_t       desc_creation_time;
00253   udf_Uint16_t          flags;
00254   udf_Uint8_t           reserved2[32];
00255   udf_Uint8_t           boot_use[1906];
00256 } GNUC_PACKED;
00257 
00259 #define BOOT_FLAGS_ERASE                0x01
00260 
00262 struct udf_extent_ad_s
00263 {
00264   udf_Uint32_t          len;
00265   udf_Uint32_t          loc;
00266 } GNUC_PACKED;
00267 
00268 typedef struct udf_extent_ad_s udf_extent_ad_t;
00269 
00271 struct udf_tag_s
00272 {
00273   udf_Uint16_t          id;
00274   udf_Uint16_t          desc_version;
00275   udf_Uint8_t           cksum;
00276   udf_Uint8_t           reserved;
00277   udf_Uint16_t          i_serial;
00278   udf_Uint16_t          desc_CRC;
00279   udf_Uint16_t          desc_CRC_len;
00280   udf_Uint32_t          loc;
00281 } GNUC_PACKED;
00282 
00283 typedef struct udf_tag_s udf_tag_t;
00284 
00286 struct NSR_desc_s
00287 {
00288   udf_Uint8_t   struct_type;
00289   udf_Uint8_t   std_id[VSD_STD_ID_SIZE];
00290   udf_Uint8_t   struct_version;
00291   udf_Uint8_t   reserved;
00292   udf_Uint8_t   struct_data[2040];
00293 } GNUC_PACKED;
00294 
00296 struct udf_pvd_s
00297 {
00298   udf_tag_t       tag;
00299   udf_Uint32_t    vol_desc_seq_num;
00300   udf_Uint32_t    primary_vol_desc_num;
00301   udf_dstring     vol_ident[UDF_VOLID_SIZE];
00302   udf_Uint16_t    vol_seq_num;
00303   udf_Uint16_t    max_vol_seqnum;
00304   udf_Uint16_t    interchange_lvl;
00305   udf_Uint16_t    max_interchange_lvl;
00306   udf_Uint32_t    charset_list;
00307   udf_Uint32_t    max_charset_list;
00308   udf_dstring     volset_id[UDF_VOLSET_ID_SIZE];
00309   udf_charspec_t  desc_charset;
00310   udf_charspec_t  explanatory_charset;
00311   udf_extent_ad_t vol_abstract;
00312   udf_extent_ad_t vol_copyright;
00313   udf_regid_t     app_ident;
00314   udf_timestamp_t recording_time;
00315   udf_regid_t     imp_ident;
00316   udf_Uint8_t     imp_use[64];
00317   udf_Uint32_t    predecessor_vol_desc_seq_location;
00318   udf_Uint16_t    flags;
00319   udf_Uint8_t     reserved[22];
00320 } GNUC_PACKED;
00321 
00322 typedef struct udf_pvd_s udf_pvd_t;
00323 
00325 #define PVD_FLAGS_VSID_COMMON           0x0001
00326 
00328 struct anchor_vol_desc_ptr_s
00329 {
00330   udf_tag_t       tag;
00331   udf_extent_ad_t main_vol_desc_seq_ext;
00332   udf_extent_ad_t reserve_vol_desc_seq_ext;
00333   udf_Uint8_t     reserved[480];
00334 } GNUC_PACKED;
00335 
00336 typedef struct anchor_vol_desc_ptr_s anchor_vol_desc_ptr_t;
00337 
00339 struct vol_desc_ptr_s
00340 {
00341   udf_tag_t       tag;
00342   udf_Uint32_t    vol_desc_seq_num;
00343   udf_extent_ad_t next_vol_desc_set_ext;
00344   udf_Uint8_t     reserved[484];
00345 } GNUC_PACKED;
00346 
00348 struct imp_use_vol_desc_s
00349 {
00350   udf_tag_t    tag;
00351   udf_Uint32_t vol_desc_seq_num;
00352   udf_regid_t  imp_id;
00353   udf_Uint8_t  imp_use[460];
00354 } GNUC_PACKED;
00355 
00357 struct partition_desc_s
00358 {
00359   udf_tag_t     tag;
00360   udf_Uint32_t  vol_desc_seq_num;
00361   udf_Uint16_t  flags;
00362   udf_Uint16_t  number;             
00363   udf_regid_t   contents;
00364   udf_Uint8_t   contents_use[128];
00365   udf_Uint32_t  access_type;
00366   udf_Uint32_t  start_loc;
00367   udf_Uint32_t  part_len;
00368   udf_regid_t   imp_id;
00369   udf_Uint8_t   imp_use[128];
00370   udf_Uint8_t   reserved[156];
00371 } GNUC_PACKED;
00372 
00373 typedef struct partition_desc_s partition_desc_t;
00374 
00376 #define PD_PARTITION_FLAGS_ALLOC        0x0001
00377 
00379 #define PD_PARTITION_CONTENTS_NSR02     "+NSR02"
00380 
00382 #define PD_PARTITION_CONTENTS_FDC01     "+FDC01"
00383 #define PD_PARTITION_CONTENTS_CD001     "+CD001"
00384 #define PD_PARTITION_CONTENTS_CDW02     "+CDW02"
00385 #define PD_PARTITION_CONTENTS_NSR03     "+NSR03"
00386 
00388 #define PD_ACCESS_TYPE_NONE             0x00000000
00389 #define PD_ACCESS_TYPE_READ_ONLY        0x00000001
00390 #define PD_ACCESS_TYPE_WRITE_ONCE       0x00000002
00391 #define PD_ACCESS_TYPE_REWRITABLE       0x00000003
00392 #define PD_ACCESS_TYPE_OVERWRITABLE     0x00000004
00393 
00395 struct udf_lb_addr_s
00396 {
00397   udf_Uint32_t  lba;
00398   udf_Uint16_t  partitionReferenceNum;
00399 } GNUC_PACKED;
00400 
00401 typedef struct udf_lb_addr_s udf_lb_addr_t;
00402 
00404 struct udf_short_ad_s
00405 {
00406   udf_Uint32_t  len;
00407   udf_Uint32_t  pos;
00408 } GNUC_PACKED;
00409 
00410 typedef struct udf_short_ad_s udf_short_ad_t;
00411 
00413 struct udf_long_ad_s
00414 {
00415   udf_Uint32_t  len;
00416   udf_lb_addr_t loc;
00417   udf_Uint8_t   imp_use[6];
00418 } GNUC_PACKED;
00419 
00420 typedef struct udf_long_ad_s udf_long_ad_t;
00421 
00423 struct logical_vol_desc_s
00424 {
00425   udf_tag_t       tag;
00426   udf_Uint32_t    seq_num;
00427   udf_charspec_t  desc_charset;
00428   udf_dstring     logvol_id[128];
00429   udf_Uint32_t    logical_blocksize;
00430   udf_regid_t     domain_id;
00431   union {
00432     udf_long_ad_t fsd_loc;
00433     udf_Uint8_t   logvol_content_use[16];
00434   } lvd_use;
00435   udf_Uint8_t     logvol_contents_use[16];
00436   udf_Uint32_t    maptable_len;
00437   udf_Uint32_t    i_partition_maps;
00438   udf_regid_t     imp_id;
00439   udf_Uint8_t     imp_use[128];
00440   udf_extent_ad_t integrity_seq_ext;
00441   udf_Uint8_t     partition_maps[0];
00442 } GNUC_PACKED;
00443 
00444 typedef struct logical_vol_desc_s logical_vol_desc_t;
00445 
00447 struct generic_partition_map
00448 {
00449   udf_Uint8_t   partition_map_type;
00450   udf_Uint8_t   partition_map_length;
00451   udf_Uint8_t   partition_mapping[0];
00452 } GNUC_PACKED;
00453 
00455 #define GP_PARTITION_MAP_TYPE_UNDEF     0x00
00456 #define GP_PARTIITON_MAP_TYPE_1         0x01
00457 #define GP_PARTITION_MAP_TYPE_2         0x02
00458 
00460 struct generic_partition_map1
00461 {
00462   udf_Uint8_t   partition_map_type;
00463   udf_Uint8_t   partition_map_length;
00464   udf_Uint16_t  vol_seq_num;
00465   udf_Uint16_t  i_partition;
00466 } GNUC_PACKED;
00467 
00469 struct generic_partition_map2
00470 {
00471   udf_Uint8_t   partition_map_type;
00472   udf_Uint8_t   partition_map_length; 
00473   udf_Uint8_t   partition_id[62];
00474 } GNUC_PACKED;
00475 
00477 struct unalloc_space_desc_s
00478 {
00479   udf_tag_t       tag;
00480   udf_Uint32_t    vol_desc_seq_num;
00481   udf_Uint32_t    i_alloc_descs;
00482   udf_extent_ad_t allocDescs[0];
00483 } GNUC_PACKED;
00484 
00486 struct terminating_desc_s
00487 {
00488   udf_tag_t    tag;
00489   udf_Uint8_t   reserved[496];
00490 } GNUC_PACKED;
00491 
00493 struct logvol_integrity_desc_s
00494 {
00495   udf_tag_t       tag;
00496   udf_timestamp_t recording_time;
00497   udf_Uint32_t    integrity_type;
00498   udf_extent_ad_t next_integrity_ext;
00499   udf_Uint8_t     logvol_contents_use[32];
00500   udf_Uint32_t    i_partitions;
00501   union { /* Same MSVC workaround as with struct udf_fileid_desc_s */
00502     udf_Uint32_t  imp_use_len;
00503     struct {
00504       udf_Uint32_t unused;
00505       udf_Uint32_t data[0];
00506     } freespace_table;
00507     struct {
00508       udf_Uint32_t unused;
00509       udf_Uint32_t data[0];
00510     } size_table;
00511     struct {
00512       udf_Uint32_t unused;
00513       udf_Uint32_t data[0];
00514     } imp_use;
00515   } u;
00516 } GNUC_PACKED;
00517 
00519 #define LVID_INTEGRITY_TYPE_OPEN        0x00000000
00520 #define LVID_INTEGRITY_TYPE_CLOSE       0x00000001
00521 
00523 struct udf_ext_ad_s
00524 {
00525   udf_Uint32_t  len;
00526   udf_Uint32_t  recorded_len;
00527   udf_Uint32_t  information_len;
00528   udf_lb_addr_t ext_loc;
00529 } GNUC_PACKED;
00530 
00531 typedef struct udf_ext_ad_s udf_ext_ad_t;
00532 
00538 struct udf_fsd_s
00539 {
00540   udf_tag_t       tag;
00541   udf_timestamp_t recording_time;
00542   udf_Uint16_t    interchange_lvl;
00543   udf_Uint16_t    maxInterchange_lvl;
00544   udf_Uint32_t    charset_list;
00545   udf_Uint32_t    max_charset_list;
00546   udf_Uint32_t    fileset_num;
00547   udf_Uint32_t    udf_fsd_num;
00548   udf_charspec_t  logical_vol_id_charset;
00549   udf_dstring     logical_vol_id[128];
00550   udf_charspec_t  fileset_charset;
00551   udf_dstring     fileSet_id[32];
00552   udf_dstring     copyright_file_id[32];
00553   udf_dstring     abstract_file_id[32];
00554   udf_long_ad_t   root_icb;
00555   udf_regid_t     domain_id;
00556   udf_long_ad_t   next_ext;
00557   udf_long_ad_t   stream_directory_ICB;
00558   udf_Uint8_t     reserved[32];
00559 } GNUC_PACKED;
00560 
00561 typedef struct udf_fsd_s udf_fsd_t;
00562 
00564 struct partition_header_desc_s
00565 {
00566   udf_short_ad_t unalloc_space_table;
00567   udf_short_ad_t unalloc_space_bitmap;
00568   udf_short_ad_t partition_integrity_table;
00569   udf_short_ad_t freed_space_table;
00570   udf_short_ad_t freed_space_bitmap;
00571   udf_Uint8_t    reserved[88];
00572 } GNUC_PACKED;
00573 
00574 typedef struct partition_header_desc_s partition_header_desc_t;
00575 
00577 struct udf_fileid_desc_s
00578 {
00579   udf_tag_t     tag;
00580   udf_Uint16_t  file_version_num;
00581   udf_Uint8_t   file_characteristics;
00582   udf_Uint8_t   i_file_id;
00583   udf_long_ad_t icb;
00584   /* MSVC workaround for multiple zero sized arrays
00585      Unlike what is the case with GNU, and against logic, an union of zero
00586      sized arrays in the Microsoft world is not zero bytes but one byte!
00587      Thus, for sizeof() to be consistent across platforms, we must use an
00588      ugly workaround that attaches the union to the last non-zero member. */
00589   union {
00590     udf_Uint16_t        i_imp_use;
00591     struct {
00592       udf_Uint16_t      unused;
00593       udf_Uint8_t       data[0];
00594     } imp_use;
00595     struct {
00596       udf_Uint16_t      unused;
00597       udf_Uint8_t       data[0];
00598     } file_id;
00599     struct {
00600       udf_Uint16_t      unused;
00601       udf_Uint8_t       data[0];
00602     } padding;
00603   } u;
00604 } GNUC_PACKED;
00605 
00606 typedef struct udf_fileid_desc_s udf_fileid_desc_t;
00607 
00613 typedef enum {
00614   UDF_FILE_HIDDEN       = (1 << 0),
00615   UDF_FILE_DIRECTORY    = (1 << 1),
00616   UDF_FILE_DELETED      = (1 << 2),
00617   UDF_FILE_PARENT       = (1 << 3),
00618   UDF_FILE_METADATA     = (1 << 4)
00619 } file_characteristics_t;
00620 
00622 struct allocExtDesc
00623 {
00624   udf_tag_t    tag;
00625   udf_Uint32_t previous_alloc_ext_loc;
00626   udf_Uint32_t i_alloc_descs;
00627 } GNUC_PACKED;
00628 
00630 struct udf_icbtag_s
00631 {
00632   udf_Uint32_t  prev_num_dirs;
00633   udf_Uint16_t  strat_type;
00634   udf_Uint16_t  strat_param;
00635   udf_Uint16_t  max_num_entries;
00636   udf_Uint8_t   reserved;
00637   udf_Uint8_t   file_type;
00638   udf_lb_addr_t parent_ICB;
00639   udf_Uint16_t  flags;
00640 } GNUC_PACKED;
00641 
00642 typedef struct udf_icbtag_s udf_icbtag_t;
00643 
00644 #define UDF_ICB_TAG_FLAGS_SETUID        0x40
00645 #define UDF_ICB_TAG_FLAGS_SETGID        0x80
00646 #define UDF_ICB_TAG_FLAGS_STICKY        0x100
00647 
00650 #define ICBTAG_STRATEGY_TYPE_UNDEF 0x0000 
00651 #define ICBTAG_STRATEGY_TYPE_1     0x0001 
00652 #define ICBTAG_STRATEGY_TYPE_2     0x0002 
00653 #define ICBTAG_STRATEGY_TYPE_3     0x0003 
00654 #define ICBTAG_STRATEGY_TYPE_4     0x0004 
00664 typedef enum {
00665   ICBTAG_FILE_TYPE_UNDEF =      0x00,
00666   ICBTAG_FILE_TYPE_USE =        0x01,
00667   ICBTAG_FILE_TYPE_PIE =        0x02,
00668   ICBTAG_FILE_TYPE_IE =         0x03,
00669   ICBTAG_FILE_TYPE_DIRECTORY =  0x04,
00670   ICBTAG_FILE_TYPE_REGULAR =    0x05,
00671   ICBTAG_FILE_TYPE_BLOCK =      0x06,
00672   ICBTAG_FILE_TYPE_CHAR =       0x07,
00673   ICBTAG_FILE_TYPE_EA =         0x08,
00674   ICBTAG_FILE_TYPE_FIFO =       0x09,
00675   ICBTAG_FILE_TYPE_SOCKET =     0x0A,
00676   ICBTAG_FILE_TYPE_TE =         0x0B,
00677   ICBTAG_FILE_TYPE_SYMLINK =    0x0C,
00678   ICBTAG_FILE_TYPE_STREAMDIR =  0x0D
00679 } icbtag_file_type_enum_t;
00680 
00682 typedef enum {
00683   ICBTAG_FLAG_AD_MASK        =  0x0007, 
00685   ICBTAG_FLAG_AD_SHORT       =  0x0000, 
00691   ICBTAG_FLAG_AD_LONG        =  0x0001, 
00697   ICBTAG_FLAG_AD_EXTENDED    =  0x0002,
00698   ICBTAG_FLAG_AD_IN_ICB      =  0x0003, 
00702   ICBTAG_FLAG_SORTED         =  0x0008,
00703   ICBTAG_FLAG_NONRELOCATABLE =  0x0010,
00704   ICBTAG_FLAG_ARCHIVE        =  0x0020,
00705   ICBTAG_FLAG_SETUID         =  0x0040,
00706   ICBTAG_FLAG_SETGID         =  0x0080,
00707   ICBTAG_FLAG_STICKY         =  0x0100,
00708   ICBTAG_FLAG_CONTIGUOUS     =  0x0200,
00709   ICBTAG_FLAG_SYSTEM         =  0x0400,
00710   ICBTAG_FLAG_TRANSFORMED    =  0x0800,
00711   ICBTAG_FLAG_MULTIVERSIONS  =  0x1000,
00712   ICBTAG_FLAG_STREAM =          0x2000
00713 } icbtag_flag_enum_t;
00714   
00716 struct indirect_entry_s
00717 {
00718   udf_tag_t       tag;
00719   udf_icbtag_t    icb_tag;
00720   udf_long_ad_t   indirect_ICB;
00721 } GNUC_PACKED;
00722 
00724 struct terminal_entry_s
00725 {
00726   udf_tag_t       tag;
00727   udf_icbtag_t    icb_tag;
00728 } GNUC_PACKED;
00729 
00731 struct udf_file_entry_s
00732 {
00733   udf_tag_t       tag;                   
00734   udf_icbtag_t    icb_tag;                
00735   udf_Uint32_t    uid;                    
00736   udf_Uint32_t    gid;                    
00737   udf_Uint32_t    permissions;            
00738   udf_Uint16_t    link_count;             
00739   udf_Uint8_t     rec_format;             
00740   udf_Uint8_t     rec_disp_attr;          
00741   udf_Uint32_t    rec_len;                
00742   udf_Uint64_t    info_len;               
00743   udf_Uint64_t    logblks_recorded;       
00744   udf_timestamp_t access_time;            
00747   udf_timestamp_t modification_time;      
00750   udf_timestamp_t attribute_time;
00751   udf_Uint32_t    checkpoint;
00752   udf_long_ad_t   ext_attr_ICB;
00753   udf_regid_t     imp_id;
00754   udf_Uint64_t    unique_ID;
00755   udf_Uint32_t    i_extended_attr;
00756   udf_Uint32_t    i_alloc_descs;
00757   /* The following union allows file entry reuse without worrying
00758      about overflows, by ensuring the struct is always the
00759      maximum possible size allowed by the specs: one UDF block. */
00760   union {
00761     udf_Uint8_t   ext_attr[0];
00762     udf_Uint8_t   alloc_descs[0];
00763     udf_Uint8_t   pad_to_one_block[2048-176];
00764   } u;
00765 } GNUC_PACKED;
00766 
00767 typedef struct udf_file_entry_s udf_file_entry_t;
00768 
00769 #define UDF_FENTRY_SIZE 176
00770 #define UDF_FENTRY_PERM_USER_MASK       0x07
00771 #define UDF_FENTRY_PERM_GRP_MASK        0xE0
00772 #define UDF_FENTRY_PERM_OWNER_MASK      0x1C00
00773 
00775 #define FE_PERM_O_EXEC                  0x00000001U
00776 #define FE_PERM_O_WRITE                 0x00000002U
00777 #define FE_PERM_O_READ                  0x00000004U
00778 #define FE_PERM_O_CHATTR                0x00000008U
00779 #define FE_PERM_O_DELETE                0x00000010U
00780 #define FE_PERM_G_EXEC                  0x00000020U
00781 #define FE_PERM_G_WRITE                 0x00000040U
00782 #define FE_PERM_G_READ                  0x00000080U
00783 #define FE_PERM_G_CHATTR                0x00000100U
00784 #define FE_PERM_G_DELETE                0x00000200U
00785 #define FE_PERM_U_EXEC                  0x00000400U
00786 #define FE_PERM_U_WRITE                 0x00000800U
00787 #define FE_PERM_U_READ                  0x00001000U
00788 #define FE_PERM_U_CHATTR                0x00002000U
00789 #define FE_PERM_U_DELETE                0x00004000U
00790 
00792 #define FE_RECORD_FMT_UNDEF             0x00
00793 #define FE_RECORD_FMT_FIXED_PAD         0x01
00794 #define FE_RECORD_FMT_FIXED             0x02
00795 #define FE_RECORD_FMT_VARIABLE8         0x03
00796 #define FE_RECORD_FMT_VARIABLE16        0x04
00797 #define FE_RECORD_FMT_VARIABLE16_MSB    0x05
00798 #define FE_RECORD_FMT_VARIABLE32        0x06
00799 #define FE_RECORD_FMT_PRINT             0x07
00800 #define FE_RECORD_FMT_LF                0x08
00801 #define FE_RECORD_FMT_CR                0x09
00802 #define FE_RECORD_FMT_CRLF              0x0A
00803 #define FE_RECORD_FMT_LFCR              0x0B
00804 
00806 #define FE_RECORD_DISPLAY_ATTR_UNDEF    0x00
00807 #define FE_RECORD_DISPLAY_ATTR_1        0x01
00808 #define FE_RECORD_DISPLAY_ATTR_2        0x02
00809 #define FE_RECORD_DISPLAY_ATTR_3        0x03
00810 
00812 struct extended_attr_header_desc_s
00813 {
00814   udf_tag_t       tag;
00815   udf_Uint32_t    imp_attr_location;
00816   udf_Uint32_t    app_attr_location;
00817 } GNUC_PACKED;
00818 
00820 struct generic_format_s
00821 {
00822   udf_Uint32_t  attr_type;
00823   udf_Uint8_t   attr_subtype;
00824   udf_Uint8_t   reserved[3];
00825   udf_Uint32_t  attrLength;
00826   udf_Uint8_t   attrData[0];
00827 } GNUC_PACKED;
00828 
00830 struct charSet_info_s
00831 {
00832   udf_Uint32_t  attr_type;
00833   udf_Uint8_t   attr_subtype;
00834   udf_Uint8_t   reserved[3];
00835   udf_Uint32_t  attrLength;
00836   udf_Uint32_t  escapeSeqLength;
00837   udf_Uint8_t   charSetType;
00838   udf_Uint8_t   escapeSeq[0];
00839 } GNUC_PACKED;
00840 
00841 /* Alternate Permissions (ECMA 167r3 4/14.10.4) */
00842 struct alt_perms_s
00843 {
00844   udf_Uint32_t  attr_type;
00845   udf_Uint8_t   attr_subtype;
00846   udf_Uint8_t   reserved[3];
00847   udf_Uint32_t  attrLength;
00848   udf_Uint16_t  owner_id;
00849   udf_Uint16_t  group_id;
00850   udf_Uint16_t  permission;
00851 } GNUC_PACKED;
00852 
00854 struct filetimes_ext_attr_s
00855 {
00856   udf_Uint32_t  attr_type;
00857   udf_Uint8_t   attr_subtype;
00858   udf_Uint8_t   reserved[3];
00859   udf_Uint32_t  attrLength;
00860   udf_Uint32_t  dataLength;
00861   udf_Uint32_t  fileTimeExistence;
00862   udf_Uint8_t   fileTimes;
00863 } GNUC_PACKED;
00864 
00866 #define FTE_CREATION                    0x00000001
00867 #define FTE_DELETION                    0x00000004
00868 #define FTE_EFFECTIVE                   0x00000008
00869 #define FTE_BACKUP                      0x00000002
00870 
00872 struct infoTimesExtAttr
00873 {
00874   udf_Uint32_t  attr_type;
00875   udf_Uint8_t   attr_subtype;
00876   udf_Uint8_t   reserved[3];
00877   udf_Uint32_t  attrLength;
00878   udf_Uint32_t  dataLength;
00879   udf_Uint32_t  infoTimeExistence;
00880   udf_Uint8_t   infoTimes[0];
00881 } GNUC_PACKED;
00882 
00884 struct deviceSpec
00885 {
00886   udf_Uint32_t  attr_type;
00887   udf_Uint8_t   attr_subtype;
00888   udf_Uint8_t   reserved[3];
00889   udf_Uint32_t  attrLength;
00890   udf_Uint32_t  imp_useLength;
00891   udf_Uint32_t  majorDevice_id;
00892   udf_Uint32_t  minorDevice_id;
00893   udf_Uint8_t   imp_use[0];
00894 } GNUC_PACKED;
00895 
00897 struct impUseExtAttr
00898 {
00899   udf_Uint32_t  attr_type;
00900   udf_Uint8_t   attr_subtype;
00901   udf_Uint8_t   reserved[3];
00902   udf_Uint32_t  attrLength;
00903   udf_Uint32_t  imp_useLength;
00904   udf_regid_t   imp_id;
00905   udf_Uint8_t   imp_use[0];
00906 } GNUC_PACKED;
00907 
00909 struct appUseExtAttr
00910 {
00911   udf_Uint32_t  attr_type;
00912   udf_Uint8_t   attr_subtype;
00913   udf_Uint8_t   reserved[3];
00914   udf_Uint32_t  attrLength;
00915   udf_Uint32_t  appUseLength;
00916   udf_regid_t   app_id;
00917   udf_Uint8_t   appUse[0];
00918 } GNUC_PACKED;
00919 
00920 #define EXTATTR_CHAR_SET                1
00921 #define EXTATTR_ALT_PERMS               3
00922 #define EXTATTR_FILE_TIMES              5
00923 #define EXTATTR_INFO_TIMES              6
00924 #define EXTATTR_DEV_SPEC                12
00925 #define EXTATTR_IMP_USE                 2048
00926 #define EXTATTR_APP_USE                 65536
00927 
00928 
00930 struct unallocSpaceEntry
00931 {
00932   udf_tag_t     tag;
00933   udf_icbtag_t  icb_tag;
00934   udf_Uint32_t  lengthAllocDescs;
00935   udf_Uint8_t   allocDescs[0];
00936 } GNUC_PACKED;
00937 
00939 struct spaceBitmapDesc
00940 {
00941   udf_tag_t     tag;
00942   udf_Uint32_t  i_bits;
00943   udf_Uint32_t  i_bytes;
00944   udf_Uint8_t   bitmap[0];
00945 } GNUC_PACKED;
00946 
00948 struct partitionIntegrityEntry
00949 {
00950   udf_tag_t       tag;
00951   udf_icbtag_t    icb_tag;
00952   udf_timestamp_t recording_time;
00953   udf_Uint8_t     integrityType;
00954   udf_Uint8_t     reserved[175];
00955   udf_regid_t     imp_id;
00956   udf_Uint8_t     imp_use[256];
00957 } GNUC_PACKED;
00958 
00962 #define EXT_RECORDED_ALLOCATED          0x00000000
00963 #define EXT_NOT_RECORDED_ALLOCATED      0x40000000
00964 #define EXT_NOT_RECORDED_NOT_ALLOCATED  0x80000000
00965 #define EXT_NEXT_EXTENT_ALLOCDECS       0xC0000000
00966 
00972 struct logical_vol_header_desc_s 
00973 {
00974   udf_Uint64_t  uniqueID;
00975   udf_Uint8_t   reserved[24];
00976 } GNUC_PACKED;
00977 
00978 typedef struct logical_vol_header_desc_s logical_vol_header_desc_t;
00979 
00981 struct pathComponent
00982 {
00983   udf_Uint8_t   component_type;
00984   udf_Uint8_t   lengthComponent_id;
00985   udf_Uint16_t  componentFileVersionNum;
00986   udf_dstring   component_id[0];
00987 } GNUC_PACKED;
00988 
00990 struct extended_file_entry
00991 {
00992   udf_tag_t       tag;                     
00993   udf_icbtag_t    icb_tag;                 
00994   udf_Uint32_t    uid;                     
00995   udf_Uint32_t    gid;                     
00996   udf_Uint32_t    permissions;             
00997   udf_Uint16_t    link_count;              
00998   udf_Uint8_t     rec_format;              
00999   udf_Uint8_t     rec_display_attr;        
01000   udf_Uint32_t    record_len;              
01001   udf_Uint64_t    info_len;                
01002   udf_Uint64_t    object_size;             
01003   udf_Uint64_t    logblks_recorded;        
01004   udf_timestamp_t access_time;             
01006   udf_timestamp_t modification_time;       
01009   udf_timestamp_t create_time;             
01010   udf_timestamp_t attribute_time;          
01013   udf_Uint32_t    checkpoint;
01014   udf_Uint32_t    reserved;                
01015   udf_long_ad_t   ext_attr_ICB;
01016   udf_long_ad_t   stream_directory_ICB;
01017   udf_regid_t     imp_id;
01018   udf_Uint64_t    unique_ID;
01019   udf_Uint32_t    length_extended_attr;
01020   udf_Uint32_t    length_alloc_descs;
01021   union { /* MSVC workaround for multiple zero sized arrays */
01022     udf_Uint8_t   ext_attr[0];
01023     udf_Uint8_t   alloc_descs[0];
01024         udf_Uint8_t       pad_to_one_block[2048-216];
01025   } u;
01026 } GNUC_PACKED;
01027 
01028 PRAGMA_END_PACKED
01029 
01035 extern tag_id_t                 debug_tagid;
01036 extern file_characteristics_t   debug_file_characteristics;
01037 extern icbtag_file_type_enum_t  debug_icbtag_file_type_enum;
01038 extern icbtag_flag_enum_t       debug_flag_enum;
01039 extern ecma_167_enum1_t         debug_ecma_167_enum1;
01040 extern ecma_167_timezone_enum_t debug_ecma_167_timezone_enum;
01041   
01042 #endif /* CDIO_ECMA_167_H */