109 ma = mount_argsu(ma, "cs_disk", args.cs_disk, 64); 110 ma = mount_argsu(ma, "cs_local", args.cs_local, 64); 111 ma = mount_argf(ma, "ssector", "%u", args.ssector); 112 ma = mount_argb(ma, !(args.flags & ISOFSMNT_NORRIP), "norrip"); 113 ma = mount_argb(ma, args.flags & ISOFSMNT_GENS, "nogens"); 114 ma = mount_argb(ma, args.flags & ISOFSMNT_EXTATT, "noextatt"); 115 ma = mount_argb(ma, !(args.flags & ISOFSMNT_NOJOLIET), "nojoliet"); 116 ma = mount_argb(ma, 117 args.flags & ISOFSMNT_BROKENJOLIET, "nobrokenjoliet"); 118 ma = mount_argb(ma, args.flags & ISOFSMNT_KICONV, "nokiconv"); 119 120 error = kernel_mount(ma, flags); 121 122 return (error); 123} 124 125static int 126cd9660_mount(struct mount *mp) 127{ 128 struct vnode *devvp; 129 struct thread *td; 130 char *fspec; 131 int error; 132 accmode_t accmode; 133 struct nameidata ndp; 134 struct iso_mnt *imp = 0; 135 136 td = curthread; 137 138 /* 139 * Unconditionally mount as read-only. 140 */ 141 MNT_ILOCK(mp); 142 mp->mnt_flag |= MNT_RDONLY; 143 MNT_IUNLOCK(mp); 144 145 fspec = vfs_getopts(mp->mnt_optnew, "from", &error); 146 if (error) 147 return (error); 148 149 imp = VFSTOISOFS(mp); 150 151 if (mp->mnt_flag & MNT_UPDATE) { 152 if (vfs_flagopt(mp->mnt_optnew, "export", NULL, 0)) 153 return (0); 154 } 155 /* 156 * Not an update, or updating the name: look up the name 157 * and verify that it refers to a sensible block device. 158 */ 159 NDINIT(&ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, fspec, td); 160 if ((error = namei(&ndp))) 161 return (error); 162 NDFREE(&ndp, NDF_ONLY_PNBUF); 163 devvp = ndp.ni_vp; 164 165 if (!vn_isdisk(devvp, &error)) { 166 vput(devvp); 167 return (error); 168 } 169 170 /* 171 * Verify that user has necessary permissions on the device, 172 * or has superuser abilities 173 */ 174 accmode = VREAD; 175 error = VOP_ACCESS(devvp, accmode, td->td_ucred, td); 176 if (error) 177 error = priv_check(td, PRIV_VFS_MOUNT_PERM); 178 if (error) { 179 vput(devvp); 180 return (error); 181 } 182 183 if ((mp->mnt_flag & MNT_UPDATE) == 0) { 184 error = iso_mountfs(devvp, mp); 185 if (error) 186 vrele(devvp); 187 } else { 188 if (devvp != imp->im_devvp) 189 error = EINVAL; /* needs translation */ 190 vput(devvp); 191 } 192 if (error) 193 return (error); 194 vfs_mountedfrom(mp, fspec); 195 return (0); 196} 197 198/* 199 * Common code for mount and mountroot 200 */ 201static int 202iso_mountfs(devvp, mp) 203 struct vnode *devvp; 204 struct mount *mp; 205{ 206 struct iso_mnt *isomp = (struct iso_mnt *)0; 207 struct buf *bp = NULL; 208 struct buf *pribp = NULL, *supbp = NULL; 209 struct cdev *dev; 210 int error = EINVAL; 211 int high_sierra = 0; 212 int iso_bsize; 213 int iso_blknum; 214 int joliet_level; 215 struct iso_volume_descriptor *vdp = 0; 216 struct iso_primary_descriptor *pri = NULL; 217 struct iso_sierra_primary_descriptor *pri_sierra = NULL; 218 struct iso_supplementary_descriptor *sup = NULL; 219 struct iso_directory_record *rootp; 220 int logical_block_size, ssector; 221 struct g_consumer *cp; 222 struct bufobj *bo; 223 char *cs_local, *cs_disk; 224 225 dev = devvp->v_rdev; 226 dev_ref(dev); 227 DROP_GIANT(); 228 g_topology_lock(); 229 error = g_vfs_open(devvp, &cp, "cd9660", 0); 230 g_topology_unlock(); 231 PICKUP_GIANT(); 232 VOP_UNLOCK(devvp, 0); 233 if (error) 234 goto out; 235 if (devvp->v_rdev->si_iosize_max != 0) 236 mp->mnt_iosize_max = devvp->v_rdev->si_iosize_max; 237 if (mp->mnt_iosize_max > MAXPHYS) 238 mp->mnt_iosize_max = MAXPHYS; 239 240 bo = &devvp->v_bufobj; 241 242 /* This is the "logical sector size". The standard says this 243 * should be 2048 or the physical sector size on the device, 244 * whichever is greater. 245 */ 246 if ((ISO_DEFAULT_BLOCK_SIZE % cp->provider->sectorsize) != 0) { 247 error = EINVAL; 248 goto out; 249 } 250 251 iso_bsize = cp->provider->sectorsize; 252 253 joliet_level = 0; 254 if (1 != vfs_scanopt(mp->mnt_optnew, "ssector", "%d", &ssector)) 255 ssector = 0; 256 for (iso_blknum = 16 + ssector; 257 iso_blknum < 100 + ssector; 258 iso_blknum++) { 259 if ((error = bread(devvp, iso_blknum * btodb(ISO_DEFAULT_BLOCK_SIZE), 260 iso_bsize, NOCRED, &bp)) != 0) 261 goto out; 262 263 vdp = (struct iso_volume_descriptor *)bp->b_data; 264 if (bcmp (vdp->id, ISO_STANDARD_ID, sizeof vdp->id) != 0) { 265 if (bcmp (vdp->id_sierra, ISO_SIERRA_ID, 266 sizeof vdp->id_sierra) != 0) { 267 error = EINVAL; 268 goto out; 269 } else 270 high_sierra = 1; 271 } 272 switch (isonum_711 (high_sierra? vdp->type_sierra: vdp->type)){ 273 case ISO_VD_PRIMARY: 274 if (pribp == NULL) { 275 pribp = bp; 276 bp = NULL; 277 pri = (struct iso_primary_descriptor *)vdp; 278 pri_sierra = 279 (struct iso_sierra_primary_descriptor *)vdp; 280 } 281 break; 282 283 case ISO_VD_SUPPLEMENTARY: 284 if (supbp == NULL) { 285 supbp = bp; 286 bp = NULL; 287 sup = (struct iso_supplementary_descriptor *)vdp; 288 289 if (!vfs_flagopt(mp->mnt_optnew, "nojoliet", NULL, 0)) { 290 if (bcmp(sup->escape, "%/@", 3) == 0) 291 joliet_level = 1; 292 if (bcmp(sup->escape, "%/C", 3) == 0) 293 joliet_level = 2; 294 if (bcmp(sup->escape, "%/E", 3) == 0) 295 joliet_level = 3; 296 297 if ((isonum_711 (sup->flags) & 1) && 298 !vfs_flagopt(mp->mnt_optnew, "brokenjoliet", NULL, 0)) 299 joliet_level = 0; 300 } 301 } 302 break; 303 304 case ISO_VD_END: 305 goto vd_end; 306 307 default: 308 break; 309 } 310 if (bp) { 311 brelse(bp); 312 bp = NULL; 313 } 314 } 315 vd_end: 316 if (bp) { 317 brelse(bp); 318 bp = NULL; 319 } 320 321 if (pri == NULL) { 322 error = EINVAL; 323 goto out; 324 } 325 326 logical_block_size = 327 isonum_723 (high_sierra? 328 pri_sierra->logical_block_size: 329 pri->logical_block_size); 330 331 if (logical_block_size < DEV_BSIZE || logical_block_size > MAXBSIZE 332 || (logical_block_size & (logical_block_size - 1)) != 0) { 333 error = EINVAL; 334 goto out; 335 } 336 337 rootp = (struct iso_directory_record *) 338 (high_sierra? 339 pri_sierra->root_directory_record: 340 pri->root_directory_record); 341 342 isomp = malloc(sizeof *isomp, M_ISOFSMNT, M_WAITOK | M_ZERO); 343 isomp->im_cp = cp; 344 isomp->im_bo = bo; 345 isomp->logical_block_size = logical_block_size; 346 isomp->volume_space_size = 347 isonum_733 (high_sierra? 348 pri_sierra->volume_space_size: 349 pri->volume_space_size); 350 isomp->joliet_level = 0; 351 /* 352 * Since an ISO9660 multi-session CD can also access previous 353 * sessions, we have to include them into the space consider- 354 * ations. This doesn't yield a very accurate number since 355 * parts of the old sessions might be inaccessible now, but we 356 * can't do much better. This is also important for the NFS 357 * filehandle validation. 358 */ 359 isomp->volume_space_size += ssector; 360 bcopy (rootp, isomp->root, sizeof isomp->root); 361 isomp->root_extent = isonum_733 (rootp->extent); 362 isomp->root_size = isonum_733 (rootp->size); 363 364 isomp->im_bmask = logical_block_size - 1; 365 isomp->im_bshift = ffs(logical_block_size) - 1; 366 367 pribp->b_flags |= B_AGE; 368 brelse(pribp); 369 pribp = NULL; 370 371 mp->mnt_data = isomp; 372 mp->mnt_stat.f_fsid.val[0] = dev2udev(dev); 373 mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum; 374 mp->mnt_maxsymlinklen = 0; 375 MNT_ILOCK(mp); 376 mp->mnt_flag |= MNT_LOCAL; 377 mp->mnt_kern_flag |= MNTK_MPSAFE | MNTK_LOOKUP_SHARED | 378 MNTK_EXTENDED_SHARED; 379 MNT_IUNLOCK(mp); 380 isomp->im_mountp = mp; 381 isomp->im_dev = dev; 382 isomp->im_devvp = devvp; 383 384 vfs_flagopt(mp->mnt_optnew, "norrip", &isomp->im_flags, ISOFSMNT_NORRIP); 385 vfs_flagopt(mp->mnt_optnew, "gens", &isomp->im_flags, ISOFSMNT_GENS); 386 vfs_flagopt(mp->mnt_optnew, "extatt", &isomp->im_flags, ISOFSMNT_EXTATT); 387 vfs_flagopt(mp->mnt_optnew, "nojoliet", &isomp->im_flags, ISOFSMNT_NOJOLIET); 388 vfs_flagopt(mp->mnt_optnew, "kiconv", &isomp->im_flags, ISOFSMNT_KICONV); 389 390 /* Check the Rock Ridge Extension support */ 391 if (!(isomp->im_flags & ISOFSMNT_NORRIP)) { 392 if ((error = bread(isomp->im_devvp, 393 (isomp->root_extent + isonum_711(rootp->ext_attr_length)) << 394 (isomp->im_bshift - DEV_BSHIFT), 395 isomp->logical_block_size, NOCRED, &bp)) != 0) 396 goto out; 397 398 rootp = (struct iso_directory_record *)bp->b_data; 399 400 if ((isomp->rr_skip = cd9660_rrip_offset(rootp,isomp)) < 0) { 401 isomp->im_flags |= ISOFSMNT_NORRIP; 402 } else { 403 isomp->im_flags &= ~ISOFSMNT_GENS; 404 } 405 406 /* 407 * The contents are valid, 408 * but they will get reread as part of another vnode, so... 409 */ 410 bp->b_flags |= B_AGE; 411 brelse(bp); 412 bp = NULL; 413 } 414 415 if (isomp->im_flags & ISOFSMNT_KICONV && cd9660_iconv) { 416 cs_local = vfs_getopts(mp->mnt_optnew, "cs_local", &error); 417 if (error) 418 goto out; 419 cs_disk = vfs_getopts(mp->mnt_optnew, "cs_disk", &error); 420 if (error) 421 goto out; 422 cd9660_iconv->open(cs_local, cs_disk, &isomp->im_d2l); 423 cd9660_iconv->open(cs_disk, cs_local, &isomp->im_l2d); 424 } else { 425 isomp->im_d2l = NULL; 426 isomp->im_l2d = NULL; 427 } 428 429 if (high_sierra) { 430 /* this effectively ignores all the mount flags */ 431 if (bootverbose) 432 log(LOG_INFO, "cd9660: High Sierra Format\n"); 433 isomp->iso_ftype = ISO_FTYPE_HIGH_SIERRA; 434 } else 435 switch (isomp->im_flags&(ISOFSMNT_NORRIP|ISOFSMNT_GENS)) { 436 default: 437 isomp->iso_ftype = ISO_FTYPE_DEFAULT; 438 break; 439 case ISOFSMNT_GENS|ISOFSMNT_NORRIP: 440 isomp->iso_ftype = ISO_FTYPE_9660; 441 break; 442 case 0: 443 if (bootverbose) 444 log(LOG_INFO, "cd9660: RockRidge Extension\n"); 445 isomp->iso_ftype = ISO_FTYPE_RRIP; 446 break; 447 } 448 449 /* Decide whether to use the Joliet descriptor */ 450 451 if (isomp->iso_ftype != ISO_FTYPE_RRIP && joliet_level) { 452 if (bootverbose) 453 log(LOG_INFO, "cd9660: Joliet Extension (Level %d)\n", 454 joliet_level); 455 rootp = (struct iso_directory_record *) 456 sup->root_directory_record; 457 bcopy (rootp, isomp->root, sizeof isomp->root); 458 isomp->root_extent = isonum_733 (rootp->extent); 459 isomp->root_size = isonum_733 (rootp->size); 460 isomp->joliet_level = joliet_level; 461 supbp->b_flags |= B_AGE; 462 } 463 464 if (supbp) { 465 brelse(supbp); 466 supbp = NULL; 467 } 468 469 return 0; 470out: 471 if (bp) 472 brelse(bp); 473 if (pribp) 474 brelse(pribp); 475 if (supbp) 476 brelse(supbp); 477 if (cp != NULL) { 478 DROP_GIANT(); 479 g_topology_lock(); 480 g_vfs_close(cp); 481 g_topology_unlock(); 482 PICKUP_GIANT(); 483 } 484 if (isomp) { 485 free((caddr_t)isomp, M_ISOFSMNT); 486 mp->mnt_data = NULL; 487 } 488 dev_rel(dev); 489 return error; 490} 491 492/* 493 * unmount system call 494 */ 495static int 496cd9660_unmount(mp, mntflags) 497 struct mount *mp; 498 int mntflags; 499{ 500 struct iso_mnt *isomp; 501 int error, flags = 0; 502 503 if (mntflags & MNT_FORCE) 504 flags |= FORCECLOSE; 505 if ((error = vflush(mp, 0, flags, curthread))) 506 return (error); 507 508 isomp = VFSTOISOFS(mp); 509 510 if (isomp->im_flags & ISOFSMNT_KICONV && cd9660_iconv) { 511 if (isomp->im_d2l) 512 cd9660_iconv->close(isomp->im_d2l); 513 if (isomp->im_l2d) 514 cd9660_iconv->close(isomp->im_l2d); 515 } 516 DROP_GIANT(); 517 g_topology_lock(); 518 g_vfs_close(isomp->im_cp); 519 g_topology_unlock(); 520 PICKUP_GIANT(); 521 vrele(isomp->im_devvp); 522 dev_rel(isomp->im_dev); 523 free((caddr_t)isomp, M_ISOFSMNT); 524 mp->mnt_data = NULL; 525 MNT_ILOCK(mp); 526 mp->mnt_flag &= ~MNT_LOCAL; 527 MNT_IUNLOCK(mp); 528 return (error); 529} 530 531/* 532 * Return root of a filesystem 533 */ 534static int 535cd9660_root(mp, flags, vpp) 536 struct mount *mp; 537 int flags; 538 struct vnode **vpp; 539{ 540 struct iso_mnt *imp = VFSTOISOFS(mp); 541 struct iso_directory_record *dp = 542 (struct iso_directory_record *)imp->root; 543 ino_t ino = isodirino(dp, imp); 544 545 /* 546 * With RRIP we must use the `.' entry of the root directory. 547 * Simply tell vget, that it's a relocated directory. 548 */ 549 return (cd9660_vget_internal(mp, ino, flags, vpp, 550 imp->iso_ftype == ISO_FTYPE_RRIP, dp)); 551} 552 553/* 554 * Get filesystem statistics. 555 */ 556static int 557cd9660_statfs(mp, sbp) 558 struct mount *mp; 559 struct statfs *sbp; 560{ 561 struct iso_mnt *isomp; 562 563 isomp = VFSTOISOFS(mp); 564 565 sbp->f_bsize = isomp->logical_block_size; 566 sbp->f_iosize = sbp->f_bsize; /* XXX */ 567 sbp->f_blocks = isomp->volume_space_size; 568 sbp->f_bfree = 0; /* total free blocks */ 569 sbp->f_bavail = 0; /* blocks free for non superuser */ 570 sbp->f_files = 0; /* total files */ 571 sbp->f_ffree = 0; /* free file nodes */ 572 return 0; 573} 574 575/* 576 * File handle to vnode 577 * 578 * Have to be really careful about stale file handles: 579 * - check that the inode number is in range 580 * - call iget() to get the locked inode 581 * - check for an unallocated inode (i_mode == 0) 582 * - check that the generation number matches 583 */ 584 585/* ARGSUSED */ 586static int 587cd9660_fhtovp(mp, fhp, vpp) 588 struct mount *mp; 589 struct fid *fhp; 590 struct vnode **vpp; 591{ 592 struct ifid ifh; 593 struct iso_node *ip; 594 struct vnode *nvp; 595 int error; 596 597 memcpy(&ifh, fhp, sizeof(ifh)); 598 599#ifdef ISOFS_DBG 600 printf("fhtovp: ino %d, start %ld\n", 601 ifh.ifid_ino, ifh.ifid_start); 602#endif 603 604 if ((error = VFS_VGET(mp, ifh.ifid_ino, LK_EXCLUSIVE, &nvp)) != 0) { 605 *vpp = NULLVP; 606 return (error); 607 } 608 ip = VTOI(nvp); 609 if (ip->inode.iso_mode == 0) { 610 vput(nvp); 611 *vpp = NULLVP; 612 return (ESTALE); 613 } 614 *vpp = nvp; 615 vnode_create_vobject(*vpp, ip->i_size, curthread); 616 return (0); 617} 618 619static int 620cd9660_vget(mp, ino, flags, vpp) 621 struct mount *mp; 622 ino_t ino; 623 int flags; 624 struct vnode **vpp; 625{ 626 627 /* 628 * XXXX 629 * It would be nice if we didn't always set the `relocated' flag 630 * and force the extra read, but I don't want to think about fixing 631 * that right now. 632 */ 633 return (cd9660_vget_internal(mp, ino, flags, vpp, 634#if 0 635 VFSTOISOFS(mp)->iso_ftype == ISO_FTYPE_RRIP, 636#else 637 0, 638#endif 639 (struct iso_directory_record *)0)); 640} 641 642int 643cd9660_vget_internal(mp, ino, flags, vpp, relocated, isodir) 644 struct mount *mp; 645 ino_t ino; 646 int flags; 647 struct vnode **vpp; 648 int relocated; 649 struct iso_directory_record *isodir; 650{ 651 struct iso_mnt *imp; 652 struct iso_node *ip; 653 struct buf *bp; 654 struct vnode *vp; 655 struct cdev *dev; 656 int error; 657 struct thread *td; 658 659 td = curthread; 660 error = vfs_hash_get(mp, ino, flags, td, vpp, NULL, NULL); 661 if (error || *vpp != NULL) 662 return (error); 663 664 /* 665 * We must promote to an exclusive lock for vnode creation. This 666 * can happen if lookup is passed LOCKSHARED. 667 */ 668 if ((flags & LK_TYPE_MASK) == LK_SHARED) { 669 flags &= ~LK_TYPE_MASK; 670 flags |= LK_EXCLUSIVE; 671 } 672 673 /* 674 * We do not lock vnode creation as it is believed to be too 675 * expensive for such rare case as simultaneous creation of vnode 676 * for same ino by different processes. We just allow them to race 677 * and check later to decide who wins. Let the race begin! 678 */ 679 680 imp = VFSTOISOFS(mp); 681 dev = imp->im_dev; 682 683 /* Allocate a new vnode/iso_node. */ 684 if ((error = getnewvnode("isofs", mp, &cd9660_vnodeops, &vp)) != 0) { 685 *vpp = NULLVP; 686 return (error); 687 } 688 ip = malloc(sizeof(struct iso_node), M_ISOFSNODE, 689 M_WAITOK | M_ZERO); 690 vp->v_data = ip; 691 ip->i_vnode = vp; 692 ip->i_number = ino; 693 694 lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL); 695 error = insmntque(vp, mp); 696 if (error != 0) { 697 free(ip, M_ISOFSNODE); 698 *vpp = NULLVP; 699 return (error); 700 } 701 error = vfs_hash_insert(vp, ino, flags, td, vpp, NULL, NULL); 702 if (error || *vpp != NULL) 703 return (error); 704 705 if (isodir == 0) { 706 int lbn, off; 707 708 lbn = lblkno(imp, ino); 709 if (lbn >= imp->volume_space_size) { 710 vput(vp); 711 printf("fhtovp: lbn exceed volume space %d\n", lbn); 712 return (ESTALE); 713 } 714 715 off = blkoff(imp, ino); 716 if (off + ISO_DIRECTORY_RECORD_SIZE > imp->logical_block_size) { 717 vput(vp); 718 printf("fhtovp: crosses block boundary %d\n", 719 off + ISO_DIRECTORY_RECORD_SIZE); 720 return (ESTALE); 721 } 722 723 error = bread(imp->im_devvp, 724 lbn << (imp->im_bshift - DEV_BSHIFT), 725 imp->logical_block_size, NOCRED, &bp); 726 if (error) { 727 vput(vp); 728 brelse(bp); 729 printf("fhtovp: bread error %d\n",error); 730 return (error); 731 } 732 isodir = (struct iso_directory_record *)(bp->b_data + off); 733 734 if (off + isonum_711(isodir->length) > 735 imp->logical_block_size) { 736 vput(vp); 737 if (bp != 0) 738 brelse(bp); 739 printf("fhtovp: directory crosses block boundary %d[off=%d/len=%d]\n", 740 off +isonum_711(isodir->length), off, 741 isonum_711(isodir->length)); 742 return (ESTALE); 743 } 744 745#if 0 746 if (isonum_733(isodir->extent) + 747 isonum_711(isodir->ext_attr_length) != ifhp->ifid_start) { 748 if (bp != 0) 749 brelse(bp); 750 printf("fhtovp: file start miss %d vs %d\n", 751 isonum_733(isodir->extent) + isonum_711(isodir->ext_attr_length), 752 ifhp->ifid_start); 753 return (ESTALE); 754 } 755#endif 756 } else 757 bp = 0; 758 759 ip->i_mnt = imp; 760 761 if (relocated) { 762 /* 763 * On relocated directories we must 764 * read the `.' entry out of a dir. 765 */ 766 ip->iso_start = ino >> imp->im_bshift; 767 if (bp != 0) 768 brelse(bp); 769 if ((error = cd9660_blkatoff(vp, (off_t)0, NULL, &bp)) != 0) { 770 vput(vp); 771 return (error); 772 } 773 isodir = (struct iso_directory_record *)bp->b_data; 774 } 775 776 ip->iso_extent = isonum_733(isodir->extent); 777 ip->i_size = isonum_733(isodir->size); 778 ip->iso_start = isonum_711(isodir->ext_attr_length) + ip->iso_extent; 779 780 /* 781 * Setup time stamp, attribute 782 */ 783 vp->v_type = VNON; 784 switch (imp->iso_ftype) { 785 default: /* ISO_FTYPE_9660 */ 786 { 787 struct buf *bp2; 788 int off; 789 if ((imp->im_flags & ISOFSMNT_EXTATT) 790 && (off = isonum_711(isodir->ext_attr_length))) 791 cd9660_blkatoff(vp, (off_t)-(off << imp->im_bshift), NULL, 792 &bp2); 793 else 794 bp2 = NULL; 795 cd9660_defattr(isodir, ip, bp2, ISO_FTYPE_9660); 796 cd9660_deftstamp(isodir, ip, bp2, ISO_FTYPE_9660); 797 if (bp2) 798 brelse(bp2); 799 break; 800 } 801 case ISO_FTYPE_RRIP: 802 cd9660_rrip_analyze(isodir, ip, imp); 803 break; 804 } 805 806 if (bp != 0) 807 brelse(bp); 808 809 /* 810 * Initialize the associated vnode 811 */ 812 switch (vp->v_type = IFTOVT(ip->inode.iso_mode)) { 813 case VFIFO: 814 vp->v_op = &cd9660_fifoops; 815 break; 816 default: 817 VN_LOCK_ASHARE(vp); 818 break; 819 } 820 821 if (ip->iso_extent == imp->root_extent) 822 vp->v_vflag |= VV_ROOT; 823 824 /* 825 * XXX need generation number? 826 */ 827 828 *vpp = vp; 829 return (0); 830}
| 111 ma = mount_argsu(ma, "cs_disk", args.cs_disk, 64); 112 ma = mount_argsu(ma, "cs_local", args.cs_local, 64); 113 ma = mount_argf(ma, "ssector", "%u", args.ssector); 114 ma = mount_argb(ma, !(args.flags & ISOFSMNT_NORRIP), "norrip"); 115 ma = mount_argb(ma, args.flags & ISOFSMNT_GENS, "nogens"); 116 ma = mount_argb(ma, args.flags & ISOFSMNT_EXTATT, "noextatt"); 117 ma = mount_argb(ma, !(args.flags & ISOFSMNT_NOJOLIET), "nojoliet"); 118 ma = mount_argb(ma, 119 args.flags & ISOFSMNT_BROKENJOLIET, "nobrokenjoliet"); 120 ma = mount_argb(ma, args.flags & ISOFSMNT_KICONV, "nokiconv"); 121 122 error = kernel_mount(ma, flags); 123 124 return (error); 125} 126 127static int 128cd9660_mount(struct mount *mp) 129{ 130 struct vnode *devvp; 131 struct thread *td; 132 char *fspec; 133 int error; 134 accmode_t accmode; 135 struct nameidata ndp; 136 struct iso_mnt *imp = 0; 137 138 td = curthread; 139 140 /* 141 * Unconditionally mount as read-only. 142 */ 143 MNT_ILOCK(mp); 144 mp->mnt_flag |= MNT_RDONLY; 145 MNT_IUNLOCK(mp); 146 147 fspec = vfs_getopts(mp->mnt_optnew, "from", &error); 148 if (error) 149 return (error); 150 151 imp = VFSTOISOFS(mp); 152 153 if (mp->mnt_flag & MNT_UPDATE) { 154 if (vfs_flagopt(mp->mnt_optnew, "export", NULL, 0)) 155 return (0); 156 } 157 /* 158 * Not an update, or updating the name: look up the name 159 * and verify that it refers to a sensible block device. 160 */ 161 NDINIT(&ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, fspec, td); 162 if ((error = namei(&ndp))) 163 return (error); 164 NDFREE(&ndp, NDF_ONLY_PNBUF); 165 devvp = ndp.ni_vp; 166 167 if (!vn_isdisk(devvp, &error)) { 168 vput(devvp); 169 return (error); 170 } 171 172 /* 173 * Verify that user has necessary permissions on the device, 174 * or has superuser abilities 175 */ 176 accmode = VREAD; 177 error = VOP_ACCESS(devvp, accmode, td->td_ucred, td); 178 if (error) 179 error = priv_check(td, PRIV_VFS_MOUNT_PERM); 180 if (error) { 181 vput(devvp); 182 return (error); 183 } 184 185 if ((mp->mnt_flag & MNT_UPDATE) == 0) { 186 error = iso_mountfs(devvp, mp); 187 if (error) 188 vrele(devvp); 189 } else { 190 if (devvp != imp->im_devvp) 191 error = EINVAL; /* needs translation */ 192 vput(devvp); 193 } 194 if (error) 195 return (error); 196 vfs_mountedfrom(mp, fspec); 197 return (0); 198} 199 200/* 201 * Common code for mount and mountroot 202 */ 203static int 204iso_mountfs(devvp, mp) 205 struct vnode *devvp; 206 struct mount *mp; 207{ 208 struct iso_mnt *isomp = (struct iso_mnt *)0; 209 struct buf *bp = NULL; 210 struct buf *pribp = NULL, *supbp = NULL; 211 struct cdev *dev; 212 int error = EINVAL; 213 int high_sierra = 0; 214 int iso_bsize; 215 int iso_blknum; 216 int joliet_level; 217 struct iso_volume_descriptor *vdp = 0; 218 struct iso_primary_descriptor *pri = NULL; 219 struct iso_sierra_primary_descriptor *pri_sierra = NULL; 220 struct iso_supplementary_descriptor *sup = NULL; 221 struct iso_directory_record *rootp; 222 int logical_block_size, ssector; 223 struct g_consumer *cp; 224 struct bufobj *bo; 225 char *cs_local, *cs_disk; 226 227 dev = devvp->v_rdev; 228 dev_ref(dev); 229 DROP_GIANT(); 230 g_topology_lock(); 231 error = g_vfs_open(devvp, &cp, "cd9660", 0); 232 g_topology_unlock(); 233 PICKUP_GIANT(); 234 VOP_UNLOCK(devvp, 0); 235 if (error) 236 goto out; 237 if (devvp->v_rdev->si_iosize_max != 0) 238 mp->mnt_iosize_max = devvp->v_rdev->si_iosize_max; 239 if (mp->mnt_iosize_max > MAXPHYS) 240 mp->mnt_iosize_max = MAXPHYS; 241 242 bo = &devvp->v_bufobj; 243 244 /* This is the "logical sector size". The standard says this 245 * should be 2048 or the physical sector size on the device, 246 * whichever is greater. 247 */ 248 if ((ISO_DEFAULT_BLOCK_SIZE % cp->provider->sectorsize) != 0) { 249 error = EINVAL; 250 goto out; 251 } 252 253 iso_bsize = cp->provider->sectorsize; 254 255 joliet_level = 0; 256 if (1 != vfs_scanopt(mp->mnt_optnew, "ssector", "%d", &ssector)) 257 ssector = 0; 258 for (iso_blknum = 16 + ssector; 259 iso_blknum < 100 + ssector; 260 iso_blknum++) { 261 if ((error = bread(devvp, iso_blknum * btodb(ISO_DEFAULT_BLOCK_SIZE), 262 iso_bsize, NOCRED, &bp)) != 0) 263 goto out; 264 265 vdp = (struct iso_volume_descriptor *)bp->b_data; 266 if (bcmp (vdp->id, ISO_STANDARD_ID, sizeof vdp->id) != 0) { 267 if (bcmp (vdp->id_sierra, ISO_SIERRA_ID, 268 sizeof vdp->id_sierra) != 0) { 269 error = EINVAL; 270 goto out; 271 } else 272 high_sierra = 1; 273 } 274 switch (isonum_711 (high_sierra? vdp->type_sierra: vdp->type)){ 275 case ISO_VD_PRIMARY: 276 if (pribp == NULL) { 277 pribp = bp; 278 bp = NULL; 279 pri = (struct iso_primary_descriptor *)vdp; 280 pri_sierra = 281 (struct iso_sierra_primary_descriptor *)vdp; 282 } 283 break; 284 285 case ISO_VD_SUPPLEMENTARY: 286 if (supbp == NULL) { 287 supbp = bp; 288 bp = NULL; 289 sup = (struct iso_supplementary_descriptor *)vdp; 290 291 if (!vfs_flagopt(mp->mnt_optnew, "nojoliet", NULL, 0)) { 292 if (bcmp(sup->escape, "%/@", 3) == 0) 293 joliet_level = 1; 294 if (bcmp(sup->escape, "%/C", 3) == 0) 295 joliet_level = 2; 296 if (bcmp(sup->escape, "%/E", 3) == 0) 297 joliet_level = 3; 298 299 if ((isonum_711 (sup->flags) & 1) && 300 !vfs_flagopt(mp->mnt_optnew, "brokenjoliet", NULL, 0)) 301 joliet_level = 0; 302 } 303 } 304 break; 305 306 case ISO_VD_END: 307 goto vd_end; 308 309 default: 310 break; 311 } 312 if (bp) { 313 brelse(bp); 314 bp = NULL; 315 } 316 } 317 vd_end: 318 if (bp) { 319 brelse(bp); 320 bp = NULL; 321 } 322 323 if (pri == NULL) { 324 error = EINVAL; 325 goto out; 326 } 327 328 logical_block_size = 329 isonum_723 (high_sierra? 330 pri_sierra->logical_block_size: 331 pri->logical_block_size); 332 333 if (logical_block_size < DEV_BSIZE || logical_block_size > MAXBSIZE 334 || (logical_block_size & (logical_block_size - 1)) != 0) { 335 error = EINVAL; 336 goto out; 337 } 338 339 rootp = (struct iso_directory_record *) 340 (high_sierra? 341 pri_sierra->root_directory_record: 342 pri->root_directory_record); 343 344 isomp = malloc(sizeof *isomp, M_ISOFSMNT, M_WAITOK | M_ZERO); 345 isomp->im_cp = cp; 346 isomp->im_bo = bo; 347 isomp->logical_block_size = logical_block_size; 348 isomp->volume_space_size = 349 isonum_733 (high_sierra? 350 pri_sierra->volume_space_size: 351 pri->volume_space_size); 352 isomp->joliet_level = 0; 353 /* 354 * Since an ISO9660 multi-session CD can also access previous 355 * sessions, we have to include them into the space consider- 356 * ations. This doesn't yield a very accurate number since 357 * parts of the old sessions might be inaccessible now, but we 358 * can't do much better. This is also important for the NFS 359 * filehandle validation. 360 */ 361 isomp->volume_space_size += ssector; 362 bcopy (rootp, isomp->root, sizeof isomp->root); 363 isomp->root_extent = isonum_733 (rootp->extent); 364 isomp->root_size = isonum_733 (rootp->size); 365 366 isomp->im_bmask = logical_block_size - 1; 367 isomp->im_bshift = ffs(logical_block_size) - 1; 368 369 pribp->b_flags |= B_AGE; 370 brelse(pribp); 371 pribp = NULL; 372 373 mp->mnt_data = isomp; 374 mp->mnt_stat.f_fsid.val[0] = dev2udev(dev); 375 mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum; 376 mp->mnt_maxsymlinklen = 0; 377 MNT_ILOCK(mp); 378 mp->mnt_flag |= MNT_LOCAL; 379 mp->mnt_kern_flag |= MNTK_MPSAFE | MNTK_LOOKUP_SHARED | 380 MNTK_EXTENDED_SHARED; 381 MNT_IUNLOCK(mp); 382 isomp->im_mountp = mp; 383 isomp->im_dev = dev; 384 isomp->im_devvp = devvp; 385 386 vfs_flagopt(mp->mnt_optnew, "norrip", &isomp->im_flags, ISOFSMNT_NORRIP); 387 vfs_flagopt(mp->mnt_optnew, "gens", &isomp->im_flags, ISOFSMNT_GENS); 388 vfs_flagopt(mp->mnt_optnew, "extatt", &isomp->im_flags, ISOFSMNT_EXTATT); 389 vfs_flagopt(mp->mnt_optnew, "nojoliet", &isomp->im_flags, ISOFSMNT_NOJOLIET); 390 vfs_flagopt(mp->mnt_optnew, "kiconv", &isomp->im_flags, ISOFSMNT_KICONV); 391 392 /* Check the Rock Ridge Extension support */ 393 if (!(isomp->im_flags & ISOFSMNT_NORRIP)) { 394 if ((error = bread(isomp->im_devvp, 395 (isomp->root_extent + isonum_711(rootp->ext_attr_length)) << 396 (isomp->im_bshift - DEV_BSHIFT), 397 isomp->logical_block_size, NOCRED, &bp)) != 0) 398 goto out; 399 400 rootp = (struct iso_directory_record *)bp->b_data; 401 402 if ((isomp->rr_skip = cd9660_rrip_offset(rootp,isomp)) < 0) { 403 isomp->im_flags |= ISOFSMNT_NORRIP; 404 } else { 405 isomp->im_flags &= ~ISOFSMNT_GENS; 406 } 407 408 /* 409 * The contents are valid, 410 * but they will get reread as part of another vnode, so... 411 */ 412 bp->b_flags |= B_AGE; 413 brelse(bp); 414 bp = NULL; 415 } 416 417 if (isomp->im_flags & ISOFSMNT_KICONV && cd9660_iconv) { 418 cs_local = vfs_getopts(mp->mnt_optnew, "cs_local", &error); 419 if (error) 420 goto out; 421 cs_disk = vfs_getopts(mp->mnt_optnew, "cs_disk", &error); 422 if (error) 423 goto out; 424 cd9660_iconv->open(cs_local, cs_disk, &isomp->im_d2l); 425 cd9660_iconv->open(cs_disk, cs_local, &isomp->im_l2d); 426 } else { 427 isomp->im_d2l = NULL; 428 isomp->im_l2d = NULL; 429 } 430 431 if (high_sierra) { 432 /* this effectively ignores all the mount flags */ 433 if (bootverbose) 434 log(LOG_INFO, "cd9660: High Sierra Format\n"); 435 isomp->iso_ftype = ISO_FTYPE_HIGH_SIERRA; 436 } else 437 switch (isomp->im_flags&(ISOFSMNT_NORRIP|ISOFSMNT_GENS)) { 438 default: 439 isomp->iso_ftype = ISO_FTYPE_DEFAULT; 440 break; 441 case ISOFSMNT_GENS|ISOFSMNT_NORRIP: 442 isomp->iso_ftype = ISO_FTYPE_9660; 443 break; 444 case 0: 445 if (bootverbose) 446 log(LOG_INFO, "cd9660: RockRidge Extension\n"); 447 isomp->iso_ftype = ISO_FTYPE_RRIP; 448 break; 449 } 450 451 /* Decide whether to use the Joliet descriptor */ 452 453 if (isomp->iso_ftype != ISO_FTYPE_RRIP && joliet_level) { 454 if (bootverbose) 455 log(LOG_INFO, "cd9660: Joliet Extension (Level %d)\n", 456 joliet_level); 457 rootp = (struct iso_directory_record *) 458 sup->root_directory_record; 459 bcopy (rootp, isomp->root, sizeof isomp->root); 460 isomp->root_extent = isonum_733 (rootp->extent); 461 isomp->root_size = isonum_733 (rootp->size); 462 isomp->joliet_level = joliet_level; 463 supbp->b_flags |= B_AGE; 464 } 465 466 if (supbp) { 467 brelse(supbp); 468 supbp = NULL; 469 } 470 471 return 0; 472out: 473 if (bp) 474 brelse(bp); 475 if (pribp) 476 brelse(pribp); 477 if (supbp) 478 brelse(supbp); 479 if (cp != NULL) { 480 DROP_GIANT(); 481 g_topology_lock(); 482 g_vfs_close(cp); 483 g_topology_unlock(); 484 PICKUP_GIANT(); 485 } 486 if (isomp) { 487 free((caddr_t)isomp, M_ISOFSMNT); 488 mp->mnt_data = NULL; 489 } 490 dev_rel(dev); 491 return error; 492} 493 494/* 495 * unmount system call 496 */ 497static int 498cd9660_unmount(mp, mntflags) 499 struct mount *mp; 500 int mntflags; 501{ 502 struct iso_mnt *isomp; 503 int error, flags = 0; 504 505 if (mntflags & MNT_FORCE) 506 flags |= FORCECLOSE; 507 if ((error = vflush(mp, 0, flags, curthread))) 508 return (error); 509 510 isomp = VFSTOISOFS(mp); 511 512 if (isomp->im_flags & ISOFSMNT_KICONV && cd9660_iconv) { 513 if (isomp->im_d2l) 514 cd9660_iconv->close(isomp->im_d2l); 515 if (isomp->im_l2d) 516 cd9660_iconv->close(isomp->im_l2d); 517 } 518 DROP_GIANT(); 519 g_topology_lock(); 520 g_vfs_close(isomp->im_cp); 521 g_topology_unlock(); 522 PICKUP_GIANT(); 523 vrele(isomp->im_devvp); 524 dev_rel(isomp->im_dev); 525 free((caddr_t)isomp, M_ISOFSMNT); 526 mp->mnt_data = NULL; 527 MNT_ILOCK(mp); 528 mp->mnt_flag &= ~MNT_LOCAL; 529 MNT_IUNLOCK(mp); 530 return (error); 531} 532 533/* 534 * Return root of a filesystem 535 */ 536static int 537cd9660_root(mp, flags, vpp) 538 struct mount *mp; 539 int flags; 540 struct vnode **vpp; 541{ 542 struct iso_mnt *imp = VFSTOISOFS(mp); 543 struct iso_directory_record *dp = 544 (struct iso_directory_record *)imp->root; 545 ino_t ino = isodirino(dp, imp); 546 547 /* 548 * With RRIP we must use the `.' entry of the root directory. 549 * Simply tell vget, that it's a relocated directory. 550 */ 551 return (cd9660_vget_internal(mp, ino, flags, vpp, 552 imp->iso_ftype == ISO_FTYPE_RRIP, dp)); 553} 554 555/* 556 * Get filesystem statistics. 557 */ 558static int 559cd9660_statfs(mp, sbp) 560 struct mount *mp; 561 struct statfs *sbp; 562{ 563 struct iso_mnt *isomp; 564 565 isomp = VFSTOISOFS(mp); 566 567 sbp->f_bsize = isomp->logical_block_size; 568 sbp->f_iosize = sbp->f_bsize; /* XXX */ 569 sbp->f_blocks = isomp->volume_space_size; 570 sbp->f_bfree = 0; /* total free blocks */ 571 sbp->f_bavail = 0; /* blocks free for non superuser */ 572 sbp->f_files = 0; /* total files */ 573 sbp->f_ffree = 0; /* free file nodes */ 574 return 0; 575} 576 577/* 578 * File handle to vnode 579 * 580 * Have to be really careful about stale file handles: 581 * - check that the inode number is in range 582 * - call iget() to get the locked inode 583 * - check for an unallocated inode (i_mode == 0) 584 * - check that the generation number matches 585 */ 586 587/* ARGSUSED */ 588static int 589cd9660_fhtovp(mp, fhp, vpp) 590 struct mount *mp; 591 struct fid *fhp; 592 struct vnode **vpp; 593{ 594 struct ifid ifh; 595 struct iso_node *ip; 596 struct vnode *nvp; 597 int error; 598 599 memcpy(&ifh, fhp, sizeof(ifh)); 600 601#ifdef ISOFS_DBG 602 printf("fhtovp: ino %d, start %ld\n", 603 ifh.ifid_ino, ifh.ifid_start); 604#endif 605 606 if ((error = VFS_VGET(mp, ifh.ifid_ino, LK_EXCLUSIVE, &nvp)) != 0) { 607 *vpp = NULLVP; 608 return (error); 609 } 610 ip = VTOI(nvp); 611 if (ip->inode.iso_mode == 0) { 612 vput(nvp); 613 *vpp = NULLVP; 614 return (ESTALE); 615 } 616 *vpp = nvp; 617 vnode_create_vobject(*vpp, ip->i_size, curthread); 618 return (0); 619} 620 621static int 622cd9660_vget(mp, ino, flags, vpp) 623 struct mount *mp; 624 ino_t ino; 625 int flags; 626 struct vnode **vpp; 627{ 628 629 /* 630 * XXXX 631 * It would be nice if we didn't always set the `relocated' flag 632 * and force the extra read, but I don't want to think about fixing 633 * that right now. 634 */ 635 return (cd9660_vget_internal(mp, ino, flags, vpp, 636#if 0 637 VFSTOISOFS(mp)->iso_ftype == ISO_FTYPE_RRIP, 638#else 639 0, 640#endif 641 (struct iso_directory_record *)0)); 642} 643 644int 645cd9660_vget_internal(mp, ino, flags, vpp, relocated, isodir) 646 struct mount *mp; 647 ino_t ino; 648 int flags; 649 struct vnode **vpp; 650 int relocated; 651 struct iso_directory_record *isodir; 652{ 653 struct iso_mnt *imp; 654 struct iso_node *ip; 655 struct buf *bp; 656 struct vnode *vp; 657 struct cdev *dev; 658 int error; 659 struct thread *td; 660 661 td = curthread; 662 error = vfs_hash_get(mp, ino, flags, td, vpp, NULL, NULL); 663 if (error || *vpp != NULL) 664 return (error); 665 666 /* 667 * We must promote to an exclusive lock for vnode creation. This 668 * can happen if lookup is passed LOCKSHARED. 669 */ 670 if ((flags & LK_TYPE_MASK) == LK_SHARED) { 671 flags &= ~LK_TYPE_MASK; 672 flags |= LK_EXCLUSIVE; 673 } 674 675 /* 676 * We do not lock vnode creation as it is believed to be too 677 * expensive for such rare case as simultaneous creation of vnode 678 * for same ino by different processes. We just allow them to race 679 * and check later to decide who wins. Let the race begin! 680 */ 681 682 imp = VFSTOISOFS(mp); 683 dev = imp->im_dev; 684 685 /* Allocate a new vnode/iso_node. */ 686 if ((error = getnewvnode("isofs", mp, &cd9660_vnodeops, &vp)) != 0) { 687 *vpp = NULLVP; 688 return (error); 689 } 690 ip = malloc(sizeof(struct iso_node), M_ISOFSNODE, 691 M_WAITOK | M_ZERO); 692 vp->v_data = ip; 693 ip->i_vnode = vp; 694 ip->i_number = ino; 695 696 lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL); 697 error = insmntque(vp, mp); 698 if (error != 0) { 699 free(ip, M_ISOFSNODE); 700 *vpp = NULLVP; 701 return (error); 702 } 703 error = vfs_hash_insert(vp, ino, flags, td, vpp, NULL, NULL); 704 if (error || *vpp != NULL) 705 return (error); 706 707 if (isodir == 0) { 708 int lbn, off; 709 710 lbn = lblkno(imp, ino); 711 if (lbn >= imp->volume_space_size) { 712 vput(vp); 713 printf("fhtovp: lbn exceed volume space %d\n", lbn); 714 return (ESTALE); 715 } 716 717 off = blkoff(imp, ino); 718 if (off + ISO_DIRECTORY_RECORD_SIZE > imp->logical_block_size) { 719 vput(vp); 720 printf("fhtovp: crosses block boundary %d\n", 721 off + ISO_DIRECTORY_RECORD_SIZE); 722 return (ESTALE); 723 } 724 725 error = bread(imp->im_devvp, 726 lbn << (imp->im_bshift - DEV_BSHIFT), 727 imp->logical_block_size, NOCRED, &bp); 728 if (error) { 729 vput(vp); 730 brelse(bp); 731 printf("fhtovp: bread error %d\n",error); 732 return (error); 733 } 734 isodir = (struct iso_directory_record *)(bp->b_data + off); 735 736 if (off + isonum_711(isodir->length) > 737 imp->logical_block_size) { 738 vput(vp); 739 if (bp != 0) 740 brelse(bp); 741 printf("fhtovp: directory crosses block boundary %d[off=%d/len=%d]\n", 742 off +isonum_711(isodir->length), off, 743 isonum_711(isodir->length)); 744 return (ESTALE); 745 } 746 747#if 0 748 if (isonum_733(isodir->extent) + 749 isonum_711(isodir->ext_attr_length) != ifhp->ifid_start) { 750 if (bp != 0) 751 brelse(bp); 752 printf("fhtovp: file start miss %d vs %d\n", 753 isonum_733(isodir->extent) + isonum_711(isodir->ext_attr_length), 754 ifhp->ifid_start); 755 return (ESTALE); 756 } 757#endif 758 } else 759 bp = 0; 760 761 ip->i_mnt = imp; 762 763 if (relocated) { 764 /* 765 * On relocated directories we must 766 * read the `.' entry out of a dir. 767 */ 768 ip->iso_start = ino >> imp->im_bshift; 769 if (bp != 0) 770 brelse(bp); 771 if ((error = cd9660_blkatoff(vp, (off_t)0, NULL, &bp)) != 0) { 772 vput(vp); 773 return (error); 774 } 775 isodir = (struct iso_directory_record *)bp->b_data; 776 } 777 778 ip->iso_extent = isonum_733(isodir->extent); 779 ip->i_size = isonum_733(isodir->size); 780 ip->iso_start = isonum_711(isodir->ext_attr_length) + ip->iso_extent; 781 782 /* 783 * Setup time stamp, attribute 784 */ 785 vp->v_type = VNON; 786 switch (imp->iso_ftype) { 787 default: /* ISO_FTYPE_9660 */ 788 { 789 struct buf *bp2; 790 int off; 791 if ((imp->im_flags & ISOFSMNT_EXTATT) 792 && (off = isonum_711(isodir->ext_attr_length))) 793 cd9660_blkatoff(vp, (off_t)-(off << imp->im_bshift), NULL, 794 &bp2); 795 else 796 bp2 = NULL; 797 cd9660_defattr(isodir, ip, bp2, ISO_FTYPE_9660); 798 cd9660_deftstamp(isodir, ip, bp2, ISO_FTYPE_9660); 799 if (bp2) 800 brelse(bp2); 801 break; 802 } 803 case ISO_FTYPE_RRIP: 804 cd9660_rrip_analyze(isodir, ip, imp); 805 break; 806 } 807 808 if (bp != 0) 809 brelse(bp); 810 811 /* 812 * Initialize the associated vnode 813 */ 814 switch (vp->v_type = IFTOVT(ip->inode.iso_mode)) { 815 case VFIFO: 816 vp->v_op = &cd9660_fifoops; 817 break; 818 default: 819 VN_LOCK_ASHARE(vp); 820 break; 821 } 822 823 if (ip->iso_extent == imp->root_extent) 824 vp->v_vflag |= VV_ROOT; 825 826 /* 827 * XXX need generation number? 828 */ 829 830 *vpp = vp; 831 return (0); 832}
|