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