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