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