hfs_vfsops.c revision 1.32 1 /* $NetBSD: hfs_vfsops.c,v 1.32 2014/08/10 08:53:22 hannken 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.32 2014/08/10 08:53:22 hannken 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 #include <sys/module.h>
131
132 #include <miscfs/genfs/genfs.h>
133 #include <miscfs/specfs/specdev.h>
134
135 #include <fs/hfs/hfs.h>
136 #include <fs/hfs/libhfs.h>
137
138 MODULE(MODULE_CLASS_VFS, hfs, NULL);
139
140 MALLOC_JUSTDEFINE(M_HFSMNT, "hfs mount", "hfs mount structures");
141
142 struct pool hfs_node_pool;
143
144 const struct vnodeopv_desc * const hfs_vnodeopv_descs[] = {
145 &hfs_vnodeop_opv_desc,
146 &hfs_specop_opv_desc,
147 &hfs_fifoop_opv_desc,
148 NULL,
149 };
150
151 struct vfsops hfs_vfsops = {
152 .vfs_name = MOUNT_HFS,
153 .vfs_min_mount_data = sizeof (struct hfs_args),
154 .vfs_mount = hfs_mount,
155 .vfs_start = hfs_start,
156 .vfs_unmount = hfs_unmount,
157 .vfs_root = hfs_root,
158 .vfs_quotactl = (void *)eopnotsupp,
159 .vfs_statvfs = hfs_statvfs,
160 .vfs_sync = hfs_sync,
161 .vfs_vget = hfs_vget,
162 .vfs_loadvnode = hfs_loadvnode,
163 .vfs_fhtovp = hfs_fhtovp,
164 .vfs_vptofh = hfs_vptofh,
165 .vfs_init = hfs_init,
166 .vfs_reinit = hfs_reinit,
167 .vfs_done = hfs_done,
168 .vfs_extattrctl = vfs_stdextattrctl,
169 .vfs_suspendctl = (void *)eopnotsupp,
170 .vfs_renamelock_enter = genfs_renamelock_enter,
171 .vfs_renamelock_exit = genfs_renamelock_exit,
172 .vfs_fsync = (void *)eopnotsupp,
173 .vfs_opv_descs = hfs_vnodeopv_descs
174 };
175
176 static const struct genfs_ops hfs_genfsops = {
177 .gop_size = genfs_size,
178 };
179
180 static int
181 hfs_modcmd(modcmd_t cmd, void *arg)
182 {
183
184 switch (cmd) {
185 case MODULE_CMD_INIT:
186 return vfs_attach(&hfs_vfsops);
187 case MODULE_CMD_FINI:
188 return vfs_detach(&hfs_vfsops);
189 default:
190 return ENOTTY;
191 }
192 }
193
194 int
195 hfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
196 {
197 struct lwp *l = curlwp;
198 struct hfs_args *args = data;
199 struct vnode *devvp;
200 struct hfsmount *hmp;
201 int error = 0;
202 int update;
203 mode_t accessmode;
204
205 if (args == NULL)
206 return EINVAL;
207 if (*data_len < sizeof *args)
208 return EINVAL;
209
210 #ifdef HFS_DEBUG
211 printf("vfsop = hfs_mount()\n");
212 #endif /* HFS_DEBUG */
213
214 if (mp->mnt_flag & MNT_GETARGS) {
215 hmp = VFSTOHFS(mp);
216 if (hmp == NULL)
217 return EIO;
218 args->fspec = NULL;
219 *data_len = sizeof *args;
220 return 0;
221 }
222
223 if (data == NULL)
224 return EINVAL;
225
226 /* FIXME: For development ONLY - disallow remounting for now */
227 #if 0
228 update = mp->mnt_flag & MNT_UPDATE;
229 #else
230 update = 0;
231 #endif
232
233 /* Check arguments */
234 if (args->fspec != NULL) {
235 /*
236 * Look up the name and verify that it's sane.
237 */
238 error = namei_simple_user(args->fspec,
239 NSM_FOLLOW_NOEMULROOT, &devvp);
240 if (error != 0)
241 return error;
242
243 if (!update) {
244 /*
245 * Be sure this is a valid block device
246 */
247 if (devvp->v_type != VBLK)
248 error = ENOTBLK;
249 else if (bdevsw_lookup(devvp->v_rdev) == NULL)
250 error = ENXIO;
251 } else {
252 /*
253 * Be sure we're still naming the same device
254 * used for our initial mount
255 */
256 hmp = VFSTOHFS(mp);
257 if (devvp != hmp->hm_devvp)
258 error = EINVAL;
259 }
260 } else {
261 if (update) {
262 /* Use the extant mount */
263 hmp = VFSTOHFS(mp);
264 devvp = hmp->hm_devvp;
265 vref(devvp);
266 } else {
267 /* New mounts must have a filename for the device */
268 return EINVAL;
269 }
270 }
271
272
273 /*
274 * If mount by non-root, then verify that user has necessary
275 * permissions on the device.
276 *
277 * Permission to update a mount is checked higher, so here we presume
278 * updating the mount is okay (for example, as far as securelevel goes)
279 * which leaves us with the normal check.
280 */
281 if (error == 0) {
282 accessmode = VREAD;
283 if (update ?
284 (mp->mnt_iflag & IMNT_WANTRDWR) != 0 :
285 (mp->mnt_flag & MNT_RDONLY) == 0)
286 accessmode |= VWRITE;
287 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
288 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_MOUNT,
289 KAUTH_REQ_SYSTEM_MOUNT_DEVICE, mp, devvp,
290 KAUTH_ARG(accessmode));
291 VOP_UNLOCK(devvp);
292 }
293
294 if (error != 0)
295 goto error;
296
297 if (update) {
298 printf("HFS: live remounting not yet supported!\n");
299 error = EINVAL;
300 goto error;
301 }
302
303 if ((error = hfs_mountfs(devvp, mp, l, args->fspec)) != 0)
304 goto error;
305
306 error = set_statvfs_info(path, UIO_USERSPACE, args->fspec, UIO_USERSPACE,
307 mp->mnt_op->vfs_name, mp, l);
308
309 #ifdef HFS_DEBUG
310 if(!update) {
311 char* volname;
312
313 hmp = VFSTOHFS(mp);
314 volname = malloc(hmp->hm_vol.name.length + 1, M_TEMP, M_WAITOK);
315 if (volname == NULL)
316 printf("could not allocate volname; ignored\n");
317 else {
318 if (hfs_unicode_to_ascii(hmp->hm_vol.name.unicode,
319 hmp->hm_vol.name.length, volname) == NULL)
320 printf("could not convert volume name to ascii; ignored\n");
321 else
322 printf("mounted volume \"%s\"\n", volname);
323 free(volname, M_TEMP);
324 }
325 }
326 #endif /* HFS_DEBUG */
327
328 return error;
329
330 error:
331 vrele(devvp);
332 return error;
333 }
334
335 int
336 hfs_start(struct mount *mp, int flags)
337 {
338
339 #ifdef HFS_DEBUG
340 printf("vfsop = hfs_start()\n");
341 #endif /* HFS_DEBUG */
342
343 return 0;
344 }
345
346 int
347 hfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l,
348 const char *devpath)
349 {
350 hfs_callback_args cbargs;
351 hfs_libcb_argsopen argsopen;
352 hfs_libcb_argsread argsread;
353 struct hfsmount *hmp;
354 kauth_cred_t cred;
355 int error;
356
357 cred = l ? l->l_cred : NOCRED;
358 error = 0;
359 hmp = NULL;
360
361 /* Create mounted volume structure. */
362 hmp = (struct hfsmount*)malloc(sizeof(struct hfsmount),
363 M_HFSMNT, M_WAITOK);
364 if (hmp == NULL) {
365 error = ENOMEM;
366 goto error;
367 }
368 memset(hmp, 0, sizeof(struct hfsmount));
369
370 mp->mnt_data = hmp;
371 mp->mnt_flag |= MNT_LOCAL;
372 vfs_getnewfsid(mp);
373
374 hmp->hm_mountp = mp;
375 hmp->hm_dev = devvp->v_rdev;
376 hmp->hm_devvp = devvp;
377
378 /*
379 * Use libhfs to open the volume and read the volume header and other
380 * useful information.
381 */
382
383 hfslib_init_cbargs(&cbargs);
384 argsopen.cred = argsread.cred = cred;
385 argsopen.l = argsread.l = l;
386 argsopen.devvp = devvp;
387 cbargs.read = (void*)&argsread;
388 cbargs.openvol = (void*)&argsopen;
389
390 if ((error = hfslib_open_volume(devpath, mp->mnt_flag & MNT_RDONLY,
391 &hmp->hm_vol, &cbargs)) != 0)
392 goto error;
393
394 /* Make sure this is not a journaled volume whose journal is dirty. */
395 if (!hfslib_is_journal_clean(&hmp->hm_vol)) {
396 printf("volume journal is dirty; not mounting\n");
397 error = EIO;
398 goto error;
399 }
400
401 mp->mnt_fs_bshift = 0;
402 while ((1 << mp->mnt_fs_bshift) < hmp->hm_vol.vh.block_size)
403 mp->mnt_fs_bshift++;
404 mp->mnt_dev_bshift = DEV_BSHIFT;
405
406 return 0;
407
408 error:
409 if (hmp != NULL)
410 free(hmp, M_HFSMNT);
411
412 return error;
413 }
414
415 int
416 hfs_unmount(struct mount *mp, int mntflags)
417 {
418 hfs_callback_args cbargs;
419 hfs_libcb_argsread argsclose;
420 struct hfsmount* hmp;
421 int error;
422 int flags;
423
424 #ifdef HFS_DEBUG
425 printf("vfsop = hfs_unmount()\n");
426 #endif /* HFS_DEBUG */
427
428 hmp = VFSTOHFS(mp);
429
430 flags = 0;
431 if (mntflags & MNT_FORCE)
432 flags |= FORCECLOSE;
433
434 if ((error = vflush(mp, NULLVP, flags)) != 0)
435 return error;
436
437 hfslib_init_cbargs(&cbargs);
438 argsclose.l = curlwp;
439 cbargs.closevol = (void*)&argsclose;
440 hfslib_close_volume(&hmp->hm_vol, &cbargs);
441
442 vrele(hmp->hm_devvp);
443
444 free(hmp, M_HFSMNT);
445 mp->mnt_data = NULL;
446 mp->mnt_flag &= ~MNT_LOCAL;
447
448 return error;
449 }
450
451 int
452 hfs_root(struct mount *mp, struct vnode **vpp)
453 {
454 struct vnode *nvp;
455 int error;
456
457 #ifdef HFS_DEBUG
458 printf("vfsop = hfs_root()\n");
459 #endif /* HFS_DEBUG */
460
461 if ((error = VFS_VGET(mp, HFS_CNID_ROOT_FOLDER, &nvp)) != 0)
462 return error;
463 *vpp = nvp;
464
465 return 0;
466 }
467
468 int
469 hfs_statvfs(struct mount *mp, struct statvfs *sbp)
470 {
471 hfs_volume_header_t *vh;
472
473 #ifdef HFS_DEBUG
474 printf("vfsop = hfs_statvfs()\n");
475 #endif /* HFS_DEBUG */
476
477 vh = &VFSTOHFS(mp)->hm_vol.vh;
478
479 sbp->f_bsize = vh->block_size;
480 sbp->f_frsize = sbp->f_bsize;
481 sbp->f_iosize = 4096;/* mac os x uses a 4 kb io size, so do the same */
482 sbp->f_blocks = vh->total_blocks;
483 sbp->f_bfree = vh->free_blocks; /* total free blocks */
484 sbp->f_bavail = vh->free_blocks; /* blocks free for non superuser */
485 sbp->f_bresvd = 0;
486 sbp->f_files = vh->file_count; /* total files */
487 sbp->f_ffree = (1<<31) - vh->file_count; /* free file nodes */
488 copy_statvfs_info(sbp, mp);
489
490 return 0;
491 }
492
493 int
494 hfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred)
495 {
496
497 #ifdef HFS_DEBUG
498 printf("vfsop = hfs_sync()\n");
499 #endif /* HFS_DEBUG */
500
501 return 0;
502 }
503
504 /*
505 * an ino_t corresponds directly to a CNID in our particular case,
506 * since both are conveniently 32-bit numbers
507 */
508 int
509 hfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
510 {
511 int error;
512
513 error = hfs_vget_internal(mp, ino, HFS_DATAFORK, vpp);
514 if (error)
515 return error;
516 error = vn_lock(*vpp, LK_EXCLUSIVE);
517 if (error) {
518 vrele(*vpp);
519 *vpp = NULL;
520 return error;
521 }
522 return 0;
523 }
524
525 /*
526 * internal version with extra arguments to allow accessing resource fork
527 */
528 int
529 hfs_vget_internal(struct mount *mp, ino_t ino, uint8_t fork,
530 struct vnode **vpp)
531 {
532 struct hfsnode_key key;
533
534 memset(&key, 0, sizeof(key));
535 key.hnk_cnid = (hfs_cnid_t)ino;
536 key.hnk_fork = (fork != HFS_RSRCFORK ? HFS_DATAFORK : HFS_RSRCFORK);
537
538 return vcache_get(mp, &key, sizeof(key), vpp);
539 }
540
541 int
542 hfs_loadvnode(struct mount *mp, struct vnode *vp,
543 const void *key, size_t key_len, const void **new_key)
544 {
545 struct hfsmount *hmp;
546 struct hfsnode *hnode;
547 struct hfsnode_key hfskey;
548 hfs_callback_args cbargs;
549 hfs_catalog_keyed_record_t rec;
550 hfs_catalog_key_t cat_key; /* the search key used to find this file on disk */
551 dev_t dev;
552
553 #ifdef HFS_DEBUG
554 printf("vfsop = hfs_loadvnode()\n");
555 #endif /* HFS_DEBUG */
556
557 KASSERT(key_len == sizeof(hfskey));
558 memcpy(&hfskey, key, key_len);
559
560 hmp = VFSTOHFS(mp);
561 dev = hmp->hm_dev;
562
563 hnode = pool_get(&hfs_node_pool, PR_WAITOK);
564 memset(hnode, 0, sizeof(*hnode));
565 hnode->h_vnode = vp;
566 hnode->h_hmp = hmp;
567 hnode->dummy = 0x1337BABE;
568 hnode->h_dev = dev;
569 hnode->h_rec.u.cnid = hfskey.hnk_cnid;
570 hnode->h_fork = hfskey.hnk_fork;
571 hnode->h_key = hfskey;
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, hfskey.hnk_cnid,
579 &rec, &cat_key, &cbargs) != 0) {
580 pool_put(&hfs_node_pool, hnode);
581 return EBADF;
582 }
583
584 memcpy(&hnode->h_rec, &rec, sizeof(hnode->h_rec));
585 hnode->h_parent = cat_key.parent_cnid;
586
587 /* XXX Eventually need to add an "ignore permissions" mount option */
588
589 /*
590 * Now convert some of the catalog record's fields into values that make
591 * sense on this system.
592 */
593 /* DATE AND TIME */
594
595 vp->v_tag = VT_HFS;
596 vp->v_op = hfs_vnodeop_p;
597 vp->v_vflag |= VV_LOCKSWORK;
598 vp->v_data = hnode;
599 genfs_node_init(vp, &hfs_genfsops);
600
601 /*
602 * Initialize the vnode from the hfsnode, check for aliases.
603 */
604 hfs_vinit(mp, hfs_specop_p, hfs_fifoop_p, &vp);
605
606 hnode->h_devvp = hmp->hm_devvp;
607 vref(hnode->h_devvp); /* Increment the ref count to the volume's device. */
608
609 /* Make sure UVM has allocated enough memory. (?) */
610 if (hnode->h_rec.u.rec_type == HFS_REC_FILE) {
611 if (hnode->h_fork == HFS_DATAFORK)
612 uvm_vnp_setsize(vp,
613 hnode->h_rec.file.data_fork.logical_size);
614 else
615 uvm_vnp_setsize(vp,
616 hnode->h_rec.file.rsrc_fork.logical_size);
617 }
618 else
619 uvm_vnp_setsize(vp, 0); /* no directly reading directories */
620
621 *new_key = &hnode->h_key;
622 return 0;
623 }
624
625 int
626 hfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
627 {
628
629 #ifdef HFS_DEBUG
630 printf("vfsop = hfs_fhtovp()\n");
631 #endif /* HFS_DEBUG */
632
633 return EOPNOTSUPP;
634 }
635
636 int
637 hfs_vptofh(struct vnode *vp, struct fid *fhp, size_t *fh_size)
638 {
639
640 #ifdef HFS_DEBUG
641 printf("vfsop = hfs_vptofh()\n");
642 #endif /* HFS_DEBUG */
643
644 return EOPNOTSUPP;
645 }
646
647 void
648 hfs_init(void)
649 {
650 hfs_callbacks callbacks;
651
652 #ifdef HFS_DEBUG
653 printf("vfsop = hfs_init()\n");
654 #endif /* HFS_DEBUG */
655
656 malloc_type_attach(M_HFSMNT);
657 pool_init(&hfs_node_pool, sizeof(struct hfsnode), 0, 0, 0, "hfsndpl",
658 &pool_allocator_nointr, IPL_NONE);
659
660 callbacks.error = hfs_libcb_error;
661 callbacks.allocmem = hfs_libcb_malloc;
662 callbacks.reallocmem = hfs_libcb_realloc;
663 callbacks.freemem = hfs_libcb_free;
664 callbacks.openvol = hfs_libcb_opendev;
665 callbacks.closevol = hfs_libcb_closedev;
666 callbacks.read = hfs_libcb_read;
667
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 pool_destroy(&hfs_node_pool);
693
694 hfslib_done();
695 }
696
697 int
698 hfs_mountroot(void)
699 {
700
701 #ifdef HFS_DEBUG
702 printf("vfsop = hfs_mountroot()\n");
703 #endif /* HFS_DEBUG */
704
705 return EOPNOTSUPP;
706 }
707