[48e3190] | 1 | /*
|
---|
| 2 | * Copyright (c) 2012 Julia Medvedeva
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[b1834a01] | 29 | /** @addtogroup udf
|
---|
[48e3190] | 30 | * @{
|
---|
| 31 | */
|
---|
| 32 |
|
---|
| 33 | #ifndef UDF_FILE_H_
|
---|
| 34 | #define UDF_FILE_H_
|
---|
| 35 |
|
---|
[8d2dd7f2] | 36 | #include <stddef.h>
|
---|
| 37 | #include <stdint.h>
|
---|
[48e3190] | 38 | #include <ipc/loc.h>
|
---|
| 39 | #include <block.h>
|
---|
| 40 | #include "udf_types.h"
|
---|
| 41 |
|
---|
| 42 | #define UDF_TAG_FILESET 256
|
---|
| 43 | #define UDF_TAG_FILEID 257
|
---|
| 44 |
|
---|
| 45 | #define UDF_ICB_TERMINAL 260
|
---|
| 46 | #define UDF_FILE_ENTRY 261
|
---|
| 47 | #define UDF_UASPACE_ENTRY 263
|
---|
| 48 | #define UDF_SPACE_BITMAP 264
|
---|
| 49 | #define UDF_EFILE_ENTRY 266
|
---|
| 50 |
|
---|
| 51 | #define UDF_FE_OFFSET 176
|
---|
| 52 | #define UDF_EFE_OFFSET 216
|
---|
| 53 | #define UDF_SB_OFFSET 24
|
---|
| 54 |
|
---|
| 55 | /* ECMA 4/14.11 */
|
---|
| 56 | #define UDF_UASE_OFFSET 40
|
---|
| 57 |
|
---|
| 58 | /* ECMA 167 4/14.6.8 */
|
---|
| 59 | #define UDF_ICBFLAG_MASK 7
|
---|
| 60 |
|
---|
| 61 | /* ECMA 167 4/17 */
|
---|
| 62 | #define UDF_ICBTYPE_UASE 1
|
---|
| 63 | #define UDF_ICBTYPE_DIR 4
|
---|
| 64 |
|
---|
| 65 | /* ECMA 167 4/14.6.8 */
|
---|
| 66 | #define UDF_SHORT_AD 0
|
---|
| 67 | #define UDF_LONG_AD 1
|
---|
| 68 | #define UDF_EXTENDED_AD 2
|
---|
| 69 |
|
---|
| 70 | /* File in allocation descriptor */
|
---|
| 71 | #define UDF_DATA_AD 3
|
---|
| 72 |
|
---|
| 73 | /* File Set Descriptor (ECMA 167 4/14.1) */
|
---|
| 74 | typedef struct udf_fileset_descriptor {
|
---|
| 75 | udf_descriptor_tag_t tag;
|
---|
| 76 | udf_timestamp_t recording_date_and_time;
|
---|
| 77 | uint16_t interchange_level;
|
---|
| 78 | uint16_t max_interchange_level;
|
---|
| 79 | uint32_t charset_list;
|
---|
| 80 | uint32_t max_charset_list;
|
---|
| 81 | uint32_t fileset_number;
|
---|
| 82 | uint32_t fileset_descriptor_number;
|
---|
| 83 | udf_charspec_t logical_volume_id_charset;
|
---|
| 84 | udf_dstring logical_volume_id[128];
|
---|
| 85 | udf_charspec_t fileset_charset;
|
---|
| 86 | udf_dstring fileset_id[32];
|
---|
| 87 | udf_dstring copyright_file_id[32];
|
---|
| 88 | udf_dstring abstract_file_id[32];
|
---|
| 89 | udf_long_ad_t root_dir_icb;
|
---|
| 90 | udf_regid_t domain_id;
|
---|
| 91 | udf_long_ad_t next_extent;
|
---|
| 92 | udf_long_ad_t system_stream_dir_icb;
|
---|
| 93 | uint8_t reserved[32];
|
---|
| 94 | } __attribute__((packed)) udf_fileset_descriptor_t;
|
---|
| 95 |
|
---|
| 96 | /* File identifier descriptor format (ECMA 167 4/14.4) */
|
---|
| 97 | typedef struct udf_file_identifier_descriptor {
|
---|
| 98 | udf_descriptor_tag_t tag;
|
---|
| 99 | uint16_t file_version_number;
|
---|
| 100 | uint8_t file_characteristics;
|
---|
[c477c80] | 101 | uint8_t length_file_id;
|
---|
[48e3190] | 102 | udf_long_ad_t icb;
|
---|
[c477c80] | 103 | uint16_t length_iu;
|
---|
[48e3190] | 104 | uint8_t implementation_use[0];
|
---|
| 105 | udf_dstring file_id[0];
|
---|
[1433ecda] | 106 | } __attribute__((packed)) udf_file_identifier_descriptor_t;
|
---|
[48e3190] | 107 |
|
---|
| 108 | /* ICB tag - Information Control Block (ECMA 167 4/14.6) */
|
---|
| 109 | typedef struct udf_icbtag {
|
---|
| 110 | uint32_t prior_recorder_nimber;
|
---|
| 111 | uint16_t strategy_type;
|
---|
| 112 | uint8_t strategy_parameter[2];
|
---|
| 113 | uint16_t max_number;
|
---|
| 114 | uint8_t reserved[1];
|
---|
| 115 | uint8_t file_type;
|
---|
| 116 | udf_lb_addr_t parent_icb;
|
---|
| 117 | uint16_t flags;
|
---|
| 118 | } __attribute__((packed)) udf_icbtag_t;
|
---|
| 119 |
|
---|
| 120 | /* File Entry format (ECMA 167 4/14.9) */
|
---|
| 121 | typedef struct udf_file_entry_descriptor {
|
---|
| 122 | udf_descriptor_tag_t tag;
|
---|
| 123 | udf_icbtag_t icbtag;
|
---|
| 124 | uint32_t uid;
|
---|
| 125 | uint32_t gid;
|
---|
| 126 | uint32_t permission;
|
---|
| 127 | uint16_t file_link_count;
|
---|
| 128 | uint8_t record_format;
|
---|
| 129 | uint8_t record_display_attributes;
|
---|
[c477c80] | 130 | uint32_t record_length;
|
---|
| 131 | uint64_t info_length;
|
---|
[48e3190] | 132 | uint64_t lblocks_recorded;
|
---|
| 133 | udf_timestamp_t access_data_and_time;
|
---|
| 134 | udf_timestamp_t mod_data_and_time;
|
---|
| 135 | udf_timestamp_t attribute_data_and_time;
|
---|
| 136 | uint32_t checkpoint;
|
---|
| 137 | udf_long_ad_t extended_attribute_icb;
|
---|
| 138 | udf_regid_t implementation_id;
|
---|
| 139 | uint64_t unique_id;
|
---|
[c477c80] | 140 | uint32_t ea_length;
|
---|
| 141 | uint32_t ad_length;
|
---|
[48e3190] | 142 | uint8_t extended_attributes [0];
|
---|
| 143 | uint8_t allocation_descriptors[0];
|
---|
| 144 | } __attribute__((packed)) udf_file_entry_descriptor_t;
|
---|
| 145 |
|
---|
| 146 | /* Extended File Entry format (ECMA 167 4/14.17) */
|
---|
| 147 | typedef struct udf_extended_file_entry_descriptor {
|
---|
| 148 | udf_descriptor_tag_t tag;
|
---|
| 149 | udf_icbtag_t icbtag;
|
---|
| 150 | uint32_t uid;
|
---|
| 151 | uint32_t gid;
|
---|
| 152 | uint32_t permission;
|
---|
| 153 | uint16_t file_link_count;
|
---|
| 154 | uint8_t record_format;
|
---|
| 155 | uint8_t record_display_attributes;
|
---|
[c477c80] | 156 | uint32_t record_length;
|
---|
| 157 | uint64_t info_length;
|
---|
[48e3190] | 158 | uint64_t object_size;
|
---|
| 159 | uint64_t lblocks_recorded;
|
---|
| 160 | udf_timestamp_t access_data_and_time;
|
---|
| 161 | udf_timestamp_t mod_data_and_time;
|
---|
| 162 | udf_timestamp_t creation_data_and_time;
|
---|
| 163 | udf_timestamp_t attribute_data_and_time;
|
---|
| 164 | uint32_t checkpoint;
|
---|
| 165 | udf_long_ad_t extended_attribute_icb;
|
---|
| 166 | udf_regid_t implementation_id;
|
---|
| 167 | uint64_t unique_id;
|
---|
[c477c80] | 168 | uint32_t ea_length;
|
---|
| 169 | uint32_t ad_length;
|
---|
[48e3190] | 170 | uint8_t extended_attributes [0];
|
---|
| 171 | uint8_t allocation_descriptors[0];
|
---|
| 172 | } __attribute__((packed)) udf_extended_file_entry_descriptor_t;
|
---|
| 173 |
|
---|
| 174 | /* Terminal Entry Descriptor (ECMA 167 4/14.8) */
|
---|
| 175 | typedef struct terminal_entry_descriptor {
|
---|
| 176 | udf_descriptor_tag_t tag;
|
---|
| 177 | udf_icbtag_t icbtag;
|
---|
| 178 | } __attribute__((packed)) udf_terminal_entry_descriptor;
|
---|
| 179 |
|
---|
[d1582b50] | 180 | /* Unallocated Space Entry format (ECMA 167 4/14.11) */
|
---|
[48e3190] | 181 | typedef struct udf_unallocated_space_entry_descriptor {
|
---|
| 182 | udf_descriptor_tag_t tag;
|
---|
| 183 | udf_icbtag_t icbtag;
|
---|
[c477c80] | 184 | uint32_t ad_length;
|
---|
[48e3190] | 185 | uint8_t allocation_descriptors[0];
|
---|
[1433ecda] | 186 | } __attribute__((packed)) udf_unallocated_space_entry_descriptor_t;
|
---|
[48e3190] | 187 |
|
---|
| 188 | /* Space Bitmap Descriptor format (ECMA 167 4/14.12) */
|
---|
| 189 | typedef struct udf_space_bitmap_descriptor {
|
---|
| 190 | udf_descriptor_tag_t tag;
|
---|
| 191 | uint32_t bits_number;
|
---|
| 192 | uint32_t byts_number;
|
---|
| 193 | uint8_t bitmap[0];
|
---|
[1433ecda] | 194 | } __attribute__((packed)) udf_space_bitmap_descriptor_t;
|
---|
[48e3190] | 195 |
|
---|
[b7fd2a0] | 196 | extern errno_t udf_node_get_core(udf_node_t *);
|
---|
| 197 | extern errno_t udf_read_icb(udf_node_t *);
|
---|
| 198 | extern errno_t udf_read_allocation_sequence(udf_node_t *, uint8_t *, uint16_t,
|
---|
[48e3190] | 199 | uint32_t, uint32_t);
|
---|
[984a9ba] | 200 | extern errno_t udf_read_file(size_t *, ipc_call_t *, udf_node_t *, aoff64_t,
|
---|
[48e3190] | 201 | size_t);
|
---|
[b7fd2a0] | 202 | extern errno_t udf_get_fid(udf_file_identifier_descriptor_t **, block_t **,
|
---|
[48e3190] | 203 | udf_node_t *, aoff64_t);
|
---|
[b7fd2a0] | 204 | extern errno_t udf_get_fid_in_allocator(udf_file_identifier_descriptor_t **,
|
---|
[48e3190] | 205 | block_t **, udf_node_t *, aoff64_t);
|
---|
[b7fd2a0] | 206 | extern errno_t udf_get_fid_in_sector(udf_file_identifier_descriptor_t **,
|
---|
[48e3190] | 207 | block_t **, udf_node_t *, aoff64_t, size_t *, void **, size_t *);
|
---|
| 208 |
|
---|
| 209 | #endif /* UDF_FILE_H_ */
|
---|
| 210 |
|
---|
| 211 | /**
|
---|
| 212 | * @}
|
---|
| 213 | */
|
---|