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