1 /*- 2 * Copyright (c) 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley 6 * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension 7 * Support code is derived from software contributed to Berkeley 8 * by Atsushi Murai (amurai@spec.co.jp). 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 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the University of 21 * California, Berkeley and its contributors. 22 * 4. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)cd9660_vnops.c 8.19 (Berkeley) 5/27/95 39 * $FreeBSD$ 40 */ 41 42 #include <sys/param.h> 43 #include <sys/systm.h> 44 #include <sys/namei.h> 45 #include <sys/kernel.h> 46 #include <sys/stat.h> 47 #include <sys/bio.h> 48 #include <sys/buf.h> 49 #include <sys/mount.h> 50 #include <sys/vnode.h> 51 #include <fs/fifofs/fifo.h> 52 #include <sys/malloc.h> 53 #include <sys/dirent.h> 54 #include <sys/unistd.h> 55 #include <sys/filio.h> 56 57 #include <vm/vm.h> 58 #include <vm/vnode_pager.h> 59 #include <vm/uma.h> 60 61 #include <isofs/cd9660/iso.h> 62 #include <isofs/cd9660/cd9660_node.h> 63 #include <isofs/cd9660/iso_rrip.h> 64 65 static int cd9660_setattr(struct vop_setattr_args *); 66 static int cd9660_access(struct vop_access_args *); 67 static int cd9660_getattr(struct vop_getattr_args *); 68 static int cd9660_ioctl(struct vop_ioctl_args *); 69 static int cd9660_pathconf(struct vop_pathconf_args *); 70 static int cd9660_read(struct vop_read_args *); 71 struct isoreaddir; 72 static int iso_uiodir(struct isoreaddir *idp, struct dirent *dp, off_t off); 73 static int iso_shipdir(struct isoreaddir *idp); 74 static int cd9660_readdir(struct vop_readdir_args *); 75 static int cd9660_readlink(struct vop_readlink_args *ap); 76 static int cd9660_strategy(struct vop_strategy_args *); 77 static int cd9660_print(struct vop_print_args *); 78 79 /* 80 * Setattr call. Only allowed for block and character special devices. 81 */ 82 int 83 cd9660_setattr(ap) 84 struct vop_setattr_args /* { 85 struct vnodeop_desc *a_desc; 86 struct vnode *a_vp; 87 struct vattr *a_vap; 88 struct ucred *a_cred; 89 struct thread *a_td; 90 } */ *ap; 91 { 92 struct vnode *vp = ap->a_vp; 93 struct vattr *vap = ap->a_vap; 94 95 if (vap->va_flags != (u_long)VNOVAL || vap->va_uid != (uid_t)VNOVAL || 96 vap->va_gid != (gid_t)VNOVAL || vap->va_atime.tv_sec != VNOVAL || 97 vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL) 98 return (EROFS); 99 if (vap->va_size != (u_quad_t)VNOVAL) { 100 switch (vp->v_type) { 101 case VDIR: 102 return (EISDIR); 103 case VLNK: 104 case VREG: 105 return (EROFS); 106 case VCHR: 107 case VBLK: 108 case VSOCK: 109 case VFIFO: 110 case VNON: 111 case VBAD: 112 return (0); 113 } 114 } 115 return (0); 116 } 117 118 /* 119 * Check mode permission on inode pointer. Mode is READ, WRITE or EXEC. 120 * The mode is shifted to select the owner/group/other fields. The 121 * super user is granted all permissions. 122 */ 123 /* ARGSUSED */ 124 static int 125 cd9660_access(ap) 126 struct vop_access_args /* { 127 struct vnode *a_vp; 128 int a_mode; 129 struct ucred *a_cred; 130 struct thread *a_td; 131 } */ *ap; 132 { 133 struct vnode *vp = ap->a_vp; 134 struct iso_node *ip = VTOI(vp); 135 mode_t mode = ap->a_mode; 136 137 /* 138 * Disallow write attempts unless the file is a socket, 139 * fifo, or a block or character device resident on the 140 * file system. 141 */ 142 if (mode & VWRITE) { 143 switch (vp->v_type) { 144 case VDIR: 145 case VLNK: 146 case VREG: 147 return (EROFS); 148 /* NOT REACHED */ 149 default: 150 break; 151 } 152 } 153 154 return (vaccess(vp->v_type, ip->inode.iso_mode, ip->inode.iso_uid, 155 ip->inode.iso_gid, ap->a_mode, ap->a_cred, NULL)); 156 } 157 158 static int 159 cd9660_getattr(ap) 160 struct vop_getattr_args /* { 161 struct vnode *a_vp; 162 struct vattr *a_vap; 163 struct ucred *a_cred; 164 struct thread *a_td; 165 } */ *ap; 166 167 { 168 struct vnode *vp = ap->a_vp; 169 register struct vattr *vap = ap->a_vap; 170 register struct iso_node *ip = VTOI(vp); 171 172 vap->va_fsid = dev2udev(ip->i_dev); 173 vap->va_fileid = ip->i_number; 174 175 vap->va_mode = ip->inode.iso_mode; 176 vap->va_nlink = ip->inode.iso_links; 177 vap->va_uid = ip->inode.iso_uid; 178 vap->va_gid = ip->inode.iso_gid; 179 vap->va_atime = ip->inode.iso_atime; 180 vap->va_mtime = ip->inode.iso_mtime; 181 vap->va_ctime = ip->inode.iso_ctime; 182 vap->va_rdev = ip->inode.iso_rdev; 183 184 vap->va_size = (u_quad_t) ip->i_size; 185 if (ip->i_size == 0 && (vap->va_mode & S_IFMT) == S_IFLNK) { 186 struct vop_readlink_args rdlnk; 187 struct iovec aiov; 188 struct uio auio; 189 char *cp; 190 191 MALLOC(cp, char *, MAXPATHLEN, M_TEMP, M_WAITOK); 192 aiov.iov_base = cp; 193 aiov.iov_len = MAXPATHLEN; 194 auio.uio_iov = &aiov; 195 auio.uio_iovcnt = 1; 196 auio.uio_offset = 0; 197 auio.uio_rw = UIO_READ; 198 auio.uio_segflg = UIO_SYSSPACE; 199 auio.uio_td = ap->a_td; 200 auio.uio_resid = MAXPATHLEN; 201 rdlnk.a_uio = &auio; 202 rdlnk.a_vp = ap->a_vp; 203 rdlnk.a_cred = ap->a_cred; 204 if (cd9660_readlink(&rdlnk) == 0) 205 vap->va_size = MAXPATHLEN - auio.uio_resid; 206 FREE(cp, M_TEMP); 207 } 208 vap->va_flags = 0; 209 vap->va_gen = 1; 210 vap->va_blocksize = ip->i_mnt->logical_block_size; 211 vap->va_bytes = (u_quad_t) ip->i_size; 212 vap->va_type = vp->v_type; 213 vap->va_filerev = 0; 214 return (0); 215 } 216 217 /* 218 * Vnode op for ioctl. 219 */ 220 static int 221 cd9660_ioctl(ap) 222 struct vop_ioctl_args /* { 223 struct vnode *a_vp; 224 int a_command; 225 caddr_t a_data; 226 int a_fflag; 227 struct ucred *a_cred; 228 struct thread *a_td; 229 } */ *ap; 230 { 231 struct vnode *vp = ap->a_vp; 232 struct iso_node *ip = VTOI(vp); 233 234 switch (ap->a_command) { 235 236 case FIOGETLBA: 237 *(int *)(ap->a_data) = ip->iso_start; 238 return 0; 239 default: 240 return (ENOTTY); 241 } 242 } 243 244 /* 245 * Vnode op for reading. 246 */ 247 static int 248 cd9660_read(ap) 249 struct vop_read_args /* { 250 struct vnode *a_vp; 251 struct uio *a_uio; 252 int a_ioflag; 253 struct ucred *a_cred; 254 } */ *ap; 255 { 256 struct vnode *vp = ap->a_vp; 257 register struct uio *uio = ap->a_uio; 258 register struct iso_node *ip = VTOI(vp); 259 register struct iso_mnt *imp; 260 struct buf *bp; 261 daddr_t lbn, rablock; 262 off_t diff; 263 int rasize, error = 0; 264 int seqcount; 265 long size, n, on; 266 267 seqcount = ap->a_ioflag >> 16; 268 269 if (uio->uio_resid == 0) 270 return (0); 271 if (uio->uio_offset < 0) 272 return (EINVAL); 273 ip->i_flag |= IN_ACCESS; 274 imp = ip->i_mnt; 275 do { 276 lbn = lblkno(imp, uio->uio_offset); 277 on = blkoff(imp, uio->uio_offset); 278 n = min((u_int)(imp->logical_block_size - on), 279 uio->uio_resid); 280 diff = (off_t)ip->i_size - uio->uio_offset; 281 if (diff <= 0) 282 return (0); 283 if (diff < n) 284 n = diff; 285 size = blksize(imp, ip, lbn); 286 rablock = lbn + 1; 287 if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) { 288 if (lblktosize(imp, rablock) < ip->i_size) 289 error = cluster_read(vp, (off_t)ip->i_size, 290 lbn, size, NOCRED, uio->uio_resid, 291 (ap->a_ioflag >> 16), &bp); 292 else 293 error = bread(vp, lbn, size, NOCRED, &bp); 294 } else { 295 if (seqcount > 1 && 296 lblktosize(imp, rablock) < ip->i_size) { 297 rasize = blksize(imp, ip, rablock); 298 error = breadn(vp, lbn, size, &rablock, 299 &rasize, 1, NOCRED, &bp); 300 } else 301 error = bread(vp, lbn, size, NOCRED, &bp); 302 } 303 n = min(n, size - bp->b_resid); 304 if (error) { 305 brelse(bp); 306 return (error); 307 } 308 309 error = uiomove(bp->b_data + on, (int)n, uio); 310 brelse(bp); 311 } while (error == 0 && uio->uio_resid > 0 && n != 0); 312 return (error); 313 } 314 315 /* 316 * Structure for reading directories 317 */ 318 struct isoreaddir { 319 struct dirent saveent; 320 struct dirent assocent; 321 struct dirent current; 322 off_t saveoff; 323 off_t assocoff; 324 off_t curroff; 325 struct uio *uio; 326 off_t uio_off; 327 int eofflag; 328 u_long *cookies; 329 int ncookies; 330 }; 331 332 int 333 iso_uiodir(idp,dp,off) 334 struct isoreaddir *idp; 335 struct dirent *dp; 336 off_t off; 337 { 338 int error; 339 340 dp->d_name[dp->d_namlen] = 0; 341 dp->d_reclen = GENERIC_DIRSIZ(dp); 342 343 if (idp->uio->uio_resid < dp->d_reclen) { 344 idp->eofflag = 0; 345 return (-1); 346 } 347 348 if (idp->cookies) { 349 if (idp->ncookies <= 0) { 350 idp->eofflag = 0; 351 return (-1); 352 } 353 354 *idp->cookies++ = off; 355 --idp->ncookies; 356 } 357 358 if ((error = uiomove((caddr_t) dp,dp->d_reclen,idp->uio)) != 0) 359 return (error); 360 idp->uio_off = off; 361 return (0); 362 } 363 364 int 365 iso_shipdir(idp) 366 struct isoreaddir *idp; 367 { 368 struct dirent *dp; 369 int cl, sl, assoc; 370 int error; 371 char *cname, *sname; 372 373 cl = idp->current.d_namlen; 374 cname = idp->current.d_name; 375 assoc = (cl > 1) && (*cname == ASSOCCHAR); 376 if (assoc) { 377 cl--; 378 cname++; 379 } 380 381 dp = &idp->saveent; 382 sname = dp->d_name; 383 if (!(sl = dp->d_namlen)) { 384 dp = &idp->assocent; 385 sname = dp->d_name + 1; 386 sl = dp->d_namlen - 1; 387 } 388 if (sl > 0) { 389 if (sl != cl 390 || bcmp(sname,cname,sl)) { 391 if (idp->assocent.d_namlen) { 392 if ((error = iso_uiodir(idp,&idp->assocent,idp->assocoff)) != 0) 393 return (error); 394 idp->assocent.d_namlen = 0; 395 } 396 if (idp->saveent.d_namlen) { 397 if ((error = iso_uiodir(idp,&idp->saveent,idp->saveoff)) != 0) 398 return (error); 399 idp->saveent.d_namlen = 0; 400 } 401 } 402 } 403 idp->current.d_reclen = GENERIC_DIRSIZ(&idp->current); 404 if (assoc) { 405 idp->assocoff = idp->curroff; 406 bcopy(&idp->current,&idp->assocent,idp->current.d_reclen); 407 } else { 408 idp->saveoff = idp->curroff; 409 bcopy(&idp->current,&idp->saveent,idp->current.d_reclen); 410 } 411 return (0); 412 } 413 414 /* 415 * Vnode op for readdir 416 */ 417 static int 418 cd9660_readdir(ap) 419 struct vop_readdir_args /* { 420 struct vnode *a_vp; 421 struct uio *a_uio; 422 struct ucred *a_cred; 423 int *a_eofflag; 424 int *a_ncookies; 425 u_long *a_cookies; 426 } */ *ap; 427 { 428 register struct uio *uio = ap->a_uio; 429 struct isoreaddir *idp; 430 struct vnode *vdp = ap->a_vp; 431 struct iso_node *dp; 432 struct iso_mnt *imp; 433 struct buf *bp = NULL; 434 struct iso_directory_record *ep; 435 int entryoffsetinblock; 436 doff_t endsearch; 437 u_long bmask; 438 int error = 0; 439 int reclen; 440 u_short namelen; 441 int ncookies = 0; 442 u_long *cookies = NULL; 443 444 dp = VTOI(vdp); 445 imp = dp->i_mnt; 446 bmask = imp->im_bmask; 447 448 MALLOC(idp, struct isoreaddir *, sizeof(*idp), M_TEMP, M_WAITOK); 449 idp->saveent.d_namlen = idp->assocent.d_namlen = 0; 450 /* 451 * XXX 452 * Is it worth trying to figure out the type? 453 */ 454 idp->saveent.d_type = idp->assocent.d_type = idp->current.d_type = 455 DT_UNKNOWN; 456 idp->uio = uio; 457 if (ap->a_ncookies == NULL) { 458 idp->cookies = NULL; 459 } else { 460 /* 461 * Guess the number of cookies needed. 462 */ 463 ncookies = uio->uio_resid / 16; 464 MALLOC(cookies, u_long *, ncookies * sizeof(u_int), M_TEMP, 465 M_WAITOK); 466 idp->cookies = cookies; 467 idp->ncookies = ncookies; 468 } 469 idp->eofflag = 1; 470 idp->curroff = uio->uio_offset; 471 472 if ((entryoffsetinblock = idp->curroff & bmask) && 473 (error = cd9660_blkatoff(vdp, (off_t)idp->curroff, NULL, &bp))) { 474 FREE(idp, M_TEMP); 475 return (error); 476 } 477 endsearch = dp->i_size; 478 479 while (idp->curroff < endsearch) { 480 /* 481 * If offset is on a block boundary, 482 * read the next directory block. 483 * Release previous if it exists. 484 */ 485 if ((idp->curroff & bmask) == 0) { 486 if (bp != NULL) 487 brelse(bp); 488 if ((error = 489 cd9660_blkatoff(vdp, (off_t)idp->curroff, NULL, &bp)) != 0) 490 break; 491 entryoffsetinblock = 0; 492 } 493 /* 494 * Get pointer to next entry. 495 */ 496 ep = (struct iso_directory_record *) 497 ((char *)bp->b_data + entryoffsetinblock); 498 499 reclen = isonum_711(ep->length); 500 if (reclen == 0) { 501 /* skip to next block, if any */ 502 idp->curroff = 503 (idp->curroff & ~bmask) + imp->logical_block_size; 504 continue; 505 } 506 507 if (reclen < ISO_DIRECTORY_RECORD_SIZE) { 508 error = EINVAL; 509 /* illegal entry, stop */ 510 break; 511 } 512 513 if (entryoffsetinblock + reclen > imp->logical_block_size) { 514 error = EINVAL; 515 /* illegal directory, so stop looking */ 516 break; 517 } 518 519 idp->current.d_namlen = isonum_711(ep->name_len); 520 521 if (reclen < ISO_DIRECTORY_RECORD_SIZE + idp->current.d_namlen) { 522 error = EINVAL; 523 /* illegal entry, stop */ 524 break; 525 } 526 527 if (isonum_711(ep->flags)&2) 528 idp->current.d_fileno = isodirino(ep, imp); 529 else 530 idp->current.d_fileno = dbtob(bp->b_blkno) + 531 entryoffsetinblock; 532 533 idp->curroff += reclen; 534 535 switch (imp->iso_ftype) { 536 case ISO_FTYPE_RRIP: 537 cd9660_rrip_getname(ep,idp->current.d_name, &namelen, 538 &idp->current.d_fileno,imp); 539 idp->current.d_namlen = (u_char)namelen; 540 if (idp->current.d_namlen) 541 error = iso_uiodir(idp,&idp->current,idp->curroff); 542 break; 543 default: /* ISO_FTYPE_DEFAULT || ISO_FTYPE_9660 || ISO_FTYPE_HIGH_SIERRA*/ 544 strcpy(idp->current.d_name,".."); 545 if (idp->current.d_namlen == 1 && ep->name[0] == 0) { 546 idp->current.d_namlen = 1; 547 error = iso_uiodir(idp,&idp->current,idp->curroff); 548 } else if (idp->current.d_namlen == 1 && ep->name[0] == 1) { 549 idp->current.d_namlen = 2; 550 error = iso_uiodir(idp,&idp->current,idp->curroff); 551 } else { 552 isofntrans(ep->name,idp->current.d_namlen, 553 idp->current.d_name, &namelen, 554 imp->iso_ftype == ISO_FTYPE_9660, 555 isonum_711(ep->flags)&4, 556 imp->joliet_level); 557 idp->current.d_namlen = (u_char)namelen; 558 if (imp->iso_ftype == ISO_FTYPE_DEFAULT) 559 error = iso_shipdir(idp); 560 else 561 error = iso_uiodir(idp,&idp->current,idp->curroff); 562 } 563 } 564 if (error) 565 break; 566 567 entryoffsetinblock += reclen; 568 } 569 570 if (!error && imp->iso_ftype == ISO_FTYPE_DEFAULT) { 571 idp->current.d_namlen = 0; 572 error = iso_shipdir(idp); 573 } 574 if (error < 0) 575 error = 0; 576 577 if (ap->a_ncookies != NULL) { 578 if (error) 579 free(cookies, M_TEMP); 580 else { 581 /* 582 * Work out the number of cookies actually used. 583 */ 584 *ap->a_ncookies = ncookies - idp->ncookies; 585 *ap->a_cookies = cookies; 586 } 587 } 588 589 if (bp) 590 brelse (bp); 591 592 uio->uio_offset = idp->uio_off; 593 *ap->a_eofflag = idp->eofflag; 594 595 FREE(idp, M_TEMP); 596 597 return (error); 598 } 599 600 /* 601 * Return target name of a symbolic link 602 * Shouldn't we get the parent vnode and read the data from there? 603 * This could eventually result in deadlocks in cd9660_lookup. 604 * But otherwise the block read here is in the block buffer two times. 605 */ 606 typedef struct iso_directory_record ISODIR; 607 typedef struct iso_node ISONODE; 608 typedef struct iso_mnt ISOMNT; 609 static int 610 cd9660_readlink(ap) 611 struct vop_readlink_args /* { 612 struct vnode *a_vp; 613 struct uio *a_uio; 614 struct ucred *a_cred; 615 } */ *ap; 616 { 617 ISONODE *ip; 618 ISODIR *dirp; 619 ISOMNT *imp; 620 struct buf *bp; 621 struct uio *uio; 622 u_short symlen; 623 int error; 624 char *symname; 625 626 ip = VTOI(ap->a_vp); 627 imp = ip->i_mnt; 628 uio = ap->a_uio; 629 630 if (imp->iso_ftype != ISO_FTYPE_RRIP) 631 return (EINVAL); 632 633 /* 634 * Get parents directory record block that this inode included. 635 */ 636 error = bread(imp->im_devvp, 637 (ip->i_number >> imp->im_bshift) << 638 (imp->im_bshift - DEV_BSHIFT), 639 imp->logical_block_size, NOCRED, &bp); 640 if (error) { 641 brelse(bp); 642 return (EINVAL); 643 } 644 645 /* 646 * Setup the directory pointer for this inode 647 */ 648 dirp = (ISODIR *)(bp->b_data + (ip->i_number & imp->im_bmask)); 649 650 /* 651 * Just make sure, we have a right one.... 652 * 1: Check not cross boundary on block 653 */ 654 if ((ip->i_number & imp->im_bmask) + isonum_711(dirp->length) 655 > (unsigned)imp->logical_block_size) { 656 brelse(bp); 657 return (EINVAL); 658 } 659 660 /* 661 * Now get a buffer 662 * Abuse a namei buffer for now. 663 */ 664 if (uio->uio_segflg == UIO_SYSSPACE) 665 symname = uio->uio_iov->iov_base; 666 else 667 symname = uma_zalloc(namei_zone, M_WAITOK); 668 669 /* 670 * Ok, we just gathering a symbolic name in SL record. 671 */ 672 if (cd9660_rrip_getsymname(dirp, symname, &symlen, imp) == 0) { 673 if (uio->uio_segflg != UIO_SYSSPACE) 674 uma_zfree(namei_zone, symname); 675 brelse(bp); 676 return (EINVAL); 677 } 678 /* 679 * Don't forget before you leave from home ;-) 680 */ 681 brelse(bp); 682 683 /* 684 * return with the symbolic name to caller's. 685 */ 686 if (uio->uio_segflg != UIO_SYSSPACE) { 687 error = uiomove(symname, symlen, uio); 688 uma_zfree(namei_zone, symname); 689 return (error); 690 } 691 uio->uio_resid -= symlen; 692 uio->uio_iov->iov_base += symlen; 693 uio->uio_iov->iov_len -= symlen; 694 return (0); 695 } 696 697 /* 698 * Calculate the logical to physical mapping if not done already, 699 * then call the device strategy routine. 700 */ 701 static int 702 cd9660_strategy(ap) 703 struct vop_strategy_args /* { 704 struct buf *a_vp; 705 struct buf *a_bp; 706 } */ *ap; 707 { 708 register struct buf *bp = ap->a_bp; 709 register struct vnode *vp = bp->b_vp; 710 register struct iso_node *ip; 711 712 ip = VTOI(vp); 713 if (vp->v_type == VBLK || vp->v_type == VCHR) 714 panic("cd9660_strategy: spec"); 715 if (bp->b_blkno == bp->b_lblkno) { 716 bp->b_blkno = (ip->iso_start + bp->b_lblkno) << 717 (ip->i_mnt->im_bshift - DEV_BSHIFT); 718 if ((long)bp->b_blkno == -1) /* XXX: cut&paste junk ? */ 719 clrbuf(bp); 720 } 721 if ((long)bp->b_blkno == -1) { /* XXX: cut&paste junk ? */ 722 bufdone(bp); 723 return (0); 724 } 725 vp = ip->i_devvp; 726 bp->b_dev = vp->v_rdev; 727 VOP_STRATEGY(vp, bp); 728 return (0); 729 } 730 731 /* 732 * Print out the contents of an inode. 733 */ 734 static int 735 cd9660_print(ap) 736 struct vop_print_args /* { 737 struct vnode *a_vp; 738 } */ *ap; 739 { 740 741 printf("tag VT_ISOFS, isofs vnode\n"); 742 return (0); 743 } 744 745 /* 746 * Return POSIX pathconf information applicable to cd9660 filesystems. 747 */ 748 static int 749 cd9660_pathconf(ap) 750 struct vop_pathconf_args /* { 751 struct vnode *a_vp; 752 int a_name; 753 register_t *a_retval; 754 } */ *ap; 755 { 756 757 switch (ap->a_name) { 758 case _PC_LINK_MAX: 759 *ap->a_retval = 1; 760 return (0); 761 case _PC_NAME_MAX: 762 if (VTOI(ap->a_vp)->i_mnt->iso_ftype == ISO_FTYPE_RRIP) 763 *ap->a_retval = NAME_MAX; 764 else 765 *ap->a_retval = 37; 766 return (0); 767 case _PC_PATH_MAX: 768 *ap->a_retval = PATH_MAX; 769 return (0); 770 case _PC_PIPE_BUF: 771 *ap->a_retval = PIPE_BUF; 772 return (0); 773 case _PC_CHOWN_RESTRICTED: 774 *ap->a_retval = 1; 775 return (0); 776 case _PC_NO_TRUNC: 777 *ap->a_retval = 1; 778 return (0); 779 default: 780 return (EINVAL); 781 } 782 /* NOTREACHED */ 783 } 784 785 /* 786 * Global vfs data structures for cd9660 787 */ 788 vop_t **cd9660_vnodeop_p; 789 static struct vnodeopv_entry_desc cd9660_vnodeop_entries[] = { 790 { &vop_default_desc, (vop_t *) vop_defaultop }, 791 { &vop_access_desc, (vop_t *) cd9660_access }, 792 { &vop_bmap_desc, (vop_t *) cd9660_bmap }, 793 { &vop_cachedlookup_desc, (vop_t *) cd9660_lookup }, 794 { &vop_getattr_desc, (vop_t *) cd9660_getattr }, 795 { &vop_inactive_desc, (vop_t *) cd9660_inactive }, 796 { &vop_ioctl_desc, (vop_t *) cd9660_ioctl }, 797 { &vop_islocked_desc, (vop_t *) vop_stdislocked }, 798 { &vop_lock_desc, (vop_t *) vop_stdlock }, 799 { &vop_lookup_desc, (vop_t *) vfs_cache_lookup }, 800 { &vop_pathconf_desc, (vop_t *) cd9660_pathconf }, 801 { &vop_print_desc, (vop_t *) cd9660_print }, 802 { &vop_read_desc, (vop_t *) cd9660_read }, 803 { &vop_readdir_desc, (vop_t *) cd9660_readdir }, 804 { &vop_readlink_desc, (vop_t *) cd9660_readlink }, 805 { &vop_reclaim_desc, (vop_t *) cd9660_reclaim }, 806 { &vop_setattr_desc, (vop_t *) cd9660_setattr }, 807 { &vop_strategy_desc, (vop_t *) cd9660_strategy }, 808 { &vop_unlock_desc, (vop_t *) vop_stdunlock }, 809 { NULL, NULL } 810 }; 811 static struct vnodeopv_desc cd9660_vnodeop_opv_desc = 812 { &cd9660_vnodeop_p, cd9660_vnodeop_entries }; 813 VNODEOP_SET(cd9660_vnodeop_opv_desc); 814 815 /* 816 * Special device vnode ops 817 */ 818 vop_t **cd9660_specop_p; 819 static struct vnodeopv_entry_desc cd9660_specop_entries[] = { 820 { &vop_default_desc, (vop_t *) spec_vnoperate }, 821 { &vop_access_desc, (vop_t *) cd9660_access }, 822 { &vop_getattr_desc, (vop_t *) cd9660_getattr }, 823 { &vop_inactive_desc, (vop_t *) cd9660_inactive }, 824 { &vop_islocked_desc, (vop_t *) vop_stdislocked }, 825 { &vop_lock_desc, (vop_t *) vop_stdlock }, 826 { &vop_print_desc, (vop_t *) cd9660_print }, 827 { &vop_reclaim_desc, (vop_t *) cd9660_reclaim }, 828 { &vop_setattr_desc, (vop_t *) cd9660_setattr }, 829 { &vop_unlock_desc, (vop_t *) vop_stdunlock }, 830 { NULL, NULL } 831 }; 832 static struct vnodeopv_desc cd9660_specop_opv_desc = 833 { &cd9660_specop_p, cd9660_specop_entries }; 834 VNODEOP_SET(cd9660_specop_opv_desc); 835 836 vop_t **cd9660_fifoop_p; 837 static struct vnodeopv_entry_desc cd9660_fifoop_entries[] = { 838 { &vop_default_desc, (vop_t *) fifo_vnoperate }, 839 { &vop_access_desc, (vop_t *) cd9660_access }, 840 { &vop_getattr_desc, (vop_t *) cd9660_getattr }, 841 { &vop_inactive_desc, (vop_t *) cd9660_inactive }, 842 { &vop_islocked_desc, (vop_t *) vop_stdislocked }, 843 { &vop_lock_desc, (vop_t *) vop_stdlock }, 844 { &vop_print_desc, (vop_t *) cd9660_print }, 845 { &vop_reclaim_desc, (vop_t *) cd9660_reclaim }, 846 { &vop_setattr_desc, (vop_t *) cd9660_setattr }, 847 { &vop_unlock_desc, (vop_t *) vop_stdunlock }, 848 { NULL, NULL } 849 }; 850 static struct vnodeopv_desc cd9660_fifoop_opv_desc = 851 { &cd9660_fifoop_p, cd9660_fifoop_entries }; 852 853 VNODEOP_SET(cd9660_fifoop_opv_desc); 854