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_UDF_VOLUME_H_
|
---|
34 | #define UDF_UDF_VOLUME_H_
|
---|
35 |
|
---|
36 | #include <sys/types.h>
|
---|
37 | #include <ipc/loc.h>
|
---|
38 | #include "udf_types.h"
|
---|
39 |
|
---|
40 | /* Descriptor Tag Identifier (ECMA 167 3/7.2.1) */
|
---|
41 | #define UDF_TAG_PVD 0x0001 /* Primary Volume Descriptor */
|
---|
42 | #define UDF_TAG_AVDP 0x0002 /* Anchor Volume Descriptor */
|
---|
43 | #define UDF_TAG_VDP 0x0003 /* Volume Descriptor Pointer */
|
---|
44 | #define UDF_TAG_IUVD 0x0004 /* Implementation Use Volume Descriptor */
|
---|
45 | #define UDF_TAG_PD 0x0005 /* Partition Descriptor */
|
---|
46 | #define UDF_TAG_LVD 0x0006 /* Logical Volume Descriptor */
|
---|
47 | #define UDF_TAG_USD 0x0007 /* Unallocated Space Descriptor */
|
---|
48 | #define UDF_TAG_TD 0x0008 /* Terminating Descriptor */
|
---|
49 | #define UDF_TAG_LVID 0x0009 /* Logical Volume Integrity Descriptor */
|
---|
50 |
|
---|
51 | /* Start adress of Anchor Volume Descriptor */
|
---|
52 | #define UDF_AVDP_SECTOR 256
|
---|
53 |
|
---|
54 | /* Volume Recognition Sequence params */
|
---|
55 | #define VRS_ADDR 32768
|
---|
56 | #define VRS_TYPE 0
|
---|
57 | #define VRS_VERSION 1
|
---|
58 | #define VRS_BEGIN "BEA01"
|
---|
59 | #define VRS_END "TEA01"
|
---|
60 | #define VRS_NSR2 "NSR02"
|
---|
61 | #define VRS_NSR3 "NSR03"
|
---|
62 | #define VRS_DEPTH 10
|
---|
63 | #define VRS_ID_LEN 5
|
---|
64 |
|
---|
65 | /* Volume Structure Descriptor (ECMA 167 2/9.1) */
|
---|
66 | typedef struct udf_vrs_descriptor {
|
---|
67 | uint8_t type; /* Structure type */
|
---|
68 | uint8_t identifier[5]; /* Standart identifier */
|
---|
69 | uint8_t version; /* Structure version */
|
---|
70 | uint8_t data[2041]; /* Structure data */
|
---|
71 | } __attribute__((packed)) udf_vrs_descriptor_t;
|
---|
72 |
|
---|
73 | /* Anchor volume descriptor (ECMA 167 3/10.2) */
|
---|
74 | typedef struct udf_anchor_volume_descriptor {
|
---|
75 | udf_descriptor_tag_t tag; /* Descriptor tag */
|
---|
76 | udf_extent_t main_extent; /* Main Volume Descriptor Sequence Extent */
|
---|
77 | udf_extent_t reserve_extent; /* Reserve Volume Descriptor Sequence Extent */
|
---|
78 | uint8_t reserved[480]; /* Structure data */
|
---|
79 | } __attribute__((packed)) udf_anchor_volume_descriptor_t;
|
---|
80 |
|
---|
81 | /* Common Volume Descriptor */
|
---|
82 | typedef struct udf_common_descriptor {
|
---|
83 | udf_descriptor_tag_t tag;
|
---|
84 | uint8_t reserved[496];
|
---|
85 | } __attribute__((packed)) udf_common_descriptor_t;
|
---|
86 |
|
---|
87 | /* Volume Descriptor Pointer (ECMA 167 3/10.3) */
|
---|
88 | typedef struct udf_volume_pointer_descriptor {
|
---|
89 | udf_descriptor_tag_t tag;
|
---|
90 | uint32_t sequence_number;
|
---|
91 | udf_extent_t next_sequence;
|
---|
92 | uint8_t reserved[484];
|
---|
93 | } __attribute__((packed)) udf_volume_pointer_descriptor_t;
|
---|
94 |
|
---|
95 | /* Primary Volume Descriptor (ECMA 167 3/10.1) */
|
---|
96 | typedef struct udf_primary_volume_descriptor {
|
---|
97 | udf_descriptor_tag_t tag;
|
---|
98 | uint32_t sequence_number;
|
---|
99 | uint32_t primary_volume_descriptor_num;
|
---|
100 | udf_dstring volume_id[32];
|
---|
101 | uint16_t max_sequence_number;
|
---|
102 | uint16_t interchange_level;
|
---|
103 | uint16_t max_interchange_level;
|
---|
104 | uint32_t charset_list;
|
---|
105 | uint32_t max_charset_list;
|
---|
106 | udf_dstring volume_set_id[128];
|
---|
107 | udf_charspec_t descriptor_charset;
|
---|
108 | udf_charspec_t explanatory_charset;
|
---|
109 | udf_extent_t volume_abstract;
|
---|
110 | udf_extent_t volume_copyright_notice;
|
---|
111 | udf_regid_t application_id;
|
---|
112 | udf_timestamp_t recording_data_and_time;
|
---|
113 | udf_regid_t implementation_id;
|
---|
114 | uint8_t implementation_use[64];
|
---|
115 | uint32_t predecessor_vds_location;
|
---|
116 | uint16_t flags;
|
---|
117 | uint8_t reserved[22];
|
---|
118 | } __attribute__((packed)) udf_primary_volume_descriptor_t;
|
---|
119 |
|
---|
120 |
|
---|
121 | /* Partition Descriptor (ECMA 167 3/10.5) */
|
---|
122 | typedef struct udf_partition_descriptor {
|
---|
123 | udf_descriptor_tag_t tag;
|
---|
124 | uint32_t sequence_number;
|
---|
125 | uint16_t flags;
|
---|
126 | uint16_t number;
|
---|
127 | udf_regid_t contents;
|
---|
128 | uint8_t contents_use[128];
|
---|
129 | uint32_t access_type;
|
---|
130 | uint32_t starting_location;
|
---|
131 | uint32_t length;
|
---|
132 | udf_regid_t implementation_id;
|
---|
133 | uint8_t implementation_use[128];
|
---|
134 | uint8_t reserved[156];
|
---|
135 | } __attribute__((packed)) udf_partition_descriptor_t;
|
---|
136 |
|
---|
137 | /* Logical Volume Descriptor (ECMA 167 3/10.6) */
|
---|
138 | typedef struct udf_logical_volume_descriptor {
|
---|
139 | udf_descriptor_tag_t tag;
|
---|
140 | uint32_t sequence_number;
|
---|
141 | udf_charspec_t charset;
|
---|
142 | udf_dstring logical_volume_id[128];
|
---|
143 | uint32_t logical_block_size;
|
---|
144 | udf_regid_t domain_id;
|
---|
145 | uint8_t logical_volume_conents_use[16];
|
---|
146 | uint32_t map_table_length;
|
---|
147 | uint32_t number_of_partitions_maps;
|
---|
148 | udf_regid_t implementation_id;
|
---|
149 | uint8_t implementation_use[128];
|
---|
150 | udf_extent_t integrity_sequence_extent;
|
---|
151 | uint8_t partition_map[0];
|
---|
152 | } __attribute__((packed)) udf_logical_volume_descriptor_t;
|
---|
153 |
|
---|
154 | typedef struct udf_volume_descriptor {
|
---|
155 | union {
|
---|
156 | udf_common_descriptor_t common;
|
---|
157 | udf_terminating_descriptor_t terminating;
|
---|
158 | udf_volume_pointer_descriptor_t pointer;
|
---|
159 | udf_partition_descriptor_t partition;
|
---|
160 | udf_logical_volume_descriptor_t logical;
|
---|
161 | udf_unallocated_space_descriptor_t unallocated;
|
---|
162 | udf_primary_volume_descriptor_t volume;
|
---|
163 | };
|
---|
164 | } __attribute__((packed)) udf_volume_descriptor_t;
|
---|
165 |
|
---|
166 | typedef struct udf_general_type {
|
---|
167 | uint8_t partition_map_type;
|
---|
168 | uint8_t partition_map_lenght;
|
---|
169 | } __attribute__((packed)) udf_general_type_t;
|
---|
170 |
|
---|
171 | typedef struct udf_type1_partition_map {
|
---|
172 | uint8_t partition_map_type;
|
---|
173 | uint8_t partition_map_lenght;
|
---|
174 | uint16_t volume_sequence_number;
|
---|
175 | uint16_t partition_number;
|
---|
176 | } __attribute__((packed)) udf_type1_partition_map_t;
|
---|
177 |
|
---|
178 | typedef struct udf_type2_partition_map {
|
---|
179 | uint8_t partition_map_type;
|
---|
180 | uint8_t partition_map_length;
|
---|
181 | uint8_t reserved1[2];
|
---|
182 | udf_regid_t partition_ident;
|
---|
183 | uint16_t volume_sequence_number;
|
---|
184 | uint16_t partition_number;
|
---|
185 | } __attribute__((packed)) udf_type2_partition_map_t;
|
---|
186 |
|
---|
187 | /* Metadata Partition Map (UDF 2.4.0 2.2.10) */
|
---|
188 | typedef struct udf_metadata_partition_map {
|
---|
189 | uint8_t partition_map_type;
|
---|
190 | uint8_t partition_map_length;
|
---|
191 | uint8_t reserved1[2];
|
---|
192 | udf_regid_t partition_ident;
|
---|
193 | uint16_t volume_sequence_number;
|
---|
194 | uint16_t partition_number;
|
---|
195 | uint32_t metadata_fileloc;
|
---|
196 | uint32_t metadata_mirror_fileloc;
|
---|
197 | uint32_t metadata_bitmap_fileloc;
|
---|
198 | uint32_t alloc_unit_size;
|
---|
199 | uint16_t align_unit_size;
|
---|
200 | uint8_t flags;
|
---|
201 | uint8_t reserved2[5];
|
---|
202 | } __attribute__((packed)) udf_metadata_partition_map_t;
|
---|
203 |
|
---|
204 | /* Partition Header Descriptor (ECMA 167 4/14.3) */
|
---|
205 | typedef struct udf_partition_header_descriptor {
|
---|
206 | udf_short_ad_t unallocated_space_table;
|
---|
207 | udf_short_ad_t unallocated_space_bitmap;
|
---|
208 | udf_short_ad_t partition_integrity_table;
|
---|
209 | udf_short_ad_t freed_space_table;
|
---|
210 | udf_short_ad_t freed_space_bitmap;
|
---|
211 | uint8_t reserved[88];
|
---|
212 | } __attribute__((packed)) udf_partition_header_descriptor_t;
|
---|
213 |
|
---|
214 | extern int udf_volume_recongnition(service_id_t);
|
---|
215 | extern int udf_get_anchor_volume_descriptor(service_id_t,
|
---|
216 | udf_anchor_volume_descriptor_t *);
|
---|
217 | extern int udf_read_volume_descriptor_sequence(service_id_t, udf_extent_t);
|
---|
218 | extern fs_index_t udf_long_ad_to_pos(udf_instance_t *, udf_long_ad_t *);
|
---|
219 |
|
---|
220 | #endif
|
---|
221 |
|
---|
222 | /**
|
---|
223 | * @}
|
---|
224 | */
|
---|