1df8bae1dSRodney W. Grimes /*- 2df8bae1dSRodney W. Grimes * Copyright (c) 1994 3df8bae1dSRodney W. Grimes * The Regents of the University of California. All rights reserved. 4df8bae1dSRodney W. Grimes * 5df8bae1dSRodney W. Grimes * This code is derived from software contributed to Berkeley 6df8bae1dSRodney W. Grimes * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension 7df8bae1dSRodney W. Grimes * Support code is derived from software contributed to Berkeley 8df8bae1dSRodney W. Grimes * by Atsushi Murai (amurai@spec.co.jp). 9df8bae1dSRodney W. Grimes * 10df8bae1dSRodney W. Grimes * Redistribution and use in source and binary forms, with or without 11df8bae1dSRodney W. Grimes * modification, are permitted provided that the following conditions 12df8bae1dSRodney W. Grimes * are met: 13df8bae1dSRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 14df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer. 15df8bae1dSRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 16df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 17df8bae1dSRodney W. Grimes * documentation and/or other materials provided with the distribution. 18df8bae1dSRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 19df8bae1dSRodney W. Grimes * must display the following acknowledgement: 20df8bae1dSRodney W. Grimes * This product includes software developed by the University of 21df8bae1dSRodney W. Grimes * California, Berkeley and its contributors. 22df8bae1dSRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 23df8bae1dSRodney W. Grimes * may be used to endorse or promote products derived from this software 24df8bae1dSRodney W. Grimes * without specific prior written permission. 25df8bae1dSRodney W. Grimes * 26df8bae1dSRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27df8bae1dSRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28df8bae1dSRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29df8bae1dSRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30df8bae1dSRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31df8bae1dSRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32df8bae1dSRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33df8bae1dSRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34df8bae1dSRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35df8bae1dSRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36df8bae1dSRodney W. Grimes * SUCH DAMAGE. 37df8bae1dSRodney W. Grimes * 38996c772fSJohn Dyson * @(#)cd9660_vnops.c 8.19 (Berkeley) 5/27/95 39c3aac50fSPeter Wemm * $FreeBSD$ 40df8bae1dSRodney W. Grimes */ 41df8bae1dSRodney W. Grimes 42df8bae1dSRodney W. Grimes #include <sys/param.h> 43df8bae1dSRodney W. Grimes #include <sys/systm.h> 44df8bae1dSRodney W. Grimes #include <sys/namei.h> 45df8bae1dSRodney W. Grimes #include <sys/kernel.h> 46df8bae1dSRodney W. Grimes #include <sys/stat.h> 479626b608SPoul-Henning Kamp #include <sys/bio.h> 48df8bae1dSRodney W. Grimes #include <sys/buf.h> 49df8bae1dSRodney W. Grimes #include <sys/mount.h> 50df8bae1dSRodney W. Grimes #include <sys/vnode.h> 51df8bae1dSRodney W. Grimes #include <miscfs/fifofs/fifo.h> 52df8bae1dSRodney W. Grimes #include <sys/malloc.h> 53c90607baSBruce Evans #include <sys/dirent.h> 54996c772fSJohn Dyson #include <sys/unistd.h> 55cb2a8dffSSøren Schmidt #include <sys/filio.h> 56df8bae1dSRodney W. Grimes 57651ae11eSMike Smith #include <vm/vm.h> 58675ea6f0SBruce Evans #include <vm/vm_zone.h> 59651ae11eSMike Smith #include <vm/vnode_pager.h> 60675ea6f0SBruce Evans 61df8bae1dSRodney W. Grimes #include <isofs/cd9660/iso.h> 62df8bae1dSRodney W. Grimes #include <isofs/cd9660/cd9660_node.h> 63df8bae1dSRodney W. Grimes #include <isofs/cd9660/iso_rrip.h> 64df8bae1dSRodney W. Grimes 6510dd32cdSBruce Evans static int cd9660_setattr __P((struct vop_setattr_args *)); 66605e9724SPoul-Henning Kamp static int cd9660_access __P((struct vop_access_args *)); 67605e9724SPoul-Henning Kamp static int cd9660_getattr __P((struct vop_getattr_args *)); 68cb2a8dffSSøren Schmidt static int cd9660_ioctl __P((struct vop_ioctl_args *)); 69f041a9bdSPoul-Henning Kamp static int cd9660_pathconf __P((struct vop_pathconf_args *)); 70605e9724SPoul-Henning Kamp static int cd9660_read __P((struct vop_read_args *)); 7110dd32cdSBruce Evans struct isoreaddir; 7210dd32cdSBruce Evans static int iso_uiodir __P((struct isoreaddir *idp, struct dirent *dp, 7310dd32cdSBruce Evans off_t off)); 7410dd32cdSBruce Evans static int iso_shipdir __P((struct isoreaddir *idp)); 75605e9724SPoul-Henning Kamp static int cd9660_readdir __P((struct vop_readdir_args *)); 7610dd32cdSBruce Evans static int cd9660_readlink __P((struct vop_readlink_args *ap)); 77605e9724SPoul-Henning Kamp static int cd9660_strategy __P((struct vop_strategy_args *)); 78605e9724SPoul-Henning Kamp static int cd9660_print __P((struct vop_print_args *)); 79651ae11eSMike Smith static int cd9660_getpages __P((struct vop_getpages_args *)); 80651ae11eSMike Smith static int cd9660_putpages __P((struct vop_putpages_args *)); 8110dd32cdSBruce Evans 82df8bae1dSRodney W. Grimes /* 83de8583ceSDavid Greenman * Setattr call. Only allowed for block and character special devices. 84de8583ceSDavid Greenman */ 85996c772fSJohn Dyson int 86de8583ceSDavid Greenman cd9660_setattr(ap) 87de8583ceSDavid Greenman struct vop_setattr_args /* { 88de8583ceSDavid Greenman struct vnodeop_desc *a_desc; 89de8583ceSDavid Greenman struct vnode *a_vp; 90de8583ceSDavid Greenman struct vattr *a_vap; 91de8583ceSDavid Greenman struct ucred *a_cred; 92de8583ceSDavid Greenman struct proc *a_p; 93de8583ceSDavid Greenman } */ *ap; 94de8583ceSDavid Greenman { 95de8583ceSDavid Greenman struct vnode *vp = ap->a_vp; 96de8583ceSDavid Greenman struct vattr *vap = ap->a_vap; 97de8583ceSDavid Greenman 9892579404SAlexander Langer if (vap->va_flags != (u_long)VNOVAL || vap->va_uid != (uid_t)VNOVAL || 9995a1574eSNate Williams vap->va_gid != (gid_t)VNOVAL || vap->va_atime.tv_sec != VNOVAL || 10095a1574eSNate Williams vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL) 101de8583ceSDavid Greenman return (EROFS); 10292579404SAlexander Langer if (vap->va_size != (u_quad_t)VNOVAL) { 103de8583ceSDavid Greenman switch (vp->v_type) { 104de8583ceSDavid Greenman case VDIR: 105de8583ceSDavid Greenman return (EISDIR); 106de8583ceSDavid Greenman case VLNK: 107de8583ceSDavid Greenman case VREG: 108de8583ceSDavid Greenman return (EROFS); 109de8583ceSDavid Greenman case VCHR: 110de8583ceSDavid Greenman case VBLK: 111de8583ceSDavid Greenman case VSOCK: 112de8583ceSDavid Greenman case VFIFO: 113d254af07SMatthew Dillon case VNON: 114d254af07SMatthew Dillon case VBAD: 115de8583ceSDavid Greenman return (0); 116de8583ceSDavid Greenman } 117de8583ceSDavid Greenman } 118996c772fSJohn Dyson return (0); 119de8583ceSDavid Greenman } 120de8583ceSDavid Greenman 121de8583ceSDavid Greenman /* 122df8bae1dSRodney W. Grimes * Check mode permission on inode pointer. Mode is READ, WRITE or EXEC. 123df8bae1dSRodney W. Grimes * The mode is shifted to select the owner/group/other fields. The 124df8bae1dSRodney W. Grimes * super user is granted all permissions. 125df8bae1dSRodney W. Grimes */ 126df8bae1dSRodney W. Grimes /* ARGSUSED */ 127605e9724SPoul-Henning Kamp static int 128df8bae1dSRodney W. Grimes cd9660_access(ap) 129df8bae1dSRodney W. Grimes struct vop_access_args /* { 130df8bae1dSRodney W. Grimes struct vnode *a_vp; 131df8bae1dSRodney W. Grimes int a_mode; 132df8bae1dSRodney W. Grimes struct ucred *a_cred; 133df8bae1dSRodney W. Grimes struct proc *a_p; 134df8bae1dSRodney W. Grimes } */ *ap; 135df8bae1dSRodney W. Grimes { 136996c772fSJohn Dyson struct vnode *vp = ap->a_vp; 137996c772fSJohn Dyson struct iso_node *ip = VTOI(vp); 138e39c53edSPoul-Henning Kamp mode_t mode = ap->a_mode; 139996c772fSJohn Dyson 140ba14c327SDavid Greenman /* 141996c772fSJohn Dyson * Disallow write attempts unless the file is a socket, 142996c772fSJohn Dyson * fifo, or a block or character device resident on the 143996c772fSJohn Dyson * file system. 144ba14c327SDavid Greenman */ 145996c772fSJohn Dyson if (mode & VWRITE) { 146996c772fSJohn Dyson switch (vp->v_type) { 147ba14c327SDavid Greenman case VDIR: 148ba14c327SDavid Greenman case VLNK: 149ba14c327SDavid Greenman case VREG: 150ba14c327SDavid Greenman return (EROFS); 151d254af07SMatthew Dillon /* NOT REACHED */ 152d254af07SMatthew Dillon default: 153d254af07SMatthew Dillon break; 154ba14c327SDavid Greenman } 155ba14c327SDavid Greenman } 156ba14c327SDavid Greenman 157e39c53edSPoul-Henning Kamp return (vaccess(vp->v_type, ip->inode.iso_mode, ip->inode.iso_uid, 158012c643dSRobert Watson ip->inode.iso_gid, ap->a_mode, ap->a_cred, NULL)); 159df8bae1dSRodney W. Grimes } 160df8bae1dSRodney W. Grimes 161605e9724SPoul-Henning Kamp static int 162df8bae1dSRodney W. Grimes cd9660_getattr(ap) 163df8bae1dSRodney W. Grimes struct vop_getattr_args /* { 164df8bae1dSRodney W. Grimes struct vnode *a_vp; 165df8bae1dSRodney W. Grimes struct vattr *a_vap; 166df8bae1dSRodney W. Grimes struct ucred *a_cred; 167df8bae1dSRodney W. Grimes struct proc *a_p; 168df8bae1dSRodney W. Grimes } */ *ap; 169df8bae1dSRodney W. Grimes 170df8bae1dSRodney W. Grimes { 171df8bae1dSRodney W. Grimes struct vnode *vp = ap->a_vp; 172df8bae1dSRodney W. Grimes register struct vattr *vap = ap->a_vap; 173df8bae1dSRodney W. Grimes register struct iso_node *ip = VTOI(vp); 174df8bae1dSRodney W. Grimes 175bfbb9ce6SPoul-Henning Kamp vap->va_fsid = dev2udev(ip->i_dev); 176df8bae1dSRodney W. Grimes vap->va_fileid = ip->i_number; 177df8bae1dSRodney W. Grimes 178df8bae1dSRodney W. Grimes vap->va_mode = ip->inode.iso_mode; 179df8bae1dSRodney W. Grimes vap->va_nlink = ip->inode.iso_links; 180df8bae1dSRodney W. Grimes vap->va_uid = ip->inode.iso_uid; 181df8bae1dSRodney W. Grimes vap->va_gid = ip->inode.iso_gid; 182df8bae1dSRodney W. Grimes vap->va_atime = ip->inode.iso_atime; 183df8bae1dSRodney W. Grimes vap->va_mtime = ip->inode.iso_mtime; 184df8bae1dSRodney W. Grimes vap->va_ctime = ip->inode.iso_ctime; 185df8bae1dSRodney W. Grimes vap->va_rdev = ip->inode.iso_rdev; 186df8bae1dSRodney W. Grimes 187df8bae1dSRodney W. Grimes vap->va_size = (u_quad_t) ip->i_size; 188996c772fSJohn Dyson if (ip->i_size == 0 && (vap->va_mode & S_IFMT) == S_IFLNK) { 189996c772fSJohn Dyson struct vop_readlink_args rdlnk; 190996c772fSJohn Dyson struct iovec aiov; 191996c772fSJohn Dyson struct uio auio; 192996c772fSJohn Dyson char *cp; 193996c772fSJohn Dyson 194996c772fSJohn Dyson MALLOC(cp, char *, MAXPATHLEN, M_TEMP, M_WAITOK); 195996c772fSJohn Dyson aiov.iov_base = cp; 196996c772fSJohn Dyson aiov.iov_len = MAXPATHLEN; 197996c772fSJohn Dyson auio.uio_iov = &aiov; 198996c772fSJohn Dyson auio.uio_iovcnt = 1; 199996c772fSJohn Dyson auio.uio_offset = 0; 200996c772fSJohn Dyson auio.uio_rw = UIO_READ; 201996c772fSJohn Dyson auio.uio_segflg = UIO_SYSSPACE; 202996c772fSJohn Dyson auio.uio_procp = ap->a_p; 203996c772fSJohn Dyson auio.uio_resid = MAXPATHLEN; 204996c772fSJohn Dyson rdlnk.a_uio = &auio; 205996c772fSJohn Dyson rdlnk.a_vp = ap->a_vp; 206996c772fSJohn Dyson rdlnk.a_cred = ap->a_cred; 207996c772fSJohn Dyson if (cd9660_readlink(&rdlnk) == 0) 208996c772fSJohn Dyson vap->va_size = MAXPATHLEN - auio.uio_resid; 209996c772fSJohn Dyson FREE(cp, M_TEMP); 210996c772fSJohn Dyson } 211df8bae1dSRodney W. Grimes vap->va_flags = 0; 212df8bae1dSRodney W. Grimes vap->va_gen = 1; 213df8bae1dSRodney W. Grimes vap->va_blocksize = ip->i_mnt->logical_block_size; 214df8bae1dSRodney W. Grimes vap->va_bytes = (u_quad_t) ip->i_size; 215df8bae1dSRodney W. Grimes vap->va_type = vp->v_type; 21694a8606fSDoug Rabson vap->va_filerev = 0; 217df8bae1dSRodney W. Grimes return (0); 218df8bae1dSRodney W. Grimes } 219df8bae1dSRodney W. Grimes 220df8bae1dSRodney W. Grimes /* 221cb2a8dffSSøren Schmidt * Vnode op for ioctl. 222cb2a8dffSSøren Schmidt */ 223cb2a8dffSSøren Schmidt static int 224cb2a8dffSSøren Schmidt cd9660_ioctl(ap) 225cb2a8dffSSøren Schmidt struct vop_ioctl_args /* { 226cb2a8dffSSøren Schmidt struct vnode *a_vp; 227cb2a8dffSSøren Schmidt int a_command; 228cb2a8dffSSøren Schmidt caddr_t a_data; 229cb2a8dffSSøren Schmidt int a_fflag; 230cb2a8dffSSøren Schmidt struct ucred *a_cred; 231cb2a8dffSSøren Schmidt struct proc *a_p; 232cb2a8dffSSøren Schmidt } */ *ap; 233cb2a8dffSSøren Schmidt { 234cb2a8dffSSøren Schmidt struct vnode *vp = ap->a_vp; 235cb2a8dffSSøren Schmidt struct iso_node *ip = VTOI(vp); 236cb2a8dffSSøren Schmidt 237cb2a8dffSSøren Schmidt switch (ap->a_command) { 238cb2a8dffSSøren Schmidt 239cb2a8dffSSøren Schmidt case FIOGETLBA: 240cb2a8dffSSøren Schmidt *(int *)(ap->a_data) = ip->iso_start; 241cb2a8dffSSøren Schmidt return 0; 242cb2a8dffSSøren Schmidt default: 243cb2a8dffSSøren Schmidt return (ENOTTY); 244cb2a8dffSSøren Schmidt } 245cb2a8dffSSøren Schmidt } 246cb2a8dffSSøren Schmidt 247cb2a8dffSSøren Schmidt /* 248df8bae1dSRodney W. Grimes * Vnode op for reading. 249df8bae1dSRodney W. Grimes */ 250605e9724SPoul-Henning Kamp static int 251df8bae1dSRodney W. Grimes cd9660_read(ap) 252df8bae1dSRodney W. Grimes struct vop_read_args /* { 253df8bae1dSRodney W. Grimes struct vnode *a_vp; 254df8bae1dSRodney W. Grimes struct uio *a_uio; 255df8bae1dSRodney W. Grimes int a_ioflag; 256df8bae1dSRodney W. Grimes struct ucred *a_cred; 257df8bae1dSRodney W. Grimes } */ *ap; 258df8bae1dSRodney W. Grimes { 259df8bae1dSRodney W. Grimes struct vnode *vp = ap->a_vp; 260df8bae1dSRodney W. Grimes register struct uio *uio = ap->a_uio; 261df8bae1dSRodney W. Grimes register struct iso_node *ip = VTOI(vp); 262df8bae1dSRodney W. Grimes register struct iso_mnt *imp; 263df8bae1dSRodney W. Grimes struct buf *bp; 2641295d82eSGary Palmer daddr_t lbn, rablock; 265df8bae1dSRodney W. Grimes off_t diff; 266df8bae1dSRodney W. Grimes int rasize, error = 0; 26767ddfcafSMatthew Dillon int seqcount; 268df8bae1dSRodney W. Grimes long size, n, on; 269df8bae1dSRodney W. Grimes 27067ddfcafSMatthew Dillon seqcount = ap->a_ioflag >> 16; 27167ddfcafSMatthew Dillon 272df8bae1dSRodney W. Grimes if (uio->uio_resid == 0) 273df8bae1dSRodney W. Grimes return (0); 274df8bae1dSRodney W. Grimes if (uio->uio_offset < 0) 275df8bae1dSRodney W. Grimes return (EINVAL); 276996c772fSJohn Dyson ip->i_flag |= IN_ACCESS; 277df8bae1dSRodney W. Grimes imp = ip->i_mnt; 278df8bae1dSRodney W. Grimes do { 279996c772fSJohn Dyson lbn = lblkno(imp, uio->uio_offset); 280996c772fSJohn Dyson on = blkoff(imp, uio->uio_offset); 281996c772fSJohn Dyson n = min((u_int)(imp->logical_block_size - on), 282df8bae1dSRodney W. Grimes uio->uio_resid); 283df8bae1dSRodney W. Grimes diff = (off_t)ip->i_size - uio->uio_offset; 284df8bae1dSRodney W. Grimes if (diff <= 0) 285df8bae1dSRodney W. Grimes return (0); 286df8bae1dSRodney W. Grimes if (diff < n) 287df8bae1dSRodney W. Grimes n = diff; 288996c772fSJohn Dyson size = blksize(imp, ip, lbn); 289df8bae1dSRodney W. Grimes rablock = lbn + 1; 29081bca6ddSKATO Takenori if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) { 2915a5573fdSBruce Evans if (lblktosize(imp, rablock) < ip->i_size) 292996c772fSJohn Dyson error = cluster_read(vp, (off_t)ip->i_size, 2938b612c4bSJohn Dyson lbn, size, NOCRED, uio->uio_resid, 2948b612c4bSJohn Dyson (ap->a_ioflag >> 16), &bp); 295df8bae1dSRodney W. Grimes else 296df8bae1dSRodney W. Grimes error = bread(vp, lbn, size, NOCRED, &bp); 297df8bae1dSRodney W. Grimes } else { 29867ddfcafSMatthew Dillon if (seqcount > 1 && 299996c772fSJohn Dyson lblktosize(imp, rablock) < ip->i_size) { 300996c772fSJohn Dyson rasize = blksize(imp, ip, rablock); 301df8bae1dSRodney W. Grimes error = breadn(vp, lbn, size, &rablock, 302df8bae1dSRodney W. Grimes &rasize, 1, NOCRED, &bp); 303df8bae1dSRodney W. Grimes } else 304df8bae1dSRodney W. Grimes error = bread(vp, lbn, size, NOCRED, &bp); 305df8bae1dSRodney W. Grimes } 306df8bae1dSRodney W. Grimes n = min(n, size - bp->b_resid); 307df8bae1dSRodney W. Grimes if (error) { 308df8bae1dSRodney W. Grimes brelse(bp); 309df8bae1dSRodney W. Grimes return (error); 310df8bae1dSRodney W. Grimes } 311df8bae1dSRodney W. Grimes 312996c772fSJohn Dyson error = uiomove(bp->b_data + on, (int)n, uio); 313df8bae1dSRodney W. Grimes brelse(bp); 314df8bae1dSRodney W. Grimes } while (error == 0 && uio->uio_resid > 0 && n != 0); 315df8bae1dSRodney W. Grimes return (error); 316df8bae1dSRodney W. Grimes } 317df8bae1dSRodney W. Grimes 318df8bae1dSRodney W. Grimes /* 319df8bae1dSRodney W. Grimes * Structure for reading directories 320df8bae1dSRodney W. Grimes */ 321df8bae1dSRodney W. Grimes struct isoreaddir { 322df8bae1dSRodney W. Grimes struct dirent saveent; 323df8bae1dSRodney W. Grimes struct dirent assocent; 324df8bae1dSRodney W. Grimes struct dirent current; 325df8bae1dSRodney W. Grimes off_t saveoff; 326df8bae1dSRodney W. Grimes off_t assocoff; 327df8bae1dSRodney W. Grimes off_t curroff; 328df8bae1dSRodney W. Grimes struct uio *uio; 329df8bae1dSRodney W. Grimes off_t uio_off; 330996c772fSJohn Dyson int eofflag; 331996c772fSJohn Dyson u_long *cookies; 332df8bae1dSRodney W. Grimes int ncookies; 333df8bae1dSRodney W. Grimes }; 334df8bae1dSRodney W. Grimes 335996c772fSJohn Dyson int 336df8bae1dSRodney W. Grimes iso_uiodir(idp,dp,off) 337df8bae1dSRodney W. Grimes struct isoreaddir *idp; 338df8bae1dSRodney W. Grimes struct dirent *dp; 339df8bae1dSRodney W. Grimes off_t off; 340df8bae1dSRodney W. Grimes { 341df8bae1dSRodney W. Grimes int error; 342df8bae1dSRodney W. Grimes 343df8bae1dSRodney W. Grimes dp->d_name[dp->d_namlen] = 0; 344c90607baSBruce Evans dp->d_reclen = GENERIC_DIRSIZ(dp); 345df8bae1dSRodney W. Grimes 346df8bae1dSRodney W. Grimes if (idp->uio->uio_resid < dp->d_reclen) { 347996c772fSJohn Dyson idp->eofflag = 0; 348996c772fSJohn Dyson return (-1); 349df8bae1dSRodney W. Grimes } 350df8bae1dSRodney W. Grimes 351996c772fSJohn Dyson if (idp->cookies) { 352df8bae1dSRodney W. Grimes if (idp->ncookies <= 0) { 353996c772fSJohn Dyson idp->eofflag = 0; 354996c772fSJohn Dyson return (-1); 355df8bae1dSRodney W. Grimes } 356df8bae1dSRodney W. Grimes 357996c772fSJohn Dyson *idp->cookies++ = off; 358df8bae1dSRodney W. Grimes --idp->ncookies; 359df8bae1dSRodney W. Grimes } 360df8bae1dSRodney W. Grimes 361d254af07SMatthew Dillon if ((error = uiomove((caddr_t) dp,dp->d_reclen,idp->uio)) != 0) 362996c772fSJohn Dyson return (error); 363df8bae1dSRodney W. Grimes idp->uio_off = off; 364996c772fSJohn Dyson return (0); 365df8bae1dSRodney W. Grimes } 366df8bae1dSRodney W. Grimes 367996c772fSJohn Dyson int 368df8bae1dSRodney W. Grimes iso_shipdir(idp) 369df8bae1dSRodney W. Grimes struct isoreaddir *idp; 370df8bae1dSRodney W. Grimes { 371df8bae1dSRodney W. Grimes struct dirent *dp; 372df8bae1dSRodney W. Grimes int cl, sl, assoc; 373df8bae1dSRodney W. Grimes int error; 374df8bae1dSRodney W. Grimes char *cname, *sname; 375df8bae1dSRodney W. Grimes 376df8bae1dSRodney W. Grimes cl = idp->current.d_namlen; 377df8bae1dSRodney W. Grimes cname = idp->current.d_name; 3781295d82eSGary Palmer assoc = (cl > 1) && (*cname == ASSOCCHAR); 3791295d82eSGary Palmer if (assoc) { 380df8bae1dSRodney W. Grimes cl--; 381df8bae1dSRodney W. Grimes cname++; 382df8bae1dSRodney W. Grimes } 383df8bae1dSRodney W. Grimes 384df8bae1dSRodney W. Grimes dp = &idp->saveent; 385df8bae1dSRodney W. Grimes sname = dp->d_name; 386df8bae1dSRodney W. Grimes if (!(sl = dp->d_namlen)) { 387df8bae1dSRodney W. Grimes dp = &idp->assocent; 388df8bae1dSRodney W. Grimes sname = dp->d_name + 1; 389df8bae1dSRodney W. Grimes sl = dp->d_namlen - 1; 390df8bae1dSRodney W. Grimes } 391df8bae1dSRodney W. Grimes if (sl > 0) { 392df8bae1dSRodney W. Grimes if (sl != cl 393df8bae1dSRodney W. Grimes || bcmp(sname,cname,sl)) { 394df8bae1dSRodney W. Grimes if (idp->assocent.d_namlen) { 395d254af07SMatthew Dillon if ((error = iso_uiodir(idp,&idp->assocent,idp->assocoff)) != 0) 396996c772fSJohn Dyson return (error); 397df8bae1dSRodney W. Grimes idp->assocent.d_namlen = 0; 398df8bae1dSRodney W. Grimes } 399df8bae1dSRodney W. Grimes if (idp->saveent.d_namlen) { 400d254af07SMatthew Dillon if ((error = iso_uiodir(idp,&idp->saveent,idp->saveoff)) != 0) 401996c772fSJohn Dyson return (error); 402df8bae1dSRodney W. Grimes idp->saveent.d_namlen = 0; 403df8bae1dSRodney W. Grimes } 404df8bae1dSRodney W. Grimes } 405df8bae1dSRodney W. Grimes } 406c90607baSBruce Evans idp->current.d_reclen = GENERIC_DIRSIZ(&idp->current); 407df8bae1dSRodney W. Grimes if (assoc) { 408df8bae1dSRodney W. Grimes idp->assocoff = idp->curroff; 409df8bae1dSRodney W. Grimes bcopy(&idp->current,&idp->assocent,idp->current.d_reclen); 410df8bae1dSRodney W. Grimes } else { 411df8bae1dSRodney W. Grimes idp->saveoff = idp->curroff; 412df8bae1dSRodney W. Grimes bcopy(&idp->current,&idp->saveent,idp->current.d_reclen); 413df8bae1dSRodney W. Grimes } 414996c772fSJohn Dyson return (0); 415df8bae1dSRodney W. Grimes } 416df8bae1dSRodney W. Grimes 417df8bae1dSRodney W. Grimes /* 418df8bae1dSRodney W. Grimes * Vnode op for readdir 419df8bae1dSRodney W. Grimes */ 420605e9724SPoul-Henning Kamp static int 421df8bae1dSRodney W. Grimes cd9660_readdir(ap) 422df8bae1dSRodney W. Grimes struct vop_readdir_args /* { 423df8bae1dSRodney W. Grimes struct vnode *a_vp; 424df8bae1dSRodney W. Grimes struct uio *a_uio; 425df8bae1dSRodney W. Grimes struct ucred *a_cred; 426996c772fSJohn Dyson int *a_eofflag; 427996c772fSJohn Dyson int *a_ncookies; 428996c772fSJohn Dyson u_long *a_cookies; 429df8bae1dSRodney W. Grimes } */ *ap; 430df8bae1dSRodney W. Grimes { 431df8bae1dSRodney W. Grimes register struct uio *uio = ap->a_uio; 432df8bae1dSRodney W. Grimes struct isoreaddir *idp; 433996c772fSJohn Dyson struct vnode *vdp = ap->a_vp; 434996c772fSJohn Dyson struct iso_node *dp; 435df8bae1dSRodney W. Grimes struct iso_mnt *imp; 436df8bae1dSRodney W. Grimes struct buf *bp = NULL; 437996c772fSJohn Dyson struct iso_directory_record *ep; 438996c772fSJohn Dyson int entryoffsetinblock; 439996c772fSJohn Dyson doff_t endsearch; 440996c772fSJohn Dyson u_long bmask; 441996c772fSJohn Dyson int error = 0; 442996c772fSJohn Dyson int reclen; 443996c772fSJohn Dyson u_short namelen; 4449abf4d6eSDoug Rabson int ncookies = 0; 445996c772fSJohn Dyson u_long *cookies = NULL; 446df8bae1dSRodney W. Grimes 447996c772fSJohn Dyson dp = VTOI(vdp); 448996c772fSJohn Dyson imp = dp->i_mnt; 449996c772fSJohn Dyson bmask = imp->im_bmask; 450df8bae1dSRodney W. Grimes 451df8bae1dSRodney W. Grimes MALLOC(idp, struct isoreaddir *, sizeof(*idp), M_TEMP, M_WAITOK); 452996c772fSJohn Dyson idp->saveent.d_namlen = idp->assocent.d_namlen = 0; 453996c772fSJohn Dyson /* 454996c772fSJohn Dyson * XXX 455996c772fSJohn Dyson * Is it worth trying to figure out the type? 456996c772fSJohn Dyson */ 457996c772fSJohn Dyson idp->saveent.d_type = idp->assocent.d_type = idp->current.d_type = 458996c772fSJohn Dyson DT_UNKNOWN; 459df8bae1dSRodney W. Grimes idp->uio = uio; 460996c772fSJohn Dyson if (ap->a_ncookies == NULL) { 461996c772fSJohn Dyson idp->cookies = NULL; 462996c772fSJohn Dyson } else { 4639abf4d6eSDoug Rabson /* 4649abf4d6eSDoug Rabson * Guess the number of cookies needed. 4659abf4d6eSDoug Rabson */ 4669abf4d6eSDoug Rabson ncookies = uio->uio_resid / 16; 467996c772fSJohn Dyson MALLOC(cookies, u_long *, ncookies * sizeof(u_int), M_TEMP, 468996c772fSJohn Dyson M_WAITOK); 469996c772fSJohn Dyson idp->cookies = cookies; 470df8bae1dSRodney W. Grimes idp->ncookies = ncookies; 471996c772fSJohn Dyson } 472996c772fSJohn Dyson idp->eofflag = 1; 473df8bae1dSRodney W. Grimes idp->curroff = uio->uio_offset; 474df8bae1dSRodney W. Grimes 475996c772fSJohn Dyson if ((entryoffsetinblock = idp->curroff & bmask) && 476cec0f20cSPoul-Henning Kamp (error = cd9660_blkatoff(vdp, (off_t)idp->curroff, NULL, &bp))) { 477df8bae1dSRodney W. Grimes FREE(idp, M_TEMP); 478df8bae1dSRodney W. Grimes return (error); 479df8bae1dSRodney W. Grimes } 480996c772fSJohn Dyson endsearch = dp->i_size; 481df8bae1dSRodney W. Grimes 482df8bae1dSRodney W. Grimes while (idp->curroff < endsearch) { 483df8bae1dSRodney W. Grimes /* 484df8bae1dSRodney W. Grimes * If offset is on a block boundary, 485df8bae1dSRodney W. Grimes * read the next directory block. 486df8bae1dSRodney W. Grimes * Release previous if it exists. 487df8bae1dSRodney W. Grimes */ 488996c772fSJohn Dyson if ((idp->curroff & bmask) == 0) { 489df8bae1dSRodney W. Grimes if (bp != NULL) 490df8bae1dSRodney W. Grimes brelse(bp); 491d254af07SMatthew Dillon if ((error = 492d254af07SMatthew Dillon cd9660_blkatoff(vdp, (off_t)idp->curroff, NULL, &bp)) != 0) 493df8bae1dSRodney W. Grimes break; 494df8bae1dSRodney W. Grimes entryoffsetinblock = 0; 495df8bae1dSRodney W. Grimes } 496df8bae1dSRodney W. Grimes /* 497df8bae1dSRodney W. Grimes * Get pointer to next entry. 498df8bae1dSRodney W. Grimes */ 499df8bae1dSRodney W. Grimes ep = (struct iso_directory_record *) 500996c772fSJohn Dyson ((char *)bp->b_data + entryoffsetinblock); 501df8bae1dSRodney W. Grimes 502df8bae1dSRodney W. Grimes reclen = isonum_711(ep->length); 503df8bae1dSRodney W. Grimes if (reclen == 0) { 504df8bae1dSRodney W. Grimes /* skip to next block, if any */ 505996c772fSJohn Dyson idp->curroff = 506996c772fSJohn Dyson (idp->curroff & ~bmask) + imp->logical_block_size; 507df8bae1dSRodney W. Grimes continue; 508df8bae1dSRodney W. Grimes } 509df8bae1dSRodney W. Grimes 510df8bae1dSRodney W. Grimes if (reclen < ISO_DIRECTORY_RECORD_SIZE) { 511df8bae1dSRodney W. Grimes error = EINVAL; 512df8bae1dSRodney W. Grimes /* illegal entry, stop */ 513df8bae1dSRodney W. Grimes break; 514df8bae1dSRodney W. Grimes } 515df8bae1dSRodney W. Grimes 516df8bae1dSRodney W. Grimes if (entryoffsetinblock + reclen > imp->logical_block_size) { 517df8bae1dSRodney W. Grimes error = EINVAL; 518df8bae1dSRodney W. Grimes /* illegal directory, so stop looking */ 519df8bae1dSRodney W. Grimes break; 520df8bae1dSRodney W. Grimes } 521df8bae1dSRodney W. Grimes 522996c772fSJohn Dyson idp->current.d_namlen = isonum_711(ep->name_len); 523996c772fSJohn Dyson 524996c772fSJohn Dyson if (reclen < ISO_DIRECTORY_RECORD_SIZE + idp->current.d_namlen) { 52581ec856aSJoerg Wunsch error = EINVAL; 52681ec856aSJoerg Wunsch /* illegal entry, stop */ 52781ec856aSJoerg Wunsch break; 52881ec856aSJoerg Wunsch } 52981ec856aSJoerg Wunsch 530996c772fSJohn Dyson if (isonum_711(ep->flags)&2) 531996c772fSJohn Dyson idp->current.d_fileno = isodirino(ep, imp); 532df8bae1dSRodney W. Grimes else 533df8bae1dSRodney W. Grimes idp->current.d_fileno = dbtob(bp->b_blkno) + 534996c772fSJohn Dyson entryoffsetinblock; 535df8bae1dSRodney W. Grimes 536df8bae1dSRodney W. Grimes idp->curroff += reclen; 537996c772fSJohn Dyson 538df8bae1dSRodney W. Grimes switch (imp->iso_ftype) { 539df8bae1dSRodney W. Grimes case ISO_FTYPE_RRIP: 540996c772fSJohn Dyson cd9660_rrip_getname(ep,idp->current.d_name, &namelen, 541df8bae1dSRodney W. Grimes &idp->current.d_fileno,imp); 542996c772fSJohn Dyson idp->current.d_namlen = (u_char)namelen; 543df8bae1dSRodney W. Grimes if (idp->current.d_namlen) 544df8bae1dSRodney W. Grimes error = iso_uiodir(idp,&idp->current,idp->curroff); 545df8bae1dSRodney W. Grimes break; 546988fa8efSJoerg Wunsch default: /* ISO_FTYPE_DEFAULT || ISO_FTYPE_9660 || ISO_FTYPE_HIGH_SIERRA*/ 547df8bae1dSRodney W. Grimes strcpy(idp->current.d_name,".."); 54844e568e2SDaniel C. Sobral if (idp->current.d_namlen == 1 && ep->name[0] == 0) { 549df8bae1dSRodney W. Grimes idp->current.d_namlen = 1; 550df8bae1dSRodney W. Grimes error = iso_uiodir(idp,&idp->current,idp->curroff); 55144e568e2SDaniel C. Sobral } else if (idp->current.d_namlen == 1 && ep->name[0] == 1) { 552df8bae1dSRodney W. Grimes idp->current.d_namlen = 2; 553df8bae1dSRodney W. Grimes error = iso_uiodir(idp,&idp->current,idp->curroff); 55444e568e2SDaniel C. Sobral } else { 555df8bae1dSRodney W. Grimes isofntrans(ep->name,idp->current.d_namlen, 556996c772fSJohn Dyson idp->current.d_name, &namelen, 557df8bae1dSRodney W. Grimes imp->iso_ftype == ISO_FTYPE_9660, 55844e568e2SDaniel C. Sobral isonum_711(ep->flags)&4, 55944e568e2SDaniel C. Sobral imp->joliet_level); 560996c772fSJohn Dyson idp->current.d_namlen = (u_char)namelen; 561df8bae1dSRodney W. Grimes if (imp->iso_ftype == ISO_FTYPE_DEFAULT) 562df8bae1dSRodney W. Grimes error = iso_shipdir(idp); 563df8bae1dSRodney W. Grimes else 564df8bae1dSRodney W. Grimes error = iso_uiodir(idp,&idp->current,idp->curroff); 565df8bae1dSRodney W. Grimes } 566df8bae1dSRodney W. Grimes } 567df8bae1dSRodney W. Grimes if (error) 568df8bae1dSRodney W. Grimes break; 569df8bae1dSRodney W. Grimes 570df8bae1dSRodney W. Grimes entryoffsetinblock += reclen; 571df8bae1dSRodney W. Grimes } 572df8bae1dSRodney W. Grimes 573df8bae1dSRodney W. Grimes if (!error && imp->iso_ftype == ISO_FTYPE_DEFAULT) { 574df8bae1dSRodney W. Grimes idp->current.d_namlen = 0; 575df8bae1dSRodney W. Grimes error = iso_shipdir(idp); 576df8bae1dSRodney W. Grimes } 577df8bae1dSRodney W. Grimes if (error < 0) 578df8bae1dSRodney W. Grimes error = 0; 579df8bae1dSRodney W. Grimes 5809abf4d6eSDoug Rabson if (ap->a_ncookies != NULL) { 5819abf4d6eSDoug Rabson if (error) 582996c772fSJohn Dyson free(cookies, M_TEMP); 5839abf4d6eSDoug Rabson else { 5849abf4d6eSDoug Rabson /* 5859abf4d6eSDoug Rabson * Work out the number of cookies actually used. 5869abf4d6eSDoug Rabson */ 5879abf4d6eSDoug Rabson *ap->a_ncookies = ncookies - idp->ncookies; 5889abf4d6eSDoug Rabson *ap->a_cookies = cookies; 5899abf4d6eSDoug Rabson } 5909abf4d6eSDoug Rabson } 5919abf4d6eSDoug Rabson 592df8bae1dSRodney W. Grimes if (bp) 593df8bae1dSRodney W. Grimes brelse (bp); 594df8bae1dSRodney W. Grimes 595df8bae1dSRodney W. Grimes uio->uio_offset = idp->uio_off; 596996c772fSJohn Dyson *ap->a_eofflag = idp->eofflag; 597df8bae1dSRodney W. Grimes 598df8bae1dSRodney W. Grimes FREE(idp, M_TEMP); 599df8bae1dSRodney W. Grimes 600df8bae1dSRodney W. Grimes return (error); 601df8bae1dSRodney W. Grimes } 602df8bae1dSRodney W. Grimes 603df8bae1dSRodney W. Grimes /* 604df8bae1dSRodney W. Grimes * Return target name of a symbolic link 605df8bae1dSRodney W. Grimes * Shouldn't we get the parent vnode and read the data from there? 606df8bae1dSRodney W. Grimes * This could eventually result in deadlocks in cd9660_lookup. 607df8bae1dSRodney W. Grimes * But otherwise the block read here is in the block buffer two times. 608df8bae1dSRodney W. Grimes */ 609df8bae1dSRodney W. Grimes typedef struct iso_directory_record ISODIR; 610df8bae1dSRodney W. Grimes typedef struct iso_node ISONODE; 611df8bae1dSRodney W. Grimes typedef struct iso_mnt ISOMNT; 612605e9724SPoul-Henning Kamp static int 613df8bae1dSRodney W. Grimes cd9660_readlink(ap) 614df8bae1dSRodney W. Grimes struct vop_readlink_args /* { 615df8bae1dSRodney W. Grimes struct vnode *a_vp; 616df8bae1dSRodney W. Grimes struct uio *a_uio; 617df8bae1dSRodney W. Grimes struct ucred *a_cred; 618df8bae1dSRodney W. Grimes } */ *ap; 619df8bae1dSRodney W. Grimes { 620df8bae1dSRodney W. Grimes ISONODE *ip; 621df8bae1dSRodney W. Grimes ISODIR *dirp; 622df8bae1dSRodney W. Grimes ISOMNT *imp; 623df8bae1dSRodney W. Grimes struct buf *bp; 624996c772fSJohn Dyson struct uio *uio; 625df8bae1dSRodney W. Grimes u_short symlen; 626df8bae1dSRodney W. Grimes int error; 627df8bae1dSRodney W. Grimes char *symname; 628df8bae1dSRodney W. Grimes 629df8bae1dSRodney W. Grimes ip = VTOI(ap->a_vp); 630df8bae1dSRodney W. Grimes imp = ip->i_mnt; 631996c772fSJohn Dyson uio = ap->a_uio; 632df8bae1dSRodney W. Grimes 633df8bae1dSRodney W. Grimes if (imp->iso_ftype != ISO_FTYPE_RRIP) 634996c772fSJohn Dyson return (EINVAL); 635df8bae1dSRodney W. Grimes 636df8bae1dSRodney W. Grimes /* 637df8bae1dSRodney W. Grimes * Get parents directory record block that this inode included. 638df8bae1dSRodney W. Grimes */ 639df8bae1dSRodney W. Grimes error = bread(imp->im_devvp, 640996c772fSJohn Dyson (ip->i_number >> imp->im_bshift) << 641996c772fSJohn Dyson (imp->im_bshift - DEV_BSHIFT), 642996c772fSJohn Dyson imp->logical_block_size, NOCRED, &bp); 643df8bae1dSRodney W. Grimes if (error) { 644df8bae1dSRodney W. Grimes brelse(bp); 645996c772fSJohn Dyson return (EINVAL); 646df8bae1dSRodney W. Grimes } 647df8bae1dSRodney W. Grimes 648df8bae1dSRodney W. Grimes /* 649df8bae1dSRodney W. Grimes * Setup the directory pointer for this inode 650df8bae1dSRodney W. Grimes */ 651996c772fSJohn Dyson dirp = (ISODIR *)(bp->b_data + (ip->i_number & imp->im_bmask)); 652df8bae1dSRodney W. Grimes 653df8bae1dSRodney W. Grimes /* 654df8bae1dSRodney W. Grimes * Just make sure, we have a right one.... 655df8bae1dSRodney W. Grimes * 1: Check not cross boundary on block 656df8bae1dSRodney W. Grimes */ 657df8bae1dSRodney W. Grimes if ((ip->i_number & imp->im_bmask) + isonum_711(dirp->length) 65892579404SAlexander Langer > (unsigned)imp->logical_block_size) { 659df8bae1dSRodney W. Grimes brelse(bp); 660996c772fSJohn Dyson return (EINVAL); 661df8bae1dSRodney W. Grimes } 662df8bae1dSRodney W. Grimes 663df8bae1dSRodney W. Grimes /* 664df8bae1dSRodney W. Grimes * Now get a buffer 665df8bae1dSRodney W. Grimes * Abuse a namei buffer for now. 666df8bae1dSRodney W. Grimes */ 667996c772fSJohn Dyson if (uio->uio_segflg == UIO_SYSSPACE) 668996c772fSJohn Dyson symname = uio->uio_iov->iov_base; 669996c772fSJohn Dyson else 67099448ed1SJohn Dyson symname = zalloc(namei_zone); 671df8bae1dSRodney W. Grimes 672df8bae1dSRodney W. Grimes /* 673df8bae1dSRodney W. Grimes * Ok, we just gathering a symbolic name in SL record. 674df8bae1dSRodney W. Grimes */ 675df8bae1dSRodney W. Grimes if (cd9660_rrip_getsymname(dirp, symname, &symlen, imp) == 0) { 676996c772fSJohn Dyson if (uio->uio_segflg != UIO_SYSSPACE) 67799448ed1SJohn Dyson zfree(namei_zone, symname); 678df8bae1dSRodney W. Grimes brelse(bp); 679996c772fSJohn Dyson return (EINVAL); 680df8bae1dSRodney W. Grimes } 681df8bae1dSRodney W. Grimes /* 682df8bae1dSRodney W. Grimes * Don't forget before you leave from home ;-) 683df8bae1dSRodney W. Grimes */ 684df8bae1dSRodney W. Grimes brelse(bp); 685df8bae1dSRodney W. Grimes 686df8bae1dSRodney W. Grimes /* 687df8bae1dSRodney W. Grimes * return with the symbolic name to caller's. 688df8bae1dSRodney W. Grimes */ 689996c772fSJohn Dyson if (uio->uio_segflg != UIO_SYSSPACE) { 690996c772fSJohn Dyson error = uiomove(symname, symlen, uio); 69199448ed1SJohn Dyson zfree(namei_zone, symname); 692996c772fSJohn Dyson return (error); 693996c772fSJohn Dyson } 694996c772fSJohn Dyson uio->uio_resid -= symlen; 695996c772fSJohn Dyson uio->uio_iov->iov_base += symlen; 696996c772fSJohn Dyson uio->uio_iov->iov_len -= symlen; 697996c772fSJohn Dyson return (0); 698df8bae1dSRodney W. Grimes } 699df8bae1dSRodney W. Grimes 700df8bae1dSRodney W. Grimes /* 701df8bae1dSRodney W. Grimes * Calculate the logical to physical mapping if not done already, 702df8bae1dSRodney W. Grimes * then call the device strategy routine. 703df8bae1dSRodney W. Grimes */ 704605e9724SPoul-Henning Kamp static int 705df8bae1dSRodney W. Grimes cd9660_strategy(ap) 706df8bae1dSRodney W. Grimes struct vop_strategy_args /* { 707fd5d1124SJulian Elischer struct buf *a_vp; 708df8bae1dSRodney W. Grimes struct buf *a_bp; 709df8bae1dSRodney W. Grimes } */ *ap; 710df8bae1dSRodney W. Grimes { 711df8bae1dSRodney W. Grimes register struct buf *bp = ap->a_bp; 712df8bae1dSRodney W. Grimes register struct vnode *vp = bp->b_vp; 713df8bae1dSRodney W. Grimes register struct iso_node *ip; 714df8bae1dSRodney W. Grimes int error; 715df8bae1dSRodney W. Grimes 716df8bae1dSRodney W. Grimes ip = VTOI(vp); 717df8bae1dSRodney W. Grimes if (vp->v_type == VBLK || vp->v_type == VCHR) 718df8bae1dSRodney W. Grimes panic("cd9660_strategy: spec"); 719df8bae1dSRodney W. Grimes if (bp->b_blkno == bp->b_lblkno) { 7201295d82eSGary Palmer if ((error = 721c83ebe77SJohn Dyson VOP_BMAP(vp, bp->b_lblkno, NULL, &bp->b_blkno, NULL, NULL))) { 722df8bae1dSRodney W. Grimes bp->b_error = error; 723c244d2deSPoul-Henning Kamp bp->b_ioflags |= BIO_ERROR; 7248177437dSPoul-Henning Kamp bufdone(bp); 725df8bae1dSRodney W. Grimes return (error); 726df8bae1dSRodney W. Grimes } 727df8bae1dSRodney W. Grimes if ((long)bp->b_blkno == -1) 728df8bae1dSRodney W. Grimes clrbuf(bp); 729df8bae1dSRodney W. Grimes } 730df8bae1dSRodney W. Grimes if ((long)bp->b_blkno == -1) { 7318177437dSPoul-Henning Kamp bufdone(bp); 732df8bae1dSRodney W. Grimes return (0); 733df8bae1dSRodney W. Grimes } 734df8bae1dSRodney W. Grimes vp = ip->i_devvp; 735df8bae1dSRodney W. Grimes bp->b_dev = vp->v_rdev; 736fd5d1124SJulian Elischer VOP_STRATEGY(vp, bp); 737df8bae1dSRodney W. Grimes return (0); 738df8bae1dSRodney W. Grimes } 739df8bae1dSRodney W. Grimes 740df8bae1dSRodney W. Grimes /* 741df8bae1dSRodney W. Grimes * Print out the contents of an inode. 742df8bae1dSRodney W. Grimes */ 743605e9724SPoul-Henning Kamp static int 744df8bae1dSRodney W. Grimes cd9660_print(ap) 745df8bae1dSRodney W. Grimes struct vop_print_args /* { 746df8bae1dSRodney W. Grimes struct vnode *a_vp; 747df8bae1dSRodney W. Grimes } */ *ap; 748df8bae1dSRodney W. Grimes { 749996c772fSJohn Dyson 750df8bae1dSRodney W. Grimes printf("tag VT_ISOFS, isofs vnode\n"); 751996c772fSJohn Dyson return (0); 752df8bae1dSRodney W. Grimes } 753df8bae1dSRodney W. Grimes 754df8bae1dSRodney W. Grimes /* 755996c772fSJohn Dyson * Return POSIX pathconf information applicable to cd9660 filesystems. 756996c772fSJohn Dyson */ 757f041a9bdSPoul-Henning Kamp static int 758996c772fSJohn Dyson cd9660_pathconf(ap) 759996c772fSJohn Dyson struct vop_pathconf_args /* { 760996c772fSJohn Dyson struct vnode *a_vp; 761996c772fSJohn Dyson int a_name; 762996c772fSJohn Dyson register_t *a_retval; 763996c772fSJohn Dyson } */ *ap; 764996c772fSJohn Dyson { 765996c772fSJohn Dyson 766996c772fSJohn Dyson switch (ap->a_name) { 767996c772fSJohn Dyson case _PC_LINK_MAX: 768996c772fSJohn Dyson *ap->a_retval = 1; 769996c772fSJohn Dyson return (0); 770996c772fSJohn Dyson case _PC_NAME_MAX: 771996c772fSJohn Dyson if (VTOI(ap->a_vp)->i_mnt->iso_ftype == ISO_FTYPE_RRIP) 772996c772fSJohn Dyson *ap->a_retval = NAME_MAX; 773996c772fSJohn Dyson else 774996c772fSJohn Dyson *ap->a_retval = 37; 775996c772fSJohn Dyson return (0); 776996c772fSJohn Dyson case _PC_PATH_MAX: 777996c772fSJohn Dyson *ap->a_retval = PATH_MAX; 778996c772fSJohn Dyson return (0); 779996c772fSJohn Dyson case _PC_PIPE_BUF: 780996c772fSJohn Dyson *ap->a_retval = PIPE_BUF; 781996c772fSJohn Dyson return (0); 782996c772fSJohn Dyson case _PC_CHOWN_RESTRICTED: 783996c772fSJohn Dyson *ap->a_retval = 1; 784996c772fSJohn Dyson return (0); 785996c772fSJohn Dyson case _PC_NO_TRUNC: 786996c772fSJohn Dyson *ap->a_retval = 1; 787996c772fSJohn Dyson return (0); 788996c772fSJohn Dyson default: 789996c772fSJohn Dyson return (EINVAL); 790996c772fSJohn Dyson } 791996c772fSJohn Dyson /* NOTREACHED */ 792df8bae1dSRodney W. Grimes } 793df8bae1dSRodney W. Grimes 794df8bae1dSRodney W. Grimes /* 795651ae11eSMike Smith * get page routine 796651ae11eSMike Smith * 797651ae11eSMike Smith * XXX By default, wimp out... note that a_offset is ignored (and always 798651ae11eSMike Smith * XXX has been). 799651ae11eSMike Smith */ 800651ae11eSMike Smith int 801651ae11eSMike Smith cd9660_getpages(ap) 802651ae11eSMike Smith struct vop_getpages_args *ap; 803651ae11eSMike Smith { 804651ae11eSMike Smith return vnode_pager_generic_getpages(ap->a_vp, ap->a_m, ap->a_count, 805651ae11eSMike Smith ap->a_reqpage); 806651ae11eSMike Smith } 807651ae11eSMike Smith 808651ae11eSMike Smith /* 809651ae11eSMike Smith * put page routine 810651ae11eSMike Smith * 811651ae11eSMike Smith * XXX By default, wimp out... note that a_offset is ignored (and always 812651ae11eSMike Smith * XXX has been). 813651ae11eSMike Smith */ 814651ae11eSMike Smith int 815651ae11eSMike Smith cd9660_putpages(ap) 816651ae11eSMike Smith struct vop_putpages_args *ap; 817651ae11eSMike Smith { 818651ae11eSMike Smith return vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count, 819651ae11eSMike Smith ap->a_sync, ap->a_rtvals); 820651ae11eSMike Smith } 821651ae11eSMike Smith 822651ae11eSMike Smith /* 823996c772fSJohn Dyson * Global vfs data structures for cd9660 824df8bae1dSRodney W. Grimes */ 825f57e6547SBruce Evans vop_t **cd9660_vnodeop_p; 826f041a9bdSPoul-Henning Kamp static struct vnodeopv_entry_desc cd9660_vnodeop_entries[] = { 827dba3870cSPoul-Henning Kamp { &vop_default_desc, (vop_t *) vop_defaultop }, 828539ef70cSPoul-Henning Kamp { &vop_access_desc, (vop_t *) cd9660_access }, 829539ef70cSPoul-Henning Kamp { &vop_bmap_desc, (vop_t *) cd9660_bmap }, 830539ef70cSPoul-Henning Kamp { &vop_cachedlookup_desc, (vop_t *) cd9660_lookup }, 831539ef70cSPoul-Henning Kamp { &vop_getattr_desc, (vop_t *) cd9660_getattr }, 832539ef70cSPoul-Henning Kamp { &vop_inactive_desc, (vop_t *) cd9660_inactive }, 833cb2a8dffSSøren Schmidt { &vop_ioctl_desc, (vop_t *) cd9660_ioctl }, 834d54d34b5SPoul-Henning Kamp { &vop_islocked_desc, (vop_t *) vop_stdislocked }, 835d54d34b5SPoul-Henning Kamp { &vop_lock_desc, (vop_t *) vop_stdlock }, 836539ef70cSPoul-Henning Kamp { &vop_lookup_desc, (vop_t *) vfs_cache_lookup }, 837539ef70cSPoul-Henning Kamp { &vop_pathconf_desc, (vop_t *) cd9660_pathconf }, 838539ef70cSPoul-Henning Kamp { &vop_print_desc, (vop_t *) cd9660_print }, 839539ef70cSPoul-Henning Kamp { &vop_read_desc, (vop_t *) cd9660_read }, 840539ef70cSPoul-Henning Kamp { &vop_readdir_desc, (vop_t *) cd9660_readdir }, 841539ef70cSPoul-Henning Kamp { &vop_readlink_desc, (vop_t *) cd9660_readlink }, 842539ef70cSPoul-Henning Kamp { &vop_reclaim_desc, (vop_t *) cd9660_reclaim }, 843539ef70cSPoul-Henning Kamp { &vop_setattr_desc, (vop_t *) cd9660_setattr }, 844539ef70cSPoul-Henning Kamp { &vop_strategy_desc, (vop_t *) cd9660_strategy }, 845d54d34b5SPoul-Henning Kamp { &vop_unlock_desc, (vop_t *) vop_stdunlock }, 846651ae11eSMike Smith { &vop_getpages_desc, (vop_t *) cd9660_getpages }, 847651ae11eSMike Smith { &vop_putpages_desc, (vop_t *) cd9660_putpages }, 848f57e6547SBruce Evans { NULL, NULL } 849df8bae1dSRodney W. Grimes }; 850605e9724SPoul-Henning Kamp static struct vnodeopv_desc cd9660_vnodeop_opv_desc = 851df8bae1dSRodney W. Grimes { &cd9660_vnodeop_p, cd9660_vnodeop_entries }; 852c901836cSGarrett Wollman VNODEOP_SET(cd9660_vnodeop_opv_desc); 853df8bae1dSRodney W. Grimes 854df8bae1dSRodney W. Grimes /* 855df8bae1dSRodney W. Grimes * Special device vnode ops 856df8bae1dSRodney W. Grimes */ 857f57e6547SBruce Evans vop_t **cd9660_specop_p; 858f041a9bdSPoul-Henning Kamp static struct vnodeopv_entry_desc cd9660_specop_entries[] = { 859138ec1f7SPoul-Henning Kamp { &vop_default_desc, (vop_t *) spec_vnoperate }, 860539ef70cSPoul-Henning Kamp { &vop_access_desc, (vop_t *) cd9660_access }, 861539ef70cSPoul-Henning Kamp { &vop_getattr_desc, (vop_t *) cd9660_getattr }, 862539ef70cSPoul-Henning Kamp { &vop_inactive_desc, (vop_t *) cd9660_inactive }, 863d54d34b5SPoul-Henning Kamp { &vop_islocked_desc, (vop_t *) vop_stdislocked }, 864d54d34b5SPoul-Henning Kamp { &vop_lock_desc, (vop_t *) vop_stdlock }, 865539ef70cSPoul-Henning Kamp { &vop_print_desc, (vop_t *) cd9660_print }, 866539ef70cSPoul-Henning Kamp { &vop_reclaim_desc, (vop_t *) cd9660_reclaim }, 867539ef70cSPoul-Henning Kamp { &vop_setattr_desc, (vop_t *) cd9660_setattr }, 868d54d34b5SPoul-Henning Kamp { &vop_unlock_desc, (vop_t *) vop_stdunlock }, 869f57e6547SBruce Evans { NULL, NULL } 870df8bae1dSRodney W. Grimes }; 871605e9724SPoul-Henning Kamp static struct vnodeopv_desc cd9660_specop_opv_desc = 872df8bae1dSRodney W. Grimes { &cd9660_specop_p, cd9660_specop_entries }; 873c901836cSGarrett Wollman VNODEOP_SET(cd9660_specop_opv_desc); 874df8bae1dSRodney W. Grimes 875f57e6547SBruce Evans vop_t **cd9660_fifoop_p; 876f041a9bdSPoul-Henning Kamp static struct vnodeopv_entry_desc cd9660_fifoop_entries[] = { 877138ec1f7SPoul-Henning Kamp { &vop_default_desc, (vop_t *) fifo_vnoperate }, 878539ef70cSPoul-Henning Kamp { &vop_access_desc, (vop_t *) cd9660_access }, 879539ef70cSPoul-Henning Kamp { &vop_getattr_desc, (vop_t *) cd9660_getattr }, 880539ef70cSPoul-Henning Kamp { &vop_inactive_desc, (vop_t *) cd9660_inactive }, 881d54d34b5SPoul-Henning Kamp { &vop_islocked_desc, (vop_t *) vop_stdislocked }, 882d54d34b5SPoul-Henning Kamp { &vop_lock_desc, (vop_t *) vop_stdlock }, 883539ef70cSPoul-Henning Kamp { &vop_print_desc, (vop_t *) cd9660_print }, 884539ef70cSPoul-Henning Kamp { &vop_reclaim_desc, (vop_t *) cd9660_reclaim }, 885539ef70cSPoul-Henning Kamp { &vop_setattr_desc, (vop_t *) cd9660_setattr }, 886d54d34b5SPoul-Henning Kamp { &vop_unlock_desc, (vop_t *) vop_stdunlock }, 887f57e6547SBruce Evans { NULL, NULL } 888df8bae1dSRodney W. Grimes }; 889605e9724SPoul-Henning Kamp static struct vnodeopv_desc cd9660_fifoop_opv_desc = 890df8bae1dSRodney W. Grimes { &cd9660_fifoop_p, cd9660_fifoop_entries }; 891c901836cSGarrett Wollman 892c901836cSGarrett Wollman VNODEOP_SET(cd9660_fifoop_opv_desc); 893