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