Search
lxdream.org :: lxdream/src/drivers/cdrom/iso_impl.h :: diff
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
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/drivers/cdrom/iso_impl.h Wed Feb 10 18:16:19 2010 +1000
1.3 @@ -0,0 +1,128 @@
1.4 +/**
1.5 + * $Id$
1.6 + *
1.7 + * ISO9660 filesystem support
1.8 + *
1.9 + * Copyright (c) 2009 Nathan Keynes.
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.20 + */
1.21 +
1.22 +#define ISO_SUPERBLOCK_OFFSET 16
1.23 +#define ISO_BOOT_DESCRIPTOR 0
1.24 +#define ISO_PRIMARY_DESCRIPTOR 1
1.25 +#define ISO_SECONDARY_DESCRIPTOR 2
1.26 +#define ISO_PARTITION_DESCRIPTOR 3
1.27 +#define ISO_TERMINAL_DESCRIPTOR 0xFF
1.28 +
1.29 +typedef struct iso_timestamp_full { /* 17 bytes */
1.30 + char year[4];
1.31 + char month[2];
1.32 + char day[2];
1.33 + char hour[2];
1.34 + char minute[2];
1.35 + char second[2];
1.36 + char hundredths[2];
1.37 + int8_t utc_offset; /* 15 min intervals from -48 to +52 7.1.2 */
1.38 +} *iso_timestamp_full_t;
1.39 +
1.40 +typedef struct iso_timestamp { /* 7 bytes */
1.41 + uint8_t year; /* Since 1900 */
1.42 + uint8_t month; /* 1 .. 12 */
1.43 + uint8_t day; /* 1 .. 31 */
1.44 + uint8_t hour; /* 0 .. 23 */
1.45 + uint8_t minute; /* 0 .. 59 */
1.46 + uint8_t second; /* 0 .. 59 */
1.47 + uint8_t utc_offset; /* 15 min intervals from -48 to +52 7.1.2 */
1.48 +} *iso_timestamp_t;
1.49 +
1.50 +#define ISO_FILE_EXISTS 0x01
1.51 +#define ISO_FILE_DIR 0x02
1.52 +#define ISO_FILE_ASSOC 0x04 /* Associated file */
1.53 +#define ISO_FILE_RECORD 0x08 /* Structure specified by XA record */
1.54 +#define ISO_FILE_PROTECT 0x10 /* Permissions specified */
1.55 +#define ISO_FILE_MULTIEXT 0x80 /* Multiple extents */
1.56 +
1.57 +typedef struct iso_dirent { /* 34+ bytes 9.1 */
1.58 + uint8_t record_len;
1.59 + uint8_t xa_record_len;
1.60 + uint32_t file_lba_le, file_lba_be;
1.61 + uint32_t file_size_le, file_size_be;
1.62 + struct iso_timestamp timestamp;
1.63 + uint8_t flags;
1.64 + uint8_t unit_size;
1.65 + uint8_t gap_size;
1.66 + uint16_t volume_seq_le, volume_seq_be;
1.67 + uint8_t file_id_len;
1.68 + char file_id[1];
1.69 +} __attribute__((packed)) *iso_dirent_t;
1.70 +
1.71 +typedef struct iso_pathtabrec { /* 8+ bytes 9.4 */
1.72 + uint8_t record_len;
1.73 + uint8_t xa_record_len;
1.74 + uint32_t file_lba;
1.75 + uint16_t parent_dir_no;
1.76 + char file_id[];
1.77 +} *iso_pathtabrec_t;
1.78 +
1.79 +typedef struct iso_xattrrec {
1.80 + uint16_t uid_le, uid_be;
1.81 + uint16_t gid_le, gid_be;
1.82 + uint16_t permissions;
1.83 + struct iso_timestamp_full create_time;
1.84 + struct iso_timestamp_full modify_time;
1.85 + struct iso_timestamp_full expiry_time;
1.86 + struct iso_timestamp_full effective_time;
1.87 + uint8_t record_format;
1.88 + uint8_t record_attrs;
1.89 + uint16_t record_len_le, record_len_be;
1.90 + char system_id[32];
1.91 + char system_use[64];
1.92 + uint8_t record_version; /* Should be 1 */
1.93 + uint8_t escape_len;
1.94 + char reserved[64];
1.95 + uint16_t app_use_len_le, app_use_len_be;
1.96 + char app_use[];
1.97 +} *iso_xattrrec_t;
1.98 +
1.99 +/** Primary Volume Descriptor */
1.100 +typedef struct iso_pvd {
1.101 + uint8_t desc_type;
1.102 + char tag[5];
1.103 + uint8_t desc_version;
1.104 + char pad0;
1.105 + char system_id[32];
1.106 + char volume_id[32];
1.107 + char pad1[8];
1.108 + uint32_t volume_size_le, volume_size_be;
1.109 + char pad2[32];
1.110 + uint16_t volume_sets_le, volume_sets_be;
1.111 + uint16_t volume_seq_le, volume_seq_be;
1.112 + uint16_t block_size_le, block_size_be;
1.113 + uint32_t pathtab_size_le, pathtab_size_be;
1.114 + uint32_t pathtab_offset_le, pathtab2_offset_le;
1.115 + uint32_t pathtab_offset_be, pathtab2_offset_be;
1.116 + struct iso_dirent root_dirent;
1.117 + char volume_set_id[128];
1.118 + char publisher_id[128];
1.119 + char preparer_id[128];
1.120 + char app_id[128];
1.121 + char copyright_file_id[37];
1.122 + char abstract_file_id[37];
1.123 + char biblio_file_id[37];
1.124 + struct iso_timestamp_full create_time;
1.125 + struct iso_timestamp_full modify_time;
1.126 + struct iso_timestamp_full expiry_time;
1.127 + struct iso_timestamp_full effective_time;
1.128 + uint8_t fs_version; /* must be 1 */
1.129 + char pad3[1166];
1.130 +} *iso_pvd_t;
1.131 +
.