1 /* $NetBSD: hfs_vfsops.c,v 1.37 2020/02/28 11:27:38 kamil 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.37 2020/02/28 11:27:38 kamil 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/file.h> 119 #include <sys/disklabel.h> 120 #include <sys/ioctl.h> 121 #include <sys/errno.h> 122 #include <sys/malloc.h> 123 #include <sys/pool.h> 124 #include <sys/lock.h> 125 #include <sys/sysctl.h> 126 #include <sys/conf.h> 127 #include <sys/kauth.h> 128 #include <sys/stat.h> 129 #include <sys/module.h> 130 131 #include <miscfs/genfs/genfs.h> 132 #include <miscfs/specfs/specdev.h> 133 134 #include <fs/hfs/hfs.h> 135 #include <fs/hfs/libhfs.h> 136 137 MODULE(MODULE_CLASS_VFS, hfs, NULL); 138 139 MALLOC_JUSTDEFINE(M_HFSMNT, "hfs mount", "hfs mount structures"); 140 141 struct pool hfs_node_pool; 142 143 const struct vnodeopv_desc * const hfs_vnodeopv_descs[] = { 144 &hfs_vnodeop_opv_desc, 145 &hfs_specop_opv_desc, 146 &hfs_fifoop_opv_desc, 147 NULL, 148 }; 149 150 struct vfsops hfs_vfsops = { 151 .vfs_name = MOUNT_HFS, 152 .vfs_min_mount_data = sizeof (struct hfs_args), 153 .vfs_mount = hfs_mount, 154 .vfs_start = hfs_start, 155 .vfs_unmount = hfs_unmount, 156 .vfs_root = hfs_root, 157 .vfs_quotactl = (void *)eopnotsupp, 158 .vfs_statvfs = hfs_statvfs, 159 .vfs_sync = hfs_sync, 160 .vfs_vget = hfs_vget, 161 .vfs_loadvnode = hfs_loadvnode, 162 .vfs_fhtovp = hfs_fhtovp, 163 .vfs_vptofh = hfs_vptofh, 164 .vfs_init = hfs_init, 165 .vfs_reinit = hfs_reinit, 166 .vfs_done = hfs_done, 167 .vfs_extattrctl = vfs_stdextattrctl, 168 .vfs_suspendctl = genfs_suspendctl, 169 .vfs_renamelock_enter = genfs_renamelock_enter, 170 .vfs_renamelock_exit = genfs_renamelock_exit, 171 .vfs_fsync = (void *)eopnotsupp, 172 .vfs_opv_descs = hfs_vnodeopv_descs 173 }; 174 175 static const struct genfs_ops hfs_genfsops = { 176 .gop_size = genfs_size, 177 }; 178 179 static int 180 hfs_modcmd(modcmd_t cmd, void *arg) 181 { 182 switch (cmd) { 183 case MODULE_CMD_INIT: 184 return vfs_attach(&hfs_vfsops); 185 case MODULE_CMD_FINI: 186 return vfs_detach(&hfs_vfsops); 187 default: 188 return ENOTTY; 189 } 190 } 191 192 int 193 hfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len) 194 { 195 struct lwp *l = curlwp; 196 struct hfs_args *args = data; 197 struct vnode *devvp; 198 struct hfsmount *hmp; 199 int error = 0; 200 int update; 201 mode_t accessmode; 202 203 if (args == NULL) 204 return EINVAL; 205 if (*data_len < sizeof *args) 206 return EINVAL; 207 208 #ifdef HFS_DEBUG 209 printf("vfsop = hfs_mount()\n"); 210 #endif /* HFS_DEBUG */ 211 212 if (mp->mnt_flag & MNT_GETARGS) { 213 hmp = VFSTOHFS(mp); 214 if (hmp == NULL) 215 return EIO; 216 args->fspec = NULL; 217 *data_len = sizeof *args; 218 return 0; 219 } 220 221 /* FIXME: For development ONLY - disallow remounting for now */ 222 #if 0 223 update = mp->mnt_flag & MNT_UPDATE; 224 #else 225 update = 0; 226 #endif 227 228 /* Check arguments */ 229 if (args->fspec != NULL) { 230 /* 231 * Look up the name and verify that it's sane. 232 */ 233 error = namei_simple_user(args->fspec, 234 NSM_FOLLOW_NOEMULROOT, &devvp); 235 if (error != 0) 236 return error; 237 238 if (!update) { 239 /* 240 * Be sure this is a valid block device 241 */ 242 if (devvp->v_type != VBLK) 243 error = ENOTBLK; 244 else if (bdevsw_lookup(devvp->v_rdev) == NULL) 245 error = ENXIO; 246 } else { 247 /* 248 * Be sure we're still naming the same device 249 * used for our initial mount 250 */ 251 hmp = VFSTOHFS(mp); 252 if (devvp != hmp->hm_devvp) 253 error = EINVAL; 254 } 255 } else { 256 if (update) { 257 /* Use the extant mount */ 258 hmp = VFSTOHFS(mp); 259 devvp = hmp->hm_devvp; 260 vref(devvp); 261 } else { 262 /* New mounts must have a filename for the device */ 263 return EINVAL; 264 } 265 } 266 267 /* 268 * If mount by non-root, then verify that user has necessary 269 * permissions on the device. 270 * 271 * Permission to update a mount is checked higher, so here we presume 272 * updating the mount is okay (for example, as far as securelevel goes) 273 * which leaves us with the normal check. 274 */ 275 if (error == 0) { 276 accessmode = VREAD; 277 if (update ? 278 (mp->mnt_iflag & IMNT_WANTRDWR) != 0 : 279 (mp->mnt_flag & MNT_RDONLY) == 0) 280 accessmode |= VWRITE; 281 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); 282 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_MOUNT, 283 KAUTH_REQ_SYSTEM_MOUNT_DEVICE, mp, devvp, 284 KAUTH_ARG(accessmode)); 285 VOP_UNLOCK(devvp); 286 } 287 288 if (error != 0) 289 goto error; 290 291 if (update) { 292 printf("HFS: live remounting not yet supported!\n"); 293 error = EINVAL; 294 goto error; 295 } 296 297 if ((error = hfs_mountfs(devvp, mp, l, args->fspec)) != 0) 298 goto error; 299 300 error = set_statvfs_info(path, UIO_USERSPACE, args->fspec, UIO_USERSPACE, 301 mp->mnt_op->vfs_name, mp, l); 302 303 #ifdef HFS_DEBUG 304 if(!update) { 305 char* volname; 306 307 hmp = VFSTOHFS(mp); 308 volname = malloc(hmp->hm_vol.name.length + 1, M_TEMP, M_WAITOK); 309 if (volname == NULL) 310 printf("could not allocate volname; ignored\n"); 311 else { 312 if (hfs_unicode_to_ascii(hmp->hm_vol.name.unicode, 313 hmp->hm_vol.name.length, volname) == NULL) 314 printf("could not convert volume name to ascii; ignored\n"); 315 else 316 printf("mounted volume \"%s\"\n", volname); 317 free(volname, M_TEMP); 318 } 319 } 320 #endif /* HFS_DEBUG */ 321 322 return error; 323 324 error: 325 vrele(devvp); 326 return error; 327 } 328 329 int 330 hfs_start(struct mount *mp, int flags) 331 { 332 #ifdef HFS_DEBUG 333 printf("vfsop = hfs_start()\n"); 334 #endif /* HFS_DEBUG */ 335 336 return 0; 337 } 338 339 int 340 hfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l, 341 const char *devpath) 342 { 343 hfs_callback_args cbargs; 344 hfs_libcb_argsopen argsopen; 345 hfs_libcb_argsread argsread; 346 struct hfsmount *hmp; 347 kauth_cred_t cred; 348 int error; 349 350 cred = l ? l->l_cred : NOCRED; 351 error = 0; 352 hmp = NULL; 353 354 /* Create mounted volume structure. */ 355 hmp = malloc(sizeof(struct hfsmount), M_HFSMNT, M_WAITOK|M_ZERO); 356 if (hmp == NULL) { 357 error = ENOMEM; 358 goto error; 359 } 360 361 mp->mnt_data = hmp; 362 mp->mnt_flag |= MNT_LOCAL; 363 vfs_getnewfsid(mp); 364 365 hmp->hm_mountp = mp; 366 hmp->hm_dev = devvp->v_rdev; 367 hmp->hm_devvp = devvp; 368 369 /* 370 * Use libhfs to open the volume and read the volume header and other 371 * useful information. 372 */ 373 374 hfslib_init_cbargs(&cbargs); 375 argsopen.cred = argsread.cred = cred; 376 argsopen.l = argsread.l = l; 377 argsopen.devvp = devvp; 378 cbargs.read = (void*)&argsread; 379 cbargs.openvol = (void*)&argsopen; 380 381 if ((error = hfslib_open_volume(devpath, mp->mnt_flag & MNT_RDONLY, 382 &hmp->hm_vol, &cbargs)) != 0) 383 goto error; 384 385 /* Make sure this is not a journaled volume whose journal is dirty. */ 386 if (!hfslib_is_journal_clean(&hmp->hm_vol)) { 387 printf("volume journal is dirty; not mounting\n"); 388 error = EIO; 389 goto error; 390 } 391 392 mp->mnt_fs_bshift = 0; 393 while ((1 << mp->mnt_fs_bshift) < hmp->hm_vol.vh.block_size) 394 mp->mnt_fs_bshift++; 395 mp->mnt_dev_bshift = DEV_BSHIFT; 396 397 return 0; 398 399 error: 400 if (hmp != NULL) 401 free(hmp, M_HFSMNT); 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 vrele(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, int lktype, 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, lktype, &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 = (1U<<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 #ifdef HFS_DEBUG 487 printf("vfsop = hfs_sync()\n"); 488 #endif /* HFS_DEBUG */ 489 490 return 0; 491 } 492 493 /* 494 * an ino_t corresponds directly to a CNID in our particular case, 495 * since both are conveniently 32-bit numbers 496 */ 497 int 498 hfs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) 499 { 500 int error; 501 502 error = hfs_vget_internal(mp, ino, HFS_DATAFORK, vpp); 503 if (error) 504 return error; 505 error = vn_lock(*vpp, lktype); 506 if (error) { 507 vrele(*vpp); 508 *vpp = NULL; 509 return error; 510 } 511 return 0; 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 hfsnode_key key; 522 523 memset(&key, 0, sizeof(key)); 524 key.hnk_cnid = (hfs_cnid_t)ino; 525 key.hnk_fork = (fork != HFS_RSRCFORK ? HFS_DATAFORK : HFS_RSRCFORK); 526 527 return vcache_get(mp, &key, sizeof(key), vpp); 528 } 529 530 int 531 hfs_loadvnode(struct mount *mp, struct vnode *vp, 532 const void *key, size_t key_len, const void **new_key) 533 { 534 struct hfsmount *hmp; 535 struct hfsnode *hnode; 536 struct hfsnode_key hfskey; 537 hfs_callback_args cbargs; 538 hfs_catalog_keyed_record_t rec; 539 hfs_catalog_key_t cat_key; /* the search key used to find this file on disk */ 540 dev_t dev; 541 542 #ifdef HFS_DEBUG 543 printf("vfsop = hfs_loadvnode()\n"); 544 #endif /* HFS_DEBUG */ 545 546 KASSERT(key_len == sizeof(hfskey)); 547 memcpy(&hfskey, key, key_len); 548 549 hmp = VFSTOHFS(mp); 550 dev = hmp->hm_dev; 551 552 hnode = pool_get(&hfs_node_pool, PR_WAITOK); 553 memset(hnode, 0, sizeof(*hnode)); 554 hnode->h_vnode = vp; 555 hnode->h_hmp = hmp; 556 hnode->dummy = 0x1337BABE; 557 hnode->h_dev = dev; 558 hnode->h_rec.u.cnid = hfskey.hnk_cnid; 559 hnode->h_fork = hfskey.hnk_fork; 560 hnode->h_key = hfskey; 561 562 /* 563 * Read catalog record from disk. 564 */ 565 hfslib_init_cbargs(&cbargs); 566 567 if (hfslib_find_catalog_record_with_cnid(&hmp->hm_vol, hfskey.hnk_cnid, 568 &rec, &cat_key, &cbargs) != 0) { 569 pool_put(&hfs_node_pool, hnode); 570 return EBADF; 571 } 572 573 memcpy(&hnode->h_rec, &rec, sizeof(hnode->h_rec)); 574 hnode->h_parent = cat_key.parent_cnid; 575 576 /* XXX Eventually need to add an "ignore permissions" mount option */ 577 578 /* 579 * Now convert some of the catalog record's fields into values that make 580 * sense on this system. 581 */ 582 /* DATE AND TIME */ 583 584 vp->v_tag = VT_HFS; 585 vp->v_op = hfs_vnodeop_p; 586 vp->v_vflag |= VV_LOCKSWORK; 587 vp->v_data = hnode; 588 genfs_node_init(vp, &hfs_genfsops); 589 590 /* 591 * Initialize the vnode from the hfsnode, check for aliases. 592 */ 593 hfs_vinit(mp, hfs_specop_p, hfs_fifoop_p, &vp); 594 595 hnode->h_devvp = hmp->hm_devvp; 596 vref(hnode->h_devvp); /* Increment the ref count to the volume's device. */ 597 598 /* Make sure UVM has allocated enough memory. (?) */ 599 if (hnode->h_rec.u.rec_type == HFS_REC_FILE) { 600 if (hnode->h_fork == HFS_DATAFORK) 601 uvm_vnp_setsize(vp, 602 hnode->h_rec.file.data_fork.logical_size); 603 else 604 uvm_vnp_setsize(vp, 605 hnode->h_rec.file.rsrc_fork.logical_size); 606 } 607 else 608 uvm_vnp_setsize(vp, 0); /* no directly reading directories */ 609 610 *new_key = &hnode->h_key; 611 return 0; 612 } 613 614 int 615 hfs_fhtovp(struct mount *mp, struct fid *fhp, int lktype, struct vnode **vpp) 616 { 617 618 #ifdef HFS_DEBUG 619 printf("vfsop = hfs_fhtovp()\n"); 620 #endif /* HFS_DEBUG */ 621 622 return EOPNOTSUPP; 623 } 624 625 int 626 hfs_vptofh(struct vnode *vp, struct fid *fhp, size_t *fh_size) 627 { 628 #ifdef HFS_DEBUG 629 printf("vfsop = hfs_vptofh()\n"); 630 #endif /* HFS_DEBUG */ 631 632 return EOPNOTSUPP; 633 } 634 635 void 636 hfs_init(void) 637 { 638 hfs_callbacks callbacks; 639 640 #ifdef HFS_DEBUG 641 printf("vfsop = hfs_init()\n"); 642 #endif /* HFS_DEBUG */ 643 644 malloc_type_attach(M_HFSMNT); 645 pool_init(&hfs_node_pool, sizeof(struct hfsnode), 0, 0, 0, "hfsndpl", 646 &pool_allocator_nointr, IPL_NONE); 647 648 callbacks.error = hfs_libcb_error; 649 callbacks.allocmem = hfs_libcb_malloc; 650 callbacks.reallocmem = hfs_libcb_realloc; 651 callbacks.freemem = hfs_libcb_free; 652 callbacks.openvol = hfs_libcb_opendev; 653 callbacks.closevol = hfs_libcb_closedev; 654 callbacks.read = hfs_libcb_read; 655 656 hfslib_init(&callbacks); 657 } 658 659 void 660 hfs_reinit(void) 661 { 662 #ifdef HFS_DEBUG 663 printf("vfsop = hfs_reinit()\n"); 664 #endif /* HFS_DEBUG */ 665 666 return; 667 } 668 669 void 670 hfs_done(void) 671 { 672 #ifdef HFS_DEBUG 673 printf("vfsop = hfs_done()\n"); 674 #endif /* HFS_DEBUG */ 675 676 malloc_type_detach(M_HFSMNT); 677 pool_destroy(&hfs_node_pool); 678 hfslib_done(); 679 } 680 681 int 682 hfs_mountroot(void) 683 { 684 #ifdef HFS_DEBUG 685 printf("vfsop = hfs_mountroot()\n"); 686 #endif /* HFS_DEBUG */ 687 688 return EOPNOTSUPP; 689 } 690