Change the kernel dev_t, representing a pointer to a specinfo structure,
[dragonfly.git] / sys / vfs / udf / udf.h
CommitLineData
03998195
JS
1/*-
2 * Copyright (c) 2001, 2002 Scott Long <scottl@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: src/sys/fs/udf/udf.h,v 1.6 2003/11/05 06:56:08 scottl Exp $
b13267a5 27 * $DragonFly: src/sys/vfs/udf/udf.h,v 1.3 2006/09/10 01:26:41 dillon Exp $
03998195
JS
28 */
29
30#define UDF_HASHTBLSIZE 100
31
32struct udf_node {
33 LIST_ENTRY(udf_node) le;
34 struct vnode *i_vnode;
35 struct vnode *i_devvp;
36 struct udf_mnt *udfmp;
b13267a5 37 cdev_t i_dev;
03998195
JS
38 ino_t hash_id;
39 long diroff;
40 struct file_entry *fentry;
41};
42
43struct udf_mnt {
44 int im_flags;
45 struct mount *im_mountp;
b13267a5 46 cdev_t im_dev;
03998195
JS
47 struct vnode *im_devvp;
48 struct netexport im_export;
49 int bsize;
50 int bshift;
51 int bmask;
52 uint32_t part_start;
53 uint32_t part_len;
54 uint64_t root_id;
55 struct vnode *root_vp;
56 struct long_ad root_icb;
57 LIST_HEAD(udf_hash_lh, udf_node) *hashtbl;
58 u_long hashsz;
59 struct lwkt_token hash_token;
60 int p_sectors;
61 int s_table_entries;
62 struct udf_sparing_table *s_table;
63};
64
65struct udf_dirstream {
66 struct udf_node *node;
67 struct udf_mnt *udfmp;
68 struct buf *bp;
69 uint8_t *data;
70 uint8_t *buf;
71 int fsize;
72 int off;
73 int this_off;
74 int offset;
75 int size;
76 int error;
77 int fid_fragment;
78};
79
80#define VFSTOUDFFS(mp) ((struct udf_mnt *)((mp)->mnt_data))
81#define VTON(vp) ((struct udf_node *)((vp)->v_data))
82
83/*
84 * The block layer refers to things in terms of 512 byte blocks by default.
85 * btodb() is expensive, so speed things up.
86 * XXX Can the block layer be forced to use a different block size?
87 */
88#define RDSECTOR(devvp, sector, size, bp) \
54078292 89 bread(devvp, (off_t)(sector) << udfmp->bshift, size, bp)
03998195
JS
90
91MALLOC_DECLARE(M_UDFFENTRY);
92MALLOC_DECLARE(M_UDFNODE);
93
94static __inline int
95udf_readlblks(struct udf_mnt *udfmp, int sector, int size, struct buf **bp)
96{
97 return (RDSECTOR(udfmp->im_devvp, sector,
98 (size + udfmp->bmask) & ~udfmp->bmask, bp));
99}
100
101static __inline int
102udf_readalblks(struct udf_mnt *udfmp, int lsector, int size, struct buf **bp)
103{
54078292
MD
104 off_t raoffset;
105 off_t loffset;
03998195
JS
106 int rasize;
107
54078292
MD
108 loffset = (off_t)(lsector + udfmp->part_start) << udfmp->bshift;
109 raoffset = loffset + (1 << udfmp->bshift);
03998195
JS
110 rasize = size;
111
54078292 112 return (breadn(udfmp->im_devvp, loffset,
03998195 113 (size + udfmp->bmask) & ~udfmp->bmask,
54078292 114 &raoffset, &rasize, 1, bp));
03998195
JS
115}
116
117/*
118 * Produce a suitable file number from an ICB.
119 * XXX If the fileno resolves to 0, we might be in big trouble.
120 * XXX Assumes the ICB is a long_ad. This struct is compatible with short_ad,
121 * but not ext_ad.
122 */
123static __inline ino_t
124udf_getid(struct long_ad *icb)
125{
126 return (icb->loc.lb_num);
127}
128
129int udf_allocv(struct mount *, struct vnode **);
130int udf_hashlookup(struct udf_mnt *, ino_t, struct vnode **);
131int udf_hashins(struct udf_node *);
132int udf_hashrem(struct udf_node *);
133int udf_checktag(struct desc_tag *, uint16_t);
134int udf_vget(struct mount *, ino_t, struct vnode **);