[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 |
|
---|
| 29 | /** @addtogroup fs
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 |
|
---|
| 33 | #ifndef UDF_FILE_H_
|
---|
| 34 | #define UDF_FILE_H_
|
---|
| 35 |
|
---|
| 36 | #include <sys/types.h>
|
---|
| 37 | #include <ipc/loc.h>
|
---|
| 38 | #include <block.h>
|
---|
| 39 | #include "udf_types.h"
|
---|
| 40 |
|
---|
| 41 | #define UDF_TAG_FILESET 256
|
---|
| 42 | #define UDF_TAG_FILEID 257
|
---|
| 43 |
|
---|
| 44 | #define UDF_ICB_TERMINAL 260
|
---|
| 45 | #define UDF_FILE_ENTRY 261
|
---|
| 46 | #define UDF_UASPACE_ENTRY 263
|
---|
| 47 | #define UDF_SPACE_BITMAP 264
|
---|
| 48 | #define UDF_EFILE_ENTRY 266
|
---|
| 49 |
|
---|
| 50 | #define UDF_FE_OFFSET 176
|
---|
| 51 | #define UDF_EFE_OFFSET 216
|
---|
| 52 | #define UDF_SB_OFFSET 24
|
---|
| 53 |
|
---|
| 54 | /* ECMA 4/14.11 */
|
---|
| 55 | #define UDF_UASE_OFFSET 40
|
---|
| 56 |
|
---|
| 57 | /* ECMA 167 4/14.6.8 */
|
---|
| 58 | #define UDF_ICBFLAG_MASK 7
|
---|
| 59 |
|
---|
| 60 | /* ECMA 167 4/17 */
|
---|
| 61 | #define UDF_ICBTYPE_UASE 1
|
---|
| 62 | #define UDF_ICBTYPE_DIR 4
|
---|
| 63 |
|
---|
| 64 | /* ECMA 167 4/14.6.8 */
|
---|
| 65 | #define UDF_SHORT_AD 0
|
---|
| 66 | #define UDF_LONG_AD 1
|
---|
| 67 | #define UDF_EXTENDED_AD 2
|
---|
| 68 |
|
---|
| 69 | /* File in allocation descriptor */
|
---|
| 70 | #define UDF_DATA_AD 3
|
---|
| 71 |
|
---|
| 72 | /* File Set Descriptor (ECMA 167 4/14.1) */
|
---|
| 73 | typedef struct udf_fileset_descriptor {
|
---|
| 74 | udf_descriptor_tag_t tag;
|
---|
| 75 | udf_timestamp_t recording_date_and_time;
|
---|
| 76 | uint16_t interchange_level;
|
---|
| 77 | uint16_t max_interchange_level;
|
---|
| 78 | uint32_t charset_list;
|
---|
| 79 | uint32_t max_charset_list;
|
---|
| 80 | uint32_t fileset_number;
|
---|
| 81 | uint32_t fileset_descriptor_number;
|
---|
| 82 | udf_charspec_t logical_volume_id_charset;
|
---|
| 83 | udf_dstring logical_volume_id[128];
|
---|
| 84 | udf_charspec_t fileset_charset;
|
---|
| 85 | udf_dstring fileset_id[32];
|
---|
| 86 | udf_dstring copyright_file_id[32];
|
---|
| 87 | udf_dstring abstract_file_id[32];
|
---|
| 88 | udf_long_ad_t root_dir_icb;
|
---|
| 89 | udf_regid_t domain_id;
|
---|
| 90 | udf_long_ad_t next_extent;
|
---|
| 91 | udf_long_ad_t system_stream_dir_icb;
|
---|
| 92 | uint8_t reserved[32];
|
---|
| 93 | } __attribute__((packed)) udf_fileset_descriptor_t;
|
---|
| 94 |
|
---|
| 95 | /* File identifier descriptor format (ECMA 167 4/14.4) */
|
---|
| 96 | typedef struct udf_file_identifier_descriptor {
|
---|
| 97 | udf_descriptor_tag_t tag;
|
---|
| 98 | uint16_t file_version_number;
|
---|
| 99 | uint8_t file_characteristics;
|
---|
| 100 | uint8_t lenght_file_id;
|
---|
| 101 | udf_long_ad_t icb;
|
---|
| 102 | uint16_t lenght_iu;
|
---|
| 103 | uint8_t implementation_use[0];
|
---|
| 104 | udf_dstring file_id[0];
|
---|
| 105 | }__attribute__((packed)) udf_file_identifier_descriptor_t;
|
---|
| 106 |
|
---|
| 107 | /* ICB tag - Information Control Block (ECMA 167 4/14.6) */
|
---|
| 108 | typedef struct udf_icbtag {
|
---|
| 109 | uint32_t prior_recorder_nimber;
|
---|
| 110 | uint16_t strategy_type;
|
---|
| 111 | uint8_t strategy_parameter[2];
|
---|
| 112 | uint16_t max_number;
|
---|
| 113 | uint8_t reserved[1];
|
---|
| 114 | uint8_t file_type;
|
---|
| 115 | udf_lb_addr_t parent_icb;
|
---|
| 116 | uint16_t flags;
|
---|
| 117 | } __attribute__((packed)) udf_icbtag_t;
|
---|
| 118 |
|
---|
| 119 | /* File Entry format (ECMA 167 4/14.9) */
|
---|
| 120 | typedef struct udf_file_entry_descriptor {
|
---|
| 121 | udf_descriptor_tag_t tag;
|
---|
| 122 | udf_icbtag_t icbtag;
|
---|
| 123 | uint32_t uid;
|
---|
| 124 | uint32_t gid;
|
---|
| 125 | uint32_t permission;
|
---|
| 126 | uint16_t file_link_count;
|
---|
| 127 | uint8_t record_format;
|
---|
| 128 | uint8_t record_display_attributes;
|
---|
| 129 | uint32_t record_lenght;
|
---|
| 130 | uint64_t info_lenght;
|
---|
| 131 | uint64_t lblocks_recorded;
|
---|
| 132 | udf_timestamp_t access_data_and_time;
|
---|
| 133 | udf_timestamp_t mod_data_and_time;
|
---|
| 134 | udf_timestamp_t attribute_data_and_time;
|
---|
| 135 | uint32_t checkpoint;
|
---|
| 136 | udf_long_ad_t extended_attribute_icb;
|
---|
| 137 | udf_regid_t implementation_id;
|
---|
| 138 | uint64_t unique_id;
|
---|
| 139 | uint32_t ea_lenght;
|
---|
| 140 | uint32_t ad_lenght;
|
---|
| 141 | uint8_t extended_attributes [0];
|
---|
| 142 | uint8_t allocation_descriptors[0];
|
---|
| 143 | } __attribute__((packed)) udf_file_entry_descriptor_t;
|
---|
| 144 |
|
---|
| 145 | /* Extended File Entry format (ECMA 167 4/14.17) */
|
---|
| 146 | typedef struct udf_extended_file_entry_descriptor {
|
---|
| 147 | udf_descriptor_tag_t tag;
|
---|
| 148 | udf_icbtag_t icbtag;
|
---|
| 149 | uint32_t uid;
|
---|
| 150 | uint32_t gid;
|
---|
| 151 | uint32_t permission;
|
---|
| 152 | uint16_t file_link_count;
|
---|
| 153 | uint8_t record_format;
|
---|
| 154 | uint8_t record_display_attributes;
|
---|
| 155 | uint32_t record_lenght;
|
---|
| 156 | uint64_t info_lenght;
|
---|
| 157 | uint64_t object_size;
|
---|
| 158 | uint64_t lblocks_recorded;
|
---|
| 159 | udf_timestamp_t access_data_and_time;
|
---|
| 160 | udf_timestamp_t mod_data_and_time;
|
---|
| 161 | udf_timestamp_t creation_data_and_time;
|
---|
| 162 | udf_timestamp_t attribute_data_and_time;
|
---|
| 163 | uint32_t checkpoint;
|
---|
| 164 | udf_long_ad_t extended_attribute_icb;
|
---|
| 165 | udf_regid_t implementation_id;
|
---|
| 166 | uint64_t unique_id;
|
---|
| 167 | uint32_t ea_lenght;
|
---|
| 168 | uint32_t ad_lenght;
|
---|
| 169 | uint8_t extended_attributes [0];
|
---|
| 170 | uint8_t allocation_descriptors[0];
|
---|
| 171 | } __attribute__((packed)) udf_extended_file_entry_descriptor_t;
|
---|
| 172 |
|
---|
| 173 | /* Terminal Entry Descriptor (ECMA 167 4/14.8) */
|
---|
| 174 | typedef struct terminal_entry_descriptor {
|
---|
| 175 | udf_descriptor_tag_t tag;
|
---|
| 176 | udf_icbtag_t icbtag;
|
---|
| 177 | } __attribute__((packed)) udf_terminal_entry_descriptor;
|
---|
| 178 |
|
---|
| 179 | /* Unallocated Space Entry format (ECMA 167 4/14.11)*/
|
---|
| 180 | typedef struct udf_unallocated_space_entry_descriptor {
|
---|
| 181 | udf_descriptor_tag_t tag;
|
---|
| 182 | udf_icbtag_t icbtag;
|
---|
| 183 | uint32_t ad_lenght;
|
---|
| 184 | uint8_t allocation_descriptors[0];
|
---|
| 185 | }__attribute__((packed)) udf_unallocated_space_entry_descriptor_t;
|
---|
| 186 |
|
---|
| 187 | /* Space Bitmap Descriptor format (ECMA 167 4/14.12) */
|
---|
| 188 | typedef struct udf_space_bitmap_descriptor {
|
---|
| 189 | udf_descriptor_tag_t tag;
|
---|
| 190 | uint32_t bits_number;
|
---|
| 191 | uint32_t byts_number;
|
---|
| 192 | uint8_t bitmap[0];
|
---|
| 193 | }__attribute__((packed)) udf_space_bitmap_descriptor_t;
|
---|
| 194 |
|
---|
| 195 | extern int udf_node_get_core(udf_node_t *);
|
---|
| 196 | extern int udf_read_icb(udf_node_t *);
|
---|
| 197 | extern int udf_read_allocation_sequence(udf_node_t *, uint8_t *, uint16_t,
|
---|
| 198 | uint32_t, uint32_t);
|
---|
| 199 | extern int udf_read_extended_allocator(udf_node_t *, uint16_t, uint32_t);
|
---|
| 200 | extern int udf_read_file(size_t *, ipc_callid_t, udf_node_t *, aoff64_t,
|
---|
| 201 | size_t);
|
---|
| 202 | extern int udf_get_fid(udf_file_identifier_descriptor_t **, block_t **,
|
---|
| 203 | udf_node_t *, aoff64_t);
|
---|
| 204 | extern int udf_get_fid_in_data(udf_file_identifier_descriptor_t **,
|
---|
| 205 | udf_node_t *, aoff64_t);
|
---|
| 206 | extern int udf_get_fid_in_allocator(udf_file_identifier_descriptor_t **,
|
---|
| 207 | block_t **, udf_node_t *, aoff64_t);
|
---|
| 208 | extern int udf_get_fid_in_sector(udf_file_identifier_descriptor_t **,
|
---|
| 209 | block_t **, udf_node_t *, aoff64_t, size_t *, void **, size_t *);
|
---|
| 210 | extern int udf_read_free_space(uint8_t *, uint16_t, uint32_t, uint32_t);
|
---|
| 211 | extern int udf_read_unallocated_space_entry(udf_instance_t *, uint64_t,
|
---|
| 212 | uint32_t);
|
---|
| 213 |
|
---|
| 214 | #endif /* UDF_FILE_H_ */
|
---|
| 215 |
|
---|
| 216 | /**
|
---|
| 217 | * @}
|
---|
| 218 | */
|
---|