Home | History | Annotate | Line # | Download | only in udf
udf.h revision 1.4.16.4
      1  1.4.16.4  yamt /* $NetBSD: udf.h,v 1.4.16.4 2007/02/26 09:11:00 yamt Exp $ */
      2  1.4.16.2  yamt 
      3  1.4.16.2  yamt /*
      4  1.4.16.2  yamt  * Copyright (c) 2006 Reinoud Zandijk
      5  1.4.16.2  yamt  * All rights reserved.
      6  1.4.16.2  yamt  *
      7  1.4.16.2  yamt  * Redistribution and use in source and binary forms, with or without
      8  1.4.16.2  yamt  * modification, are permitted provided that the following conditions
      9  1.4.16.2  yamt  * are met:
     10  1.4.16.2  yamt  * 1. Redistributions of source code must retain the above copyright
     11  1.4.16.2  yamt  *    notice, this list of conditions and the following disclaimer.
     12  1.4.16.2  yamt  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.4.16.2  yamt  *    notice, this list of conditions and the following disclaimer in the
     14  1.4.16.2  yamt  *    documentation and/or other materials provided with the distribution.
     15  1.4.16.2  yamt  * 3. All advertising materials mentioning features or use of this software
     16  1.4.16.2  yamt  *    must display the following acknowledgement:
     17  1.4.16.2  yamt  *          This product includes software developed for the
     18  1.4.16.2  yamt  *          NetBSD Project.  See http://www.NetBSD.org/ for
     19  1.4.16.2  yamt  *          information about NetBSD.
     20  1.4.16.2  yamt  * 4. The name of the author may not be used to endorse or promote products
     21  1.4.16.2  yamt  *    derived from this software without specific prior written permission.
     22  1.4.16.2  yamt  *
     23  1.4.16.2  yamt  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     24  1.4.16.2  yamt  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25  1.4.16.2  yamt  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26  1.4.16.2  yamt  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     27  1.4.16.2  yamt  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     28  1.4.16.2  yamt  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     29  1.4.16.2  yamt  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     30  1.4.16.2  yamt  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     31  1.4.16.2  yamt  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     32  1.4.16.2  yamt  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33  1.4.16.2  yamt  *
     34  1.4.16.2  yamt  */
     35  1.4.16.2  yamt 
     36  1.4.16.2  yamt #ifndef _FS_UDF_UDF_H_
     37  1.4.16.2  yamt #define _FS_UDF_UDF_H_
     38  1.4.16.2  yamt 
     39  1.4.16.2  yamt #include <sys/queue.h>
     40  1.4.16.2  yamt #include <sys/uio.h>
     41  1.4.16.2  yamt 
     42  1.4.16.2  yamt #include "udf_osta.h"
     43  1.4.16.2  yamt #include "ecma167-udf.h"
     44  1.4.16.2  yamt #include <sys/cdio.h>
     45  1.4.16.2  yamt #include <miscfs/genfs/genfs_node.h>
     46  1.4.16.2  yamt 
     47  1.4.16.2  yamt /* TODO make `udf_verbose' set by sysctl */
     48  1.4.16.2  yamt /* debug section */
     49  1.4.16.2  yamt extern int udf_verbose;
     50  1.4.16.2  yamt 
     51  1.4.16.2  yamt /* initial value of udf_verbose */
     52  1.4.16.2  yamt #define UDF_DEBUGGING		0x000
     53  1.4.16.2  yamt 
     54  1.4.16.2  yamt /* debug categories */
     55  1.4.16.2  yamt #define UDF_DEBUG_VOLUMES	0x001
     56  1.4.16.2  yamt #define UDF_DEBUG_LOCKING	0x002
     57  1.4.16.2  yamt #define UDF_DEBUG_NODE		0x004
     58  1.4.16.2  yamt #define UDF_DEBUG_LOOKUP	0x008
     59  1.4.16.2  yamt #define UDF_DEBUG_READDIR	0x010
     60  1.4.16.2  yamt #define UDF_DEBUG_FIDS		0x020
     61  1.4.16.2  yamt #define UDF_DEBUG_DESCRIPTOR	0x040
     62  1.4.16.2  yamt #define UDF_DEBUG_TRANSLATE	0x080
     63  1.4.16.2  yamt #define UDF_DEBUG_STRATEGY	0x100
     64  1.4.16.2  yamt #define UDF_DEBUG_READ		0x200
     65  1.4.16.2  yamt #define UDF_DEBUG_CALL		0x400
     66  1.4.16.2  yamt #define UDF_DEBUG_NOTIMPL	UDF_DEBUG_CALL
     67  1.4.16.2  yamt 
     68  1.4.16.2  yamt 
     69  1.4.16.2  yamt #ifdef DEBUG
     70  1.4.16.3  yamt #ifdef SYSCTL_SETUP_PROTO
     71  1.4.16.3  yamt SYSCTL_SETUP_PROTO(sysctl_vfs_udf_setup);
     72  1.4.16.3  yamt #endif /* SYSCTL_SETUP_PROTO */
     73  1.4.16.3  yamt #endif
     74  1.4.16.3  yamt 
     75  1.4.16.3  yamt 
     76  1.4.16.3  yamt #ifdef DEBUG
     77  1.4.16.2  yamt #define DPRINTF(name, arg) { \
     78  1.4.16.2  yamt 		if (udf_verbose & UDF_DEBUG_##name) {\
     79  1.4.16.2  yamt 			printf arg;\
     80  1.4.16.2  yamt 		};\
     81  1.4.16.2  yamt 	}
     82  1.4.16.2  yamt #define DPRINTFIF(name, cond, arg) { \
     83  1.4.16.2  yamt 		if (udf_verbose & UDF_DEBUG_##name) { \
     84  1.4.16.2  yamt 			if (cond) printf arg;\
     85  1.4.16.2  yamt 		};\
     86  1.4.16.2  yamt 	}
     87  1.4.16.2  yamt #else
     88  1.4.16.2  yamt #define DPRINTF(name, arg) {}
     89  1.4.16.2  yamt #define DPRINTFIF(name, cond, arg) {}
     90  1.4.16.2  yamt #endif
     91  1.4.16.2  yamt 
     92  1.4.16.2  yamt 
     93  1.4.16.2  yamt /* constants to identify what kind of identifier we are dealing with */
     94  1.4.16.2  yamt #define UDF_REGID_DOMAIN		 1
     95  1.4.16.2  yamt #define UDF_REGID_UDF			 2
     96  1.4.16.2  yamt #define UDF_REGID_IMPLEMENTATION	 3
     97  1.4.16.2  yamt #define UDF_REGID_APPLICATION		 4
     98  1.4.16.2  yamt #define UDF_REGID_NAME			99
     99  1.4.16.2  yamt 
    100  1.4.16.2  yamt 
    101  1.4.16.2  yamt /* DON'T change these: they identify 13thmonkey's UDF implementation */
    102  1.4.16.2  yamt #define APP_NAME		"*NetBSD UDF"
    103  1.4.16.2  yamt #define APP_VERSION_MAIN	1
    104  1.4.16.2  yamt #define APP_VERSION_SUB		0
    105  1.4.16.2  yamt #define IMPL_NAME		"*13thMonkey.org"
    106  1.4.16.2  yamt 
    107  1.4.16.2  yamt 
    108  1.4.16.2  yamt /* Configuration values */
    109  1.4.16.2  yamt #define UDF_INODE_HASHBITS 	10
    110  1.4.16.2  yamt #define UDF_INODE_HASHSIZE	(1<<UDF_INODE_HASHBITS)
    111  1.4.16.2  yamt #define UDF_INODE_HASHMASK	(UDF_INODE_HASHSIZE - 1)
    112  1.4.16.2  yamt 
    113  1.4.16.2  yamt 
    114  1.4.16.2  yamt /* structure space */
    115  1.4.16.2  yamt #define UDF_ANCHORS		4	/* 256, 512, N-256, N */
    116  1.4.16.2  yamt #define UDF_PARTITIONS		4	/* overkill */
    117  1.4.16.2  yamt #define UDF_PMAPS		4	/* overkill */
    118  1.4.16.2  yamt 
    119  1.4.16.2  yamt 
    120  1.4.16.2  yamt /* constants */
    121  1.4.16.2  yamt #define UDF_MAX_NAMELEN		255			/* as per SPEC */
    122  1.4.16.2  yamt #define UDF_TRANS_ZERO		((uint64_t) -1)
    123  1.4.16.2  yamt #define UDF_TRANS_UNMAPPED	((uint64_t) -2)
    124  1.4.16.2  yamt #define UDF_TRANS_INTERN	((uint64_t) -3)
    125  1.4.16.2  yamt #define UDF_MAX_SECTOR		((uint64_t) -10)	/* high water mark */
    126  1.4.16.2  yamt 
    127  1.4.16.2  yamt 
    128  1.4.16.2  yamt /* malloc pools */
    129  1.4.16.2  yamt MALLOC_DECLARE(M_UDFMNT);
    130  1.4.16.2  yamt MALLOC_DECLARE(M_UDFVOLD);
    131  1.4.16.2  yamt MALLOC_DECLARE(M_UDFTEMP);
    132  1.4.16.2  yamt 
    133  1.4.16.2  yamt struct pool udf_node_pool;
    134  1.4.16.2  yamt 
    135  1.4.16.2  yamt struct udf_node;
    136  1.4.16.2  yamt 
    137  1.4.16.2  yamt /* pre cleanup */
    138  1.4.16.2  yamt struct udf_mount {
    139  1.4.16.2  yamt 	struct mount		*vfs_mountp;
    140  1.4.16.2  yamt 	struct vnode		*devvp;
    141  1.4.16.2  yamt 	struct mmc_discinfo	 discinfo;
    142  1.4.16.2  yamt 	struct udf_args		 mount_args;
    143  1.4.16.2  yamt 
    144  1.4.16.2  yamt 	/* read in structures */
    145  1.4.16.2  yamt 	struct anchor_vdp	*anchors[UDF_ANCHORS];	/* anchors to VDS    */
    146  1.4.16.2  yamt 	struct pri_vol_desc	*primary_vol;		/* identification    */
    147  1.4.16.2  yamt 	struct logvol_desc	*logical_vol;		/* main mapping v->p */
    148  1.4.16.2  yamt 	struct unalloc_sp_desc	*unallocated;		/* free UDF space    */
    149  1.4.16.2  yamt 	struct impvol_desc	*implementation;	/* likely reduntant  */
    150  1.4.16.2  yamt 	struct logvol_int_desc	*logvol_integrity;	/* current integrity */
    151  1.4.16.2  yamt 	struct part_desc	*partitions[UDF_PARTITIONS]; /* partitions   */
    152  1.4.16.2  yamt 
    153  1.4.16.2  yamt 	/* derived; points *into* other structures */
    154  1.4.16.2  yamt 	struct udf_logvol_info	*logvol_info;		/* integrity descr.  */
    155  1.4.16.2  yamt 
    156  1.4.16.2  yamt 	/* fileset and root directories */
    157  1.4.16.2  yamt 	struct fileset_desc	*fileset_desc;		/* normally one      */
    158  1.4.16.2  yamt 
    159  1.4.16.2  yamt 	/* logical to physical translations */
    160  1.4.16.2  yamt 	int 			 vtop[UDF_PMAPS+1];	/* vpartnr trans     */
    161  1.4.16.2  yamt 	int			 vtop_tp[UDF_PMAPS+1];	/* type of trans     */
    162  1.4.16.2  yamt 
    163  1.4.16.3  yamt 	/* VAT */
    164  1.4.16.3  yamt 	uint32_t		 first_possible_vat_location;
    165  1.4.16.3  yamt 	uint32_t		 last_possible_vat_location;
    166  1.4.16.2  yamt 	uint32_t		 vat_table_alloc_length;
    167  1.4.16.2  yamt 	uint32_t		 vat_entries;
    168  1.4.16.2  yamt 	uint32_t		 vat_offset;		/* offset in table   */
    169  1.4.16.2  yamt 	uint8_t			*vat_table;		/* read in data      */
    170  1.4.16.2  yamt 
    171  1.4.16.3  yamt 	/* sparable */
    172  1.4.16.2  yamt 	uint32_t		 sparable_packet_len;
    173  1.4.16.2  yamt 	struct udf_sparing_table*sparing_table;
    174  1.4.16.2  yamt 
    175  1.4.16.3  yamt 	/* meta */
    176  1.4.16.4  yamt 	struct udf_node 	*metadata_file;
    177  1.4.16.4  yamt 	struct udf_node 	*metadatamirror_file;
    178  1.4.16.4  yamt 	struct udf_node 	*metadatabitmap_file;
    179  1.4.16.2  yamt 
    180  1.4.16.2  yamt 	/* disc allocation */
    181  1.4.16.2  yamt 	int			data_alloc, meta_alloc;	/* allocation scheme */
    182  1.4.16.2  yamt 
    183  1.4.16.2  yamt 	struct mmc_trackinfo	datatrack;
    184  1.4.16.2  yamt 	struct mmc_trackinfo	metadatatrack;
    185  1.4.16.2  yamt 		/* TODO free space and usage per partition */
    186  1.4.16.2  yamt 		/* ... [UDF_PARTITIONS]; */
    187  1.4.16.2  yamt 
    188  1.4.16.2  yamt 	/* hash table to lookup ino_t -> udf_node */
    189  1.4.16.2  yamt 	LIST_HEAD(, udf_node) udf_nodes[UDF_INODE_HASHSIZE];
    190  1.4.16.2  yamt 
    191  1.4.16.2  yamt 	/* allocation pool for udf_node's descriptors */
    192  1.4.16.3  yamt 	struct pool *desc_pool;
    193  1.4.16.2  yamt 
    194  1.4.16.2  yamt 	/* locks */
    195  1.4.16.2  yamt 	struct simplelock ihash_slock;
    196  1.4.16.2  yamt 	struct lock       get_node_lock;
    197  1.4.16.2  yamt 
    198  1.4.16.2  yamt 	/* lists */
    199  1.4.16.2  yamt 	STAILQ_HEAD(, udf_node) dirty_nodes;
    200  1.4.16.2  yamt 	STAILQ_HEAD(udfmntpts, udf_mount) all_udf_mntpnts;
    201  1.4.16.2  yamt };
    202  1.4.16.2  yamt 
    203  1.4.16.2  yamt 
    204  1.4.16.2  yamt #define UDF_VTOP_RAWPART UDF_PMAPS	/* [0..UDF_PMAPS> are normal     */
    205  1.4.16.2  yamt 
    206  1.4.16.2  yamt /* virtual to physical mapping types */
    207  1.4.16.2  yamt #define UDF_VTOP_TYPE_RAW            0
    208  1.4.16.2  yamt #define UDF_VTOP_TYPE_UNKNOWN        0
    209  1.4.16.2  yamt #define UDF_VTOP_TYPE_PHYS           1
    210  1.4.16.2  yamt #define UDF_VTOP_TYPE_VIRT           2
    211  1.4.16.2  yamt #define UDF_VTOP_TYPE_SPARABLE       3
    212  1.4.16.2  yamt #define UDF_VTOP_TYPE_META           4
    213  1.4.16.2  yamt 
    214  1.4.16.2  yamt /* allocation strategies */
    215  1.4.16.2  yamt #define UDF_ALLOC_SPACEMAP           1  /* spacemaps                     */
    216  1.4.16.2  yamt #define UDF_ALLOC_SEQUENTIAL         2  /* linear on NWA                 */
    217  1.4.16.2  yamt #define UDF_ALLOC_VAT                3  /* VAT handling                  */
    218  1.4.16.2  yamt #define UDF_ALLOC_METABITMAP         4  /* metadata bitmap               */
    219  1.4.16.2  yamt #define UDF_ALLOC_METASEQUENTIAL     5  /* in chunks seq., nodes not seq */
    220  1.4.16.2  yamt #define UDF_ALLOC_RELAXEDSEQUENTIAL  6  /* only nodes not seq.           */
    221  1.4.16.2  yamt 
    222  1.4.16.2  yamt /* readdir cookies */
    223  1.4.16.2  yamt #define UDF_DIRCOOKIE_DOT 1
    224  1.4.16.2  yamt 
    225  1.4.16.2  yamt 
    226  1.4.16.2  yamt struct udf_node {
    227  1.4.16.2  yamt 	struct genfs_node	i_gnode;		/* has to be first   */
    228  1.4.16.2  yamt 	struct vnode		*vnode;			/* vnode associated  */
    229  1.4.16.2  yamt 	struct udf_mount	*ump;
    230  1.4.16.2  yamt 
    231  1.4.16.2  yamt 	/* one of `fe' or `efe' can be set, not both (UDF file entry dscr.)  */
    232  1.4.16.2  yamt 	struct file_entry	*fe;
    233  1.4.16.2  yamt 	struct extfile_entry	*efe;
    234  1.4.16.2  yamt 
    235  1.4.16.2  yamt 	/* location found and recording location & hints */
    236  1.4.16.2  yamt 	struct long_ad		 loc;			/* FID/hash loc.     */
    237  1.4.16.2  yamt 	struct long_ad		 next_loc;		/* strat 4096 loc    */
    238  1.4.16.2  yamt 	int			 needs_indirect;	/* has missing indr. */
    239  1.4.16.3  yamt 	uint64_t		 last_diroffset;	/* speeding up lookup*/
    240  1.4.16.2  yamt 
    241  1.4.16.2  yamt 	/* TODO support for allocation extents? */
    242  1.4.16.2  yamt 
    243  1.4.16.2  yamt 	/* device number from extended attributes = makedev(min,maj) */
    244  1.4.16.2  yamt 	dev_t			 rdev;
    245  1.4.16.2  yamt 
    246  1.4.16.2  yamt 	/* misc */
    247  1.4.16.2  yamt 	struct lockf		*lockf;			/* lock list         */
    248  1.4.16.2  yamt 
    249  1.4.16.2  yamt 	/* possibly not needed */
    250  1.4.16.2  yamt 	long			 refcnt;
    251  1.4.16.2  yamt 	int			 dirty;
    252  1.4.16.2  yamt 	int			 hold;
    253  1.4.16.2  yamt 
    254  1.4.16.2  yamt 	struct udf_node		*extattr;
    255  1.4.16.2  yamt 	struct udf_node		*streamdir;
    256  1.4.16.2  yamt 
    257  1.4.16.2  yamt 	LIST_ENTRY(udf_node)	 hashchain;		/* all udf nodes     */
    258  1.4.16.2  yamt 	STAILQ_ENTRY(udf_node)	 dirty_nodes;		/* dirty udf nodes   */
    259  1.4.16.2  yamt };
    260  1.4.16.2  yamt 
    261  1.4.16.2  yamt #endif /* !_FS_UDF_UDF_H_ */
    262