Thu Dec 3 14:29:04 2009 UTC ()
vrele, not vput for unlocked devvp


(pooka)
diff -r1.23 -r1.24 src/sys/fs/hfs/hfs_vfsops.c

cvs diff -r1.23 -r1.24 src/sys/fs/hfs/hfs_vfsops.c (switch to unified diff)

--- src/sys/fs/hfs/hfs_vfsops.c 2009/11/27 16:11:35 1.23
+++ src/sys/fs/hfs/hfs_vfsops.c 2009/12/03 14:29:04 1.24
@@ -1,723 +1,723 @@ @@ -1,723 +1,723 @@
1/* $NetBSD: hfs_vfsops.c,v 1.23 2009/11/27 16:11:35 pooka Exp $ */ 1/* $NetBSD: hfs_vfsops.c,v 1.24 2009/12/03 14:29:04 pooka Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc. 4 * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Yevgeny Binder and Dieter Baron. 8 * by Yevgeny Binder and Dieter Baron.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */  30 */
31 31
32/* 32/*
33 * Copyright (c) 1991, 1993, 1994 33 * Copyright (c) 1991, 1993, 1994
34 * The Regents of the University of California. All rights reserved. 34 * The Regents of the University of California. All rights reserved.
35 * (c) UNIX System Laboratories, Inc. 35 * (c) UNIX System Laboratories, Inc.
36 * All or some portions of this file are derived from material licensed 36 * All or some portions of this file are derived from material licensed
37 * to the University of California by American Telephone and Telegraph 37 * to the University of California by American Telephone and Telegraph
38 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 38 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
39 * the permission of UNIX System Laboratories, Inc. 39 * the permission of UNIX System Laboratories, Inc.
40 * 40 *
41 * Redistribution and use in source and binary forms, with or without 41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions 42 * modification, are permitted provided that the following conditions
43 * are met: 43 * are met:
44 * 1. Redistributions of source code must retain the above copyright 44 * 1. Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer. 45 * notice, this list of conditions and the following disclaimer.
46 * 2. Redistributions in binary form must reproduce the above copyright 46 * 2. Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in the 47 * notice, this list of conditions and the following disclaimer in the
48 * documentation and/or other materials provided with the distribution. 48 * documentation and/or other materials provided with the distribution.
49 * 3. Neither the name of the University nor the names of its contributors 49 * 3. Neither the name of the University nor the names of its contributors
50 * may be used to endorse or promote products derived from this software 50 * may be used to endorse or promote products derived from this software
51 * without specific prior written permission. 51 * without specific prior written permission.
52 * 52 *
53 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 53 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 54 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * SUCH DAMAGE. 63 * SUCH DAMAGE.
64 */ 64 */
65  65
66 /* 66 /*
67 * Copyright (c) 1989, 1991, 1993, 1994 67 * Copyright (c) 1989, 1991, 1993, 1994
68 * The Regents of the University of California. All rights reserved. 68 * The Regents of the University of California. All rights reserved.
69 * 69 *
70 * Redistribution and use in source and binary forms, with or without 70 * Redistribution and use in source and binary forms, with or without
71 * modification, are permitted provided that the following conditions 71 * modification, are permitted provided that the following conditions
72 * are met: 72 * are met:
73 * 1. Redistributions of source code must retain the above copyright 73 * 1. Redistributions of source code must retain the above copyright
74 * notice, this list of conditions and the following disclaimer. 74 * notice, this list of conditions and the following disclaimer.
75 * 2. Redistributions in binary form must reproduce the above copyright 75 * 2. Redistributions in binary form must reproduce the above copyright
76 * notice, this list of conditions and the following disclaimer in the 76 * notice, this list of conditions and the following disclaimer in the
77 * documentation and/or other materials provided with the distribution. 77 * documentation and/or other materials provided with the distribution.
78 * 3. Neither the name of the University nor the names of its contributors 78 * 3. Neither the name of the University nor the names of its contributors
79 * may be used to endorse or promote products derived from this software 79 * may be used to endorse or promote products derived from this software
80 * without specific prior written permission. 80 * without specific prior written permission.
81 * 81 *
82 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 82 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
83 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 83 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
84 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 84 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
85 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 85 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
86 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 86 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
87 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 87 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
88 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 88 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
89 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 89 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
90 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 90 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
91 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 91 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
92 * SUCH DAMAGE. 92 * SUCH DAMAGE.
93 */ 93 */
94 94
95 95
96 96
97/* 97/*
98 * Apple HFS+ filesystem 98 * Apple HFS+ filesystem
99 */ 99 */
100 100
101#include <sys/cdefs.h> 101#include <sys/cdefs.h>
102__KERNEL_RCSID(0, "$NetBSD: hfs_vfsops.c,v 1.23 2009/11/27 16:11:35 pooka Exp $"); 102__KERNEL_RCSID(0, "$NetBSD: hfs_vfsops.c,v 1.24 2009/12/03 14:29:04 pooka Exp $");
103 103
104#ifdef _KERNEL_OPT 104#ifdef _KERNEL_OPT
105#include "opt_compat_netbsd.h" 105#include "opt_compat_netbsd.h"
106#endif 106#endif
107 107
108#include <sys/param.h> 108#include <sys/param.h>
109#include <sys/systm.h> 109#include <sys/systm.h>
110#include <sys/namei.h> 110#include <sys/namei.h>
111#include <sys/proc.h> 111#include <sys/proc.h>
112#include <sys/kernel.h> 112#include <sys/kernel.h>
113#include <sys/vnode.h> 113#include <sys/vnode.h>
114#include <sys/socket.h> 114#include <sys/socket.h>
115#include <sys/mount.h> 115#include <sys/mount.h>
116#include <sys/buf.h> 116#include <sys/buf.h>
117#include <sys/device.h> 117#include <sys/device.h>
118#include <sys/mbuf.h> 118#include <sys/mbuf.h>
119#include <sys/file.h> 119#include <sys/file.h>
120#include <sys/disklabel.h> 120#include <sys/disklabel.h>
121#include <sys/ioctl.h> 121#include <sys/ioctl.h>
122#include <sys/errno.h> 122#include <sys/errno.h>
123#include <sys/malloc.h> 123#include <sys/malloc.h>
124#include <sys/pool.h> 124#include <sys/pool.h>
125#include <sys/lock.h> 125#include <sys/lock.h>
126#include <sys/sysctl.h> 126#include <sys/sysctl.h>
127#include <sys/conf.h> 127#include <sys/conf.h>
128#include <sys/kauth.h> 128#include <sys/kauth.h>
129#include <sys/stat.h> 129#include <sys/stat.h>
130#include <sys/module.h> 130#include <sys/module.h>
131 131
132#include <miscfs/genfs/genfs.h> 132#include <miscfs/genfs/genfs.h>
133#include <miscfs/specfs/specdev.h> 133#include <miscfs/specfs/specdev.h>
134 134
135#include <fs/hfs/hfs.h> 135#include <fs/hfs/hfs.h>
136#include <fs/hfs/libhfs.h> 136#include <fs/hfs/libhfs.h>
137 137
138MODULE(MODULE_CLASS_VFS, hfs, NULL); 138MODULE(MODULE_CLASS_VFS, hfs, NULL);
139 139
140MALLOC_JUSTDEFINE(M_HFSMNT, "hfs mount", "hfs mount structures"); 140MALLOC_JUSTDEFINE(M_HFSMNT, "hfs mount", "hfs mount structures");
141 141
142extern kmutex_t hfs_hashlock; 142extern kmutex_t hfs_hashlock;
143 143
144const struct vnodeopv_desc * const hfs_vnodeopv_descs[] = { 144const struct vnodeopv_desc * const hfs_vnodeopv_descs[] = {
145 &hfs_vnodeop_opv_desc, 145 &hfs_vnodeop_opv_desc,
146 &hfs_specop_opv_desc, 146 &hfs_specop_opv_desc,
147 &hfs_fifoop_opv_desc, 147 &hfs_fifoop_opv_desc,
148 NULL, 148 NULL,
149}; 149};
150 150
151struct vfsops hfs_vfsops = { 151struct vfsops hfs_vfsops = {
152 MOUNT_HFS, 152 MOUNT_HFS,
153 sizeof (struct hfs_args), 153 sizeof (struct hfs_args),
154 hfs_mount, 154 hfs_mount,
155 hfs_start, 155 hfs_start,
156 hfs_unmount, 156 hfs_unmount,
157 hfs_root, 157 hfs_root,
158 (void *)eopnotsupp, /* vfs_quotactl */ 158 (void *)eopnotsupp, /* vfs_quotactl */
159 hfs_statvfs, 159 hfs_statvfs,
160 hfs_sync, 160 hfs_sync,
161 hfs_vget, 161 hfs_vget,
162 hfs_fhtovp, 162 hfs_fhtovp,
163 hfs_vptofh, 163 hfs_vptofh,
164 hfs_init, 164 hfs_init,
165 hfs_reinit, 165 hfs_reinit,
166 hfs_done, 166 hfs_done,
167 NULL, /* vfs_mountroot */ 167 NULL, /* vfs_mountroot */
168 NULL, /* vfs_snapshot */ 168 NULL, /* vfs_snapshot */
169 vfs_stdextattrctl, 169 vfs_stdextattrctl,
170 (void *)eopnotsupp, /* vfs_suspendctl */ 170 (void *)eopnotsupp, /* vfs_suspendctl */
171 genfs_renamelock_enter, 171 genfs_renamelock_enter,
172 genfs_renamelock_exit, 172 genfs_renamelock_exit,
173 (void *)eopnotsupp, 173 (void *)eopnotsupp,
174 hfs_vnodeopv_descs, 174 hfs_vnodeopv_descs,
175 0, 175 0,
176 { NULL, NULL }, 176 { NULL, NULL },
177}; 177};
178 178
179static const struct genfs_ops hfs_genfsops = { 179static const struct genfs_ops hfs_genfsops = {
180 .gop_size = genfs_size, 180 .gop_size = genfs_size,
181}; 181};
182 182
183static int 183static int
184hfs_modcmd(modcmd_t cmd, void *arg) 184hfs_modcmd(modcmd_t cmd, void *arg)
185{ 185{
186 186
187 switch (cmd) { 187 switch (cmd) {
188 case MODULE_CMD_INIT: 188 case MODULE_CMD_INIT:
189 return vfs_attach(&hfs_vfsops); 189 return vfs_attach(&hfs_vfsops);
190 case MODULE_CMD_FINI: 190 case MODULE_CMD_FINI:
191 return vfs_detach(&hfs_vfsops); 191 return vfs_detach(&hfs_vfsops);
192 default: 192 default:
193 return ENOTTY; 193 return ENOTTY;
194 } 194 }
195} 195}
196 196
197int 197int
198hfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len) 198hfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
199{ 199{
200 struct lwp *l = curlwp; 200 struct lwp *l = curlwp;
201 struct hfs_args *args = data; 201 struct hfs_args *args = data;
202 struct vnode *devvp; 202 struct vnode *devvp;
203 struct hfsmount *hmp; 203 struct hfsmount *hmp;
204 int error; 204 int error;
205 int update; 205 int update;
206 mode_t accessmode; 206 mode_t accessmode;
207 207
208 if (*data_len < sizeof *args) 208 if (*data_len < sizeof *args)
209 return EINVAL; 209 return EINVAL;
210 210
211#ifdef HFS_DEBUG  211#ifdef HFS_DEBUG
212 printf("vfsop = hfs_mount()\n"); 212 printf("vfsop = hfs_mount()\n");
213#endif /* HFS_DEBUG */ 213#endif /* HFS_DEBUG */
214  214
215 if (mp->mnt_flag & MNT_GETARGS) { 215 if (mp->mnt_flag & MNT_GETARGS) {
216 hmp = VFSTOHFS(mp); 216 hmp = VFSTOHFS(mp);
217 if (hmp == NULL) 217 if (hmp == NULL)
218 return EIO; 218 return EIO;
219 args->fspec = NULL; 219 args->fspec = NULL;
220 *data_len = sizeof *args; 220 *data_len = sizeof *args;
221 return 0; 221 return 0;
222 } 222 }
223 223
224 if (data == NULL) 224 if (data == NULL)
225 return EINVAL; 225 return EINVAL;
226 226
227/* FIXME: For development ONLY - disallow remounting for now */ 227/* FIXME: For development ONLY - disallow remounting for now */
228#if 0 228#if 0
229 update = mp->mnt_flag & MNT_UPDATE; 229 update = mp->mnt_flag & MNT_UPDATE;
230#else 230#else
231 update = 0; 231 update = 0;
232#endif 232#endif
233 233
234 /* Check arguments */ 234 /* Check arguments */
235 if (args->fspec != NULL) { 235 if (args->fspec != NULL) {
236 /* 236 /*
237 * Look up the name and verify that it's sane. 237 * Look up the name and verify that it's sane.
238 */ 238 */
239 error = namei_simple_user(args->fspec, 239 error = namei_simple_user(args->fspec,
240 NSM_FOLLOW_NOEMULROOT, &devvp); 240 NSM_FOLLOW_NOEMULROOT, &devvp);
241 if (error != 0) 241 if (error != 0)
242 return error; 242 return error;
243  243
244 if (!update) { 244 if (!update) {
245 /* 245 /*
246 * Be sure this is a valid block device 246 * Be sure this is a valid block device
247 */ 247 */
248 if (devvp->v_type != VBLK) 248 if (devvp->v_type != VBLK)
249 error = ENOTBLK; 249 error = ENOTBLK;
250 else if (bdevsw_lookup(devvp->v_rdev) == NULL) 250 else if (bdevsw_lookup(devvp->v_rdev) == NULL)
251 error = ENXIO; 251 error = ENXIO;
252 } else { 252 } else {
253 /* 253 /*
254 * Be sure we're still naming the same device 254 * Be sure we're still naming the same device
255 * used for our initial mount 255 * used for our initial mount
256 */ 256 */
257 hmp = VFSTOHFS(mp); 257 hmp = VFSTOHFS(mp);
258 if (devvp != hmp->hm_devvp) 258 if (devvp != hmp->hm_devvp)
259 error = EINVAL; 259 error = EINVAL;
260 } 260 }
261 } else { 261 } else {
262 if (update) { 262 if (update) {
263 /* Use the extant mount */ 263 /* Use the extant mount */
264 hmp = VFSTOHFS(mp); 264 hmp = VFSTOHFS(mp);
265 devvp = hmp->hm_devvp; 265 devvp = hmp->hm_devvp;
266 vref(devvp); 266 vref(devvp);
267 } else { 267 } else {
268 /* New mounts must have a filename for the device */ 268 /* New mounts must have a filename for the device */
269 return EINVAL; 269 return EINVAL;
270 } 270 }
271 } 271 }
272 272
273  273
274 /* 274 /*
275 * If mount by non-root, then verify that user has necessary 275 * If mount by non-root, then verify that user has necessary
276 * permissions on the device. 276 * permissions on the device.
277 * 277 *
278 * Permission to update a mount is checked higher, so here we presume 278 * Permission to update a mount is checked higher, so here we presume
279 * updating the mount is okay (for example, as far as securelevel goes) 279 * updating the mount is okay (for example, as far as securelevel goes)
280 * which leaves us with the normal check. 280 * which leaves us with the normal check.
281 */ 281 */
282 if (error == 0) { 282 if (error == 0) {
283 accessmode = VREAD; 283 accessmode = VREAD;
284 if (update ? 284 if (update ?
285 (mp->mnt_iflag & IMNT_WANTRDWR) != 0 : 285 (mp->mnt_iflag & IMNT_WANTRDWR) != 0 :
286 (mp->mnt_flag & MNT_RDONLY) == 0) 286 (mp->mnt_flag & MNT_RDONLY) == 0)
287 accessmode |= VWRITE; 287 accessmode |= VWRITE;
288 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); 288 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
289 error = genfs_can_mount(devvp, accessmode, l->l_cred); 289 error = genfs_can_mount(devvp, accessmode, l->l_cred);
290 VOP_UNLOCK(devvp, 0); 290 VOP_UNLOCK(devvp, 0);
291 } 291 }
292 292
293 if (error != 0) 293 if (error != 0)
294 goto error; 294 goto error;
295 295
296 if (update) { 296 if (update) {
297 printf("HFS: live remounting not yet supported!\n"); 297 printf("HFS: live remounting not yet supported!\n");
298 error = EINVAL; 298 error = EINVAL;
299 goto error; 299 goto error;
300 } 300 }
301 301
302 if ((error = hfs_mountfs(devvp, mp, l, args->fspec)) != 0) 302 if ((error = hfs_mountfs(devvp, mp, l, args->fspec)) != 0)
303 goto error; 303 goto error;
304  304
305 error = set_statvfs_info(path, UIO_USERSPACE, args->fspec, UIO_USERSPACE, 305 error = set_statvfs_info(path, UIO_USERSPACE, args->fspec, UIO_USERSPACE,
306 mp->mnt_op->vfs_name, mp, l); 306 mp->mnt_op->vfs_name, mp, l);
307 307
308#ifdef HFS_DEBUG 308#ifdef HFS_DEBUG
309 if(!update) { 309 if(!update) {
310 char* volname; 310 char* volname;
311  311
312 hmp = VFSTOHFS(mp); 312 hmp = VFSTOHFS(mp);
313 volname = malloc(hmp->hm_vol.name.length + 1, M_TEMP, M_WAITOK); 313 volname = malloc(hmp->hm_vol.name.length + 1, M_TEMP, M_WAITOK);
314 if (volname == NULL) 314 if (volname == NULL)
315 printf("could not allocate volname; ignored\n"); 315 printf("could not allocate volname; ignored\n");
316 else { 316 else {
317 if (hfs_unicode_to_ascii(hmp->hm_vol.name.unicode, 317 if (hfs_unicode_to_ascii(hmp->hm_vol.name.unicode,
318 hmp->hm_vol.name.length, volname) == NULL) 318 hmp->hm_vol.name.length, volname) == NULL)
319 printf("could not convert volume name to ascii; ignored\n"); 319 printf("could not convert volume name to ascii; ignored\n");
320 else 320 else
321 printf("mounted volume \"%s\"\n", volname); 321 printf("mounted volume \"%s\"\n", volname);
322 free(volname, M_TEMP); 322 free(volname, M_TEMP);
323 } 323 }
324 } 324 }
325#endif /* HFS_DEBUG */ 325#endif /* HFS_DEBUG */
326  326
327 return error; 327 return error;
328  328
329error: 329error:
330 vrele(devvp); 330 vrele(devvp);
331 return error; 331 return error;
332} 332}
333 333
334int 334int
335hfs_start(struct mount *mp, int flags) 335hfs_start(struct mount *mp, int flags)
336{ 336{
337 337
338#ifdef HFS_DEBUG  338#ifdef HFS_DEBUG
339 printf("vfsop = hfs_start()\n"); 339 printf("vfsop = hfs_start()\n");
340#endif /* HFS_DEBUG */ 340#endif /* HFS_DEBUG */
341 341
342 return 0; 342 return 0;
343} 343}
344 344
345int 345int
346hfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l, 346hfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l,
347 const char *devpath) 347 const char *devpath)
348{ 348{
349 hfs_callback_args cbargs; 349 hfs_callback_args cbargs;
350 hfs_libcb_argsopen argsopen; 350 hfs_libcb_argsopen argsopen;
351 hfs_libcb_argsread argsread; 351 hfs_libcb_argsread argsread;
352 struct hfsmount *hmp; 352 struct hfsmount *hmp;
353 kauth_cred_t cred; 353 kauth_cred_t cred;
354 int error; 354 int error;
355  355
356 cred = l ? l->l_cred : NOCRED; 356 cred = l ? l->l_cred : NOCRED;
357 error = 0; 357 error = 0;
358 hmp = NULL; 358 hmp = NULL;
359 359
360 /* Create mounted volume structure. */ 360 /* Create mounted volume structure. */
361 hmp = (struct hfsmount*)malloc(sizeof(struct hfsmount), 361 hmp = (struct hfsmount*)malloc(sizeof(struct hfsmount),
362 M_HFSMNT, M_WAITOK); 362 M_HFSMNT, M_WAITOK);
363 if (hmp == NULL) { 363 if (hmp == NULL) {
364 error = ENOMEM; 364 error = ENOMEM;
365 goto error; 365 goto error;
366 } 366 }
367 memset(hmp, 0, sizeof(struct hfsmount)); 367 memset(hmp, 0, sizeof(struct hfsmount));
368  368
369 mp->mnt_data = hmp; 369 mp->mnt_data = hmp;
370 mp->mnt_flag |= MNT_LOCAL; 370 mp->mnt_flag |= MNT_LOCAL;
371 vfs_getnewfsid(mp); 371 vfs_getnewfsid(mp);
372 372
373 hmp->hm_mountp = mp; 373 hmp->hm_mountp = mp;
374 hmp->hm_dev = devvp->v_rdev; 374 hmp->hm_dev = devvp->v_rdev;
375 hmp->hm_devvp = devvp; 375 hmp->hm_devvp = devvp;
376  376
377 /* 377 /*
378 * Use libhfs to open the volume and read the volume header and other 378 * Use libhfs to open the volume and read the volume header and other
379 * useful information. 379 * useful information.
380 */ 380 */
381  381
382 hfslib_init_cbargs(&cbargs); 382 hfslib_init_cbargs(&cbargs);
383 argsopen.cred = argsread.cred = cred; 383 argsopen.cred = argsread.cred = cred;
384 argsopen.l = argsread.l = l; 384 argsopen.l = argsread.l = l;
385 argsopen.devvp = devvp; 385 argsopen.devvp = devvp;
386 cbargs.read = (void*)&argsread; 386 cbargs.read = (void*)&argsread;
387 cbargs.openvol = (void*)&argsopen; 387 cbargs.openvol = (void*)&argsopen;
388 388
389 if ((error = hfslib_open_volume(devpath, mp->mnt_flag & MNT_RDONLY, 389 if ((error = hfslib_open_volume(devpath, mp->mnt_flag & MNT_RDONLY,
390 &hmp->hm_vol, &cbargs)) != 0) 390 &hmp->hm_vol, &cbargs)) != 0)
391 goto error; 391 goto error;
392  392
393 /* Make sure this is not a journaled volume whose journal is dirty. */ 393 /* Make sure this is not a journaled volume whose journal is dirty. */
394 if (!hfslib_is_journal_clean(&hmp->hm_vol)) { 394 if (!hfslib_is_journal_clean(&hmp->hm_vol)) {
395 printf("volume journal is dirty; not mounting\n"); 395 printf("volume journal is dirty; not mounting\n");
396 error = EIO; 396 error = EIO;
397 goto error; 397 goto error;
398 } 398 }
399 399
400 mp->mnt_fs_bshift = 0; 400 mp->mnt_fs_bshift = 0;
401 while ((1 << mp->mnt_fs_bshift) < hmp->hm_vol.vh.block_size) 401 while ((1 << mp->mnt_fs_bshift) < hmp->hm_vol.vh.block_size)
402 mp->mnt_fs_bshift++; 402 mp->mnt_fs_bshift++;
403 mp->mnt_dev_bshift = DEV_BSHIFT; 403 mp->mnt_dev_bshift = DEV_BSHIFT;
404 404
405 return 0; 405 return 0;
406  406
407error: 407error:
408 if (hmp != NULL) 408 if (hmp != NULL)
409 free(hmp, M_HFSMNT); 409 free(hmp, M_HFSMNT);
410  410
411 return error; 411 return error;
412} 412}
413 413
414int 414int
415hfs_unmount(struct mount *mp, int mntflags) 415hfs_unmount(struct mount *mp, int mntflags)
416{ 416{
417 hfs_callback_args cbargs; 417 hfs_callback_args cbargs;
418 hfs_libcb_argsread argsclose; 418 hfs_libcb_argsread argsclose;
419 struct hfsmount* hmp; 419 struct hfsmount* hmp;
420 int error; 420 int error;
421 int flags; 421 int flags;
422  422
423#ifdef HFS_DEBUG  423#ifdef HFS_DEBUG
424 printf("vfsop = hfs_unmount()\n"); 424 printf("vfsop = hfs_unmount()\n");
425#endif /* HFS_DEBUG */ 425#endif /* HFS_DEBUG */
426 426
427 hmp = VFSTOHFS(mp); 427 hmp = VFSTOHFS(mp);
428  428
429 flags = 0; 429 flags = 0;
430 if (mntflags & MNT_FORCE) 430 if (mntflags & MNT_FORCE)
431 flags |= FORCECLOSE; 431 flags |= FORCECLOSE;
432  432
433 if ((error = vflush(mp, NULLVP, flags)) != 0) 433 if ((error = vflush(mp, NULLVP, flags)) != 0)
434 return error; 434 return error;
435 435
436 hfslib_init_cbargs(&cbargs); 436 hfslib_init_cbargs(&cbargs);
437 argsclose.l = curlwp; 437 argsclose.l = curlwp;
438 cbargs.closevol = (void*)&argsclose; 438 cbargs.closevol = (void*)&argsclose;
439 hfslib_close_volume(&hmp->hm_vol, &cbargs); 439 hfslib_close_volume(&hmp->hm_vol, &cbargs);
440  440
441 vput(hmp->hm_devvp); 441 vrele(hmp->hm_devvp);
442 442
443 free(hmp, M_HFSMNT); 443 free(hmp, M_HFSMNT);
444 mp->mnt_data = NULL; 444 mp->mnt_data = NULL;
445 mp->mnt_flag &= ~MNT_LOCAL; 445 mp->mnt_flag &= ~MNT_LOCAL;
446  446
447 return error; 447 return error;
448} 448}
449 449
450int 450int
451hfs_root(struct mount *mp, struct vnode **vpp) 451hfs_root(struct mount *mp, struct vnode **vpp)
452{ 452{
453 struct vnode *nvp; 453 struct vnode *nvp;
454 int error; 454 int error;
455 455
456#ifdef HFS_DEBUG  456#ifdef HFS_DEBUG
457 printf("vfsop = hfs_root()\n"); 457 printf("vfsop = hfs_root()\n");
458#endif /* HFS_DEBUG */ 458#endif /* HFS_DEBUG */
459  459
460 if ((error = VFS_VGET(mp, HFS_CNID_ROOT_FOLDER, &nvp)) != 0) 460 if ((error = VFS_VGET(mp, HFS_CNID_ROOT_FOLDER, &nvp)) != 0)
461 return error; 461 return error;
462 *vpp = nvp; 462 *vpp = nvp;
463  463
464 return 0; 464 return 0;
465} 465}
466 466
467int 467int
468hfs_statvfs(struct mount *mp, struct statvfs *sbp) 468hfs_statvfs(struct mount *mp, struct statvfs *sbp)
469{ 469{
470 hfs_volume_header_t *vh; 470 hfs_volume_header_t *vh;
471  471
472#ifdef HFS_DEBUG  472#ifdef HFS_DEBUG
473 printf("vfsop = hfs_statvfs()\n"); 473 printf("vfsop = hfs_statvfs()\n");
474#endif /* HFS_DEBUG */ 474#endif /* HFS_DEBUG */
475 475
476 vh = &VFSTOHFS(mp)->hm_vol.vh; 476 vh = &VFSTOHFS(mp)->hm_vol.vh;
477  477
478 sbp->f_bsize = vh->block_size; 478 sbp->f_bsize = vh->block_size;
479 sbp->f_frsize = sbp->f_bsize; 479 sbp->f_frsize = sbp->f_bsize;
480 sbp->f_iosize = 4096;/* mac os x uses a 4 kb io size, so do the same */ 480 sbp->f_iosize = 4096;/* mac os x uses a 4 kb io size, so do the same */
481 sbp->f_blocks = vh->total_blocks; 481 sbp->f_blocks = vh->total_blocks;
482 sbp->f_bfree = vh->free_blocks; /* total free blocks */ 482 sbp->f_bfree = vh->free_blocks; /* total free blocks */
483 sbp->f_bavail = vh->free_blocks; /* blocks free for non superuser */ 483 sbp->f_bavail = vh->free_blocks; /* blocks free for non superuser */
484 sbp->f_bresvd = 0; 484 sbp->f_bresvd = 0;
485 sbp->f_files = vh->file_count; /* total files */ 485 sbp->f_files = vh->file_count; /* total files */
486 sbp->f_ffree = (1<<31) - vh->file_count; /* free file nodes */ 486 sbp->f_ffree = (1<<31) - vh->file_count; /* free file nodes */
487 copy_statvfs_info(sbp, mp); 487 copy_statvfs_info(sbp, mp);
488  488
489 return 0; 489 return 0;
490} 490}
491 491
492int 492int
493hfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred) 493hfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred)
494{ 494{
495 495
496#ifdef HFS_DEBUG  496#ifdef HFS_DEBUG
497 printf("vfsop = hfs_sync()\n"); 497 printf("vfsop = hfs_sync()\n");
498#endif /* HFS_DEBUG */ 498#endif /* HFS_DEBUG */
499 499
500 return 0; 500 return 0;
501} 501}
502 502
503/* 503/*
504 * an ino_t corresponds directly to a CNID in our particular case, 504 * an ino_t corresponds directly to a CNID in our particular case,
505 * since both are conveniently 32-bit numbers 505 * since both are conveniently 32-bit numbers
506 */ 506 */
507int 507int
508hfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) 508hfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
509{ 509{
510 return hfs_vget_internal(mp, ino, HFS_DATAFORK, vpp); 510 return hfs_vget_internal(mp, ino, HFS_DATAFORK, vpp);
511} 511}
512 512
513/* 513/*
514 * internal version with extra arguments to allow accessing resource fork 514 * internal version with extra arguments to allow accessing resource fork
515 */ 515 */
516int 516int
517hfs_vget_internal(struct mount *mp, ino_t ino, uint8_t fork, 517hfs_vget_internal(struct mount *mp, ino_t ino, uint8_t fork,
518 struct vnode **vpp) 518 struct vnode **vpp)
519{ 519{
520 struct hfsmount *hmp; 520 struct hfsmount *hmp;
521 struct hfsnode *hnode; 521 struct hfsnode *hnode;
522 struct vnode *vp; 522 struct vnode *vp;
523 hfs_callback_args cbargs; 523 hfs_callback_args cbargs;
524 hfs_cnid_t cnid; 524 hfs_cnid_t cnid;
525 hfs_catalog_keyed_record_t rec; 525 hfs_catalog_keyed_record_t rec;
526 hfs_catalog_key_t key; /* the search key used to find this file on disk */ 526 hfs_catalog_key_t key; /* the search key used to find this file on disk */
527 dev_t dev; 527 dev_t dev;
528 int error; 528 int error;
529 529
530#ifdef HFS_DEBUG  530#ifdef HFS_DEBUG
531 printf("vfsop = hfs_vget()\n"); 531 printf("vfsop = hfs_vget()\n");
532#endif /* HFS_DEBUG */ 532#endif /* HFS_DEBUG */
533 533
534 hnode = NULL; 534 hnode = NULL;
535 vp = NULL; 535 vp = NULL;
536 hmp = VFSTOHFS(mp); 536 hmp = VFSTOHFS(mp);
537 dev = hmp->hm_dev; 537 dev = hmp->hm_dev;
538 cnid = (hfs_cnid_t)ino; 538 cnid = (hfs_cnid_t)ino;
539 539
540 if (fork != HFS_RSRCFORK) 540 if (fork != HFS_RSRCFORK)
541 fork = HFS_DATAFORK; 541 fork = HFS_DATAFORK;
542 542
543 retry: 543 retry:
544 /* Check if this vnode has already been allocated. If so, just return it. */ 544 /* Check if this vnode has already been allocated. If so, just return it. */
545 if ((*vpp = hfs_nhashget(dev, cnid, fork, LK_EXCLUSIVE)) != NULL) 545 if ((*vpp = hfs_nhashget(dev, cnid, fork, LK_EXCLUSIVE)) != NULL)
546 return 0; 546 return 0;
547 547
548 /* Allocate a new vnode/inode. */ 548 /* Allocate a new vnode/inode. */
549 if ((error = getnewvnode(VT_HFS, mp, hfs_vnodeop_p, &vp)) != 0) 549 if ((error = getnewvnode(VT_HFS, mp, hfs_vnodeop_p, &vp)) != 0)
550 goto error; 550 goto error;
551 hnode = malloc(sizeof(struct hfsnode), M_TEMP, 551 hnode = malloc(sizeof(struct hfsnode), M_TEMP,
552 M_WAITOK | M_ZERO); 552 M_WAITOK | M_ZERO);
553 553
554 /* 554 /*
555 * If someone beat us to it while sleeping in getnewvnode(), 555 * If someone beat us to it while sleeping in getnewvnode(),
556 * push back the freshly allocated vnode we don't need, and return. 556 * push back the freshly allocated vnode we don't need, and return.
557 */ 557 */
558 mutex_enter(&hfs_hashlock); 558 mutex_enter(&hfs_hashlock);
559 if (hfs_nhashget(dev, cnid, fork, 0) != NULL) { 559 if (hfs_nhashget(dev, cnid, fork, 0) != NULL) {
560 mutex_exit(&hfs_hashlock); 560 mutex_exit(&hfs_hashlock);
561 ungetnewvnode(vp); 561 ungetnewvnode(vp);
562 free(hnode, M_TEMP); 562 free(hnode, M_TEMP);
563 goto retry; 563 goto retry;
564 } 564 }
565 565
566 vp->v_vflag |= VV_LOCKSWORK;  566 vp->v_vflag |= VV_LOCKSWORK;
567 vp->v_data = hnode; 567 vp->v_data = hnode;
568 genfs_node_init(vp, &hfs_genfsops); 568 genfs_node_init(vp, &hfs_genfsops);
569  569
570 hnode->h_vnode = vp; 570 hnode->h_vnode = vp;
571 hnode->h_hmp = hmp; 571 hnode->h_hmp = hmp;
572 hnode->dummy = 0x1337BABE; 572 hnode->dummy = 0x1337BABE;
573  573
574 /* 574 /*
575 * We need to put this vnode into the hash chain and lock it so that other 575 * We need to put this vnode into the hash chain and lock it so that other
576 * requests for this inode will block if they arrive while we are sleeping 576 * requests for this inode will block if they arrive while we are sleeping
577 * waiting for old data structures to be purged or for the contents of the 577 * waiting for old data structures to be purged or for the contents of the
578 * disk portion of this inode to be read. The hash chain requires the node's 578 * disk portion of this inode to be read. The hash chain requires the node's
579 * device and cnid to be known. Since this information was passed in the 579 * device and cnid to be known. Since this information was passed in the
580 * arguments, fill in the appropriate hfsnode fields without reading having 580 * arguments, fill in the appropriate hfsnode fields without reading having
581 * to read the disk. 581 * to read the disk.
582 */ 582 */
583 hnode->h_dev = dev; 583 hnode->h_dev = dev;
584 hnode->h_rec.u.cnid = cnid; 584 hnode->h_rec.u.cnid = cnid;
585 hnode->h_fork = fork; 585 hnode->h_fork = fork;
586 586
587 hfs_nhashinsert(hnode); 587 hfs_nhashinsert(hnode);
588 mutex_exit(&hfs_hashlock); 588 mutex_exit(&hfs_hashlock);
589 589
590 590
591 /* 591 /*
592 * Read catalog record from disk. 592 * Read catalog record from disk.
593 */ 593 */
594 hfslib_init_cbargs(&cbargs); 594 hfslib_init_cbargs(&cbargs);
595  595
596 if (hfslib_find_catalog_record_with_cnid(&hmp->hm_vol, cnid, 596 if (hfslib_find_catalog_record_with_cnid(&hmp->hm_vol, cnid,
597 &rec, &key, &cbargs) != 0) { 597 &rec, &key, &cbargs) != 0) {
598 vput(vp); 598 vput(vp);
599 error = EBADF; 599 error = EBADF;
600 goto error; 600 goto error;
601 } 601 }
602  602
603 memcpy(&hnode->h_rec, &rec, sizeof(hnode->h_rec)); 603 memcpy(&hnode->h_rec, &rec, sizeof(hnode->h_rec));
604 hnode->h_parent = key.parent_cnid; 604 hnode->h_parent = key.parent_cnid;
605 605
606 /* XXX Eventually need to add an "ignore permissions" mount option */ 606 /* XXX Eventually need to add an "ignore permissions" mount option */
607 607
608 /* 608 /*
609 * Now convert some of the catalog record's fields into values that make 609 * Now convert some of the catalog record's fields into values that make
610 * sense on this system. 610 * sense on this system.
611 */ 611 */
612 /* DATE AND TIME */ 612 /* DATE AND TIME */
613 613
614 /* 614 /*
615 * Initialize the vnode from the hfsnode, check for aliases. 615 * Initialize the vnode from the hfsnode, check for aliases.
616 * Note that the underlying vnode may change. 616 * Note that the underlying vnode may change.
617 */ 617 */
618 hfs_vinit(mp, hfs_specop_p, hfs_fifoop_p, &vp); 618 hfs_vinit(mp, hfs_specop_p, hfs_fifoop_p, &vp);
619 619
620 hnode->h_devvp = hmp->hm_devvp;  620 hnode->h_devvp = hmp->hm_devvp;
621 VREF(hnode->h_devvp); /* Increment the ref count to the volume's device. */ 621 VREF(hnode->h_devvp); /* Increment the ref count to the volume's device. */
622 622
623 /* Make sure UVM has allocated enough memory. (?) */ 623 /* Make sure UVM has allocated enough memory. (?) */
624 if (hnode->h_rec.u.rec_type == HFS_REC_FILE) { 624 if (hnode->h_rec.u.rec_type == HFS_REC_FILE) {
625 if (hnode->h_fork == HFS_DATAFORK) 625 if (hnode->h_fork == HFS_DATAFORK)
626 uvm_vnp_setsize(vp, 626 uvm_vnp_setsize(vp,
627 hnode->h_rec.file.data_fork.logical_size); 627 hnode->h_rec.file.data_fork.logical_size);
628 else 628 else
629 uvm_vnp_setsize(vp, 629 uvm_vnp_setsize(vp,
630 hnode->h_rec.file.rsrc_fork.logical_size); 630 hnode->h_rec.file.rsrc_fork.logical_size);
631 } 631 }
632 else 632 else
633 uvm_vnp_setsize(vp, 0); /* no directly reading directories */ 633 uvm_vnp_setsize(vp, 0); /* no directly reading directories */
634  634
635 *vpp = vp; 635 *vpp = vp;
636  636
637 return 0; 637 return 0;
638 638
639error: 639error:
640 *vpp = NULL; 640 *vpp = NULL;
641 return error; 641 return error;
642} 642}
643 643
644int 644int
645hfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) 645hfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
646{ 646{
647 647
648#ifdef HFS_DEBUG  648#ifdef HFS_DEBUG
649 printf("vfsop = hfs_fhtovp()\n"); 649 printf("vfsop = hfs_fhtovp()\n");
650#endif /* HFS_DEBUG */ 650#endif /* HFS_DEBUG */
651 651
652 return EOPNOTSUPP; 652 return EOPNOTSUPP;
653} 653}
654 654
655int 655int
656hfs_vptofh(struct vnode *vp, struct fid *fhp, size_t *fh_size) 656hfs_vptofh(struct vnode *vp, struct fid *fhp, size_t *fh_size)
657{ 657{
658 658
659#ifdef HFS_DEBUG  659#ifdef HFS_DEBUG
660 printf("vfsop = hfs_vptofh()\n"); 660 printf("vfsop = hfs_vptofh()\n");
661#endif /* HFS_DEBUG */ 661#endif /* HFS_DEBUG */
662 662
663 return EOPNOTSUPP; 663 return EOPNOTSUPP;
664} 664}
665 665
666void 666void
667hfs_init(void) 667hfs_init(void)
668{ 668{
669 hfs_callbacks callbacks; 669 hfs_callbacks callbacks;
670 670
671#ifdef HFS_DEBUG  671#ifdef HFS_DEBUG
672 printf("vfsop = hfs_init()\n"); 672 printf("vfsop = hfs_init()\n");
673#endif /* HFS_DEBUG */ 673#endif /* HFS_DEBUG */
674 674
675 malloc_type_attach(M_HFSMNT); 675 malloc_type_attach(M_HFSMNT);
676 676
677 callbacks.error = hfs_libcb_error; 677 callbacks.error = hfs_libcb_error;
678 callbacks.allocmem = hfs_libcb_malloc; 678 callbacks.allocmem = hfs_libcb_malloc;
679 callbacks.reallocmem = hfs_libcb_realloc; 679 callbacks.reallocmem = hfs_libcb_realloc;
680 callbacks.freemem = hfs_libcb_free; 680 callbacks.freemem = hfs_libcb_free;
681 callbacks.openvol = hfs_libcb_opendev; 681 callbacks.openvol = hfs_libcb_opendev;
682 callbacks.closevol = hfs_libcb_closedev; 682 callbacks.closevol = hfs_libcb_closedev;
683 callbacks.read = hfs_libcb_read; 683 callbacks.read = hfs_libcb_read;
684 684
685 hfs_nhashinit(); 685 hfs_nhashinit();
686 hfslib_init(&callbacks); 686 hfslib_init(&callbacks);
687} 687}
688 688
689void 689void
690hfs_reinit(void) 690hfs_reinit(void)
691{ 691{
692 692
693#ifdef HFS_DEBUG  693#ifdef HFS_DEBUG
694 printf("vfsop = hfs_reinit()\n"); 694 printf("vfsop = hfs_reinit()\n");
695#endif /* HFS_DEBUG */ 695#endif /* HFS_DEBUG */
696 696
697 return; 697 return;
698} 698}
699 699
700void 700void
701hfs_done(void) 701hfs_done(void)
702{ 702{
703 703
704#ifdef HFS_DEBUG  704#ifdef HFS_DEBUG
705 printf("vfsop = hfs_done()\n"); 705 printf("vfsop = hfs_done()\n");
706#endif /* HFS_DEBUG */ 706#endif /* HFS_DEBUG */
707 707
708 malloc_type_detach(M_HFSMNT); 708 malloc_type_detach(M_HFSMNT);
709 709
710 hfslib_done(); 710 hfslib_done();
711 hfs_nhashdone(); 711 hfs_nhashdone();
712} 712}
713 713
714int 714int
715hfs_mountroot(void) 715hfs_mountroot(void)
716{ 716{
717 717
718#ifdef HFS_DEBUG  718#ifdef HFS_DEBUG
719 printf("vfsop = hfs_mountroot()\n"); 719 printf("vfsop = hfs_mountroot()\n");
720#endif /* HFS_DEBUG */ 720#endif /* HFS_DEBUG */
721 721
722 return EOPNOTSUPP; 722 return EOPNOTSUPP;
723} 723}