2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2001, 2002 Scott Long <scottl@freebsd.org>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 /* Structure/definitions/constants a la ECMA 167 rev. 3 */
42 TAGID_UNALLOC_SPACE = 7,
44 TAGID_LOGVOL_INTEGRITY = 9,
50 /* Descriptor tag [3/7.2] */
53 uint16_t descriptor_ver;
58 uint16_t desc_crc_len;
62 /* Recorded Address [4/7.1] */
68 /* Extent Descriptor [3/7.1] */
74 /* Short Allocation Descriptor [4/14.14.1] */
80 /* Long Allocation Descriptor [4/14.14.2] */
88 /* Extended Allocation Descriptor [4/14.14.3] */
93 struct lb_addr ex_loc;
103 /* Character set spec [1/7.2.1] */
109 /* Timestamp [1/7.3] */
123 /* Entity Identifier [1/7.4] */
124 #define UDF_REGID_ID_SIZE 23
127 uint8_t id[UDF_REGID_ID_SIZE];
128 uint8_t id_suffix[8];
131 /* ICB Tag [4/14.6] */
133 uint32_t prev_num_dirs;
135 uint8_t strat_param[2];
136 uint16_t max_num_entries;
139 struct lb_addr parent_icb;
142 #define UDF_ICB_TAG_FLAGS_SETUID 0x40
143 #define UDF_ICB_TAG_FLAGS_SETGID 0x80
144 #define UDF_ICB_TAG_FLAGS_STICKY 0x100
146 /* Anchor Volume Descriptor Pointer [3/10.2] */
149 struct extent_ad main_vds_ex;
150 struct extent_ad reserve_vds_ex;
153 /* Volume Descriptor Pointer [3/10.3] */
154 struct vol_desc_ptr {
157 struct extent_ad next_vds_ex;
160 /* Primary Volume Descriptor [3/10.1] */
161 struct pri_vol_desc {
167 uint16_t max_vol_seq;
169 uint16_t max_ichg_lvl;
170 uint32_t charset_list;
171 uint32_t max_charset_list;
173 struct charspec desc_charset;
174 struct charspec explanatory_charset;
175 struct extent_ad vol_abstract;
176 struct extent_ad vol_copyright;
178 struct timestamp time;
181 uint32_t prev_vds_lov;
183 uint8_t reserved[22];
186 /* Logical Volume Descriptor [3/10.6] */
190 struct charspec desc_charset;
193 struct regid domain_id;
195 struct long_ad fsd_loc;
196 uint8_t logvol_content_use[16];
198 uint32_t mt_l; /* Partition map length */
199 uint32_t n_pm; /* Number of partition maps */
201 uint8_t imp_use[128];
202 struct extent_ad integrity_seq_id;
206 /* Type 1 Partition Map [3/10.7.2] */
210 uint16_t vol_seq_num;
214 #define UDF_PMAP_TYPE1_SIZE 6
216 /* Type 2 Partition Map [3/10.7.3] */
223 #define UDF_PMAP_TYPE2_SIZE 64
225 /* Virtual Partition Map [UDF 2.01/2.2.8] */
226 struct part_map_virt {
231 uint16_t vol_seq_num;
233 uint8_t reserved1[24];
236 /* Sparable Partition Map [UDF 2.01/2.2.9] */
237 struct part_map_spare {
242 uint16_t vol_seq_num;
245 uint8_t n_st; /* Number of Sparing Tables */
252 struct part_map_1 pm1;
253 struct part_map_2 pm2;
254 struct part_map_virt pmv;
255 struct part_map_spare pms;
258 /* Sparing Map Entry [UDF 2.01/2.2.11] */
259 struct spare_map_entry {
264 /* Sparing Table [UDF 2.01/2.2.11] */
265 struct udf_sparing_table {
268 uint16_t rt_l; /* Relocation Table len */
271 struct spare_map_entry entries[1];
274 /* Partition Descriptor [3/10.5] */
280 struct regid contents;
281 uint8_t contents_use[128];
282 uint32_t access_type;
286 uint8_t imp_use[128];
287 uint8_t reserved[156];
290 /* File Set Descriptor [4/14.1] */
291 struct fileset_desc {
293 struct timestamp time;
295 uint16_t max_ichg_lvl;
296 uint32_t charset_list;
297 uint32_t max_charset_list;
298 uint32_t fileset_num;
299 uint32_t fileset_desc_num;
300 struct charspec logvol_id_charset;
302 struct charspec fileset_charset;
304 char copyright_file_id[32];
305 char abstract_file_id[32];
306 struct long_ad rootdir_icb;
307 struct regid domain_id;
308 struct long_ad next_ex;
309 struct long_ad streamdir_icb;
310 uint8_t reserved[32];
313 /* File Identifier Descriptor [4/14.4] */
318 uint8_t l_fi; /* Length of file identifier area */
320 uint16_t l_iu; /* Length of implementation use area */
323 #define UDF_FID_SIZE 38
324 #define UDF_FILE_CHAR_VIS (1 << 0) /* Visible */
325 #define UDF_FILE_CHAR_DIR (1 << 1) /* Directory */
326 #define UDF_FILE_CHAR_DEL (1 << 2) /* Deleted */
327 #define UDF_FILE_CHAR_PAR (1 << 3) /* Parent Directory */
328 #define UDF_FILE_CHAR_META (1 << 4) /* Stream metadata */
330 /* File Entry [4/14.9] */
333 struct icb_tag icbtag;
339 uint8_t rec_disp_attr;
342 uint64_t logblks_rec;
343 struct timestamp atime;
344 struct timestamp mtime;
345 struct timestamp attrtime;
347 struct long_ad ex_attr_icb;
350 uint32_t l_ea; /* Length of extended attribute area */
351 uint32_t l_ad; /* Length of allocation descriptors */
354 #define UDF_FENTRY_SIZE 176
355 #define UDF_FENTRY_PERM_USER_MASK 0x07
356 #define UDF_FENTRY_PERM_GRP_MASK 0xE0
357 #define UDF_FENTRY_PERM_OWNER_MASK 0x1C00
359 /* Path Component [4/14.16.1] */
360 struct path_component {
364 uint8_t identifier[1];
366 #define UDF_PATH_ROOT 2
367 #define UDF_PATH_DOTDOT 3
368 #define UDF_PATH_DOT 4
369 #define UDF_PATH_PATH 5
373 struct anchor_vdp avdp;
374 struct vol_desc_ptr vdp;
375 struct pri_vol_desc pvd;
376 struct logvol_desc lvd;
378 struct fileset_desc fsd;
379 struct fileid_desc fid;
380 struct file_entry fe;
385 #define GETICB(ad_type, fentry, offset) \
386 (struct ad_type *)&fentry->data[offset]
388 #define GETICBLEN(ad_type, icb) le32toh(((struct ad_type *)(icb))->len)