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