Search
lxdream.org :: lxdream/src/drivers/cdrom/iso_impl.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/cdrom/iso_impl.h
changeset 1099:566cdeb157ec
author nkeynes
date Wed Feb 10 18:16:19 2010 +1000 (10 years ago)
permissions -rw-r--r--
last change First draft of basic ISO9660 filesystem reader
view annotate diff log raw
     1 /**
     2  * $Id$
     3  *
     4  * ISO9660 filesystem support
     5  *
     6  * Copyright (c) 2009 Nathan Keynes.
     7  *
     8  * This program is free software; you can redistribute it and/or modify
     9  * it under the terms of the GNU General Public License as published by
    10  * the Free Software Foundation; either version 2 of the License, or
    11  * (at your option) any later version.
    12  *
    13  * This program is distributed in the hope that it will be useful,
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  * GNU General Public License for more details.
    17  */
    19 #define ISO_SUPERBLOCK_OFFSET 16
    20 #define ISO_BOOT_DESCRIPTOR 0
    21 #define ISO_PRIMARY_DESCRIPTOR 1
    22 #define ISO_SECONDARY_DESCRIPTOR 2
    23 #define ISO_PARTITION_DESCRIPTOR 3
    24 #define ISO_TERMINAL_DESCRIPTOR 0xFF
    26 typedef struct iso_timestamp_full { /* 17 bytes */
    27     char year[4];
    28     char month[2];
    29     char day[2];
    30     char hour[2];
    31     char minute[2];
    32     char second[2];
    33     char hundredths[2];
    34     int8_t utc_offset; /* 15 min intervals from -48 to +52 7.1.2 */
    35 } *iso_timestamp_full_t;
    37 typedef struct iso_timestamp { /* 7 bytes */
    38     uint8_t year; /* Since 1900 */
    39     uint8_t month; /* 1 .. 12 */
    40     uint8_t day; /* 1 ..  31 */
    41     uint8_t hour; /* 0 .. 23 */
    42     uint8_t minute; /* 0 .. 59 */
    43     uint8_t second; /* 0 .. 59 */
    44     uint8_t utc_offset; /* 15 min intervals from -48 to +52 7.1.2 */
    45 } *iso_timestamp_t;
    47 #define ISO_FILE_EXISTS   0x01
    48 #define ISO_FILE_DIR      0x02
    49 #define ISO_FILE_ASSOC    0x04 /* Associated file */
    50 #define ISO_FILE_RECORD   0x08 /* Structure specified by XA record */
    51 #define ISO_FILE_PROTECT  0x10 /* Permissions specified */
    52 #define ISO_FILE_MULTIEXT 0x80 /* Multiple extents */
    54 typedef struct iso_dirent { /* 34+ bytes 9.1 */
    55     uint8_t record_len;
    56     uint8_t xa_record_len;
    57     uint32_t file_lba_le, file_lba_be;
    58     uint32_t file_size_le, file_size_be;
    59     struct iso_timestamp timestamp;
    60     uint8_t flags;
    61     uint8_t unit_size;
    62     uint8_t gap_size;
    63     uint16_t volume_seq_le, volume_seq_be;
    64     uint8_t file_id_len;
    65     char file_id[1];
    66 } __attribute__((packed)) *iso_dirent_t;
    68 typedef struct iso_pathtabrec { /* 8+ bytes 9.4 */
    69     uint8_t record_len;
    70     uint8_t xa_record_len;
    71     uint32_t file_lba;
    72     uint16_t parent_dir_no;
    73     char file_id[];
    74 } *iso_pathtabrec_t;
    76 typedef struct iso_xattrrec {
    77     uint16_t uid_le, uid_be;
    78     uint16_t gid_le, gid_be;
    79     uint16_t permissions;
    80     struct iso_timestamp_full create_time;
    81     struct iso_timestamp_full modify_time;
    82     struct iso_timestamp_full expiry_time;
    83     struct iso_timestamp_full effective_time;
    84     uint8_t record_format;
    85     uint8_t record_attrs;
    86     uint16_t record_len_le, record_len_be;
    87     char system_id[32];
    88     char system_use[64];
    89     uint8_t record_version; /* Should be 1 */
    90     uint8_t escape_len;
    91     char reserved[64];
    92     uint16_t app_use_len_le, app_use_len_be;
    93     char app_use[];
    94 } *iso_xattrrec_t;
    96 /** Primary Volume Descriptor */
    97 typedef struct iso_pvd {
    98     uint8_t desc_type;
    99     char tag[5];
   100     uint8_t desc_version;
   101     char pad0;
   102     char system_id[32];
   103     char volume_id[32];
   104     char pad1[8];
   105     uint32_t volume_size_le, volume_size_be;
   106     char pad2[32];
   107     uint16_t volume_sets_le, volume_sets_be;
   108     uint16_t volume_seq_le, volume_seq_be;
   109     uint16_t block_size_le, block_size_be;
   110     uint32_t pathtab_size_le, pathtab_size_be;
   111     uint32_t pathtab_offset_le, pathtab2_offset_le;
   112     uint32_t pathtab_offset_be, pathtab2_offset_be;
   113     struct iso_dirent root_dirent;
   114     char volume_set_id[128];
   115     char publisher_id[128];
   116     char preparer_id[128];
   117     char app_id[128];
   118     char copyright_file_id[37];
   119     char abstract_file_id[37];
   120     char biblio_file_id[37];
   121     struct iso_timestamp_full create_time;
   122     struct iso_timestamp_full modify_time;
   123     struct iso_timestamp_full expiry_time;
   124     struct iso_timestamp_full effective_time;
   125     uint8_t fs_version; /* must be 1 */
   126     char pad3[1166];
   127 } *iso_pvd_t;
.