1 /* $NetBSD: hfs_vfsops.c,v 1.13 2007/12/08 19:29:43 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.13 2007/12/08 19:29:43 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 sizeof (struct hfs_args), 150 hfs_mount, 151 hfs_start, 152 hfs_unmount, 153 hfs_root, 154 (void *)eopnotsupp, /* vfs_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 vfs_stdextattrctl, 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 { 180 struct lwp *l = curlwp; 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); 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); 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) 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) 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 = curlwp; 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_statvfs(struct mount *mp, struct statvfs *sbp) 460 { 461 hfs_volume_header_t *vh; 462 463 #ifdef HFS_DEBUG 464 printf("vfsop = hfs_statvfs()\n"); 465 #endif /* HFS_DEBUG */ 466 467 vh = &VFSTOHFS(mp)->hm_vol.vh; 468 469 sbp->f_bsize = vh->block_size; 470 sbp->f_frsize = sbp->f_bsize; 471 sbp->f_iosize = 4096;/* mac os x uses a 4 kb io size, so do the same */ 472 sbp->f_blocks = vh->total_blocks; 473 sbp->f_bfree = vh->free_blocks; /* total free blocks */ 474 sbp->f_bavail = vh->free_blocks; /* blocks free for non superuser */ 475 sbp->f_bresvd = 0; 476 sbp->f_files = vh->file_count; /* total files */ 477 sbp->f_ffree = (1<<31) - vh->file_count; /* free file nodes */ 478 copy_statvfs_info(sbp, mp); 479 480 return 0; 481 } 482 483 int 484 hfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred) 485 { 486 487 #ifdef HFS_DEBUG 488 printf("vfsop = hfs_sync()\n"); 489 #endif /* HFS_DEBUG */ 490 491 return 0; 492 } 493 494 /* 495 * an ino_t corresponds directly to a CNID in our particular case, 496 * since both are conveniently 32-bit numbers 497 */ 498 int 499 hfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) 500 { 501 return hfs_vget_internal(mp, ino, HFS_DATAFORK, vpp); 502 } 503 504 /* 505 * internal version with extra arguments to allow accessing resource fork 506 */ 507 int 508 hfs_vget_internal(struct mount *mp, ino_t ino, uint8_t fork, 509 struct vnode **vpp) 510 { 511 struct hfsmount *hmp; 512 struct hfsnode *hnode; 513 struct vnode *vp; 514 hfs_callback_args cbargs; 515 hfs_cnid_t cnid; 516 hfs_catalog_keyed_record_t rec; 517 hfs_catalog_key_t key; /* the search key used to find this file on disk */ 518 dev_t dev; 519 int error; 520 521 #ifdef HFS_DEBUG 522 printf("vfsop = hfs_vget()\n"); 523 #endif /* HFS_DEBUG */ 524 525 hnode = NULL; 526 vp = NULL; 527 hmp = VFSTOHFS(mp); 528 dev = hmp->hm_dev; 529 cnid = (hfs_cnid_t)ino; 530 531 if (fork != HFS_RSRCFORK) 532 fork = HFS_DATAFORK; 533 534 /* Check if this vnode has already been allocated. If so, just return it. */ 535 if ((*vpp = hfs_nhashget(dev, cnid, fork, LK_EXCLUSIVE)) != NULL) 536 return 0; 537 538 /* Allocate a new vnode/inode. */ 539 if ((error = getnewvnode(VT_HFS, mp, hfs_vnodeop_p, &vp)) != 0) 540 goto error; 541 542 /* 543 * If someone beat us to it while sleeping in getnewvnode(), 544 * push back the freshly allocated vnode we don't need, and return. 545 */ 546 547 do { 548 if ((*vpp = hfs_nhashget(dev, cnid, fork, LK_EXCLUSIVE)) 549 != NULL) { 550 ungetnewvnode(vp); 551 return 0; 552 } 553 } while (lockmgr(&hfs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0)); 554 555 vp->v_vflag |= VV_LOCKSWORK; 556 557 MALLOC(hnode, struct hfsnode *, sizeof(struct hfsnode), M_TEMP, 558 M_WAITOK + M_ZERO); 559 vp->v_data = hnode; 560 genfs_node_init(vp, &hfs_genfsops); 561 562 hnode->h_vnode = vp; 563 hnode->h_hmp = hmp; 564 hnode->dummy = 0x1337BABE; 565 566 /* 567 * We need to put this vnode into the hash chain and lock it so that other 568 * requests for this inode will block if they arrive while we are sleeping 569 * waiting for old data structures to be purged or for the contents of the 570 * disk portion of this inode to be read. The hash chain requires the node's 571 * device and cnid to be known. Since this information was passed in the 572 * arguments, fill in the appropriate hfsnode fields without reading having 573 * to read the disk. 574 */ 575 hnode->h_dev = dev; 576 hnode->h_rec.cnid = cnid; 577 hnode->h_fork = fork; 578 579 hfs_nhashinsert(hnode); 580 lockmgr(&hfs_hashlock, LK_RELEASE, 0); 581 582 583 /* 584 * Read catalog record from disk. 585 */ 586 hfslib_init_cbargs(&cbargs); 587 588 if (hfslib_find_catalog_record_with_cnid(&hmp->hm_vol, cnid, 589 &rec, &key, &cbargs) != 0) { 590 vput(vp); 591 error = EBADF; 592 goto error; 593 } 594 595 memcpy(&hnode->h_rec, &rec, sizeof(hnode->h_rec)); 596 hnode->h_parent = key.parent_cnid; 597 598 /* XXX Eventually need to add an "ignore permissions" mount option */ 599 600 /* 601 * Now convert some of the catalog record's fields into values that make 602 * sense on this system. 603 */ 604 /* DATE AND TIME */ 605 606 /* 607 * Initialize the vnode from the hfsnode, check for aliases. 608 * Note that the underlying vnode may change. 609 */ 610 hfs_vinit(mp, hfs_specop_p, hfs_fifoop_p, &vp); 611 612 hnode->h_devvp = hmp->hm_devvp; 613 VREF(hnode->h_devvp); /* Increment the ref count to the volume's device. */ 614 615 /* Make sure UVM has allocated enough memory. (?) */ 616 if (hnode->h_rec.rec_type == HFS_REC_FILE) { 617 if (hnode->h_fork == HFS_DATAFORK) 618 uvm_vnp_setsize(vp, 619 hnode->h_rec.file.data_fork.logical_size); 620 else 621 uvm_vnp_setsize(vp, 622 hnode->h_rec.file.rsrc_fork.logical_size); 623 } 624 else 625 uvm_vnp_setsize(vp, 0); /* no directly reading directories */ 626 627 *vpp = vp; 628 629 return 0; 630 631 error: 632 *vpp = NULL; 633 return error; 634 } 635 636 int 637 hfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) 638 { 639 640 #ifdef HFS_DEBUG 641 printf("vfsop = hfs_fhtovp()\n"); 642 #endif /* HFS_DEBUG */ 643 644 return EOPNOTSUPP; 645 } 646 647 int 648 hfs_vptofh(struct vnode *vp, struct fid *fhp, size_t *fh_size) 649 { 650 651 #ifdef HFS_DEBUG 652 printf("vfsop = hfs_vptofh()\n"); 653 #endif /* HFS_DEBUG */ 654 655 return EOPNOTSUPP; 656 } 657 658 void 659 hfs_init(void) 660 { 661 hfs_callbacks callbacks; 662 663 #ifdef HFS_DEBUG 664 printf("vfsop = hfs_init()\n"); 665 #endif /* HFS_DEBUG */ 666 667 malloc_type_attach(M_HFSMNT); 668 669 callbacks.error = hfs_libcb_error; 670 callbacks.allocmem = hfs_libcb_malloc; 671 callbacks.reallocmem = hfs_libcb_realloc; 672 callbacks.freemem = hfs_libcb_free; 673 callbacks.openvol = hfs_libcb_opendev; 674 callbacks.closevol = hfs_libcb_closedev; 675 callbacks.read = hfs_libcb_read; 676 677 hfs_nhashinit(); 678 hfslib_init(&callbacks); 679 } 680 681 void 682 hfs_reinit(void) 683 { 684 685 #ifdef HFS_DEBUG 686 printf("vfsop = hfs_reinit()\n"); 687 #endif /* HFS_DEBUG */ 688 689 return; 690 } 691 692 void 693 hfs_done(void) 694 { 695 696 #ifdef HFS_DEBUG 697 printf("vfsop = hfs_done()\n"); 698 #endif /* HFS_DEBUG */ 699 700 malloc_type_detach(M_HFSMNT); 701 702 hfslib_done(); 703 hfs_nhashdone(); 704 } 705 706 int 707 hfs_mountroot(void) 708 { 709 710 #ifdef HFS_DEBUG 711 printf("vfsop = hfs_mountroot()\n"); 712 #endif /* HFS_DEBUG */ 713 714 return EOPNOTSUPP; 715 } 716