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.3 (Berkeley) 1/23/94 39 * $Id: cd9660_vnops.c,v 1.3 1994/08/02 07:41:36 davidg Exp $ 40 */ 41 42 #include <sys/param.h> 43 #include <sys/systm.h> 44 #include <sys/namei.h> 45 #include <sys/resourcevar.h> 46 #include <sys/kernel.h> 47 #include <sys/file.h> 48 #include <sys/stat.h> 49 #include <sys/buf.h> 50 #include <sys/proc.h> 51 #include <sys/conf.h> 52 #include <sys/mount.h> 53 #include <sys/vnode.h> 54 #include <miscfs/specfs/specdev.h> 55 #include <miscfs/fifofs/fifo.h> 56 #include <sys/malloc.h> 57 #include <sys/dir.h> 58 59 #include <isofs/cd9660/iso.h> 60 #include <isofs/cd9660/cd9660_node.h> 61 #include <isofs/cd9660/iso_rrip.h> 62 63 #if 0 64 /* 65 * Mknod vnode call 66 * Actually remap the device number 67 */ 68 cd9660_mknod(ndp, vap, cred, p) 69 struct nameidata *ndp; 70 struct ucred *cred; 71 struct vattr *vap; 72 struct proc *p; 73 { 74 #ifndef ISODEVMAP 75 free(ndp->ni_pnbuf, M_NAMEI); 76 vput(ndp->ni_dvp); 77 vput(ndp->ni_vp); 78 return EINVAL; 79 #else 80 register struct vnode *vp; 81 struct iso_node *ip; 82 struct iso_dnode *dp; 83 int error; 84 85 vp = ndp->ni_vp; 86 ip = VTOI(vp); 87 88 if (ip->i_mnt->iso_ftype != ISO_FTYPE_RRIP 89 || vap->va_type != vp->v_type 90 || (vap->va_type != VCHR && vap->va_type != VBLK)) { 91 free(ndp->ni_pnbuf, M_NAMEI); 92 vput(ndp->ni_dvp); 93 vput(ndp->ni_vp); 94 return EINVAL; 95 } 96 97 dp = iso_dmap(ip->i_dev,ip->i_number,1); 98 if (ip->inode.iso_rdev == vap->va_rdev || vap->va_rdev == VNOVAL) { 99 /* same as the unmapped one, delete the mapping */ 100 remque(dp); 101 FREE(dp,M_CACHE); 102 } else 103 /* enter new mapping */ 104 dp->d_dev = vap->va_rdev; 105 106 /* 107 * Remove inode so that it will be reloaded by iget and 108 * checked to see if it is an alias of an existing entry 109 * in the inode cache. 110 */ 111 vput(vp); 112 vp->v_type = VNON; 113 vgone(vp); 114 return (0); 115 #endif 116 } 117 #endif 118 119 /* 120 * Open called. 121 * 122 * Nothing to do. 123 */ 124 /* ARGSUSED */ 125 int 126 cd9660_open(ap) 127 struct vop_open_args /* { 128 struct vnode *a_vp; 129 int a_mode; 130 struct ucred *a_cred; 131 struct proc *a_p; 132 } */ *ap; 133 { 134 return (0); 135 } 136 137 /* 138 * Close called 139 * 140 * Update the times on the inode on writeable file systems. 141 */ 142 /* ARGSUSED */ 143 int 144 cd9660_close(ap) 145 struct vop_close_args /* { 146 struct vnode *a_vp; 147 int a_fflag; 148 struct ucred *a_cred; 149 struct proc *a_p; 150 } */ *ap; 151 { 152 return (0); 153 } 154 155 /* 156 * Check mode permission on inode pointer. Mode is READ, WRITE or EXEC. 157 * The mode is shifted to select the owner/group/other fields. The 158 * super user is granted all permissions. 159 */ 160 /* ARGSUSED */ 161 int 162 cd9660_access(ap) 163 struct vop_access_args /* { 164 struct vnode *a_vp; 165 int a_mode; 166 struct ucred *a_cred; 167 struct proc *a_p; 168 } */ *ap; 169 { 170 return (0); 171 } 172 173 int 174 cd9660_getattr(ap) 175 struct vop_getattr_args /* { 176 struct vnode *a_vp; 177 struct vattr *a_vap; 178 struct ucred *a_cred; 179 struct proc *a_p; 180 } */ *ap; 181 182 { 183 struct vnode *vp = ap->a_vp; 184 register struct vattr *vap = ap->a_vap; 185 register struct iso_node *ip = VTOI(vp); 186 int i; 187 188 vap->va_fsid = ip->i_dev; 189 vap->va_fileid = ip->i_number; 190 191 vap->va_mode = ip->inode.iso_mode; 192 vap->va_nlink = ip->inode.iso_links; 193 vap->va_uid = ip->inode.iso_uid; 194 vap->va_gid = ip->inode.iso_gid; 195 vap->va_atime = ip->inode.iso_atime; 196 vap->va_mtime = ip->inode.iso_mtime; 197 vap->va_ctime = ip->inode.iso_ctime; 198 vap->va_rdev = ip->inode.iso_rdev; 199 200 vap->va_size = (u_quad_t) ip->i_size; 201 vap->va_flags = 0; 202 vap->va_gen = 1; 203 vap->va_blocksize = ip->i_mnt->logical_block_size; 204 vap->va_bytes = (u_quad_t) ip->i_size; 205 vap->va_type = vp->v_type; 206 return (0); 207 } 208 209 #if ISO_DEFAULT_BLOCK_SIZE >= NBPG 210 #ifdef DEBUG 211 extern int doclusterread; 212 #else 213 #define doclusterread 1 214 #endif 215 #else 216 /* XXX until cluster routines can handle block sizes less than one page */ 217 #define doclusterread 0 218 #endif 219 220 /* 221 * Vnode op for reading. 222 */ 223 int 224 cd9660_read(ap) 225 struct vop_read_args /* { 226 struct vnode *a_vp; 227 struct uio *a_uio; 228 int a_ioflag; 229 struct ucred *a_cred; 230 } */ *ap; 231 { 232 struct vnode *vp = ap->a_vp; 233 register struct uio *uio = ap->a_uio; 234 register struct iso_node *ip = VTOI(vp); 235 register struct iso_mnt *imp; 236 struct buf *bp; 237 daddr_t lbn, bn, rablock; 238 off_t diff; 239 int rasize, error = 0; 240 long size, n, on; 241 242 if (uio->uio_resid == 0) 243 return (0); 244 if (uio->uio_offset < 0) 245 return (EINVAL); 246 ip->i_flag |= IACC; 247 imp = ip->i_mnt; 248 do { 249 lbn = iso_lblkno(imp, uio->uio_offset); 250 on = iso_blkoff(imp, uio->uio_offset); 251 n = min((unsigned)(imp->logical_block_size - on), 252 uio->uio_resid); 253 diff = (off_t)ip->i_size - uio->uio_offset; 254 if (diff <= 0) 255 return (0); 256 if (diff < n) 257 n = diff; 258 size = iso_blksize(imp, ip, lbn); 259 rablock = lbn + 1; 260 if (doclusterread) { 261 if (iso_lblktosize(imp, rablock) <= ip->i_size) 262 error = cluster_read(vp, (off_t)ip->i_size, 263 lbn, size, NOCRED, &bp); 264 else 265 error = bread(vp, lbn, size, NOCRED, &bp); 266 } else { 267 if (vp->v_lastr + 1 == lbn && 268 iso_lblktosize(imp, rablock) < ip->i_size) { 269 rasize = iso_blksize(imp, ip, rablock); 270 error = breadn(vp, lbn, size, &rablock, 271 &rasize, 1, NOCRED, &bp); 272 } else 273 error = bread(vp, lbn, size, NOCRED, &bp); 274 } 275 vp->v_lastr = lbn; 276 n = min(n, size - bp->b_resid); 277 if (error) { 278 brelse(bp); 279 return (error); 280 } 281 282 error = uiomove(bp->b_un.b_addr + on, (int)n, uio); 283 brelse(bp); 284 } while (error == 0 && uio->uio_resid > 0 && n != 0); 285 return (error); 286 } 287 288 /* ARGSUSED */ 289 int 290 cd9660_ioctl(ap) 291 struct vop_ioctl_args /* { 292 struct vnode *a_vp; 293 int a_command; 294 caddr_t a_data; 295 int a_fflag; 296 struct ucred *a_cred; 297 struct proc *a_p; 298 } */ *ap; 299 { 300 printf("You did ioctl for isofs !!\n"); 301 return (ENOTTY); 302 } 303 304 /* ARGSUSED */ 305 int 306 cd9660_select(ap) 307 struct vop_select_args /* { 308 struct vnode *a_vp; 309 int a_which; 310 int a_fflags; 311 struct ucred *a_cred; 312 struct proc *a_p; 313 } */ *ap; 314 { 315 316 /* 317 * We should really check to see if I/O is possible. 318 */ 319 return (1); 320 } 321 322 /* 323 * Mmap a file 324 * 325 * NB Currently unsupported. 326 */ 327 /* ARGSUSED */ 328 int 329 cd9660_mmap(ap) 330 struct vop_mmap_args /* { 331 struct vnode *a_vp; 332 int a_fflags; 333 struct ucred *a_cred; 334 struct proc *a_p; 335 } */ *ap; 336 { 337 338 return (EINVAL); 339 } 340 341 /* 342 * Seek on a file 343 * 344 * Nothing to do, so just return. 345 */ 346 /* ARGSUSED */ 347 int 348 cd9660_seek(ap) 349 struct vop_seek_args /* { 350 struct vnode *a_vp; 351 off_t a_oldoff; 352 off_t a_newoff; 353 struct ucred *a_cred; 354 } */ *ap; 355 { 356 357 return (0); 358 } 359 360 /* 361 * Structure for reading directories 362 */ 363 struct isoreaddir { 364 struct dirent saveent; 365 struct dirent assocent; 366 struct dirent current; 367 off_t saveoff; 368 off_t assocoff; 369 off_t curroff; 370 struct uio *uio; 371 off_t uio_off; 372 u_int *cookiep; 373 int ncookies; 374 int eof; 375 }; 376 377 static int 378 iso_uiodir(idp,dp,off) 379 struct isoreaddir *idp; 380 struct dirent *dp; 381 off_t off; 382 { 383 int error; 384 385 dp->d_name[dp->d_namlen] = 0; 386 dp->d_reclen = DIRSIZ(dp); 387 388 if (idp->uio->uio_resid < dp->d_reclen) { 389 idp->eof = 0; 390 return -1; 391 } 392 393 if (idp->cookiep) { 394 if (idp->ncookies <= 0) { 395 idp->eof = 0; 396 return -1; 397 } 398 399 *idp->cookiep++ = off; 400 --idp->ncookies; 401 } 402 403 if (error = uiomove(dp,dp->d_reclen,idp->uio)) 404 return error; 405 idp->uio_off = off; 406 return 0; 407 } 408 409 static int 410 iso_shipdir(idp) 411 struct isoreaddir *idp; 412 { 413 struct dirent *dp; 414 int cl, sl, assoc; 415 int error; 416 char *cname, *sname; 417 418 cl = idp->current.d_namlen; 419 cname = idp->current.d_name; 420 if (assoc = cl > 1 && *cname == ASSOCCHAR) { 421 cl--; 422 cname++; 423 } 424 425 dp = &idp->saveent; 426 sname = dp->d_name; 427 if (!(sl = dp->d_namlen)) { 428 dp = &idp->assocent; 429 sname = dp->d_name + 1; 430 sl = dp->d_namlen - 1; 431 } 432 if (sl > 0) { 433 if (sl != cl 434 || bcmp(sname,cname,sl)) { 435 if (idp->assocent.d_namlen) { 436 if (error = iso_uiodir(idp,&idp->assocent,idp->assocoff)) 437 return error; 438 idp->assocent.d_namlen = 0; 439 } 440 if (idp->saveent.d_namlen) { 441 if (error = iso_uiodir(idp,&idp->saveent,idp->saveoff)) 442 return error; 443 idp->saveent.d_namlen = 0; 444 } 445 } 446 } 447 idp->current.d_reclen = DIRSIZ(&idp->current); 448 if (assoc) { 449 idp->assocoff = idp->curroff; 450 bcopy(&idp->current,&idp->assocent,idp->current.d_reclen); 451 } else { 452 idp->saveoff = idp->curroff; 453 bcopy(&idp->current,&idp->saveent,idp->current.d_reclen); 454 } 455 return 0; 456 } 457 458 /* 459 * Vnode op for readdir 460 * XXX make sure everything still works now that eofflagp and cookiep 461 * are no longer args. 462 */ 463 int 464 cd9660_readdir(ap) 465 struct vop_readdir_args /* { 466 struct vnode *a_vp; 467 struct uio *a_uio; 468 struct ucred *a_cred; 469 } */ *ap; 470 { 471 register struct uio *uio = ap->a_uio; 472 struct isoreaddir *idp; 473 int entryoffsetinblock; 474 int error = 0; 475 int endsearch; 476 struct iso_directory_record *ep; 477 u_short elen; 478 int reclen; 479 struct iso_mnt *imp; 480 struct iso_node *ip; 481 struct buf *bp = NULL; 482 483 ip = VTOI(ap->a_vp); 484 imp = ip->i_mnt; 485 486 MALLOC(idp,struct isoreaddir *,sizeof(*idp),M_TEMP,M_WAITOK); 487 idp->saveent.d_namlen = 0; 488 idp->assocent.d_namlen = 0; 489 idp->uio = uio; 490 #if 0 491 idp->cookiep = cookies; 492 idp->ncookies = ncookies; 493 idp->eof = 1; 494 #else 495 idp->cookiep = 0; 496 #endif 497 idp->curroff = uio->uio_offset; 498 499 entryoffsetinblock = iso_blkoff(imp, idp->curroff); 500 if (entryoffsetinblock != 0) { 501 if (error = iso_blkatoff(ip, idp->curroff, &bp)) { 502 FREE(idp,M_TEMP); 503 return (error); 504 } 505 } 506 507 endsearch = ip->i_size; 508 509 while (idp->curroff < endsearch) { 510 /* 511 * If offset is on a block boundary, 512 * read the next directory block. 513 * Release previous if it exists. 514 */ 515 516 if (iso_blkoff(imp, idp->curroff) == 0) { 517 if (bp != NULL) 518 brelse(bp); 519 if (error = iso_blkatoff(ip, idp->curroff, &bp)) 520 break; 521 entryoffsetinblock = 0; 522 } 523 /* 524 * Get pointer to next entry. 525 */ 526 527 ep = (struct iso_directory_record *) 528 (bp->b_un.b_addr + entryoffsetinblock); 529 530 reclen = isonum_711 (ep->length); 531 if (reclen == 0) { 532 /* skip to next block, if any */ 533 idp->curroff = roundup (idp->curroff, 534 imp->logical_block_size); 535 continue; 536 } 537 538 if (reclen < ISO_DIRECTORY_RECORD_SIZE) { 539 error = EINVAL; 540 /* illegal entry, stop */ 541 break; 542 } 543 544 if (entryoffsetinblock + reclen > imp->logical_block_size) { 545 error = EINVAL; 546 /* illegal directory, so stop looking */ 547 break; 548 } 549 550 idp->current.d_namlen = isonum_711 (ep->name_len); 551 if (isonum_711(ep->flags)&2) 552 isodirino(&idp->current.d_fileno,ep,imp); 553 else 554 idp->current.d_fileno = dbtob(bp->b_blkno) + 555 idp->curroff; 556 557 if (reclen < ISO_DIRECTORY_RECORD_SIZE + idp->current.d_namlen) { 558 error = EINVAL; 559 /* illegal entry, stop */ 560 break; 561 } 562 563 idp->curroff += reclen; 564 /* 565 * 566 */ 567 switch (imp->iso_ftype) { 568 case ISO_FTYPE_RRIP: 569 cd9660_rrip_getname(ep,idp->current.d_name, 570 (u_short *)&idp->current.d_namlen, 571 &idp->current.d_fileno,imp); 572 if (idp->current.d_namlen) 573 error = iso_uiodir(idp,&idp->current,idp->curroff); 574 break; 575 default: /* ISO_FTYPE_DEFAULT || ISO_FTYPE_9660 */ 576 strcpy(idp->current.d_name,".."); 577 switch (ep->name[0]) { 578 case 0: 579 idp->current.d_namlen = 1; 580 error = iso_uiodir(idp,&idp->current,idp->curroff); 581 break; 582 case 1: 583 idp->current.d_namlen = 2; 584 error = iso_uiodir(idp,&idp->current,idp->curroff); 585 break; 586 default: 587 isofntrans(ep->name,idp->current.d_namlen, 588 idp->current.d_name, &elen, 589 imp->iso_ftype == ISO_FTYPE_9660, 590 isonum_711(ep->flags)&4); 591 idp->current.d_namlen = (u_char)elen; 592 if (imp->iso_ftype == ISO_FTYPE_DEFAULT) 593 error = iso_shipdir(idp); 594 else 595 error = iso_uiodir(idp,&idp->current,idp->curroff); 596 break; 597 } 598 } 599 if (error) 600 break; 601 602 entryoffsetinblock += reclen; 603 } 604 605 if (!error && imp->iso_ftype == ISO_FTYPE_DEFAULT) { 606 idp->current.d_namlen = 0; 607 error = iso_shipdir(idp); 608 } 609 if (error < 0) 610 error = 0; 611 612 if (bp) 613 brelse (bp); 614 615 uio->uio_offset = idp->uio_off; 616 #if 0 617 *eofflagp = idp->eof; 618 #endif 619 620 FREE(idp,M_TEMP); 621 622 return (error); 623 } 624 625 /* 626 * Return target name of a symbolic link 627 * Shouldn't we get the parent vnode and read the data from there? 628 * This could eventually result in deadlocks in cd9660_lookup. 629 * But otherwise the block read here is in the block buffer two times. 630 */ 631 typedef struct iso_directory_record ISODIR; 632 typedef struct iso_node ISONODE; 633 typedef struct iso_mnt ISOMNT; 634 int 635 cd9660_readlink(ap) 636 struct vop_readlink_args /* { 637 struct vnode *a_vp; 638 struct uio *a_uio; 639 struct ucred *a_cred; 640 } */ *ap; 641 { 642 ISONODE *ip; 643 ISODIR *dirp; 644 ISOMNT *imp; 645 struct buf *bp; 646 u_short symlen; 647 int error; 648 char *symname; 649 ino_t ino; 650 651 ip = VTOI(ap->a_vp); 652 imp = ip->i_mnt; 653 654 if (imp->iso_ftype != ISO_FTYPE_RRIP) 655 return EINVAL; 656 657 /* 658 * Get parents directory record block that this inode included. 659 */ 660 error = bread(imp->im_devvp, 661 (daddr_t)(ip->i_number / DEV_BSIZE), 662 imp->logical_block_size, 663 NOCRED, 664 &bp); 665 if (error) { 666 brelse(bp); 667 return EINVAL; 668 } 669 670 /* 671 * Setup the directory pointer for this inode 672 */ 673 dirp = (ISODIR *)(bp->b_un.b_addr + (ip->i_number & imp->im_bmask)); 674 #ifdef DEBUG 675 printf("lbn=%d,off=%d,bsize=%d,DEV_BSIZE=%d, dirp= %08x, b_addr=%08x, offset=%08x(%08x)\n", 676 (daddr_t)(ip->i_number >> imp->im_bshift), 677 ip->i_number & imp->im_bmask, 678 imp->logical_block_size, 679 DEV_BSIZE, 680 dirp, 681 bp->b_un.b_addr, 682 ip->i_number, 683 ip->i_number & imp->im_bmask ); 684 #endif 685 686 /* 687 * Just make sure, we have a right one.... 688 * 1: Check not cross boundary on block 689 */ 690 if ((ip->i_number & imp->im_bmask) + isonum_711(dirp->length) 691 > imp->logical_block_size) { 692 brelse(bp); 693 return EINVAL; 694 } 695 696 /* 697 * Now get a buffer 698 * Abuse a namei buffer for now. 699 */ 700 MALLOC(symname,char *,MAXPATHLEN,M_NAMEI,M_WAITOK); 701 702 /* 703 * Ok, we just gathering a symbolic name in SL record. 704 */ 705 if (cd9660_rrip_getsymname(dirp,symname,&symlen,imp) == 0) { 706 FREE(symname,M_NAMEI); 707 brelse(bp); 708 return EINVAL; 709 } 710 /* 711 * Don't forget before you leave from home ;-) 712 */ 713 brelse(bp); 714 715 /* 716 * return with the symbolic name to caller's. 717 */ 718 error = uiomove(symname,symlen,ap->a_uio); 719 720 FREE(symname,M_NAMEI); 721 722 return error; 723 } 724 725 /* 726 * Ufs abort op, called after namei() when a CREATE/DELETE isn't actually 727 * done. If a buffer has been saved in anticipation of a CREATE, delete it. 728 */ 729 int 730 cd9660_abortop(ap) 731 struct vop_abortop_args /* { 732 struct vnode *a_dvp; 733 struct componentname *a_cnp; 734 } */ *ap; 735 { 736 if ((ap->a_cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF) 737 FREE(ap->a_cnp->cn_pnbuf, M_NAMEI); 738 return 0; 739 } 740 741 /* 742 * Lock an inode. 743 */ 744 int 745 cd9660_lock(ap) 746 struct vop_lock_args /* { 747 struct vnode *a_vp; 748 } */ *ap; 749 { 750 register struct iso_node *ip = VTOI(ap->a_vp); 751 752 ISO_ILOCK(ip); 753 return 0; 754 } 755 756 /* 757 * Unlock an inode. 758 */ 759 int 760 cd9660_unlock(ap) 761 struct vop_unlock_args /* { 762 struct vnode *a_vp; 763 } */ *ap; 764 { 765 register struct iso_node *ip = VTOI(ap->a_vp); 766 767 if (!(ip->i_flag & ILOCKED)) 768 panic("cd9660_unlock NOT LOCKED"); 769 ISO_IUNLOCK(ip); 770 return 0; 771 } 772 773 /* 774 * Check for a locked inode. 775 */ 776 int 777 cd9660_islocked(ap) 778 struct vop_islocked_args /* { 779 struct vnode *a_vp; 780 } */ *ap; 781 { 782 783 if (VTOI(ap->a_vp)->i_flag & ILOCKED) 784 return 1; 785 return 0; 786 } 787 788 /* 789 * Calculate the logical to physical mapping if not done already, 790 * then call the device strategy routine. 791 */ 792 int 793 cd9660_strategy(ap) 794 struct vop_strategy_args /* { 795 struct buf *a_bp; 796 } */ *ap; 797 { 798 register struct buf *bp = ap->a_bp; 799 register struct vnode *vp = bp->b_vp; 800 register struct iso_node *ip; 801 int error; 802 803 ip = VTOI(vp); 804 if (vp->v_type == VBLK || vp->v_type == VCHR) 805 panic("cd9660_strategy: spec"); 806 if (bp->b_blkno == bp->b_lblkno) { 807 if (error = 808 VOP_BMAP(vp, bp->b_lblkno, NULL, &bp->b_blkno, NULL)) { 809 bp->b_error = error; 810 bp->b_flags |= B_ERROR; 811 biodone(bp); 812 return (error); 813 } 814 if ((long)bp->b_blkno == -1) 815 clrbuf(bp); 816 } 817 if ((long)bp->b_blkno == -1) { 818 biodone(bp); 819 return (0); 820 } 821 vp = ip->i_devvp; 822 bp->b_dev = vp->v_rdev; 823 VOCALL (vp->v_op, VOFFSET(vop_strategy), ap); 824 return (0); 825 } 826 827 /* 828 * Print out the contents of an inode. 829 */ 830 int 831 cd9660_print(ap) 832 struct vop_print_args /* { 833 struct vnode *a_vp; 834 } */ *ap; 835 { 836 printf("tag VT_ISOFS, isofs vnode\n"); 837 return 0; 838 } 839 840 /* 841 * Unsupported operation 842 */ 843 int 844 cd9660_enotsupp() 845 { 846 847 return (EOPNOTSUPP); 848 } 849 850 /* 851 * Global vfs data structures for isofs 852 */ 853 #define cd9660_create \ 854 ((int (*) __P((struct vop_create_args *)))cd9660_enotsupp) 855 #define cd9660_mknod ((int (*) __P((struct vop_mknod_args *)))cd9660_enotsupp) 856 #define cd9660_setattr \ 857 ((int (*) __P((struct vop_setattr_args *)))cd9660_enotsupp) 858 #define cd9660_write ((int (*) __P((struct vop_write_args *)))cd9660_enotsupp) 859 #define cd9660_fsync ((int (*) __P((struct vop_fsync_args *)))nullop) 860 #define cd9660_remove \ 861 ((int (*) __P((struct vop_remove_args *)))cd9660_enotsupp) 862 #define cd9660_link ((int (*) __P((struct vop_link_args *)))cd9660_enotsupp) 863 #define cd9660_rename \ 864 ((int (*) __P((struct vop_rename_args *)))cd9660_enotsupp) 865 #define cd9660_mkdir ((int (*) __P((struct vop_mkdir_args *)))cd9660_enotsupp) 866 #define cd9660_rmdir ((int (*) __P((struct vop_rmdir_args *)))cd9660_enotsupp) 867 #define cd9660_symlink \ 868 ((int (*) __P((struct vop_symlink_args *)))cd9660_enotsupp) 869 #define cd9660_pathconf \ 870 ((int (*) __P((struct vop_pathconf_args *)))cd9660_enotsupp) 871 #define cd9660_advlock \ 872 ((int (*) __P((struct vop_advlock_args *)))cd9660_enotsupp) 873 #define cd9660_blkatoff \ 874 ((int (*) __P((struct vop_blkatoff_args *)))cd9660_enotsupp) 875 #define cd9660_valloc ((int(*) __P(( \ 876 struct vnode *pvp, \ 877 int mode, \ 878 struct ucred *cred, \ 879 struct vnode **vpp))) cd9660_enotsupp) 880 #define cd9660_vfree ((int (*) __P((struct vop_vfree_args *)))cd9660_enotsupp) 881 #define cd9660_truncate \ 882 ((int (*) __P((struct vop_truncate_args *)))cd9660_enotsupp) 883 #define cd9660_update \ 884 ((int (*) __P((struct vop_update_args *)))cd9660_enotsupp) 885 #define cd9660_bwrite \ 886 ((int (*) __P((struct vop_bwrite_args *)))cd9660_enotsupp) 887 888 /* 889 * Global vfs data structures for nfs 890 */ 891 int (**cd9660_vnodeop_p)(); 892 struct vnodeopv_entry_desc cd9660_vnodeop_entries[] = { 893 { &vop_default_desc, vn_default_error }, 894 { &vop_lookup_desc, cd9660_lookup }, /* lookup */ 895 { &vop_create_desc, cd9660_create }, /* create */ 896 { &vop_mknod_desc, cd9660_mknod }, /* mknod */ 897 { &vop_open_desc, cd9660_open }, /* open */ 898 { &vop_close_desc, cd9660_close }, /* close */ 899 { &vop_access_desc, cd9660_access }, /* access */ 900 { &vop_getattr_desc, cd9660_getattr }, /* getattr */ 901 { &vop_setattr_desc, cd9660_setattr }, /* setattr */ 902 { &vop_read_desc, cd9660_read }, /* read */ 903 { &vop_write_desc, cd9660_write }, /* write */ 904 { &vop_ioctl_desc, cd9660_ioctl }, /* ioctl */ 905 { &vop_select_desc, cd9660_select }, /* select */ 906 { &vop_mmap_desc, cd9660_mmap }, /* mmap */ 907 { &vop_fsync_desc, cd9660_fsync }, /* fsync */ 908 { &vop_seek_desc, cd9660_seek }, /* seek */ 909 { &vop_remove_desc, cd9660_remove }, /* remove */ 910 { &vop_link_desc, cd9660_link }, /* link */ 911 { &vop_rename_desc, cd9660_rename }, /* rename */ 912 { &vop_mkdir_desc, cd9660_mkdir }, /* mkdir */ 913 { &vop_rmdir_desc, cd9660_rmdir }, /* rmdir */ 914 { &vop_symlink_desc, cd9660_symlink }, /* symlink */ 915 { &vop_readdir_desc, cd9660_readdir }, /* readdir */ 916 { &vop_readlink_desc, cd9660_readlink },/* readlink */ 917 { &vop_abortop_desc, cd9660_abortop }, /* abortop */ 918 { &vop_inactive_desc, cd9660_inactive },/* inactive */ 919 { &vop_reclaim_desc, cd9660_reclaim }, /* reclaim */ 920 { &vop_lock_desc, cd9660_lock }, /* lock */ 921 { &vop_unlock_desc, cd9660_unlock }, /* unlock */ 922 { &vop_bmap_desc, cd9660_bmap }, /* bmap */ 923 { &vop_strategy_desc, cd9660_strategy },/* strategy */ 924 { &vop_print_desc, cd9660_print }, /* print */ 925 { &vop_islocked_desc, cd9660_islocked },/* islocked */ 926 { &vop_pathconf_desc, cd9660_pathconf },/* pathconf */ 927 { &vop_advlock_desc, cd9660_advlock }, /* advlock */ 928 { &vop_blkatoff_desc, cd9660_blkatoff },/* blkatoff */ 929 { &vop_valloc_desc, cd9660_valloc }, /* valloc */ 930 { &vop_vfree_desc, cd9660_vfree }, /* vfree */ 931 { &vop_truncate_desc, cd9660_truncate },/* truncate */ 932 { &vop_update_desc, cd9660_update }, /* update */ 933 { &vop_bwrite_desc, vn_bwrite }, 934 { (struct vnodeop_desc*)NULL, (int(*)())NULL } 935 }; 936 struct vnodeopv_desc cd9660_vnodeop_opv_desc = 937 { &cd9660_vnodeop_p, cd9660_vnodeop_entries }; 938 939 /* 940 * Special device vnode ops 941 */ 942 int (**cd9660_specop_p)(); 943 struct vnodeopv_entry_desc cd9660_specop_entries[] = { 944 { &vop_default_desc, vn_default_error }, 945 { &vop_lookup_desc, spec_lookup }, /* lookup */ 946 { &vop_create_desc, cd9660_create }, /* create */ 947 { &vop_mknod_desc, cd9660_mknod }, /* mknod */ 948 { &vop_open_desc, spec_open }, /* open */ 949 { &vop_close_desc, spec_close }, /* close */ 950 { &vop_access_desc, cd9660_access }, /* access */ 951 { &vop_getattr_desc, cd9660_getattr }, /* getattr */ 952 { &vop_setattr_desc, cd9660_setattr }, /* setattr */ 953 { &vop_read_desc, spec_read }, /* read */ 954 { &vop_write_desc, spec_write }, /* write */ 955 { &vop_ioctl_desc, spec_ioctl }, /* ioctl */ 956 { &vop_select_desc, spec_select }, /* select */ 957 { &vop_mmap_desc, spec_mmap }, /* mmap */ 958 { &vop_fsync_desc, spec_fsync }, /* fsync */ 959 { &vop_seek_desc, spec_seek }, /* seek */ 960 { &vop_remove_desc, cd9660_remove }, /* remove */ 961 { &vop_link_desc, cd9660_link }, /* link */ 962 { &vop_rename_desc, cd9660_rename }, /* rename */ 963 { &vop_mkdir_desc, cd9660_mkdir }, /* mkdir */ 964 { &vop_rmdir_desc, cd9660_rmdir }, /* rmdir */ 965 { &vop_symlink_desc, cd9660_symlink }, /* symlink */ 966 { &vop_readdir_desc, spec_readdir }, /* readdir */ 967 { &vop_readlink_desc, spec_readlink }, /* readlink */ 968 { &vop_abortop_desc, spec_abortop }, /* abortop */ 969 { &vop_inactive_desc, cd9660_inactive },/* inactive */ 970 { &vop_reclaim_desc, cd9660_reclaim }, /* reclaim */ 971 { &vop_lock_desc, cd9660_lock }, /* lock */ 972 { &vop_unlock_desc, cd9660_unlock }, /* unlock */ 973 { &vop_bmap_desc, spec_bmap }, /* bmap */ 974 /* XXX strategy: panics, should be notsupp instead? */ 975 { &vop_strategy_desc, cd9660_strategy },/* strategy */ 976 { &vop_print_desc, cd9660_print }, /* print */ 977 { &vop_islocked_desc, cd9660_islocked },/* islocked */ 978 { &vop_pathconf_desc, spec_pathconf }, /* pathconf */ 979 { &vop_advlock_desc, spec_advlock }, /* advlock */ 980 { &vop_blkatoff_desc, spec_blkatoff }, /* blkatoff */ 981 { &vop_valloc_desc, spec_valloc }, /* valloc */ 982 { &vop_vfree_desc, spec_vfree }, /* vfree */ 983 { &vop_truncate_desc, spec_truncate }, /* truncate */ 984 { &vop_update_desc, cd9660_update }, /* update */ 985 { &vop_bwrite_desc, vn_bwrite }, 986 { (struct vnodeop_desc*)NULL, (int(*)())NULL } 987 }; 988 struct vnodeopv_desc cd9660_specop_opv_desc = 989 { &cd9660_specop_p, cd9660_specop_entries }; 990 991 #ifdef FIFO 992 int (**cd9660_fifoop_p)(); 993 struct vnodeopv_entry_desc cd9660_fifoop_entries[] = { 994 { &vop_default_desc, vn_default_error }, 995 { &vop_lookup_desc, fifo_lookup }, /* lookup */ 996 { &vop_create_desc, cd9660_create }, /* create */ 997 { &vop_mknod_desc, cd9660_mknod }, /* mknod */ 998 { &vop_open_desc, fifo_open }, /* open */ 999 { &vop_close_desc, fifo_close }, /* close */ 1000 { &vop_access_desc, cd9660_access }, /* access */ 1001 { &vop_getattr_desc, cd9660_getattr }, /* getattr */ 1002 { &vop_setattr_desc, cd9660_setattr }, /* setattr */ 1003 { &vop_read_desc, fifo_read }, /* read */ 1004 { &vop_write_desc, fifo_write }, /* write */ 1005 { &vop_ioctl_desc, fifo_ioctl }, /* ioctl */ 1006 { &vop_select_desc, fifo_select }, /* select */ 1007 { &vop_mmap_desc, fifo_mmap }, /* mmap */ 1008 { &vop_fsync_desc, fifo_fsync }, /* fsync */ 1009 { &vop_seek_desc, fifo_seek }, /* seek */ 1010 { &vop_remove_desc, cd9660_remove }, /* remove */ 1011 { &vop_link_desc, cd9660_link }, /* link */ 1012 { &vop_rename_desc, cd9660_rename }, /* rename */ 1013 { &vop_mkdir_desc, cd9660_mkdir }, /* mkdir */ 1014 { &vop_rmdir_desc, cd9660_rmdir }, /* rmdir */ 1015 { &vop_symlink_desc, cd9660_symlink }, /* symlink */ 1016 { &vop_readdir_desc, fifo_readdir }, /* readdir */ 1017 { &vop_readlink_desc, fifo_readlink }, /* readlink */ 1018 { &vop_abortop_desc, fifo_abortop }, /* abortop */ 1019 { &vop_inactive_desc, cd9660_inactive },/* inactive */ 1020 { &vop_reclaim_desc, cd9660_reclaim }, /* reclaim */ 1021 { &vop_lock_desc, cd9660_lock }, /* lock */ 1022 { &vop_unlock_desc, cd9660_unlock }, /* unlock */ 1023 { &vop_bmap_desc, fifo_bmap }, /* bmap */ 1024 { &vop_strategy_desc, fifo_badop }, /* strategy */ 1025 { &vop_print_desc, cd9660_print }, /* print */ 1026 { &vop_islocked_desc, cd9660_islocked },/* islocked */ 1027 { &vop_pathconf_desc, fifo_pathconf }, /* pathconf */ 1028 { &vop_advlock_desc, fifo_advlock }, /* advlock */ 1029 { &vop_blkatoff_desc, fifo_blkatoff }, /* blkatoff */ 1030 { &vop_valloc_desc, fifo_valloc }, /* valloc */ 1031 { &vop_vfree_desc, fifo_vfree }, /* vfree */ 1032 { &vop_truncate_desc, fifo_truncate }, /* truncate */ 1033 { &vop_update_desc, cd9660_update }, /* update */ 1034 { &vop_bwrite_desc, vn_bwrite }, 1035 { (struct vnodeop_desc*)NULL, (int(*)())NULL } 1036 }; 1037 struct vnodeopv_desc cd9660_fifoop_opv_desc = 1038 { &cd9660_fifoop_p, cd9660_fifoop_entries }; 1039 #endif /* FIFO */ 1040