Fork me on GitHub

root/include/fiwix/fs_iso9660.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * fiwix/include/fiwix/fs_iso9660.h
   3  *
   4  * Copyright 2018, Jordi Sanfeliu. All rights reserved.
   5  * Distributed under the terms of the Fiwix License.
   6  */
   7 
   8 #ifndef _FIWIX_FS_ISO9660_H
   9 #define _FIWIX_FS_ISO9660_H
  10 
  11 #include <fiwix/types.h>
  12 #include <fiwix/limits.h>
  13 
  14 #define ISO9660_SUPERBLOCK      16      /* ISO9660 superblock is in block 16 */
  15 #define ISO9660_STANDARD_ID     "CD001" /* standard identification */
  16 #define ISO9660_SUPER_MAGIC     0x9660
  17 
  18 #define ISO9660_VD_BOOT                 0
  19 #define ISO9660_VD_PRIMARY              1
  20 #define ISO9660_VD_SUPPLEMENTARY        2
  21 #define ISO9660_VD_PARTITION            3
  22 #define ISO9660_VD_END                  255
  23 
  24 #define ISODCL(from, to)        ((to - from) + 1)       /* descriptor length */
  25 
  26 #define ISO9660_MAX_VD          10      /* maximum number of VD per CDROM */
  27 
  28 /* inodes will have their directory block and their offset packed as follows:
  29  * 7FF7FF
  30  * \-/\-/
  31  *  ^  ^
  32  *  |  +----- offset value                      (11bit entries)
  33  *  +-------- directory block where to find it  (11bit entries)
  34  */
  35 #define ISO9660_INODE_BITS      11      /* FIXME: it could be greater (16bit) */
  36 #define ISO9660_INODE_MASK      0x7FF
  37 
  38 #define ISO9660_FILE_NOTEXIST   0x01    /* file shouldn't exists for the user */
  39 #define ISO9660_FILE_ISDIR      0x02    /* is a directory */
  40 #define ISO9660_FILE_ISASSOC    0x04    /* associated file */
  41 #define ISO9660_FILE_HASRECFMT  0x08    /* has a record format */
  42 #define ISO9660_FILE_HASOWNER   0x10    /* has owner and group defined */
  43 #define ISO9660_FILE_RESERVED5  0x20    /* reserved */
  44 #define ISO9660_FILE_RESERVED6  0x40    /* reserved */
  45 #define ISO9660_FILE_ISMULTIEXT 0x80    /* has more directory records */
  46 
  47 #define SP_MAGIC1               0xBE
  48 #define SP_MAGIC2               0xEF
  49 #define GET_SIG(s1, s2)         ((s1 << 8) | s2)
  50 
  51 #define SL_CURRENT              0x02
  52 #define SL_PARENT               0x04
  53 #define SL_ROOT                 0x08
  54 
  55 #define TF_CREATION             0x01
  56 #define TF_MODIFY               0x02
  57 #define TF_ACCESS               0x04
  58 #define TF_ATTRIBUTES           0x08
  59 #define TF_BACKUP               0x10
  60 #define TF_EXPIRATION           0x20
  61 #define TF_EFFECTIVE            0x40
  62 #define TF_LONG_FORM            0x80
  63 
  64 #define NM_CONTINUE             0
  65 #define NM_CURRENT              1
  66 #define NM_PARENT               2
  67 
  68 /* formerly Primary Volume Descriptor */
  69 struct iso9660_super_block {
  70         char type                       [ISODCL(  1,   1)];     /* 7.1.1 */
  71         char id                         [ISODCL(  2,   6)];
  72         char version                    [ISODCL(  7,   7)];     /* 7.1.1 */
  73         char unused1                    [ISODCL(  8,   8)];
  74         char system_id                  [ISODCL(  9,  40)];     /* a-chars */
  75         char volume_id                  [ISODCL( 41,  72)];     /* d-chars */
  76         char unused2                    [ISODCL( 73,  80)];
  77         char volume_space_size          [ISODCL( 81,  88)];     /* 7.3.3 */
  78         char unused3                    [ISODCL( 89, 120)];
  79         char volume_set_size            [ISODCL(121, 124)];     /* 7.2.3 */
  80         char volume_sequence_number     [ISODCL(125, 128)];     /* 7.2.3 */
  81         char logical_block_size         [ISODCL(129, 132)];     /* 7.2.3 */
  82         char path_table_size            [ISODCL(133, 140)];     /* 7.3.3 */
  83         char type_l_path_table          [ISODCL(141, 144)];     /* 7.3.1 */
  84         char opt_type_l_path_table      [ISODCL(145, 148)];     /* 7.3.1 */
  85         char type_m_path_table          [ISODCL(149, 152)];     /* 7.3.2 */
  86         char opt_type_m_path_table      [ISODCL(153, 156)];     /* 7.3.2 */
  87         char root_directory_record      [ISODCL(157, 190)];     /* 9.1 */
  88         char volume_set_id              [ISODCL(191, 318)];     /* d-chars */
  89         char publisher_id               [ISODCL(319, 446)];     /* a-chars */
  90         char preparer_id                [ISODCL(447, 574)];     /* a-chars */
  91         char application_id             [ISODCL(575, 702)];     /* a-chars */
  92         char copyright_file_id          [ISODCL(703, 739)];     /* 7.5 d-chars */
  93         char abstract_file_id           [ISODCL(740, 776)];     /* 7.5 d-chars */
  94         char bibliographic_file_id      [ISODCL(777, 813)];     /* 7.5 d-chars */
  95         char creation_date              [ISODCL(814, 830)];     /* 8.4.26.1 */
  96         char modification_date          [ISODCL(831, 847)];     /* 8.4.26.1 */
  97         char expiration_date            [ISODCL(848, 864)];     /* 8.4.26.1 */
  98         char effective_date             [ISODCL(865, 881)];     /* 8.4.26.1 */
  99         char file_structure_version     [ISODCL(882, 882)];
 100         char unused4                    [ISODCL(883, 883)];
 101         char application_data           [ISODCL(884, 1395)];
 102         char unused5                    [ISODCL(1396, 2048)];
 103 };
 104 
 105 struct iso9660_directory_record
 106 {
 107         char length                     [ISODCL( 1,  1)];       /* 7.1.1 */
 108         char ext_attr_length            [ISODCL( 2,  2)];       /* 7.1.1 */
 109         char extent                     [ISODCL( 3, 10)];       /* 7.3.3 */
 110         char size                       [ISODCL(11, 18)];       /* 7.3.3 */
 111         char date                       [ISODCL(19, 25)];       /* 7 by 7.1.1 */
 112         char flags                      [ISODCL(26, 26)];
 113         char file_unit_size             [ISODCL(27, 27)];       /* 7.1.1 */
 114         char interleave                 [ISODCL(28, 28)];       /* 7.1.1 */
 115         char volume_sequence_number     [ISODCL(29, 32)];       /* 7.2.3 */
 116         char name_len                   [ISODCL(33, 33)];       /* 7.1.1 */
 117         char name[0];
 118 };
 119 
 120 struct iso9660_pathtable_record
 121 {
 122         char length                     [ISODCL( 1,  1)];       /* 7.1.1 */
 123         char ext_attr_length            [ISODCL( 2,  2)];       /* 7.1.1 */
 124         char extent                     [ISODCL( 3,  6)];       /* 7.3 */
 125         char parent                     [ISODCL( 7,  8)];       /* 7.2 */
 126         char name[0];
 127 };
 128 
 129 struct susp_sp {
 130         unsigned char magic[2];
 131         char len_skip;
 132 };
 133 
 134 struct susp_ce {
 135         char block[8];
 136         char offset[8];
 137         char size[8];
 138 };
 139 
 140 struct susp_er {
 141         char len_id;
 142         char len_des;
 143         char len_src;
 144         char ext_ver;
 145         char data[0];
 146 };
 147 
 148 struct rrip_px {
 149         char mode[8];
 150         char nlink[8];
 151         char uid[8];
 152         char gid[8];
 153         char sn[8];
 154 };
 155 
 156 struct rrip_pn {
 157         char dev_h[8];
 158         char dev_l[8];
 159 };
 160 
 161 struct rrip_sl_component {
 162         unsigned char flags;
 163         unsigned char len;
 164         char name[0];
 165 };
 166 
 167 struct rrip_sl {
 168         unsigned char flags;
 169         struct rrip_sl_component area;
 170 };
 171 
 172 struct rrip_nm {
 173         unsigned char flags;
 174         char name[0];
 175 };
 176 
 177 struct rrip_tf_timestamp {
 178         char time[7];           /* assumes LONG_FORM bit always set to zero */
 179 };
 180 
 181 struct rrip_tf {
 182         char flags;
 183         struct rrip_tf_timestamp times[0];
 184 };
 185 
 186 struct susp_rrip {
 187         char signature[2];
 188         unsigned char len;
 189         unsigned char version;
 190         union {
 191                 struct susp_sp sp;
 192                 struct susp_ce ce;
 193                 struct susp_er er;
 194                 struct rrip_px px;
 195                 struct rrip_pn pn;
 196                 struct rrip_sl sl;
 197                 struct rrip_nm nm;
 198                 struct rrip_tf tf;
 199         } u;
 200 };
 201 
 202 struct iso9660_inode {
 203         __blk_t i_extent;
 204         struct inode *i_parent;         /* inode of its parent directory */
 205 };
 206 
 207 struct iso9660_sb_info {
 208         __u32 s_root_inode;
 209         char *pathtable_raw;
 210         struct iso9660_pathtable_record **pathtable;
 211         int paths;
 212         unsigned char rrip;
 213         struct iso9660_super_block *sb;
 214 };
 215 
 216 #endif /* _FIWIX_FS_ISO9660_H */

/* [previous][next][first][last][top][bottom][index][help] */