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