1*0a6a1f1dSLionel Sambuc /* $NetBSD: udf.h,v 1.50 2015/08/24 08:31:56 hannken Exp $ */ 29f988b79SJean-Baptiste Boric 39f988b79SJean-Baptiste Boric /* 49f988b79SJean-Baptiste Boric * Copyright (c) 2006, 2008 Reinoud Zandijk 59f988b79SJean-Baptiste Boric * All rights reserved. 69f988b79SJean-Baptiste Boric * 79f988b79SJean-Baptiste Boric * Redistribution and use in source and binary forms, with or without 89f988b79SJean-Baptiste Boric * modification, are permitted provided that the following conditions 99f988b79SJean-Baptiste Boric * are met: 109f988b79SJean-Baptiste Boric * 1. Redistributions of source code must retain the above copyright 119f988b79SJean-Baptiste Boric * notice, this list of conditions and the following disclaimer. 129f988b79SJean-Baptiste Boric * 2. Redistributions in binary form must reproduce the above copyright 139f988b79SJean-Baptiste Boric * notice, this list of conditions and the following disclaimer in the 149f988b79SJean-Baptiste Boric * documentation and/or other materials provided with the distribution. 159f988b79SJean-Baptiste Boric * 169f988b79SJean-Baptiste Boric * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 179f988b79SJean-Baptiste Boric * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 189f988b79SJean-Baptiste Boric * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 199f988b79SJean-Baptiste Boric * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 209f988b79SJean-Baptiste Boric * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 219f988b79SJean-Baptiste Boric * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 229f988b79SJean-Baptiste Boric * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 239f988b79SJean-Baptiste Boric * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 249f988b79SJean-Baptiste Boric * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 259f988b79SJean-Baptiste Boric * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 269f988b79SJean-Baptiste Boric * 279f988b79SJean-Baptiste Boric */ 289f988b79SJean-Baptiste Boric 299f988b79SJean-Baptiste Boric #ifndef _FS_UDF_UDF_H_ 309f988b79SJean-Baptiste Boric #define _FS_UDF_UDF_H_ 319f988b79SJean-Baptiste Boric 329f988b79SJean-Baptiste Boric #include <sys/queue.h> 339f988b79SJean-Baptiste Boric #include <sys/rbtree.h> 349f988b79SJean-Baptiste Boric #include <sys/uio.h> 359f988b79SJean-Baptiste Boric #include <sys/mutex.h> 369f988b79SJean-Baptiste Boric 379f988b79SJean-Baptiste Boric #include "udf_osta.h" 389f988b79SJean-Baptiste Boric #include "ecma167-udf.h" 399f988b79SJean-Baptiste Boric #include <sys/cdio.h> 409f988b79SJean-Baptiste Boric #include <sys/bufq.h> 419f988b79SJean-Baptiste Boric #include <sys/disk.h> 429f988b79SJean-Baptiste Boric #include <sys/kthread.h> 439f988b79SJean-Baptiste Boric #include <miscfs/genfs/genfs_node.h> 449f988b79SJean-Baptiste Boric 459f988b79SJean-Baptiste Boric /* debug section */ 469f988b79SJean-Baptiste Boric extern int udf_verbose; 479f988b79SJean-Baptiste Boric 489f988b79SJean-Baptiste Boric /* undefine UDF_COMPLETE_DELETE to need `purge'; but purge is not implemented */ 499f988b79SJean-Baptiste Boric #define UDF_COMPLETE_DELETE 509f988b79SJean-Baptiste Boric 519f988b79SJean-Baptiste Boric /* debug categories */ 529f988b79SJean-Baptiste Boric #define UDF_DEBUG_VOLUMES 0x0000001 539f988b79SJean-Baptiste Boric #define UDF_DEBUG_LOCKING 0x0000002 549f988b79SJean-Baptiste Boric #define UDF_DEBUG_NODE 0x0000004 559f988b79SJean-Baptiste Boric #define UDF_DEBUG_LOOKUP 0x0000008 569f988b79SJean-Baptiste Boric #define UDF_DEBUG_READDIR 0x0000010 579f988b79SJean-Baptiste Boric #define UDF_DEBUG_FIDS 0x0000020 589f988b79SJean-Baptiste Boric #define UDF_DEBUG_DESCRIPTOR 0x0000040 599f988b79SJean-Baptiste Boric #define UDF_DEBUG_TRANSLATE 0x0000080 609f988b79SJean-Baptiste Boric #define UDF_DEBUG_STRATEGY 0x0000100 619f988b79SJean-Baptiste Boric #define UDF_DEBUG_READ 0x0000200 629f988b79SJean-Baptiste Boric #define UDF_DEBUG_WRITE 0x0000400 639f988b79SJean-Baptiste Boric #define UDF_DEBUG_CALL 0x0000800 649f988b79SJean-Baptiste Boric #define UDF_DEBUG_ATTR 0x0001000 659f988b79SJean-Baptiste Boric #define UDF_DEBUG_EXTATTR 0x0002000 669f988b79SJean-Baptiste Boric #define UDF_DEBUG_ALLOC 0x0004000 679f988b79SJean-Baptiste Boric #define UDF_DEBUG_ADWLK 0x0008000 689f988b79SJean-Baptiste Boric #define UDF_DEBUG_DIRHASH 0x0010000 699f988b79SJean-Baptiste Boric #define UDF_DEBUG_NOTIMPL 0x0020000 709f988b79SJean-Baptiste Boric #define UDF_DEBUG_SHEDULE 0x0040000 719f988b79SJean-Baptiste Boric #define UDF_DEBUG_ECCLINE 0x0080000 729f988b79SJean-Baptiste Boric #define UDF_DEBUG_SYNC 0x0100000 739f988b79SJean-Baptiste Boric #define UDF_DEBUG_PARANOIA 0x0200000 749f988b79SJean-Baptiste Boric #define UDF_DEBUG_PARANOIDADWLK 0x0400000 759f988b79SJean-Baptiste Boric #define UDF_DEBUG_NODEDUMP 0x0800000 769f988b79SJean-Baptiste Boric #define UDF_DEBUG_RESERVE 0x1000000 779f988b79SJean-Baptiste Boric 789f988b79SJean-Baptiste Boric /* initial value of udf_verbose */ 799f988b79SJean-Baptiste Boric #define UDF_DEBUGGING 0 809f988b79SJean-Baptiste Boric 819f988b79SJean-Baptiste Boric #ifdef UDF_DEBUG 829f988b79SJean-Baptiste Boric #define DPRINTF(name, arg) { \ 839f988b79SJean-Baptiste Boric if (udf_verbose & UDF_DEBUG_##name) {\ 849f988b79SJean-Baptiste Boric printf arg;\ 859f988b79SJean-Baptiste Boric };\ 869f988b79SJean-Baptiste Boric } 879f988b79SJean-Baptiste Boric #define DPRINTFIF(name, cond, arg) { \ 889f988b79SJean-Baptiste Boric if (udf_verbose & UDF_DEBUG_##name) { \ 899f988b79SJean-Baptiste Boric if (cond) printf arg;\ 909f988b79SJean-Baptiste Boric };\ 919f988b79SJean-Baptiste Boric } 929f988b79SJean-Baptiste Boric #else 939f988b79SJean-Baptiste Boric #define DPRINTF(name, arg) {} 949f988b79SJean-Baptiste Boric #define DPRINTFIF(name, cond, arg) {} 959f988b79SJean-Baptiste Boric #endif 969f988b79SJean-Baptiste Boric 97*0a6a1f1dSLionel Sambuc VFS_PROTOS(udf); 989f988b79SJean-Baptiste Boric 999f988b79SJean-Baptiste Boric /* constants to identify what kind of identifier we are dealing with */ 1009f988b79SJean-Baptiste Boric #define UDF_REGID_DOMAIN 1 1019f988b79SJean-Baptiste Boric #define UDF_REGID_UDF 2 1029f988b79SJean-Baptiste Boric #define UDF_REGID_IMPLEMENTATION 3 1039f988b79SJean-Baptiste Boric #define UDF_REGID_APPLICATION 4 1049f988b79SJean-Baptiste Boric #define UDF_REGID_NAME 99 1059f988b79SJean-Baptiste Boric 1069f988b79SJean-Baptiste Boric 1079f988b79SJean-Baptiste Boric /* DON'T change these: they identify 13thmonkey's UDF implementation */ 1089f988b79SJean-Baptiste Boric #define APP_NAME "*NetBSD UDF" 1099f988b79SJean-Baptiste Boric #define APP_VERSION_MAIN 0 1109f988b79SJean-Baptiste Boric #define APP_VERSION_SUB 5 1119f988b79SJean-Baptiste Boric #define IMPL_NAME "*NetBSD kernel UDF" 1129f988b79SJean-Baptiste Boric 1139f988b79SJean-Baptiste Boric 1149f988b79SJean-Baptiste Boric /* Configuration values */ 1159f988b79SJean-Baptiste Boric #define UDF_INODE_HASHBITS 10 1169f988b79SJean-Baptiste Boric #define UDF_INODE_HASHSIZE (1<<UDF_INODE_HASHBITS) 1179f988b79SJean-Baptiste Boric #define UDF_INODE_HASHMASK (UDF_INODE_HASHSIZE - 1) 1189f988b79SJean-Baptiste Boric #define UDF_ECCBUF_HASHBITS 10 1199f988b79SJean-Baptiste Boric #define UDF_ECCBUF_HASHSIZE (1<<UDF_ECCBUF_HASHBITS) 1209f988b79SJean-Baptiste Boric #define UDF_ECCBUF_HASHMASK (UDF_ECCBUF_HASHSIZE -1) 1219f988b79SJean-Baptiste Boric 1229f988b79SJean-Baptiste Boric #define UDF_ECCLINE_MAXFREE 5 /* picked, needs calculation */ 1239f988b79SJean-Baptiste Boric #define UDF_ECCLINE_MAXBUSY 100 /* picked, needs calculation */ 1249f988b79SJean-Baptiste Boric 1259f988b79SJean-Baptiste Boric #define UDF_MAX_MAPPINGS (MAXPHYS/DEV_BSIZE) /* 128 */ 1269f988b79SJean-Baptiste Boric #define UDF_VAT_CHUNKSIZE (64*1024) /* picked */ 1279f988b79SJean-Baptiste Boric #define UDF_SYMLINKBUFLEN (64*1024) /* picked */ 1289f988b79SJean-Baptiste Boric 1299f988b79SJean-Baptiste Boric #define UDF_DISC_SLACK (128) /* picked, at least 64 kb or 128 */ 1309f988b79SJean-Baptiste Boric #define UDF_ISO_VRS_SIZE (32*2048) /* 32 ISO `sectors' */ 1319f988b79SJean-Baptiste Boric 132*0a6a1f1dSLionel Sambuc #define UDF_MAX_INDIRS_FOLLOW 1024 /* picked */ 133*0a6a1f1dSLionel Sambuc 1349f988b79SJean-Baptiste Boric 1359f988b79SJean-Baptiste Boric /* structure space */ 1369f988b79SJean-Baptiste Boric #define UDF_ANCHORS 4 /* 256, 512, N-256, N */ 1379f988b79SJean-Baptiste Boric #define UDF_PARTITIONS 4 /* overkill */ 1389f988b79SJean-Baptiste Boric #define UDF_PMAPS 5 /* overkill */ 1399f988b79SJean-Baptiste Boric #define UDF_LVDINT_SEGMENTS 100 /* big overkill */ 1409f988b79SJean-Baptiste Boric #define UDF_LVINT_LOSSAGE 4 /* lose 2 openings */ 1419f988b79SJean-Baptiste Boric #define UDF_MAX_ALLOC_EXTENTS 50 /* overkill */ 1429f988b79SJean-Baptiste Boric 1439f988b79SJean-Baptiste Boric 1449f988b79SJean-Baptiste Boric /* constants */ 1459f988b79SJean-Baptiste Boric #define UDF_MAXNAMLEN 255 /* as per SPEC */ 1469f988b79SJean-Baptiste Boric #define UDF_TRANS_ZERO ((uint64_t) -1) 1479f988b79SJean-Baptiste Boric #define UDF_TRANS_UNMAPPED ((uint64_t) -2) 1489f988b79SJean-Baptiste Boric #define UDF_TRANS_INTERN ((uint64_t) -3) 1499f988b79SJean-Baptiste Boric #define UDF_MAX_SECTOR ((uint64_t) -10) /* high water mark */ 1509f988b79SJean-Baptiste Boric 1519f988b79SJean-Baptiste Boric 1529f988b79SJean-Baptiste Boric /* RW content hint for allocation and other purposes */ 1539f988b79SJean-Baptiste Boric #define UDF_C_ABSOLUTE 0 /* blob to write at absolute */ 1549f988b79SJean-Baptiste Boric #define UDF_C_PROCESSED 0 /* not relevant */ 1559f988b79SJean-Baptiste Boric #define UDF_C_USERDATA 1 /* all but userdata is metadata */ 1569f988b79SJean-Baptiste Boric #define UDF_C_DSCR 2 /* update sectornr and CRC */ 1579f988b79SJean-Baptiste Boric #define UDF_C_FLOAT_DSCR 3 /* update sectornr and CRC; sequential */ 1589f988b79SJean-Baptiste Boric #define UDF_C_NODE 4 /* file/dir node, update sectornr and CRC */ 1599f988b79SJean-Baptiste Boric #define UDF_C_FIDS 5 /* update all contained fids */ 1609f988b79SJean-Baptiste Boric #define UDF_C_METADATA_SBM 6 /* space bitmap, update sectornr and CRC */ 1619f988b79SJean-Baptiste Boric #define UDF_C_EXTATTRS 7 /* dunno what to do yet */ 1629f988b79SJean-Baptiste Boric 1639f988b79SJean-Baptiste Boric /* use unused b_freelistindex for our UDF_C_TYPE */ 1649f988b79SJean-Baptiste Boric #define b_udf_c_type b_freelistindex 1659f988b79SJean-Baptiste Boric 1669f988b79SJean-Baptiste Boric 1679f988b79SJean-Baptiste Boric /* virtual to physical mapping types */ 1689f988b79SJean-Baptiste Boric #define UDF_VTOP_RAWPART UDF_PMAPS /* [0..UDF_PMAPS> are normal */ 1699f988b79SJean-Baptiste Boric 1709f988b79SJean-Baptiste Boric #define UDF_VTOP_TYPE_RAW 0 1719f988b79SJean-Baptiste Boric #define UDF_VTOP_TYPE_UNKNOWN 0 1729f988b79SJean-Baptiste Boric #define UDF_VTOP_TYPE_PHYS 1 1739f988b79SJean-Baptiste Boric #define UDF_VTOP_TYPE_VIRT 2 1749f988b79SJean-Baptiste Boric #define UDF_VTOP_TYPE_SPARABLE 3 1759f988b79SJean-Baptiste Boric #define UDF_VTOP_TYPE_META 4 1769f988b79SJean-Baptiste Boric 1779f988b79SJean-Baptiste Boric 1789f988b79SJean-Baptiste Boric /* allocation strategies */ 1799f988b79SJean-Baptiste Boric #define UDF_ALLOC_INVALID 0 1809f988b79SJean-Baptiste Boric #define UDF_ALLOC_SEQUENTIAL 1 /* linear on NWA */ 1819f988b79SJean-Baptiste Boric #define UDF_ALLOC_VAT 2 /* VAT handling */ 1829f988b79SJean-Baptiste Boric #define UDF_ALLOC_SPACEMAP 3 /* spacemaps */ 1839f988b79SJean-Baptiste Boric #define UDF_ALLOC_METABITMAP 4 /* metadata bitmap */ 1849f988b79SJean-Baptiste Boric #define UDF_ALLOC_METASEQUENTIAL 5 /* in chunks seq., nodes not seq */ 1859f988b79SJean-Baptiste Boric #define UDF_ALLOC_RELAXEDSEQUENTIAL 6 /* only nodes not seq. */ 1869f988b79SJean-Baptiste Boric 1879f988b79SJean-Baptiste Boric 1889f988b79SJean-Baptiste Boric /* logical volume open/close actions */ 1899f988b79SJean-Baptiste Boric #define UDF_OPEN_SESSION 0x01 /* if needed writeout VRS + VDS */ 1909f988b79SJean-Baptiste Boric #define UDF_CLOSE_SESSION 0x02 /* close session after writing VAT */ 1919f988b79SJean-Baptiste Boric #define UDF_FINALISE_DISC 0x04 /* close session after writing VAT */ 1929f988b79SJean-Baptiste Boric #define UDF_WRITE_VAT 0x08 /* sequential VAT filesystem */ 1939f988b79SJean-Baptiste Boric #define UDF_WRITE_LVINT 0x10 /* write out open lvint */ 1949f988b79SJean-Baptiste Boric #define UDF_WRITE_PART_BITMAPS 0x20 /* write out partition space bitmaps */ 1959f988b79SJean-Baptiste Boric #define UDF_APPENDONLY_LVINT 0x40 /* no shifting, only appending */ 1969f988b79SJean-Baptiste Boric #define UDF_WRITE_METAPART_NODES 0x80 /* write out metadata partition nodes*/ 1979f988b79SJean-Baptiste Boric #define UDFLOGVOL_BITS "\20\1OPEN_SESSION\2CLOSE_SESSION\3FINALISE_DISC" \ 1989f988b79SJean-Baptiste Boric "\4WRITE_VAT\5WRITE_LVINT\6WRITE_PART_BITMAPS" \ 1999f988b79SJean-Baptiste Boric "\7APPENDONLY_LVINT\10WRITE_METAPART_NODES" 2009f988b79SJean-Baptiste Boric 2019f988b79SJean-Baptiste Boric /* logical volume error handling actions */ 2029f988b79SJean-Baptiste Boric #define UDF_UPDATE_TRACKINFO 0x01 /* update trackinfo and re-shedule */ 2039f988b79SJean-Baptiste Boric #define UDF_REMAP_BLOCK 0x02 /* remap the failing block length */ 2049f988b79SJean-Baptiste Boric #define UDFONERROR_BITS "\20\1UPDATE_TRACKINFO\2REMAP_BLOCK" 2059f988b79SJean-Baptiste Boric 2069f988b79SJean-Baptiste Boric 2079f988b79SJean-Baptiste Boric /* readdir cookies */ 2089f988b79SJean-Baptiste Boric #define UDF_DIRCOOKIE_DOT 1 2099f988b79SJean-Baptiste Boric 2109f988b79SJean-Baptiste Boric 2119f988b79SJean-Baptiste Boric /* malloc pools */ 2129f988b79SJean-Baptiste Boric MALLOC_DECLARE(M_UDFMNT); 2139f988b79SJean-Baptiste Boric MALLOC_DECLARE(M_UDFVOLD); 2149f988b79SJean-Baptiste Boric MALLOC_DECLARE(M_UDFTEMP); 2159f988b79SJean-Baptiste Boric 2169f988b79SJean-Baptiste Boric extern struct pool udf_node_pool; 2179f988b79SJean-Baptiste Boric struct udf_node; 2189f988b79SJean-Baptiste Boric struct udf_strategy; 2199f988b79SJean-Baptiste Boric 2209f988b79SJean-Baptiste Boric 2219f988b79SJean-Baptiste Boric struct udf_lvintq { 2229f988b79SJean-Baptiste Boric uint32_t start; 2239f988b79SJean-Baptiste Boric uint32_t end; 2249f988b79SJean-Baptiste Boric uint32_t pos; 2259f988b79SJean-Baptiste Boric uint32_t wpos; 2269f988b79SJean-Baptiste Boric }; 2279f988b79SJean-Baptiste Boric 2289f988b79SJean-Baptiste Boric 2299f988b79SJean-Baptiste Boric struct udf_bitmap { 2309f988b79SJean-Baptiste Boric uint8_t *blob; /* allocated */ 2319f988b79SJean-Baptiste Boric uint8_t *bits; /* bits themselves */ 2329f988b79SJean-Baptiste Boric uint8_t *pages; /* dirty pages */ 2339f988b79SJean-Baptiste Boric uint32_t max_offset; /* in bits */ 2349f988b79SJean-Baptiste Boric uint32_t data_pos; /* position in data */ 2359f988b79SJean-Baptiste Boric uint32_t metadata_pos; /* .. in metadata */ 2369f988b79SJean-Baptiste Boric }; 2379f988b79SJean-Baptiste Boric 2389f988b79SJean-Baptiste Boric 2399f988b79SJean-Baptiste Boric struct udf_strat_args { 2409f988b79SJean-Baptiste Boric struct udf_mount *ump; 2419f988b79SJean-Baptiste Boric struct udf_node *udf_node; 2429f988b79SJean-Baptiste Boric struct long_ad *icb; 2439f988b79SJean-Baptiste Boric union dscrptr *dscr; 2449f988b79SJean-Baptiste Boric struct buf *nestbuf; 2459f988b79SJean-Baptiste Boric kauth_cred_t cred; 2469f988b79SJean-Baptiste Boric int waitfor; 2479f988b79SJean-Baptiste Boric }; 2489f988b79SJean-Baptiste Boric 2499f988b79SJean-Baptiste Boric struct udf_strategy { 2509f988b79SJean-Baptiste Boric int (*create_logvol_dscr) (struct udf_strat_args *args); 2519f988b79SJean-Baptiste Boric void (*free_logvol_dscr) (struct udf_strat_args *args); 2529f988b79SJean-Baptiste Boric int (*read_logvol_dscr) (struct udf_strat_args *args); 2539f988b79SJean-Baptiste Boric int (*write_logvol_dscr) (struct udf_strat_args *args); 2549f988b79SJean-Baptiste Boric void (*queuebuf) (struct udf_strat_args *args); 2559f988b79SJean-Baptiste Boric void (*discstrat_init) (struct udf_strat_args *args); 2569f988b79SJean-Baptiste Boric void (*discstrat_finish) (struct udf_strat_args *args); 2579f988b79SJean-Baptiste Boric }; 2589f988b79SJean-Baptiste Boric 2599f988b79SJean-Baptiste Boric extern struct udf_strategy udf_strat_bootstrap; 2609f988b79SJean-Baptiste Boric extern struct udf_strategy udf_strat_sequential; 2619f988b79SJean-Baptiste Boric extern struct udf_strategy udf_strat_direct; 2629f988b79SJean-Baptiste Boric extern struct udf_strategy udf_strat_rmw; 2639f988b79SJean-Baptiste Boric 2649f988b79SJean-Baptiste Boric 2659f988b79SJean-Baptiste Boric /* pre cleanup */ 2669f988b79SJean-Baptiste Boric struct udf_mount { 2679f988b79SJean-Baptiste Boric struct mount *vfs_mountp; 2689f988b79SJean-Baptiste Boric struct vnode *devvp; 2699f988b79SJean-Baptiste Boric struct mmc_discinfo discinfo; 2709f988b79SJean-Baptiste Boric struct udf_args mount_args; 2719f988b79SJean-Baptiste Boric 2729f988b79SJean-Baptiste Boric /* format descriptors */ 2739f988b79SJean-Baptiste Boric kmutex_t logvol_mutex; 2749f988b79SJean-Baptiste Boric struct anchor_vdp *anchors[UDF_ANCHORS]; /* anchors to VDS */ 2759f988b79SJean-Baptiste Boric struct pri_vol_desc *primary_vol; /* identification */ 2769f988b79SJean-Baptiste Boric struct logvol_desc *logical_vol; /* main mapping v->p */ 2779f988b79SJean-Baptiste Boric struct unalloc_sp_desc *unallocated; /* free UDF space */ 2789f988b79SJean-Baptiste Boric struct impvol_desc *implementation; /* likely reduntant */ 2799f988b79SJean-Baptiste Boric struct logvol_int_desc *logvol_integrity; /* current integrity */ 2809f988b79SJean-Baptiste Boric struct part_desc *partitions[UDF_PARTITIONS]; /* partitions */ 2819f988b79SJean-Baptiste Boric /* logvol_info is derived; points *into* other structures */ 2829f988b79SJean-Baptiste Boric struct udf_logvol_info *logvol_info; /* integrity descr. */ 2839f988b79SJean-Baptiste Boric 2849f988b79SJean-Baptiste Boric /* fileset and root directories */ 2859f988b79SJean-Baptiste Boric struct fileset_desc *fileset_desc; /* normally one */ 2869f988b79SJean-Baptiste Boric 2879f988b79SJean-Baptiste Boric /* tracing logvol integrity history */ 2889f988b79SJean-Baptiste Boric struct udf_lvintq lvint_trace[UDF_LVDINT_SEGMENTS]; 2899f988b79SJean-Baptiste Boric int lvopen; /* logvol actions */ 2909f988b79SJean-Baptiste Boric int lvclose; /* logvol actions */ 2919f988b79SJean-Baptiste Boric 2929f988b79SJean-Baptiste Boric /* logical to physical translations */ 2939f988b79SJean-Baptiste Boric int vtop[UDF_PMAPS+1]; /* vpartnr trans */ 2949f988b79SJean-Baptiste Boric int vtop_tp[UDF_PMAPS+1]; /* type of trans */ 2959f988b79SJean-Baptiste Boric 2969f988b79SJean-Baptiste Boric /* disc allocation / writing method */ 2979f988b79SJean-Baptiste Boric kmutex_t allocate_mutex; 2989f988b79SJean-Baptiste Boric int lvreadwrite; /* error handling */ 2999f988b79SJean-Baptiste Boric int vtop_alloc[UDF_PMAPS+1]; /* alloc scheme */ 3009f988b79SJean-Baptiste Boric int data_part; 3019f988b79SJean-Baptiste Boric int node_part; 3029f988b79SJean-Baptiste Boric int fids_part; 3039f988b79SJean-Baptiste Boric 3049f988b79SJean-Baptiste Boric /* sequential track info */ 3059f988b79SJean-Baptiste Boric struct mmc_trackinfo data_track; 3069f988b79SJean-Baptiste Boric struct mmc_trackinfo metadata_track; 3079f988b79SJean-Baptiste Boric 3089f988b79SJean-Baptiste Boric /* VAT */ 3099f988b79SJean-Baptiste Boric uint32_t first_possible_vat_location; 3109f988b79SJean-Baptiste Boric uint32_t last_possible_vat_location; 3119f988b79SJean-Baptiste Boric uint32_t vat_entries; 3129f988b79SJean-Baptiste Boric uint32_t vat_offset; /* offset in table */ 3139f988b79SJean-Baptiste Boric uint32_t vat_last_free_lb; /* last free lb_num */ 3149f988b79SJean-Baptiste Boric uint32_t vat_table_len; 3159f988b79SJean-Baptiste Boric uint32_t vat_table_alloc_len; 3169f988b79SJean-Baptiste Boric uint8_t *vat_table; 3179f988b79SJean-Baptiste Boric uint8_t *vat_pages; /* TODO */ 3189f988b79SJean-Baptiste Boric struct udf_node *vat_node; /* system node */ 3199f988b79SJean-Baptiste Boric 3209f988b79SJean-Baptiste Boric /* space bitmaps for physical partitions */ 3219f988b79SJean-Baptiste Boric struct space_bitmap_desc*part_unalloc_dscr[UDF_PARTITIONS]; 3229f988b79SJean-Baptiste Boric struct space_bitmap_desc*part_freed_dscr [UDF_PARTITIONS]; 3239f988b79SJean-Baptiste Boric struct udf_bitmap part_unalloc_bits[UDF_PARTITIONS]; 3249f988b79SJean-Baptiste Boric struct udf_bitmap part_freed_bits [UDF_PARTITIONS]; 3259f988b79SJean-Baptiste Boric 3269f988b79SJean-Baptiste Boric /* sparable */ 3279f988b79SJean-Baptiste Boric uint32_t sparable_packet_size; 3289f988b79SJean-Baptiste Boric uint32_t packet_size; 3299f988b79SJean-Baptiste Boric struct udf_sparing_table*sparing_table; 3309f988b79SJean-Baptiste Boric 3319f988b79SJean-Baptiste Boric /* meta */ 3329f988b79SJean-Baptiste Boric struct udf_node *metadata_node; /* system node */ 3339f988b79SJean-Baptiste Boric struct udf_node *metadatamirror_node; /* system node */ 3349f988b79SJean-Baptiste Boric struct udf_node *metadatabitmap_node; /* system node */ 3359f988b79SJean-Baptiste Boric struct space_bitmap_desc*metadata_unalloc_dscr; 3369f988b79SJean-Baptiste Boric struct udf_bitmap metadata_unalloc_bits; 3379f988b79SJean-Baptiste Boric uint32_t metadata_alloc_unit_size; 3389f988b79SJean-Baptiste Boric uint16_t metadata_alignment_unit_size; 3399f988b79SJean-Baptiste Boric uint8_t metadata_flags; 3409f988b79SJean-Baptiste Boric 3419f988b79SJean-Baptiste Boric /* rb tree for lookup icb to udf_node and sorted list for sync */ 3429f988b79SJean-Baptiste Boric struct rb_tree udf_node_tree; 3439f988b79SJean-Baptiste Boric 3449f988b79SJean-Baptiste Boric /* syncing */ 3459f988b79SJean-Baptiste Boric int syncing; /* are we syncing? */ 346*0a6a1f1dSLionel Sambuc kmutex_t sync_lock; /* serialize syncing */ 3479f988b79SJean-Baptiste Boric 3489f988b79SJean-Baptiste Boric /* late allocation */ 3499f988b79SJean-Baptiste Boric int32_t uncommitted_lbs[UDF_PARTITIONS]; 3509f988b79SJean-Baptiste Boric struct long_ad *la_node_ad_cpy; /* issue buf */ 3519f988b79SJean-Baptiste Boric uint64_t *la_lmapping, *la_pmapping; /* issue buf */ 3529f988b79SJean-Baptiste Boric 3539f988b79SJean-Baptiste Boric /* lists */ 3549f988b79SJean-Baptiste Boric STAILQ_HEAD(udfmntpts, udf_mount) all_udf_mntpnts; 3559f988b79SJean-Baptiste Boric 3569f988b79SJean-Baptiste Boric /* device strategy */ 3579f988b79SJean-Baptiste Boric struct udf_strategy *strategy; 3589f988b79SJean-Baptiste Boric void *strategy_private; 3599f988b79SJean-Baptiste Boric }; 3609f988b79SJean-Baptiste Boric 3619f988b79SJean-Baptiste Boric /* 3629f988b79SJean-Baptiste Boric * UDF node describing a file/directory. 3639f988b79SJean-Baptiste Boric * 3649f988b79SJean-Baptiste Boric * BUGALERT claim node_mutex before reading/writing to prevent inconsistencies ! 3659f988b79SJean-Baptiste Boric */ 3669f988b79SJean-Baptiste Boric struct udf_node { 3679f988b79SJean-Baptiste Boric struct genfs_node i_gnode; /* has to be first */ 3689f988b79SJean-Baptiste Boric struct vnode *vnode; /* vnode associated */ 3699f988b79SJean-Baptiste Boric struct udf_mount *ump; 3709f988b79SJean-Baptiste Boric 3719f988b79SJean-Baptiste Boric kmutex_t node_mutex; 3729f988b79SJean-Baptiste Boric kcondvar_t node_lock; /* sleeping lock */ 3739f988b79SJean-Baptiste Boric char const *lock_fname; 3749f988b79SJean-Baptiste Boric int lock_lineno; 3759f988b79SJean-Baptiste Boric 3769f988b79SJean-Baptiste Boric /* rb_node for fast lookup and fast sequential visiting */ 3779f988b79SJean-Baptiste Boric struct rb_node rbnode; 3789f988b79SJean-Baptiste Boric 3799f988b79SJean-Baptiste Boric /* one of `fe' or `efe' can be set, not both (UDF file entry dscr.) */ 3809f988b79SJean-Baptiste Boric struct file_entry *fe; 3819f988b79SJean-Baptiste Boric struct extfile_entry *efe; 3829f988b79SJean-Baptiste Boric struct alloc_ext_entry *ext[UDF_MAX_ALLOC_EXTENTS]; 3839f988b79SJean-Baptiste Boric int num_extensions; 3849f988b79SJean-Baptiste Boric 3859f988b79SJean-Baptiste Boric /* location found, recording location & hints */ 3869f988b79SJean-Baptiste Boric struct long_ad loc; /* FID/hash loc. */ 3879f988b79SJean-Baptiste Boric struct long_ad write_loc; /* strat 4096 loc */ 3889f988b79SJean-Baptiste Boric int needs_indirect; /* has missing indr. */ 3899f988b79SJean-Baptiste Boric struct long_ad ext_loc[UDF_MAX_ALLOC_EXTENTS]; 3909f988b79SJean-Baptiste Boric 3919f988b79SJean-Baptiste Boric struct dirhash *dir_hash; 3929f988b79SJean-Baptiste Boric 3939f988b79SJean-Baptiste Boric /* misc */ 3949f988b79SJean-Baptiste Boric uint32_t i_flags; /* associated flags */ 3959f988b79SJean-Baptiste Boric struct lockf *lockf; /* lock list */ 3969f988b79SJean-Baptiste Boric uint32_t outstanding_bufs; /* file data */ 3979f988b79SJean-Baptiste Boric uint32_t outstanding_nodedscr; /* node dscr */ 3989f988b79SJean-Baptiste Boric int32_t uncommitted_lbs; /* in UBC */ 3999f988b79SJean-Baptiste Boric 4009f988b79SJean-Baptiste Boric /* references to associated nodes */ 4019f988b79SJean-Baptiste Boric struct udf_node *extattr; 4029f988b79SJean-Baptiste Boric struct udf_node *streamdir; 4039f988b79SJean-Baptiste Boric struct udf_node *my_parent; /* if extended attr. */ 4049f988b79SJean-Baptiste Boric }; 4059f988b79SJean-Baptiste Boric 4069f988b79SJean-Baptiste Boric 4079f988b79SJean-Baptiste Boric /* misc. flags stored in i_flags (XXX needs cleaning up) */ 4089f988b79SJean-Baptiste Boric #define IN_ACCESS 0x0001 /* Inode access time update request */ 4099f988b79SJean-Baptiste Boric #define IN_CHANGE 0x0002 /* Inode change time update request */ 4109f988b79SJean-Baptiste Boric #define IN_UPDATE 0x0004 /* Inode was written to; update mtime*/ 4119f988b79SJean-Baptiste Boric #define IN_MODIFY 0x0008 /* Modification time update request */ 4129f988b79SJean-Baptiste Boric #define IN_MODIFIED 0x0010 /* node has been modified */ 4139f988b79SJean-Baptiste Boric #define IN_ACCESSED 0x0020 /* node has been accessed */ 4149f988b79SJean-Baptiste Boric #define IN_RENAME 0x0040 /* node is being renamed. XXX ?? */ 4159f988b79SJean-Baptiste Boric #define IN_DELETED 0x0080 /* node is unlinked, no FID reference*/ 4169f988b79SJean-Baptiste Boric #define IN_LOCKED 0x0100 /* node is locked by condvar */ 4179f988b79SJean-Baptiste Boric #define IN_SYNCED 0x0200 /* node is being used by sync */ 4189f988b79SJean-Baptiste Boric #define IN_CALLBACK_ULK 0x0400 /* node will be unlocked by callback */ 4199f988b79SJean-Baptiste Boric #define IN_NODE_REBUILD 0x0800 /* node is rebuild */ 4209f988b79SJean-Baptiste Boric 4219f988b79SJean-Baptiste Boric 4229f988b79SJean-Baptiste Boric #define IN_FLAGBITS \ 4239f988b79SJean-Baptiste Boric "\10\1IN_ACCESS\2IN_CHANGE\3IN_UPDATE\4IN_MODIFY\5IN_MODIFIED" \ 4249f988b79SJean-Baptiste Boric "\6IN_ACCESSED\7IN_RENAME\10IN_DELETED\11IN_LOCKED\12IN_SYNCED" \ 4259f988b79SJean-Baptiste Boric "\13IN_CALLBACK_ULK\14IN_NODE_REBUILD" 4269f988b79SJean-Baptiste Boric 4279f988b79SJean-Baptiste Boric #endif /* !_FS_UDF_UDF_H_ */ 428