hfs_vfsops.c revision 1.2 1 /* $NetBSD: hfs_vfsops.c,v 1.2 2007/03/06 11:28:48 dillo 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.2 2007/03/06 11:28:48 dillo 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_DEFINE(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, args.offset)) != 0)
291 goto error;
292
293 error = set_statvfs_info(path, UIO_USERSPACE, args.fspec, UIO_SYSSPACE,
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, uint64_t offset)
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, offset, 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 hmp->offset = offset >> DEV_BSHIFT;
389 mp->mnt_fs_bshift = 0;
390 while ((1 << mp->mnt_fs_bshift) < hmp->hm_vol.vh.block_size)
391 mp->mnt_fs_bshift++;
392 mp->mnt_dev_bshift = DEV_BSHIFT;
393
394 return 0;
395
396 error:
397 if (hmp != NULL)
398 free(hmp, M_HFSMNT);
399
400 return error;
401 }
402
403 int
404 hfs_unmount(struct mount *mp, int mntflags, struct lwp *l)
405 {
406 hfs_callback_args cbargs;
407 hfs_libcb_argsread argsclose;
408 struct hfsmount* hmp;
409 int error;
410 int flags;
411
412 #ifdef HFS_DEBUG
413 printf("vfsop = hfs_unmount()\n");
414 #endif /* HFS_DEBUG */
415
416 hmp = VFSTOHFS(mp);
417
418 flags = 0;
419 if (mntflags & MNT_FORCE)
420 flags |= FORCECLOSE;
421
422 if ((error = vflush(mp, NULLVP, flags)) != 0)
423 return error;
424
425 hfslib_init_cbargs(&cbargs);
426 argsclose.l = l;
427 cbargs.closevol = (void*)&argsclose;
428 hfslib_close_volume(&hmp->hm_vol, &cbargs);
429
430 vput(hmp->hm_devvp);
431
432 free(hmp, M_HFSMNT);
433 mp->mnt_data = NULL;
434 mp->mnt_flag &= ~MNT_LOCAL;
435
436 return error;
437 }
438
439 int
440 hfs_root(struct mount *mp, struct vnode **vpp)
441 {
442 struct vnode *nvp;
443 int error;
444
445 #ifdef HFS_DEBUG
446 printf("vfsop = hfs_root()\n");
447 #endif /* HFS_DEBUG */
448
449 if ((error = VFS_VGET(mp, HFS_CNID_ROOT_FOLDER, &nvp)) != 0)
450 return error;
451 *vpp = nvp;
452
453 return 0;
454 }
455
456 int
457 hfs_quotactl(struct mount *mp, int cmds, uid_t uid, void *arg,
458 struct lwp *l)
459 {
460
461 #ifdef HFS_DEBUG
462 printf("vfsop = hfs_quotactl()\n");
463 #endif /* HFS_DEBUG */
464
465 return EOPNOTSUPP;
466 }
467
468 int
469 hfs_statvfs(struct mount *mp, struct statvfs *sbp, struct lwp *l)
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, struct lwp *l)
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 return hfs_vget_internal(mp, ino, HFS_DATAFORK, vpp);
512 }
513
514 /*
515 * internal version with extra arguments to allow accessing resource fork
516 */
517 int
518 hfs_vget_internal(struct mount *mp, ino_t ino, uint8_t fork,
519 struct vnode **vpp)
520 {
521 struct hfsmount *hmp;
522 struct hfsnode *hnode;
523 struct vnode *vp;
524 hfs_callback_args cbargs;
525 hfs_cnid_t cnid;
526 hfs_catalog_keyed_record_t rec;
527 hfs_catalog_key_t key; /* the search key used to find this file on disk */
528 dev_t dev;
529 int error;
530
531 #ifdef HFS_DEBUG
532 printf("vfsop = hfs_vget()\n");
533 #endif /* HFS_DEBUG */
534
535 hnode = NULL;
536 vp = NULL;
537 hmp = VFSTOHFS(mp);
538 dev = hmp->hm_dev;
539 cnid = (hfs_cnid_t)ino;
540
541 if (fork != HFS_RSRCFORK)
542 fork = HFS_DATAFORK;
543
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)
546 return 0;
547
548 /* Allocate a new vnode/inode. */
549 if ((error = getnewvnode(VT_HFS, mp, hfs_vnodeop_p, &vp)) != 0)
550 goto error;
551
552 /*
553 * If someone beat us to it while sleeping in getnewvnode(),
554 * push back the freshly allocated vnode we don't need, and return.
555 */
556
557 do {
558 if ((*vpp = hfs_nhashget(dev, cnid, fork, LK_EXCLUSIVE))
559 != NULL) {
560 ungetnewvnode(vp);
561 return 0;
562 }
563 } while (lockmgr(&hfs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0));
564
565 vp->v_flag |= VLOCKSWORK;
566
567 MALLOC(hnode, struct hfsnode *, sizeof(struct hfsnode), M_TEMP,
568 M_WAITOK + M_ZERO);
569 vp->v_data = hnode;
570
571 hnode->h_vnode = vp;
572 hnode->h_hmp = hmp;
573 hnode->dummy = 0x1337BABE;
574
575 /*
576 * We need to put this vnode into the hash chain and lock it so that other
577 * requests for this inode will block if they arrive while we are sleeping
578 * waiting for old data structures to be purged or for the contents of the
579 * disk portion of this inode to be read. The hash chain requires the node's
580 * device and cnid to be known. Since this information was passed in the
581 * arguments, fill in the appropriate hfsnode fields without reading having
582 * to read the disk.
583 */
584 hnode->h_dev = dev;
585 hnode->h_rec.cnid = cnid;
586 hnode->h_fork = fork;
587
588 hfs_nhashinsert(hnode);
589 lockmgr(&hfs_hashlock, LK_RELEASE, 0);
590
591
592 /*
593 * Read catalog record from disk.
594 */
595 hfslib_init_cbargs(&cbargs);
596
597 if (hfslib_find_catalog_record_with_cnid(&hmp->hm_vol, cnid,
598 &rec, &key, &cbargs) != 0) {
599 vput(vp);
600 error = EBADF;
601 goto error;
602 }
603
604 memcpy(&hnode->h_rec, &rec, sizeof(hnode->h_rec));
605 hnode->h_parent = key.parent_cnid;
606
607 /* XXX Eventually need to add an "ignore permissions" mount option */
608
609 /*
610 * Now convert some of the catalog record's fields into values that make
611 * sense on this system.
612 */
613 /* DATE AND TIME */
614
615 /*
616 * Initialize the vnode from the hfsnode, check for aliases.
617 * Note that the underlying vnode may have changed.
618 */
619
620 hfs_vinit(mp, hfs_specop_p, hfs_fifoop_p, &vp);
621
622 genfs_node_init(vp, &hfs_genfsops);
623 hnode->h_devvp = hmp->hm_devvp;
624 VREF(hnode->h_devvp); /* Increment the ref count to the volume's device. */
625
626 /* Make sure UVM has allocated enough memory. (?) */
627 if (hnode->h_rec.rec_type == HFS_REC_FILE) {
628 if (hnode->h_fork == HFS_DATAFORK)
629 uvm_vnp_setsize(vp,
630 hnode->h_rec.file.data_fork.logical_size);
631 else
632 uvm_vnp_setsize(vp,
633 hnode->h_rec.file.rsrc_fork.logical_size);
634 }
635 else
636 uvm_vnp_setsize(vp, 0); /* no directly reading directories */
637
638 *vpp = vp;
639
640 return 0;
641
642 error:
643 *vpp = NULL;
644 return error;
645 }
646
647 int
648 hfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
649 {
650
651 #ifdef HFS_DEBUG
652 printf("vfsop = hfs_fhtovp()\n");
653 #endif /* HFS_DEBUG */
654
655 return EOPNOTSUPP;
656 }
657
658 int
659 hfs_vptofh(struct vnode *vp, struct fid *fhp, size_t *fh_size)
660 {
661
662 #ifdef HFS_DEBUG
663 printf("vfsop = hfs_vptofh()\n");
664 #endif /* HFS_DEBUG */
665
666 return EOPNOTSUPP;
667 }
668
669 void
670 hfs_init(void)
671 {
672 hfs_callbacks callbacks;
673
674 #ifdef HFS_DEBUG
675 printf("vfsop = hfs_init()\n");
676 #endif /* HFS_DEBUG */
677
678 #ifdef _LKM
679 malloc_type_attach(M_HFSMNT);
680 #endif
681
682 callbacks.error = hfs_libcb_error;
683 callbacks.allocmem = hfs_libcb_malloc;
684 callbacks.reallocmem = hfs_libcb_realloc;
685 callbacks.freemem = hfs_libcb_free;
686 callbacks.openvol = hfs_libcb_opendev;
687 callbacks.closevol = hfs_libcb_closedev;
688 callbacks.read = hfs_libcb_read;
689
690 hfs_nhashinit();
691 hfslib_init(&callbacks);
692 }
693
694 void
695 hfs_reinit(void)
696 {
697
698 #ifdef HFS_DEBUG
699 printf("vfsop = hfs_reinit()\n");
700 #endif /* HFS_DEBUG */
701
702 return;
703 }
704
705 void
706 hfs_done(void)
707 {
708
709 #ifdef HFS_DEBUG
710 printf("vfsop = hfs_done()\n");
711 #endif /* HFS_DEBUG */
712
713 #ifdef _LKM
714 malloc_type_detach(M_HFSMNT);
715 #endif
716
717 hfslib_done();
718 hfs_nhashdone();
719 }
720
721 int
722 hfs_mountroot(void)
723 {
724
725 #ifdef HFS_DEBUG
726 printf("vfsop = hfs_mountroot()\n");
727 #endif /* HFS_DEBUG */
728
729 return EOPNOTSUPP;
730 }
731
732 int hfs_extattrctl(struct mount *mp, int cmd, struct vnode *vp,
733 int attrnamespace, const char *attrname, struct lwp *l)
734 {
735
736 #ifdef HFS_DEBUG
737 printf("vfsop = hfs_checkexp()\n");
738 #endif /* HFS_DEBUG */
739
740 return EOPNOTSUPP;
741 }
742