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