xref: /freebsd/sys/fs/cd9660/cd9660_vnops.c (revision 99448ed11d42574b59b878cbb42797573b951c6a)
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
3999448ed1SJohn Dyson  * $Id: cd9660_vnops.c,v 1.38 1997/09/14 02:57:43 peter 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/kernel.h>
46df8bae1dSRodney W. Grimes #include <sys/stat.h>
479d322006SKATO Takenori #include <sys/sysctl.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/specfs/specdev.h>
52df8bae1dSRodney W. Grimes #include <miscfs/fifofs/fifo.h>
53df8bae1dSRodney W. Grimes #include <sys/malloc.h>
54c90607baSBruce Evans #include <sys/dirent.h>
55996c772fSJohn Dyson #include <sys/unistd.h>
56df8bae1dSRodney W. Grimes 
57df8bae1dSRodney W. Grimes #include <isofs/cd9660/iso.h>
58df8bae1dSRodney W. Grimes #include <isofs/cd9660/cd9660_node.h>
59df8bae1dSRodney W. Grimes #include <isofs/cd9660/iso_rrip.h>
60df8bae1dSRodney W. Grimes 
6110dd32cdSBruce Evans static int cd9660_setattr __P((struct vop_setattr_args *));
62605e9724SPoul-Henning Kamp static int cd9660_open __P((struct vop_open_args *));
63605e9724SPoul-Henning Kamp static int cd9660_close __P((struct vop_close_args *));
64605e9724SPoul-Henning Kamp static int cd9660_access __P((struct vop_access_args *));
65605e9724SPoul-Henning Kamp static int cd9660_getattr __P((struct vop_getattr_args *));
66605e9724SPoul-Henning Kamp static int cd9660_read __P((struct vop_read_args *));
67605e9724SPoul-Henning Kamp static int cd9660_ioctl __P((struct vop_ioctl_args *));
68605e9724SPoul-Henning Kamp static int cd9660_mmap __P((struct vop_mmap_args *));
69605e9724SPoul-Henning Kamp static int cd9660_seek __P((struct vop_seek_args *));
7010dd32cdSBruce Evans struct isoreaddir;
7110dd32cdSBruce Evans static int iso_uiodir __P((struct isoreaddir *idp, struct dirent *dp,
7210dd32cdSBruce Evans 			   off_t off));
7310dd32cdSBruce Evans static int iso_shipdir __P((struct isoreaddir *idp));
74605e9724SPoul-Henning Kamp static int cd9660_readdir __P((struct vop_readdir_args *));
7510dd32cdSBruce Evans static int cd9660_readlink __P((struct vop_readlink_args *ap));
76605e9724SPoul-Henning Kamp static int cd9660_abortop __P((struct vop_abortop_args *));
77605e9724SPoul-Henning Kamp static int cd9660_lock __P((struct vop_lock_args *));
78605e9724SPoul-Henning Kamp static int cd9660_unlock __P((struct vop_unlock_args *));
79605e9724SPoul-Henning Kamp static int cd9660_strategy __P((struct vop_strategy_args *));
80605e9724SPoul-Henning Kamp static int cd9660_print __P((struct vop_print_args *));
81605e9724SPoul-Henning Kamp static int cd9660_islocked __P((struct vop_islocked_args *));
8210dd32cdSBruce Evans 
83df8bae1dSRodney W. Grimes /*
849d322006SKATO Takenori  * Sysctl values for the cd9660 filesystem.
859d322006SKATO Takenori  */
869d322006SKATO Takenori #define	CD9660_CLUSTERREAD	1	/* cluster reading enabled */
879d322006SKATO Takenori #define	CD9660_MAXID		2	/* number of valid cd9660 ids */
889d322006SKATO Takenori 
899d322006SKATO Takenori #define	CD9660_NAMES { \
909d322006SKATO Takenori 	{0, 0}, \
919d322006SKATO Takenori 	{ "doclusterread", CTLTYPE_INT}, \
929d322006SKATO Takenori }
939d322006SKATO Takenori 
949d322006SKATO Takenori /*
95de8583ceSDavid Greenman  * Setattr call. Only allowed for block and character special devices.
96de8583ceSDavid Greenman  */
97996c772fSJohn Dyson int
98de8583ceSDavid Greenman cd9660_setattr(ap)
99de8583ceSDavid Greenman 	struct vop_setattr_args /* {
100de8583ceSDavid Greenman 		struct vnodeop_desc *a_desc;
101de8583ceSDavid Greenman 		struct vnode *a_vp;
102de8583ceSDavid Greenman 		struct vattr *a_vap;
103de8583ceSDavid Greenman 		struct ucred *a_cred;
104de8583ceSDavid Greenman 		struct proc *a_p;
105de8583ceSDavid Greenman 	} */ *ap;
106de8583ceSDavid Greenman {
107de8583ceSDavid Greenman 	struct vnode *vp = ap->a_vp;
108de8583ceSDavid Greenman 	struct vattr *vap = ap->a_vap;
109de8583ceSDavid Greenman 
11092579404SAlexander Langer   	if (vap->va_flags != (u_long)VNOVAL || vap->va_uid != (uid_t)VNOVAL ||
11195a1574eSNate Williams 	    vap->va_gid != (gid_t)VNOVAL || vap->va_atime.tv_sec != VNOVAL ||
11295a1574eSNate Williams 	    vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL)
113de8583ceSDavid Greenman 		return (EROFS);
11492579404SAlexander Langer 	if (vap->va_size != (u_quad_t)VNOVAL) {
115de8583ceSDavid Greenman  		switch (vp->v_type) {
116de8583ceSDavid Greenman  		case VDIR:
117de8583ceSDavid Greenman  			return (EISDIR);
118de8583ceSDavid Greenman 		case VLNK:
119de8583ceSDavid Greenman 		case VREG:
120de8583ceSDavid Greenman 			return (EROFS);
121de8583ceSDavid Greenman  		case VCHR:
122de8583ceSDavid Greenman  		case VBLK:
123de8583ceSDavid Greenman  		case VSOCK:
124de8583ceSDavid Greenman  		case VFIFO:
125de8583ceSDavid Greenman 			return (0);
126de8583ceSDavid Greenman 		}
127de8583ceSDavid Greenman 	}
128996c772fSJohn Dyson 	return (0);
129de8583ceSDavid Greenman }
130de8583ceSDavid Greenman 
131de8583ceSDavid Greenman /*
132df8bae1dSRodney W. Grimes  * Open called.
133df8bae1dSRodney W. Grimes  *
134df8bae1dSRodney W. Grimes  * Nothing to do.
135df8bae1dSRodney W. Grimes  */
136df8bae1dSRodney W. Grimes /* ARGSUSED */
137605e9724SPoul-Henning Kamp static int
138df8bae1dSRodney W. Grimes cd9660_open(ap)
139df8bae1dSRodney W. Grimes 	struct vop_open_args /* {
140df8bae1dSRodney W. Grimes 		struct vnode *a_vp;
141df8bae1dSRodney W. Grimes 		int  a_mode;
142df8bae1dSRodney W. Grimes 		struct ucred *a_cred;
143df8bae1dSRodney W. Grimes 		struct proc *a_p;
144df8bae1dSRodney W. Grimes 	} */ *ap;
145df8bae1dSRodney W. Grimes {
146df8bae1dSRodney W. Grimes 	return (0);
147df8bae1dSRodney W. Grimes }
148df8bae1dSRodney W. Grimes 
149df8bae1dSRodney W. Grimes /*
150df8bae1dSRodney W. Grimes  * Close called
151df8bae1dSRodney W. Grimes  *
152df8bae1dSRodney W. Grimes  * Update the times on the inode on writeable file systems.
153df8bae1dSRodney W. Grimes  */
154df8bae1dSRodney W. Grimes /* ARGSUSED */
155605e9724SPoul-Henning Kamp static int
156df8bae1dSRodney W. Grimes cd9660_close(ap)
157df8bae1dSRodney W. Grimes 	struct vop_close_args /* {
158df8bae1dSRodney W. Grimes 		struct vnode *a_vp;
159df8bae1dSRodney W. Grimes 		int  a_fflag;
160df8bae1dSRodney W. Grimes 		struct ucred *a_cred;
161df8bae1dSRodney W. Grimes 		struct proc *a_p;
162df8bae1dSRodney W. Grimes 	} */ *ap;
163df8bae1dSRodney W. Grimes {
164df8bae1dSRodney W. Grimes 	return (0);
165df8bae1dSRodney W. Grimes }
166df8bae1dSRodney W. Grimes 
167df8bae1dSRodney W. Grimes /*
168df8bae1dSRodney W. Grimes  * Check mode permission on inode pointer. Mode is READ, WRITE or EXEC.
169df8bae1dSRodney W. Grimes  * The mode is shifted to select the owner/group/other fields. The
170df8bae1dSRodney W. Grimes  * super user is granted all permissions.
171df8bae1dSRodney W. Grimes  */
172df8bae1dSRodney W. Grimes /* ARGSUSED */
173605e9724SPoul-Henning Kamp static int
174df8bae1dSRodney W. Grimes cd9660_access(ap)
175df8bae1dSRodney W. Grimes 	struct vop_access_args /* {
176df8bae1dSRodney W. Grimes 		struct vnode *a_vp;
177df8bae1dSRodney W. Grimes 		int  a_mode;
178df8bae1dSRodney W. Grimes 		struct ucred *a_cred;
179df8bae1dSRodney W. Grimes 		struct proc *a_p;
180df8bae1dSRodney W. Grimes 	} */ *ap;
181df8bae1dSRodney W. Grimes {
182996c772fSJohn Dyson 	struct vnode *vp = ap->a_vp;
183996c772fSJohn Dyson 	struct iso_node *ip = VTOI(vp);
184996c772fSJohn Dyson 	struct ucred *cred = ap->a_cred;
185996c772fSJohn Dyson 	mode_t mask, mode = ap->a_mode;
186996c772fSJohn Dyson 	gid_t *gp;
187996c772fSJohn Dyson 	int i;
188996c772fSJohn Dyson 
189ba14c327SDavid Greenman 	/*
190996c772fSJohn Dyson 	 * Disallow write attempts unless the file is a socket,
191996c772fSJohn Dyson 	 * fifo, or a block or character device resident on the
192996c772fSJohn Dyson 	 * file system.
193ba14c327SDavid Greenman 	 */
194996c772fSJohn Dyson 	if (mode & VWRITE) {
195996c772fSJohn Dyson 		switch (vp->v_type) {
196ba14c327SDavid Greenman 		case VDIR:
197ba14c327SDavid Greenman 		case VLNK:
198ba14c327SDavid Greenman 		case VREG:
199ba14c327SDavid Greenman 			return (EROFS);
200ba14c327SDavid Greenman 		}
201ba14c327SDavid Greenman 	}
202ba14c327SDavid Greenman 
203996c772fSJohn Dyson 	/* User id 0 always gets access. */
204996c772fSJohn Dyson 	if (cred->cr_uid == 0)
205df8bae1dSRodney W. Grimes 		return (0);
206996c772fSJohn Dyson 
207996c772fSJohn Dyson 	mask = 0;
208996c772fSJohn Dyson 
209996c772fSJohn Dyson 	/* Otherwise, check the owner. */
210996c772fSJohn Dyson 	if (cred->cr_uid == ip->inode.iso_uid) {
211996c772fSJohn Dyson 		if (mode & VEXEC)
212996c772fSJohn Dyson 			mask |= S_IXUSR;
213996c772fSJohn Dyson 		if (mode & VREAD)
214996c772fSJohn Dyson 			mask |= S_IRUSR;
215996c772fSJohn Dyson 		if (mode & VWRITE)
216996c772fSJohn Dyson 			mask |= S_IWUSR;
217996c772fSJohn Dyson 		return ((ip->inode.iso_mode & mask) == mask ? 0 : EACCES);
218996c772fSJohn Dyson 	}
219996c772fSJohn Dyson 
220996c772fSJohn Dyson 	/* Otherwise, check the groups. */
221996c772fSJohn Dyson 	for (i = 0, gp = cred->cr_groups; i < cred->cr_ngroups; i++, gp++)
222996c772fSJohn Dyson 		if (ip->inode.iso_gid == *gp) {
223996c772fSJohn Dyson 			if (mode & VEXEC)
224996c772fSJohn Dyson 				mask |= S_IXGRP;
225996c772fSJohn Dyson 			if (mode & VREAD)
226996c772fSJohn Dyson 				mask |= S_IRGRP;
227996c772fSJohn Dyson 			if (mode & VWRITE)
228996c772fSJohn Dyson 				mask |= S_IWGRP;
229996c772fSJohn Dyson 			return ((ip->inode.iso_mode & mask) == mask ?
230996c772fSJohn Dyson 			    0 : EACCES);
231996c772fSJohn Dyson 		}
232996c772fSJohn Dyson 
233996c772fSJohn Dyson 	/* Otherwise, check everyone else. */
234996c772fSJohn Dyson 	if (mode & VEXEC)
235996c772fSJohn Dyson 		mask |= S_IXOTH;
236996c772fSJohn Dyson 	if (mode & VREAD)
237996c772fSJohn Dyson 		mask |= S_IROTH;
238996c772fSJohn Dyson 	if (mode & VWRITE)
239996c772fSJohn Dyson 		mask |= S_IWOTH;
240996c772fSJohn Dyson 	return ((ip->inode.iso_mode & mask) == mask ? 0 : EACCES);
241df8bae1dSRodney W. Grimes }
242df8bae1dSRodney W. Grimes 
243605e9724SPoul-Henning Kamp static int
244df8bae1dSRodney W. Grimes cd9660_getattr(ap)
245df8bae1dSRodney W. Grimes 	struct vop_getattr_args /* {
246df8bae1dSRodney W. Grimes 		struct vnode *a_vp;
247df8bae1dSRodney W. Grimes 		struct vattr *a_vap;
248df8bae1dSRodney W. Grimes 		struct ucred *a_cred;
249df8bae1dSRodney W. Grimes 		struct proc *a_p;
250df8bae1dSRodney W. Grimes 	} */ *ap;
251df8bae1dSRodney W. Grimes 
252df8bae1dSRodney W. Grimes {
253df8bae1dSRodney W. Grimes 	struct vnode *vp = ap->a_vp;
254df8bae1dSRodney W. Grimes 	register struct vattr *vap = ap->a_vap;
255df8bae1dSRodney W. Grimes 	register struct iso_node *ip = VTOI(vp);
256df8bae1dSRodney W. Grimes 
257df8bae1dSRodney W. Grimes 	vap->va_fsid	= ip->i_dev;
258df8bae1dSRodney W. Grimes 	vap->va_fileid	= ip->i_number;
259df8bae1dSRodney W. Grimes 
260df8bae1dSRodney W. Grimes 	vap->va_mode	= ip->inode.iso_mode;
261df8bae1dSRodney W. Grimes 	vap->va_nlink	= ip->inode.iso_links;
262df8bae1dSRodney W. Grimes 	vap->va_uid	= ip->inode.iso_uid;
263df8bae1dSRodney W. Grimes 	vap->va_gid	= ip->inode.iso_gid;
264df8bae1dSRodney W. Grimes 	vap->va_atime	= ip->inode.iso_atime;
265df8bae1dSRodney W. Grimes 	vap->va_mtime	= ip->inode.iso_mtime;
266df8bae1dSRodney W. Grimes 	vap->va_ctime	= ip->inode.iso_ctime;
267df8bae1dSRodney W. Grimes 	vap->va_rdev	= ip->inode.iso_rdev;
268df8bae1dSRodney W. Grimes 
269df8bae1dSRodney W. Grimes 	vap->va_size	= (u_quad_t) ip->i_size;
270996c772fSJohn Dyson 	if (ip->i_size == 0 && (vap->va_mode & S_IFMT) == S_IFLNK) {
271996c772fSJohn Dyson 		struct vop_readlink_args rdlnk;
272996c772fSJohn Dyson 		struct iovec aiov;
273996c772fSJohn Dyson 		struct uio auio;
274996c772fSJohn Dyson 		char *cp;
275996c772fSJohn Dyson 
276996c772fSJohn Dyson 		MALLOC(cp, char *, MAXPATHLEN, M_TEMP, M_WAITOK);
277996c772fSJohn Dyson 		aiov.iov_base = cp;
278996c772fSJohn Dyson 		aiov.iov_len = MAXPATHLEN;
279996c772fSJohn Dyson 		auio.uio_iov = &aiov;
280996c772fSJohn Dyson 		auio.uio_iovcnt = 1;
281996c772fSJohn Dyson 		auio.uio_offset = 0;
282996c772fSJohn Dyson 		auio.uio_rw = UIO_READ;
283996c772fSJohn Dyson 		auio.uio_segflg = UIO_SYSSPACE;
284996c772fSJohn Dyson 		auio.uio_procp = ap->a_p;
285996c772fSJohn Dyson 		auio.uio_resid = MAXPATHLEN;
286996c772fSJohn Dyson 		rdlnk.a_uio = &auio;
287996c772fSJohn Dyson 		rdlnk.a_vp = ap->a_vp;
288996c772fSJohn Dyson 		rdlnk.a_cred = ap->a_cred;
289996c772fSJohn Dyson 		if (cd9660_readlink(&rdlnk) == 0)
290996c772fSJohn Dyson 			vap->va_size = MAXPATHLEN - auio.uio_resid;
291996c772fSJohn Dyson 		FREE(cp, M_TEMP);
292996c772fSJohn Dyson 	}
293df8bae1dSRodney W. Grimes 	vap->va_flags	= 0;
294df8bae1dSRodney W. Grimes 	vap->va_gen = 1;
295df8bae1dSRodney W. Grimes 	vap->va_blocksize = ip->i_mnt->logical_block_size;
296df8bae1dSRodney W. Grimes 	vap->va_bytes	= (u_quad_t) ip->i_size;
297df8bae1dSRodney W. Grimes 	vap->va_type	= vp->v_type;
29894a8606fSDoug Rabson 	vap->va_filerev	= 0;
299df8bae1dSRodney W. Grimes 	return (0);
300df8bae1dSRodney W. Grimes }
301df8bae1dSRodney W. Grimes 
3029d322006SKATO Takenori static int	cd9660_doclusterread = 1;
3039d322006SKATO Takenori SYSCTL_NODE(_vfs, MOUNT_CD9660, cd9660, CTLFLAG_RW, 0, "CD9660 filesystem");
3049d322006SKATO Takenori SYSCTL_INT(_vfs_cd9660, CD9660_CLUSTERREAD, doclusterread,
3059d322006SKATO Takenori 		   CTLFLAG_RW, &cd9660_doclusterread, 0, "");
306df8bae1dSRodney W. Grimes 
307df8bae1dSRodney W. Grimes /*
308df8bae1dSRodney W. Grimes  * Vnode op for reading.
309df8bae1dSRodney W. Grimes  */
310605e9724SPoul-Henning Kamp static int
311df8bae1dSRodney W. Grimes cd9660_read(ap)
312df8bae1dSRodney W. Grimes 	struct vop_read_args /* {
313df8bae1dSRodney W. Grimes 		struct vnode *a_vp;
314df8bae1dSRodney W. Grimes 		struct uio *a_uio;
315df8bae1dSRodney W. Grimes 		int a_ioflag;
316df8bae1dSRodney W. Grimes 		struct ucred *a_cred;
317df8bae1dSRodney W. Grimes 	} */ *ap;
318df8bae1dSRodney W. Grimes {
319df8bae1dSRodney W. Grimes 	struct vnode *vp = ap->a_vp;
320df8bae1dSRodney W. Grimes 	register struct uio *uio = ap->a_uio;
321df8bae1dSRodney W. Grimes 	register struct iso_node *ip = VTOI(vp);
322df8bae1dSRodney W. Grimes 	register struct iso_mnt *imp;
323df8bae1dSRodney W. Grimes 	struct buf *bp;
3241295d82eSGary Palmer 	daddr_t lbn, rablock;
325df8bae1dSRodney W. Grimes 	off_t diff;
326df8bae1dSRodney W. Grimes 	int rasize, error = 0;
327df8bae1dSRodney W. Grimes 	long size, n, on;
328df8bae1dSRodney W. Grimes 
329df8bae1dSRodney W. Grimes 	if (uio->uio_resid == 0)
330df8bae1dSRodney W. Grimes 		return (0);
331df8bae1dSRodney W. Grimes 	if (uio->uio_offset < 0)
332df8bae1dSRodney W. Grimes 		return (EINVAL);
333996c772fSJohn Dyson 	ip->i_flag |= IN_ACCESS;
334df8bae1dSRodney W. Grimes 	imp = ip->i_mnt;
335df8bae1dSRodney W. Grimes 	do {
336996c772fSJohn Dyson 		lbn = lblkno(imp, uio->uio_offset);
337996c772fSJohn Dyson 		on = blkoff(imp, uio->uio_offset);
338996c772fSJohn Dyson 		n = min((u_int)(imp->logical_block_size - on),
339df8bae1dSRodney W. Grimes 			uio->uio_resid);
340df8bae1dSRodney W. Grimes 		diff = (off_t)ip->i_size - uio->uio_offset;
341df8bae1dSRodney W. Grimes 		if (diff <= 0)
342df8bae1dSRodney W. Grimes 			return (0);
343df8bae1dSRodney W. Grimes 		if (diff < n)
344df8bae1dSRodney W. Grimes 			n = diff;
345996c772fSJohn Dyson 		size = blksize(imp, ip, lbn);
346df8bae1dSRodney W. Grimes 		rablock = lbn + 1;
3479d322006SKATO Takenori 		if (cd9660_doclusterread) {
348996c772fSJohn Dyson 			if (lblktosize(imp, rablock) <= ip->i_size)
349996c772fSJohn Dyson 				error = cluster_read(vp, (off_t)ip->i_size,
3508b612c4bSJohn Dyson 				         lbn, size, NOCRED, uio->uio_resid,
3518b612c4bSJohn Dyson 					 (ap->a_ioflag >> 16), &bp);
352df8bae1dSRodney W. Grimes 			else
353df8bae1dSRodney W. Grimes 				error = bread(vp, lbn, size, NOCRED, &bp);
354df8bae1dSRodney W. Grimes 		} else {
355df8bae1dSRodney W. Grimes 			if (vp->v_lastr + 1 == lbn &&
356996c772fSJohn Dyson 			    lblktosize(imp, rablock) < ip->i_size) {
357996c772fSJohn Dyson 				rasize = blksize(imp, ip, rablock);
358df8bae1dSRodney W. Grimes 				error = breadn(vp, lbn, size, &rablock,
359df8bae1dSRodney W. Grimes 					       &rasize, 1, NOCRED, &bp);
360df8bae1dSRodney W. Grimes 			} else
361df8bae1dSRodney W. Grimes 				error = bread(vp, lbn, size, NOCRED, &bp);
362df8bae1dSRodney W. Grimes 		}
363df8bae1dSRodney W. Grimes 		vp->v_lastr = lbn;
364df8bae1dSRodney W. Grimes 		n = min(n, size - bp->b_resid);
365df8bae1dSRodney W. Grimes 		if (error) {
366df8bae1dSRodney W. Grimes 			brelse(bp);
367df8bae1dSRodney W. Grimes 			return (error);
368df8bae1dSRodney W. Grimes 		}
369df8bae1dSRodney W. Grimes 
370996c772fSJohn Dyson 		error = uiomove(bp->b_data + on, (int)n, uio);
371df8bae1dSRodney W. Grimes 		brelse(bp);
372df8bae1dSRodney W. Grimes 	} while (error == 0 && uio->uio_resid > 0 && n != 0);
373df8bae1dSRodney W. Grimes 	return (error);
374df8bae1dSRodney W. Grimes }
375df8bae1dSRodney W. Grimes 
376df8bae1dSRodney W. Grimes /* ARGSUSED */
377605e9724SPoul-Henning Kamp static int
378df8bae1dSRodney W. Grimes cd9660_ioctl(ap)
379df8bae1dSRodney W. Grimes 	struct vop_ioctl_args /* {
380df8bae1dSRodney W. Grimes 		struct vnode *a_vp;
381996c772fSJohn Dyson 		u_long a_command;
382df8bae1dSRodney W. Grimes 		caddr_t  a_data;
383df8bae1dSRodney W. Grimes 		int  a_fflag;
384df8bae1dSRodney W. Grimes 		struct ucred *a_cred;
385df8bae1dSRodney W. Grimes 		struct proc *a_p;
386df8bae1dSRodney W. Grimes 	} */ *ap;
387df8bae1dSRodney W. Grimes {
388df8bae1dSRodney W. Grimes 	printf("You did ioctl for isofs !!\n");
389df8bae1dSRodney W. Grimes 	return (ENOTTY);
390df8bae1dSRodney W. Grimes }
391df8bae1dSRodney W. Grimes 
392df8bae1dSRodney W. Grimes /*
393df8bae1dSRodney W. Grimes  * Mmap a file
394df8bae1dSRodney W. Grimes  *
395df8bae1dSRodney W. Grimes  * NB Currently unsupported.
396df8bae1dSRodney W. Grimes  */
397df8bae1dSRodney W. Grimes /* ARGSUSED */
398605e9724SPoul-Henning Kamp static int
399df8bae1dSRodney W. Grimes cd9660_mmap(ap)
400df8bae1dSRodney W. Grimes 	struct vop_mmap_args /* {
401df8bae1dSRodney W. Grimes 		struct vnode *a_vp;
402df8bae1dSRodney W. Grimes 		int  a_fflags;
403df8bae1dSRodney W. Grimes 		struct ucred *a_cred;
404df8bae1dSRodney W. Grimes 		struct proc *a_p;
405df8bae1dSRodney W. Grimes 	} */ *ap;
406df8bae1dSRodney W. Grimes {
407df8bae1dSRodney W. Grimes 
408df8bae1dSRodney W. Grimes 	return (EINVAL);
409df8bae1dSRodney W. Grimes }
410df8bae1dSRodney W. Grimes 
411df8bae1dSRodney W. Grimes /*
412df8bae1dSRodney W. Grimes  * Seek on a file
413df8bae1dSRodney W. Grimes  *
414df8bae1dSRodney W. Grimes  * Nothing to do, so just return.
415df8bae1dSRodney W. Grimes  */
416df8bae1dSRodney W. Grimes /* ARGSUSED */
417605e9724SPoul-Henning Kamp static int
418df8bae1dSRodney W. Grimes cd9660_seek(ap)
419df8bae1dSRodney W. Grimes 	struct vop_seek_args /* {
420df8bae1dSRodney W. Grimes 		struct vnode *a_vp;
421df8bae1dSRodney W. Grimes 		off_t  a_oldoff;
422df8bae1dSRodney W. Grimes 		off_t  a_newoff;
423df8bae1dSRodney W. Grimes 		struct ucred *a_cred;
424df8bae1dSRodney W. Grimes 	} */ *ap;
425df8bae1dSRodney W. Grimes {
426df8bae1dSRodney W. Grimes 
427df8bae1dSRodney W. Grimes 	return (0);
428df8bae1dSRodney W. Grimes }
429df8bae1dSRodney W. Grimes 
430df8bae1dSRodney W. Grimes /*
431df8bae1dSRodney W. Grimes  * Structure for reading directories
432df8bae1dSRodney W. Grimes  */
433df8bae1dSRodney W. Grimes struct isoreaddir {
434df8bae1dSRodney W. Grimes 	struct dirent saveent;
435df8bae1dSRodney W. Grimes 	struct dirent assocent;
436df8bae1dSRodney W. Grimes 	struct dirent current;
437df8bae1dSRodney W. Grimes 	off_t saveoff;
438df8bae1dSRodney W. Grimes 	off_t assocoff;
439df8bae1dSRodney W. Grimes 	off_t curroff;
440df8bae1dSRodney W. Grimes 	struct uio *uio;
441df8bae1dSRodney W. Grimes 	off_t uio_off;
442996c772fSJohn Dyson 	int eofflag;
443996c772fSJohn Dyson 	u_long *cookies;
444df8bae1dSRodney W. Grimes 	int ncookies;
445df8bae1dSRodney W. Grimes };
446df8bae1dSRodney W. Grimes 
447996c772fSJohn Dyson int
448df8bae1dSRodney W. Grimes iso_uiodir(idp,dp,off)
449df8bae1dSRodney W. Grimes 	struct isoreaddir *idp;
450df8bae1dSRodney W. Grimes 	struct dirent *dp;
451df8bae1dSRodney W. Grimes 	off_t off;
452df8bae1dSRodney W. Grimes {
453df8bae1dSRodney W. Grimes 	int error;
454df8bae1dSRodney W. Grimes 
455df8bae1dSRodney W. Grimes 	dp->d_name[dp->d_namlen] = 0;
456c90607baSBruce Evans 	dp->d_reclen = GENERIC_DIRSIZ(dp);
457df8bae1dSRodney W. Grimes 
458df8bae1dSRodney W. Grimes 	if (idp->uio->uio_resid < dp->d_reclen) {
459996c772fSJohn Dyson 		idp->eofflag = 0;
460996c772fSJohn Dyson 		return (-1);
461df8bae1dSRodney W. Grimes 	}
462df8bae1dSRodney W. Grimes 
463996c772fSJohn Dyson 	if (idp->cookies) {
464df8bae1dSRodney W. Grimes 		if (idp->ncookies <= 0) {
465996c772fSJohn Dyson 			idp->eofflag = 0;
466996c772fSJohn Dyson 			return (-1);
467df8bae1dSRodney W. Grimes 		}
468df8bae1dSRodney W. Grimes 
469996c772fSJohn Dyson 		*idp->cookies++ = off;
470df8bae1dSRodney W. Grimes 		--idp->ncookies;
471df8bae1dSRodney W. Grimes 	}
472df8bae1dSRodney W. Grimes 
473996c772fSJohn Dyson 	if (error = uiomove((caddr_t) dp,dp->d_reclen,idp->uio))
474996c772fSJohn Dyson 		return (error);
475df8bae1dSRodney W. Grimes 	idp->uio_off = off;
476996c772fSJohn Dyson 	return (0);
477df8bae1dSRodney W. Grimes }
478df8bae1dSRodney W. Grimes 
479996c772fSJohn Dyson int
480df8bae1dSRodney W. Grimes iso_shipdir(idp)
481df8bae1dSRodney W. Grimes 	struct isoreaddir *idp;
482df8bae1dSRodney W. Grimes {
483df8bae1dSRodney W. Grimes 	struct dirent *dp;
484df8bae1dSRodney W. Grimes 	int cl, sl, assoc;
485df8bae1dSRodney W. Grimes 	int error;
486df8bae1dSRodney W. Grimes 	char *cname, *sname;
487df8bae1dSRodney W. Grimes 
488df8bae1dSRodney W. Grimes 	cl = idp->current.d_namlen;
489df8bae1dSRodney W. Grimes 	cname = idp->current.d_name;
4901295d82eSGary Palmer assoc = (cl > 1) && (*cname == ASSOCCHAR);
4911295d82eSGary Palmer 	if (assoc) {
492df8bae1dSRodney W. Grimes 		cl--;
493df8bae1dSRodney W. Grimes 		cname++;
494df8bae1dSRodney W. Grimes 	}
495df8bae1dSRodney W. Grimes 
496df8bae1dSRodney W. Grimes 	dp = &idp->saveent;
497df8bae1dSRodney W. Grimes 	sname = dp->d_name;
498df8bae1dSRodney W. Grimes 	if (!(sl = dp->d_namlen)) {
499df8bae1dSRodney W. Grimes 		dp = &idp->assocent;
500df8bae1dSRodney W. Grimes 		sname = dp->d_name + 1;
501df8bae1dSRodney W. Grimes 		sl = dp->d_namlen - 1;
502df8bae1dSRodney W. Grimes 	}
503df8bae1dSRodney W. Grimes 	if (sl > 0) {
504df8bae1dSRodney W. Grimes 		if (sl != cl
505df8bae1dSRodney W. Grimes 		    || bcmp(sname,cname,sl)) {
506df8bae1dSRodney W. Grimes 			if (idp->assocent.d_namlen) {
507996c772fSJohn Dyson 				if (error = iso_uiodir(idp,&idp->assocent,idp->assocoff))
508996c772fSJohn Dyson 					return (error);
509df8bae1dSRodney W. Grimes 				idp->assocent.d_namlen = 0;
510df8bae1dSRodney W. Grimes 			}
511df8bae1dSRodney W. Grimes 			if (idp->saveent.d_namlen) {
512996c772fSJohn Dyson 				if (error = iso_uiodir(idp,&idp->saveent,idp->saveoff))
513996c772fSJohn Dyson 					return (error);
514df8bae1dSRodney W. Grimes 				idp->saveent.d_namlen = 0;
515df8bae1dSRodney W. Grimes 			}
516df8bae1dSRodney W. Grimes 		}
517df8bae1dSRodney W. Grimes 	}
518c90607baSBruce Evans 	idp->current.d_reclen = GENERIC_DIRSIZ(&idp->current);
519df8bae1dSRodney W. Grimes 	if (assoc) {
520df8bae1dSRodney W. Grimes 		idp->assocoff = idp->curroff;
521df8bae1dSRodney W. Grimes 		bcopy(&idp->current,&idp->assocent,idp->current.d_reclen);
522df8bae1dSRodney W. Grimes 	} else {
523df8bae1dSRodney W. Grimes 		idp->saveoff = idp->curroff;
524df8bae1dSRodney W. Grimes 		bcopy(&idp->current,&idp->saveent,idp->current.d_reclen);
525df8bae1dSRodney W. Grimes 	}
526996c772fSJohn Dyson 	return (0);
527df8bae1dSRodney W. Grimes }
528df8bae1dSRodney W. Grimes 
529df8bae1dSRodney W. Grimes /*
530df8bae1dSRodney W. Grimes  * Vnode op for readdir
531df8bae1dSRodney W. Grimes  */
532605e9724SPoul-Henning Kamp static int
533df8bae1dSRodney W. Grimes cd9660_readdir(ap)
534df8bae1dSRodney W. Grimes 	struct vop_readdir_args /* {
535df8bae1dSRodney W. Grimes 		struct vnode *a_vp;
536df8bae1dSRodney W. Grimes 		struct uio *a_uio;
537df8bae1dSRodney W. Grimes 		struct ucred *a_cred;
538996c772fSJohn Dyson 		int *a_eofflag;
539996c772fSJohn Dyson 		int *a_ncookies;
540996c772fSJohn Dyson 		u_long *a_cookies;
541df8bae1dSRodney W. Grimes 	} */ *ap;
542df8bae1dSRodney W. Grimes {
543df8bae1dSRodney W. Grimes 	register struct uio *uio = ap->a_uio;
544df8bae1dSRodney W. Grimes 	struct isoreaddir *idp;
545996c772fSJohn Dyson 	struct vnode *vdp = ap->a_vp;
546996c772fSJohn Dyson 	struct iso_node *dp;
547df8bae1dSRodney W. Grimes 	struct iso_mnt *imp;
548df8bae1dSRodney W. Grimes 	struct buf *bp = NULL;
549996c772fSJohn Dyson 	struct iso_directory_record *ep;
550996c772fSJohn Dyson 	int entryoffsetinblock;
551996c772fSJohn Dyson 	doff_t endsearch;
552996c772fSJohn Dyson 	u_long bmask;
553996c772fSJohn Dyson 	int error = 0;
554996c772fSJohn Dyson 	int reclen;
555996c772fSJohn Dyson 	u_short namelen;
5569abf4d6eSDoug Rabson 	int ncookies = 0;
557996c772fSJohn Dyson 	u_long *cookies = NULL;
558df8bae1dSRodney W. Grimes 
559996c772fSJohn Dyson 	dp = VTOI(vdp);
560996c772fSJohn Dyson 	imp = dp->i_mnt;
561996c772fSJohn Dyson 	bmask = imp->im_bmask;
562df8bae1dSRodney W. Grimes 
563df8bae1dSRodney W. Grimes 	MALLOC(idp, struct isoreaddir *, sizeof(*idp), M_TEMP, M_WAITOK);
564996c772fSJohn Dyson 	idp->saveent.d_namlen = idp->assocent.d_namlen = 0;
565996c772fSJohn Dyson 	/*
566996c772fSJohn Dyson 	 * XXX
567996c772fSJohn Dyson 	 * Is it worth trying to figure out the type?
568996c772fSJohn Dyson 	 */
569996c772fSJohn Dyson 	idp->saveent.d_type = idp->assocent.d_type = idp->current.d_type =
570996c772fSJohn Dyson 	    DT_UNKNOWN;
571df8bae1dSRodney W. Grimes 	idp->uio = uio;
572996c772fSJohn Dyson 	if (ap->a_ncookies == NULL) {
573996c772fSJohn Dyson 		idp->cookies = NULL;
574996c772fSJohn Dyson 	} else {
5759abf4d6eSDoug Rabson 		/*
5769abf4d6eSDoug Rabson 		 * Guess the number of cookies needed.
5779abf4d6eSDoug Rabson 		 */
5789abf4d6eSDoug Rabson 		ncookies = uio->uio_resid / 16;
579996c772fSJohn Dyson 		MALLOC(cookies, u_long *, ncookies * sizeof(u_int), M_TEMP,
580996c772fSJohn Dyson 		    M_WAITOK);
581996c772fSJohn Dyson 		idp->cookies = cookies;
582df8bae1dSRodney W. Grimes 		idp->ncookies = ncookies;
583996c772fSJohn Dyson 	}
584996c772fSJohn Dyson 	idp->eofflag = 1;
585df8bae1dSRodney W. Grimes 	idp->curroff = uio->uio_offset;
586df8bae1dSRodney W. Grimes 
587996c772fSJohn Dyson 	if ((entryoffsetinblock = idp->curroff & bmask) &&
588996c772fSJohn Dyson 	    (error = VOP_BLKATOFF(vdp, (off_t)idp->curroff, NULL, &bp))) {
589df8bae1dSRodney W. Grimes 		FREE(idp, M_TEMP);
590df8bae1dSRodney W. Grimes 		return (error);
591df8bae1dSRodney W. Grimes 	}
592996c772fSJohn Dyson 	endsearch = dp->i_size;
593df8bae1dSRodney W. Grimes 
594df8bae1dSRodney W. Grimes 	while (idp->curroff < endsearch) {
595df8bae1dSRodney W. Grimes 		/*
596df8bae1dSRodney W. Grimes 		 * If offset is on a block boundary,
597df8bae1dSRodney W. Grimes 		 * read the next directory block.
598df8bae1dSRodney W. Grimes 		 * Release previous if it exists.
599df8bae1dSRodney W. Grimes 		 */
600996c772fSJohn Dyson 		if ((idp->curroff & bmask) == 0) {
601df8bae1dSRodney W. Grimes 			if (bp != NULL)
602df8bae1dSRodney W. Grimes 				brelse(bp);
603996c772fSJohn Dyson 			if (error =
604996c772fSJohn Dyson 			    VOP_BLKATOFF(vdp, (off_t)idp->curroff, NULL, &bp))
605df8bae1dSRodney W. Grimes 				break;
606df8bae1dSRodney W. Grimes 			entryoffsetinblock = 0;
607df8bae1dSRodney W. Grimes 		}
608df8bae1dSRodney W. Grimes 		/*
609df8bae1dSRodney W. Grimes 		 * Get pointer to next entry.
610df8bae1dSRodney W. Grimes 		 */
611df8bae1dSRodney W. Grimes 		ep = (struct iso_directory_record *)
612996c772fSJohn Dyson 			((char *)bp->b_data + entryoffsetinblock);
613df8bae1dSRodney W. Grimes 
614df8bae1dSRodney W. Grimes 		reclen = isonum_711(ep->length);
615df8bae1dSRodney W. Grimes 		if (reclen == 0) {
616df8bae1dSRodney W. Grimes 			/* skip to next block, if any */
617996c772fSJohn Dyson 			idp->curroff =
618996c772fSJohn Dyson 			    (idp->curroff & ~bmask) + imp->logical_block_size;
619df8bae1dSRodney W. Grimes 			continue;
620df8bae1dSRodney W. Grimes 		}
621df8bae1dSRodney W. Grimes 
622df8bae1dSRodney W. Grimes 		if (reclen < ISO_DIRECTORY_RECORD_SIZE) {
623df8bae1dSRodney W. Grimes 			error = EINVAL;
624df8bae1dSRodney W. Grimes 			/* illegal entry, stop */
625df8bae1dSRodney W. Grimes 			break;
626df8bae1dSRodney W. Grimes 		}
627df8bae1dSRodney W. Grimes 
628df8bae1dSRodney W. Grimes 		if (entryoffsetinblock + reclen > imp->logical_block_size) {
629df8bae1dSRodney W. Grimes 			error = EINVAL;
630df8bae1dSRodney W. Grimes 			/* illegal directory, so stop looking */
631df8bae1dSRodney W. Grimes 			break;
632df8bae1dSRodney W. Grimes 		}
633df8bae1dSRodney W. Grimes 
634996c772fSJohn Dyson 		idp->current.d_namlen = isonum_711(ep->name_len);
635996c772fSJohn Dyson 
636996c772fSJohn Dyson 		if (reclen < ISO_DIRECTORY_RECORD_SIZE + idp->current.d_namlen) {
63781ec856aSJoerg Wunsch 			error = EINVAL;
63881ec856aSJoerg Wunsch 			/* illegal entry, stop */
63981ec856aSJoerg Wunsch 			break;
64081ec856aSJoerg Wunsch 		}
64181ec856aSJoerg Wunsch 
642996c772fSJohn Dyson 		if (isonum_711(ep->flags)&2)
643996c772fSJohn Dyson 			idp->current.d_fileno = isodirino(ep, imp);
644df8bae1dSRodney W. Grimes 		else
645df8bae1dSRodney W. Grimes 			idp->current.d_fileno = dbtob(bp->b_blkno) +
646996c772fSJohn Dyson 				entryoffsetinblock;
647df8bae1dSRodney W. Grimes 
648df8bae1dSRodney W. Grimes 		idp->curroff += reclen;
649996c772fSJohn Dyson 
650df8bae1dSRodney W. Grimes 		switch (imp->iso_ftype) {
651df8bae1dSRodney W. Grimes 		case ISO_FTYPE_RRIP:
652996c772fSJohn Dyson 			cd9660_rrip_getname(ep,idp->current.d_name, &namelen,
653df8bae1dSRodney W. Grimes 					   &idp->current.d_fileno,imp);
654996c772fSJohn Dyson 			idp->current.d_namlen = (u_char)namelen;
655df8bae1dSRodney W. Grimes 			if (idp->current.d_namlen)
656df8bae1dSRodney W. Grimes 				error = iso_uiodir(idp,&idp->current,idp->curroff);
657df8bae1dSRodney W. Grimes 			break;
658988fa8efSJoerg Wunsch 		default: /* ISO_FTYPE_DEFAULT || ISO_FTYPE_9660 || ISO_FTYPE_HIGH_SIERRA*/
659df8bae1dSRodney W. Grimes 			strcpy(idp->current.d_name,"..");
660df8bae1dSRodney W. Grimes 			switch (ep->name[0]) {
661df8bae1dSRodney W. Grimes 			case 0:
662df8bae1dSRodney W. Grimes 				idp->current.d_namlen = 1;
663df8bae1dSRodney W. Grimes 				error = iso_uiodir(idp,&idp->current,idp->curroff);
664df8bae1dSRodney W. Grimes 				break;
665df8bae1dSRodney W. Grimes 			case 1:
666df8bae1dSRodney W. Grimes 				idp->current.d_namlen = 2;
667df8bae1dSRodney W. Grimes 				error = iso_uiodir(idp,&idp->current,idp->curroff);
668df8bae1dSRodney W. Grimes 				break;
669df8bae1dSRodney W. Grimes 			default:
670df8bae1dSRodney W. Grimes 				isofntrans(ep->name,idp->current.d_namlen,
671996c772fSJohn Dyson 					   idp->current.d_name, &namelen,
672df8bae1dSRodney W. Grimes 					   imp->iso_ftype == ISO_FTYPE_9660,
673996c772fSJohn Dyson 					   isonum_711(ep->flags)&4);
674996c772fSJohn Dyson 				idp->current.d_namlen = (u_char)namelen;
675df8bae1dSRodney W. Grimes 				if (imp->iso_ftype == ISO_FTYPE_DEFAULT)
676df8bae1dSRodney W. Grimes 					error = iso_shipdir(idp);
677df8bae1dSRodney W. Grimes 				else
678df8bae1dSRodney W. Grimes 					error = iso_uiodir(idp,&idp->current,idp->curroff);
679df8bae1dSRodney W. Grimes 				break;
680df8bae1dSRodney W. Grimes 			}
681df8bae1dSRodney W. Grimes 		}
682df8bae1dSRodney W. Grimes 		if (error)
683df8bae1dSRodney W. Grimes 			break;
684df8bae1dSRodney W. Grimes 
685df8bae1dSRodney W. Grimes 		entryoffsetinblock += reclen;
686df8bae1dSRodney W. Grimes 	}
687df8bae1dSRodney W. Grimes 
688df8bae1dSRodney W. Grimes 	if (!error && imp->iso_ftype == ISO_FTYPE_DEFAULT) {
689df8bae1dSRodney W. Grimes 		idp->current.d_namlen = 0;
690df8bae1dSRodney W. Grimes 		error = iso_shipdir(idp);
691df8bae1dSRodney W. Grimes 	}
692df8bae1dSRodney W. Grimes 	if (error < 0)
693df8bae1dSRodney W. Grimes 		error = 0;
694df8bae1dSRodney W. Grimes 
6959abf4d6eSDoug Rabson 	if (ap->a_ncookies != NULL) {
6969abf4d6eSDoug Rabson 		if (error)
697996c772fSJohn Dyson 			free(cookies, M_TEMP);
6989abf4d6eSDoug Rabson 		else {
6999abf4d6eSDoug Rabson 			/*
7009abf4d6eSDoug Rabson 			 * Work out the number of cookies actually used.
7019abf4d6eSDoug Rabson 			 */
7029abf4d6eSDoug Rabson 			*ap->a_ncookies = ncookies - idp->ncookies;
7039abf4d6eSDoug Rabson 			*ap->a_cookies = cookies;
7049abf4d6eSDoug Rabson 		}
7059abf4d6eSDoug Rabson 	}
7069abf4d6eSDoug Rabson 
707df8bae1dSRodney W. Grimes 	if (bp)
708df8bae1dSRodney W. Grimes 		brelse (bp);
709df8bae1dSRodney W. Grimes 
710df8bae1dSRodney W. Grimes 	uio->uio_offset = idp->uio_off;
711996c772fSJohn Dyson 	*ap->a_eofflag = idp->eofflag;
712df8bae1dSRodney W. Grimes 
713df8bae1dSRodney W. Grimes 	FREE(idp, M_TEMP);
714df8bae1dSRodney W. Grimes 
715df8bae1dSRodney W. Grimes 	return (error);
716df8bae1dSRodney W. Grimes }
717df8bae1dSRodney W. Grimes 
718df8bae1dSRodney W. Grimes /*
719df8bae1dSRodney W. Grimes  * Return target name of a symbolic link
720df8bae1dSRodney W. Grimes  * Shouldn't we get the parent vnode and read the data from there?
721df8bae1dSRodney W. Grimes  * This could eventually result in deadlocks in cd9660_lookup.
722df8bae1dSRodney W. Grimes  * But otherwise the block read here is in the block buffer two times.
723df8bae1dSRodney W. Grimes  */
724df8bae1dSRodney W. Grimes typedef struct iso_directory_record ISODIR;
725df8bae1dSRodney W. Grimes typedef struct iso_node		    ISONODE;
726df8bae1dSRodney W. Grimes typedef struct iso_mnt		    ISOMNT;
727605e9724SPoul-Henning Kamp static int
728df8bae1dSRodney W. Grimes cd9660_readlink(ap)
729df8bae1dSRodney W. Grimes 	struct vop_readlink_args /* {
730df8bae1dSRodney W. Grimes 		struct vnode *a_vp;
731df8bae1dSRodney W. Grimes 		struct uio *a_uio;
732df8bae1dSRodney W. Grimes 		struct ucred *a_cred;
733df8bae1dSRodney W. Grimes 	} */ *ap;
734df8bae1dSRodney W. Grimes {
735df8bae1dSRodney W. Grimes 	ISONODE	*ip;
736df8bae1dSRodney W. Grimes 	ISODIR	*dirp;
737df8bae1dSRodney W. Grimes 	ISOMNT	*imp;
738df8bae1dSRodney W. Grimes 	struct	buf *bp;
739996c772fSJohn Dyson 	struct	uio *uio;
740df8bae1dSRodney W. Grimes 	u_short	symlen;
741df8bae1dSRodney W. Grimes 	int	error;
742df8bae1dSRodney W. Grimes 	char	*symname;
743df8bae1dSRodney W. Grimes 
744df8bae1dSRodney W. Grimes 	ip  = VTOI(ap->a_vp);
745df8bae1dSRodney W. Grimes 	imp = ip->i_mnt;
746996c772fSJohn Dyson 	uio = ap->a_uio;
747df8bae1dSRodney W. Grimes 
748df8bae1dSRodney W. Grimes 	if (imp->iso_ftype != ISO_FTYPE_RRIP)
749996c772fSJohn Dyson 		return (EINVAL);
750df8bae1dSRodney W. Grimes 
751df8bae1dSRodney W. Grimes 	/*
752df8bae1dSRodney W. Grimes 	 * Get parents directory record block that this inode included.
753df8bae1dSRodney W. Grimes 	 */
754df8bae1dSRodney W. Grimes 	error = bread(imp->im_devvp,
755996c772fSJohn Dyson 		      (ip->i_number >> imp->im_bshift) <<
756996c772fSJohn Dyson 		      (imp->im_bshift - DEV_BSHIFT),
757996c772fSJohn Dyson 		      imp->logical_block_size, NOCRED, &bp);
758df8bae1dSRodney W. Grimes 	if (error) {
759df8bae1dSRodney W. Grimes 		brelse(bp);
760996c772fSJohn Dyson 		return (EINVAL);
761df8bae1dSRodney W. Grimes 	}
762df8bae1dSRodney W. Grimes 
763df8bae1dSRodney W. Grimes 	/*
764df8bae1dSRodney W. Grimes 	 * Setup the directory pointer for this inode
765df8bae1dSRodney W. Grimes 	 */
766996c772fSJohn Dyson 	dirp = (ISODIR *)(bp->b_data + (ip->i_number & imp->im_bmask));
767df8bae1dSRodney W. Grimes 
768df8bae1dSRodney W. Grimes 	/*
769df8bae1dSRodney W. Grimes 	 * Just make sure, we have a right one....
770df8bae1dSRodney W. Grimes 	 *   1: Check not cross boundary on block
771df8bae1dSRodney W. Grimes 	 */
772df8bae1dSRodney W. Grimes 	if ((ip->i_number & imp->im_bmask) + isonum_711(dirp->length)
77392579404SAlexander Langer 	    > (unsigned)imp->logical_block_size) {
774df8bae1dSRodney W. Grimes 		brelse(bp);
775996c772fSJohn Dyson 		return (EINVAL);
776df8bae1dSRodney W. Grimes 	}
777df8bae1dSRodney W. Grimes 
778df8bae1dSRodney W. Grimes 	/*
779df8bae1dSRodney W. Grimes 	 * Now get a buffer
780df8bae1dSRodney W. Grimes 	 * Abuse a namei buffer for now.
781df8bae1dSRodney W. Grimes 	 */
782996c772fSJohn Dyson 	if (uio->uio_segflg == UIO_SYSSPACE)
783996c772fSJohn Dyson 		symname = uio->uio_iov->iov_base;
784996c772fSJohn Dyson 	else
78599448ed1SJohn Dyson 		symname = zalloc(namei_zone);
786df8bae1dSRodney W. Grimes 
787df8bae1dSRodney W. Grimes 	/*
788df8bae1dSRodney W. Grimes 	 * Ok, we just gathering a symbolic name in SL record.
789df8bae1dSRodney W. Grimes 	 */
790df8bae1dSRodney W. Grimes 	if (cd9660_rrip_getsymname(dirp, symname, &symlen, imp) == 0) {
791996c772fSJohn Dyson 		if (uio->uio_segflg != UIO_SYSSPACE)
79299448ed1SJohn Dyson 			zfree(namei_zone, symname);
793df8bae1dSRodney W. Grimes 		brelse(bp);
794996c772fSJohn Dyson 		return (EINVAL);
795df8bae1dSRodney W. Grimes 	}
796df8bae1dSRodney W. Grimes 	/*
797df8bae1dSRodney W. Grimes 	 * Don't forget before you leave from home ;-)
798df8bae1dSRodney W. Grimes 	 */
799df8bae1dSRodney W. Grimes 	brelse(bp);
800df8bae1dSRodney W. Grimes 
801df8bae1dSRodney W. Grimes 	/*
802df8bae1dSRodney W. Grimes 	 * return with the symbolic name to caller's.
803df8bae1dSRodney W. Grimes 	 */
804996c772fSJohn Dyson 	if (uio->uio_segflg != UIO_SYSSPACE) {
805996c772fSJohn Dyson 		error = uiomove(symname, symlen, uio);
80699448ed1SJohn Dyson 		zfree(namei_zone, symname);
807996c772fSJohn Dyson 		return (error);
808996c772fSJohn Dyson 	}
809996c772fSJohn Dyson 	uio->uio_resid -= symlen;
810996c772fSJohn Dyson 	uio->uio_iov->iov_base += symlen;
811996c772fSJohn Dyson 	uio->uio_iov->iov_len -= symlen;
812996c772fSJohn Dyson 	return (0);
813df8bae1dSRodney W. Grimes }
814df8bae1dSRodney W. Grimes 
815df8bae1dSRodney W. Grimes /*
816df8bae1dSRodney W. Grimes  * Ufs abort op, called after namei() when a CREATE/DELETE isn't actually
817df8bae1dSRodney W. Grimes  * done. If a buffer has been saved in anticipation of a CREATE, delete it.
818df8bae1dSRodney W. Grimes  */
819605e9724SPoul-Henning Kamp static int
820df8bae1dSRodney W. Grimes cd9660_abortop(ap)
821df8bae1dSRodney W. Grimes 	struct vop_abortop_args /* {
822df8bae1dSRodney W. Grimes 		struct vnode *a_dvp;
823df8bae1dSRodney W. Grimes 		struct componentname *a_cnp;
824df8bae1dSRodney W. Grimes 	} */ *ap;
825df8bae1dSRodney W. Grimes {
826df8bae1dSRodney W. Grimes 	if ((ap->a_cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF)
82799448ed1SJohn Dyson 		zfree(namei_zone, ap->a_cnp->cn_pnbuf);
828996c772fSJohn Dyson 	return (0);
829df8bae1dSRodney W. Grimes }
830df8bae1dSRodney W. Grimes 
831df8bae1dSRodney W. Grimes /*
832df8bae1dSRodney W. Grimes  * Lock an inode.
833df8bae1dSRodney W. Grimes  */
834605e9724SPoul-Henning Kamp static int
835df8bae1dSRodney W. Grimes cd9660_lock(ap)
836df8bae1dSRodney W. Grimes 	struct vop_lock_args /* {
837df8bae1dSRodney W. Grimes 		struct vnode *a_vp;
838996c772fSJohn Dyson 		int a_flags;
839996c772fSJohn Dyson 		struct proc *a_p;
840df8bae1dSRodney W. Grimes 	} */ *ap;
841df8bae1dSRodney W. Grimes {
842996c772fSJohn Dyson 	struct vnode *vp = ap->a_vp;
843df8bae1dSRodney W. Grimes 
844996c772fSJohn Dyson 	return (lockmgr(&VTOI(vp)->i_lock, ap->a_flags, &vp->v_interlock,
845996c772fSJohn Dyson 		ap->a_p));
846df8bae1dSRodney W. Grimes }
847df8bae1dSRodney W. Grimes 
848df8bae1dSRodney W. Grimes /*
849df8bae1dSRodney W. Grimes  * Unlock an inode.
850df8bae1dSRodney W. Grimes  */
851605e9724SPoul-Henning Kamp static int
852df8bae1dSRodney W. Grimes cd9660_unlock(ap)
853df8bae1dSRodney W. Grimes 	struct vop_unlock_args /* {
854df8bae1dSRodney W. Grimes 		struct vnode *a_vp;
855996c772fSJohn Dyson 		int a_flags;
856996c772fSJohn Dyson 		struct proc *a_p;
857df8bae1dSRodney W. Grimes 	} */ *ap;
858df8bae1dSRodney W. Grimes {
859996c772fSJohn Dyson 	struct vnode *vp = ap->a_vp;
860df8bae1dSRodney W. Grimes 
861996c772fSJohn Dyson 	return (lockmgr(&VTOI(vp)->i_lock, ap->a_flags | LK_RELEASE,
862996c772fSJohn Dyson 		&vp->v_interlock, ap->a_p));
863df8bae1dSRodney W. Grimes }
864df8bae1dSRodney W. Grimes 
865df8bae1dSRodney W. Grimes /*
866df8bae1dSRodney W. Grimes  * Calculate the logical to physical mapping if not done already,
867df8bae1dSRodney W. Grimes  * then call the device strategy routine.
868df8bae1dSRodney W. Grimes  */
869605e9724SPoul-Henning Kamp static int
870df8bae1dSRodney W. Grimes cd9660_strategy(ap)
871df8bae1dSRodney W. Grimes 	struct vop_strategy_args /* {
872df8bae1dSRodney W. Grimes 		struct buf *a_bp;
873df8bae1dSRodney W. Grimes 	} */ *ap;
874df8bae1dSRodney W. Grimes {
875df8bae1dSRodney W. Grimes 	register struct buf *bp = ap->a_bp;
876df8bae1dSRodney W. Grimes 	register struct vnode *vp = bp->b_vp;
877df8bae1dSRodney W. Grimes 	register struct iso_node *ip;
878df8bae1dSRodney W. Grimes 	int error;
879df8bae1dSRodney W. Grimes 
880df8bae1dSRodney W. Grimes 	ip = VTOI(vp);
881df8bae1dSRodney W. Grimes 	if (vp->v_type == VBLK || vp->v_type == VCHR)
882df8bae1dSRodney W. Grimes 		panic("cd9660_strategy: spec");
883df8bae1dSRodney W. Grimes 	if (bp->b_blkno == bp->b_lblkno) {
8841295d82eSGary Palmer 		if ((error =
885c83ebe77SJohn Dyson 		    VOP_BMAP(vp, bp->b_lblkno, NULL, &bp->b_blkno, NULL, NULL))) {
886df8bae1dSRodney W. Grimes 			bp->b_error = error;
887df8bae1dSRodney W. Grimes 			bp->b_flags |= B_ERROR;
888df8bae1dSRodney W. Grimes 			biodone(bp);
889df8bae1dSRodney W. Grimes 			return (error);
890df8bae1dSRodney W. Grimes 		}
891df8bae1dSRodney W. Grimes 		if ((long)bp->b_blkno == -1)
892df8bae1dSRodney W. Grimes 			clrbuf(bp);
893df8bae1dSRodney W. Grimes 	}
894df8bae1dSRodney W. Grimes 	if ((long)bp->b_blkno == -1) {
895df8bae1dSRodney W. Grimes 		biodone(bp);
896df8bae1dSRodney W. Grimes 		return (0);
897df8bae1dSRodney W. Grimes 	}
898df8bae1dSRodney W. Grimes 	vp = ip->i_devvp;
899df8bae1dSRodney W. Grimes 	bp->b_dev = vp->v_rdev;
900df8bae1dSRodney W. Grimes 	VOCALL (vp->v_op, VOFFSET(vop_strategy), ap);
901df8bae1dSRodney W. Grimes 	return (0);
902df8bae1dSRodney W. Grimes }
903df8bae1dSRodney W. Grimes 
904df8bae1dSRodney W. Grimes /*
905df8bae1dSRodney W. Grimes  * Print out the contents of an inode.
906df8bae1dSRodney W. Grimes  */
907605e9724SPoul-Henning Kamp static int
908df8bae1dSRodney W. Grimes cd9660_print(ap)
909df8bae1dSRodney W. Grimes 	struct vop_print_args /* {
910df8bae1dSRodney W. Grimes 		struct vnode *a_vp;
911df8bae1dSRodney W. Grimes 	} */ *ap;
912df8bae1dSRodney W. Grimes {
913996c772fSJohn Dyson 
914df8bae1dSRodney W. Grimes 	printf("tag VT_ISOFS, isofs vnode\n");
915996c772fSJohn Dyson 	return (0);
916df8bae1dSRodney W. Grimes }
917df8bae1dSRodney W. Grimes 
918df8bae1dSRodney W. Grimes /*
919996c772fSJohn Dyson  * Check for a locked inode.
920df8bae1dSRodney W. Grimes  */
921996c772fSJohn Dyson int
922996c772fSJohn Dyson cd9660_islocked(ap)
923996c772fSJohn Dyson 	struct vop_islocked_args /* {
924996c772fSJohn Dyson 		struct vnode *a_vp;
925996c772fSJohn Dyson 	} */ *ap;
926df8bae1dSRodney W. Grimes {
927df8bae1dSRodney W. Grimes 
928996c772fSJohn Dyson 	return (lockstatus(&VTOI(ap->a_vp)->i_lock));
929996c772fSJohn Dyson }
930996c772fSJohn Dyson 
931996c772fSJohn Dyson /*
932996c772fSJohn Dyson  * Return POSIX pathconf information applicable to cd9660 filesystems.
933996c772fSJohn Dyson  */
934996c772fSJohn Dyson int
935996c772fSJohn Dyson cd9660_pathconf(ap)
936996c772fSJohn Dyson 	struct vop_pathconf_args /* {
937996c772fSJohn Dyson 		struct vnode *a_vp;
938996c772fSJohn Dyson 		int a_name;
939996c772fSJohn Dyson 		register_t *a_retval;
940996c772fSJohn Dyson 	} */ *ap;
941996c772fSJohn Dyson {
942996c772fSJohn Dyson 
943996c772fSJohn Dyson 	switch (ap->a_name) {
944996c772fSJohn Dyson 	case _PC_LINK_MAX:
945996c772fSJohn Dyson 		*ap->a_retval = 1;
946996c772fSJohn Dyson 		return (0);
947996c772fSJohn Dyson 	case _PC_NAME_MAX:
948996c772fSJohn Dyson 		if (VTOI(ap->a_vp)->i_mnt->iso_ftype == ISO_FTYPE_RRIP)
949996c772fSJohn Dyson 			*ap->a_retval = NAME_MAX;
950996c772fSJohn Dyson 		else
951996c772fSJohn Dyson 			*ap->a_retval = 37;
952996c772fSJohn Dyson 		return (0);
953996c772fSJohn Dyson 	case _PC_PATH_MAX:
954996c772fSJohn Dyson 		*ap->a_retval = PATH_MAX;
955996c772fSJohn Dyson 		return (0);
956996c772fSJohn Dyson 	case _PC_PIPE_BUF:
957996c772fSJohn Dyson 		*ap->a_retval = PIPE_BUF;
958996c772fSJohn Dyson 		return (0);
959996c772fSJohn Dyson 	case _PC_CHOWN_RESTRICTED:
960996c772fSJohn Dyson 		*ap->a_retval = 1;
961996c772fSJohn Dyson 		return (0);
962996c772fSJohn Dyson 	case _PC_NO_TRUNC:
963996c772fSJohn Dyson 		*ap->a_retval = 1;
964996c772fSJohn Dyson 		return (0);
965996c772fSJohn Dyson 	default:
966996c772fSJohn Dyson 		return (EINVAL);
967996c772fSJohn Dyson 	}
968996c772fSJohn Dyson 	/* NOTREACHED */
969df8bae1dSRodney W. Grimes }
970df8bae1dSRodney W. Grimes 
971df8bae1dSRodney W. Grimes /*
972df8bae1dSRodney W. Grimes  * Global vfs data structures for isofs
973df8bae1dSRodney W. Grimes  */
974df8bae1dSRodney W. Grimes #define cd9660_create \
975996c772fSJohn Dyson 	((int (*) __P((struct  vop_create_args *)))eopnotsupp)
976996c772fSJohn Dyson #define cd9660_mknod ((int (*) __P((struct  vop_mknod_args *)))eopnotsupp)
977996c772fSJohn Dyson #define cd9660_write ((int (*) __P((struct  vop_write_args *)))eopnotsupp)
978996c772fSJohn Dyson #ifdef NFS
979996c772fSJohn Dyson #define	 cd9660_lease_check lease_check
980996c772fSJohn Dyson #else
981996c772fSJohn Dyson #define	 cd9660_lease_check ((int (*) __P((struct vop_lease_args *)))nullop)
982996c772fSJohn Dyson #endif
983a6aeade2SPeter Wemm #define cd9660_poll vop_nopoll
984df8bae1dSRodney W. Grimes #define cd9660_fsync ((int (*) __P((struct  vop_fsync_args *)))nullop)
985df8bae1dSRodney W. Grimes #define cd9660_remove \
986996c772fSJohn Dyson 	((int (*) __P((struct  vop_remove_args *)))eopnotsupp)
987996c772fSJohn Dyson #define cd9660_link ((int (*) __P((struct  vop_link_args *)))eopnotsupp)
988df8bae1dSRodney W. Grimes #define cd9660_rename \
989996c772fSJohn Dyson 	((int (*) __P((struct  vop_rename_args *)))eopnotsupp)
990996c772fSJohn Dyson #define cd9660_mkdir ((int (*) __P((struct  vop_mkdir_args *)))eopnotsupp)
991996c772fSJohn Dyson #define cd9660_rmdir ((int (*) __P((struct  vop_rmdir_args *)))eopnotsupp)
992df8bae1dSRodney W. Grimes #define cd9660_symlink \
993996c772fSJohn Dyson 	((int (*) __P((struct vop_symlink_args *)))eopnotsupp)
994df8bae1dSRodney W. Grimes #define cd9660_advlock \
995996c772fSJohn Dyson 	((int (*) __P((struct vop_advlock_args *)))eopnotsupp)
996df8bae1dSRodney W. Grimes #define cd9660_valloc ((int(*) __P(( \
997df8bae1dSRodney W. Grimes 		struct vnode *pvp, \
998df8bae1dSRodney W. Grimes 		int mode, \
999df8bae1dSRodney W. Grimes 		struct ucred *cred, \
1000996c772fSJohn Dyson 		struct vnode **vpp))) eopnotsupp)
1001996c772fSJohn Dyson #define cd9660_vfree ((int (*) __P((struct  vop_vfree_args *)))eopnotsupp)
1002df8bae1dSRodney W. Grimes #define cd9660_truncate \
1003996c772fSJohn Dyson 	((int (*) __P((struct  vop_truncate_args *)))eopnotsupp)
1004df8bae1dSRodney W. Grimes #define cd9660_update \
1005996c772fSJohn Dyson 	((int (*) __P((struct  vop_update_args *)))eopnotsupp)
1006df8bae1dSRodney W. Grimes #define cd9660_bwrite \
1007996c772fSJohn Dyson 	((int (*) __P((struct  vop_bwrite_args *)))eopnotsupp)
1008df8bae1dSRodney W. Grimes 
1009df8bae1dSRodney W. Grimes /*
1010996c772fSJohn Dyson  * Global vfs data structures for cd9660
1011df8bae1dSRodney W. Grimes  */
1012f57e6547SBruce Evans vop_t **cd9660_vnodeop_p;
1013996c772fSJohn Dyson struct vnodeopv_entry_desc cd9660_vnodeop_entries[] = {
1014996c772fSJohn Dyson 
1015f57e6547SBruce Evans 	{ &vop_default_desc, (vop_t *)vn_default_error },
10160fa2443fSPoul-Henning Kamp 	{ &vop_lookup_desc, (vop_t *)vfs_cache_lookup },	/* lookup */
10170fa2443fSPoul-Henning Kamp 	{ &vop_cachedlookup_desc, (vop_t *)cd9660_lookup },	/* lookup */
1018f57e6547SBruce Evans 	{ &vop_create_desc, (vop_t *)cd9660_create },	/* create */
1019a6aeade2SPeter Wemm /* XXX: vop_whiteout */
1020f57e6547SBruce Evans 	{ &vop_mknod_desc, (vop_t *)cd9660_mknod },	/* mknod */
1021f57e6547SBruce Evans 	{ &vop_open_desc, (vop_t *)cd9660_open },	/* open */
1022f57e6547SBruce Evans 	{ &vop_close_desc, (vop_t *)cd9660_close },	/* close */
1023f57e6547SBruce Evans 	{ &vop_access_desc, (vop_t *)cd9660_access },	/* access */
1024f57e6547SBruce Evans 	{ &vop_getattr_desc, (vop_t *)cd9660_getattr },	/* getattr */
1025f57e6547SBruce Evans 	{ &vop_setattr_desc, (vop_t *)cd9660_setattr },	/* setattr */
1026f57e6547SBruce Evans 	{ &vop_read_desc, (vop_t *)cd9660_read },	/* read */
1027f57e6547SBruce Evans 	{ &vop_write_desc, (vop_t *)cd9660_write },	/* write */
1028996c772fSJohn Dyson 	{ &vop_lease_desc, (vop_t *)cd9660_lease_check },/* lease */
1029f57e6547SBruce Evans 	{ &vop_ioctl_desc, (vop_t *)cd9660_ioctl },	/* ioctl */
1030a6aeade2SPeter Wemm 	{ &vop_poll_desc, (vop_t *)cd9660_poll },	/* poll */
1031996c772fSJohn Dyson 	{ &vop_revoke_desc, (vop_t *)cd9660_revoke },	/* revoke */
1032f57e6547SBruce Evans 	{ &vop_mmap_desc, (vop_t *)cd9660_mmap },	/* mmap */
1033f57e6547SBruce Evans 	{ &vop_fsync_desc, (vop_t *)cd9660_fsync },	/* fsync */
1034f57e6547SBruce Evans 	{ &vop_seek_desc, (vop_t *)cd9660_seek },	/* seek */
1035f57e6547SBruce Evans 	{ &vop_remove_desc, (vop_t *)cd9660_remove },	/* remove */
1036f57e6547SBruce Evans 	{ &vop_link_desc, (vop_t *)cd9660_link },	/* link */
1037f57e6547SBruce Evans 	{ &vop_rename_desc, (vop_t *)cd9660_rename },	/* rename */
1038f57e6547SBruce Evans 	{ &vop_mkdir_desc, (vop_t *)cd9660_mkdir },	/* mkdir */
1039f57e6547SBruce Evans 	{ &vop_rmdir_desc, (vop_t *)cd9660_rmdir },	/* rmdir */
1040f57e6547SBruce Evans 	{ &vop_symlink_desc, (vop_t *)cd9660_symlink },	/* symlink */
1041f57e6547SBruce Evans 	{ &vop_readdir_desc, (vop_t *)cd9660_readdir },	/* readdir */
1042f57e6547SBruce Evans 	{ &vop_readlink_desc, (vop_t *)cd9660_readlink },/* readlink */
1043f57e6547SBruce Evans 	{ &vop_abortop_desc, (vop_t *)cd9660_abortop },	/* abortop */
1044f57e6547SBruce Evans 	{ &vop_inactive_desc, (vop_t *)cd9660_inactive },/* inactive */
1045f57e6547SBruce Evans 	{ &vop_reclaim_desc, (vop_t *)cd9660_reclaim },	/* reclaim */
1046f57e6547SBruce Evans 	{ &vop_lock_desc, (vop_t *)cd9660_lock },	/* lock */
1047f57e6547SBruce Evans 	{ &vop_unlock_desc, (vop_t *)cd9660_unlock },	/* unlock */
1048f57e6547SBruce Evans 	{ &vop_bmap_desc, (vop_t *)cd9660_bmap },	/* bmap */
1049f57e6547SBruce Evans 	{ &vop_strategy_desc, (vop_t *)cd9660_strategy },/* strategy */
1050f57e6547SBruce Evans 	{ &vop_print_desc, (vop_t *)cd9660_print },	/* print */
1051f57e6547SBruce Evans 	{ &vop_islocked_desc, (vop_t *)cd9660_islocked },/* islocked */
1052f57e6547SBruce Evans 	{ &vop_pathconf_desc, (vop_t *)cd9660_pathconf },/* pathconf */
1053f57e6547SBruce Evans 	{ &vop_advlock_desc, (vop_t *)cd9660_advlock },	/* advlock */
1054f57e6547SBruce Evans 	{ &vop_blkatoff_desc, (vop_t *)cd9660_blkatoff },/* blkatoff */
1055f57e6547SBruce Evans 	{ &vop_valloc_desc, (vop_t *)cd9660_valloc },	/* valloc */
1056a6aeade2SPeter Wemm /* XXX: vop_reallocblks */
1057f57e6547SBruce Evans 	{ &vop_vfree_desc, (vop_t *)cd9660_vfree },	/* vfree */
1058f57e6547SBruce Evans 	{ &vop_truncate_desc, (vop_t *)cd9660_truncate },/* truncate */
1059f57e6547SBruce Evans 	{ &vop_update_desc, (vop_t *)cd9660_update },	/* update */
1060a6aeade2SPeter Wemm /* XXX: vop_getpages */
1061a6aeade2SPeter Wemm /* XXX: vop_putpages */
1062996c772fSJohn Dyson 	{ &vop_bwrite_desc, (vop_t *)vn_bwrite },
1063f57e6547SBruce Evans 	{ NULL, NULL }
1064df8bae1dSRodney W. Grimes };
1065605e9724SPoul-Henning Kamp static struct vnodeopv_desc cd9660_vnodeop_opv_desc =
1066df8bae1dSRodney W. Grimes 	{ &cd9660_vnodeop_p, cd9660_vnodeop_entries };
1067c901836cSGarrett Wollman VNODEOP_SET(cd9660_vnodeop_opv_desc);
1068df8bae1dSRodney W. Grimes 
1069df8bae1dSRodney W. Grimes /*
1070df8bae1dSRodney W. Grimes  * Special device vnode ops
1071df8bae1dSRodney W. Grimes  */
1072f57e6547SBruce Evans vop_t **cd9660_specop_p;
1073996c772fSJohn Dyson struct vnodeopv_entry_desc cd9660_specop_entries[] = {
1074f57e6547SBruce Evans 	{ &vop_default_desc, (vop_t *)vn_default_error },
1075f57e6547SBruce Evans 	{ &vop_lookup_desc, (vop_t *)spec_lookup },	/* lookup */
1076a6aeade2SPeter Wemm /* XXX: vop_cachedlookup */
1077996c772fSJohn Dyson 	{ &vop_create_desc, (vop_t *)spec_create },	/* create */
1078a6aeade2SPeter Wemm /* XXX: vop_whiteout */
1079996c772fSJohn Dyson 	{ &vop_mknod_desc, (vop_t *)spec_mknod },	/* mknod */
1080f57e6547SBruce Evans 	{ &vop_open_desc, (vop_t *)spec_open },		/* open */
1081f57e6547SBruce Evans 	{ &vop_close_desc, (vop_t *)spec_close },	/* close */
1082f57e6547SBruce Evans 	{ &vop_access_desc, (vop_t *)cd9660_access },	/* access */
1083f57e6547SBruce Evans 	{ &vop_getattr_desc, (vop_t *)cd9660_getattr },	/* getattr */
1084f57e6547SBruce Evans 	{ &vop_setattr_desc, (vop_t *)cd9660_setattr },	/* setattr */
1085f57e6547SBruce Evans 	{ &vop_read_desc, (vop_t *)spec_read },		/* read */
1086f57e6547SBruce Evans 	{ &vop_write_desc, (vop_t *)spec_write },	/* write */
1087996c772fSJohn Dyson 	{ &vop_lease_desc, (vop_t *)spec_lease_check },	/* lease */
1088f57e6547SBruce Evans 	{ &vop_ioctl_desc, (vop_t *)spec_ioctl },	/* ioctl */
1089a6aeade2SPeter Wemm 	{ &vop_poll_desc, (vop_t *)spec_poll },		/* poll */
1090996c772fSJohn Dyson 	{ &vop_revoke_desc, (vop_t *)spec_revoke },	/* revoke */
1091f57e6547SBruce Evans 	{ &vop_mmap_desc, (vop_t *)spec_mmap },		/* mmap */
1092f57e6547SBruce Evans 	{ &vop_fsync_desc, (vop_t *)spec_fsync },	/* fsync */
1093f57e6547SBruce Evans 	{ &vop_seek_desc, (vop_t *)spec_seek },		/* seek */
1094996c772fSJohn Dyson 	{ &vop_remove_desc, (vop_t *)spec_remove },	/* remove */
1095996c772fSJohn Dyson 	{ &vop_link_desc, (vop_t *)spec_link },		/* link */
1096996c772fSJohn Dyson 	{ &vop_rename_desc, (vop_t *)spec_rename },	/* rename */
1097996c772fSJohn Dyson 	{ &vop_mkdir_desc, (vop_t *)spec_mkdir },	/* mkdir */
1098996c772fSJohn Dyson 	{ &vop_rmdir_desc, (vop_t *)spec_rmdir },	/* rmdir */
1099996c772fSJohn Dyson 	{ &vop_symlink_desc, (vop_t *)spec_symlink },	/* symlink */
1100f57e6547SBruce Evans 	{ &vop_readdir_desc, (vop_t *)spec_readdir },	/* readdir */
1101f57e6547SBruce Evans 	{ &vop_readlink_desc, (vop_t *)spec_readlink },	/* readlink */
1102f57e6547SBruce Evans 	{ &vop_abortop_desc, (vop_t *)spec_abortop },	/* abortop */
1103f57e6547SBruce Evans 	{ &vop_inactive_desc, (vop_t *)cd9660_inactive },/* inactive */
1104f57e6547SBruce Evans 	{ &vop_reclaim_desc, (vop_t *)cd9660_reclaim },	/* reclaim */
1105f57e6547SBruce Evans 	{ &vop_lock_desc, (vop_t *)cd9660_lock },	/* lock */
1106f57e6547SBruce Evans 	{ &vop_unlock_desc, (vop_t *)cd9660_unlock },	/* unlock */
1107f57e6547SBruce Evans 	{ &vop_bmap_desc, (vop_t *)spec_bmap },		/* bmap */
1108f57e6547SBruce Evans 	{ &vop_strategy_desc, (vop_t *)spec_strategy },	/* strategy */
1109f57e6547SBruce Evans 	{ &vop_print_desc, (vop_t *)cd9660_print },	/* print */
1110f57e6547SBruce Evans 	{ &vop_islocked_desc, (vop_t *)cd9660_islocked },/* islocked */
1111f57e6547SBruce Evans 	{ &vop_pathconf_desc, (vop_t *)spec_pathconf },	/* pathconf */
1112f57e6547SBruce Evans 	{ &vop_advlock_desc, (vop_t *)spec_advlock },	/* advlock */
1113f57e6547SBruce Evans 	{ &vop_blkatoff_desc, (vop_t *)spec_blkatoff },	/* blkatoff */
1114f57e6547SBruce Evans 	{ &vop_valloc_desc, (vop_t *)spec_valloc },	/* valloc */
1115a6aeade2SPeter Wemm /* XXX: vop_reallocblks */
1116f57e6547SBruce Evans 	{ &vop_vfree_desc, (vop_t *)spec_vfree },	/* vfree */
1117f57e6547SBruce Evans 	{ &vop_truncate_desc, (vop_t *)spec_truncate },	/* truncate */
1118f57e6547SBruce Evans 	{ &vop_update_desc, (vop_t *)cd9660_update },	/* update */
1119a6aeade2SPeter Wemm /* XXX: vop_getpages */
1120a6aeade2SPeter Wemm /* XXX: vop_putpages */
1121996c772fSJohn Dyson 	{ &vop_bwrite_desc, (vop_t *)vn_bwrite },
1122f57e6547SBruce Evans 	{ NULL, NULL }
1123df8bae1dSRodney W. Grimes };
1124605e9724SPoul-Henning Kamp static struct vnodeopv_desc cd9660_specop_opv_desc =
1125df8bae1dSRodney W. Grimes 	{ &cd9660_specop_p, cd9660_specop_entries };
1126c901836cSGarrett Wollman VNODEOP_SET(cd9660_specop_opv_desc);
1127df8bae1dSRodney W. Grimes 
1128f57e6547SBruce Evans vop_t **cd9660_fifoop_p;
1129996c772fSJohn Dyson struct vnodeopv_entry_desc cd9660_fifoop_entries[] = {
1130f57e6547SBruce Evans 	{ &vop_default_desc, (vop_t *)vn_default_error },
1131f57e6547SBruce Evans 	{ &vop_lookup_desc, (vop_t *)fifo_lookup },	/* lookup */
1132a6aeade2SPeter Wemm /* XXX: vop_cachedlookup */
1133996c772fSJohn Dyson 	{ &vop_create_desc, (vop_t *)fifo_create },	/* create */
1134a6aeade2SPeter Wemm /* XXX: vop_whiteout */
1135996c772fSJohn Dyson 	{ &vop_mknod_desc, (vop_t *)fifo_mknod },	/* mknod */
1136f57e6547SBruce Evans 	{ &vop_open_desc, (vop_t *)fifo_open },		/* open */
1137f57e6547SBruce Evans 	{ &vop_close_desc, (vop_t *)fifo_close },	/* close */
1138f57e6547SBruce Evans 	{ &vop_access_desc, (vop_t *)cd9660_access },	/* access */
1139f57e6547SBruce Evans 	{ &vop_getattr_desc, (vop_t *)cd9660_getattr },	/* getattr */
1140f57e6547SBruce Evans 	{ &vop_setattr_desc, (vop_t *)cd9660_setattr },	/* setattr */
1141f57e6547SBruce Evans 	{ &vop_read_desc, (vop_t *)fifo_read },		/* read */
1142f57e6547SBruce Evans 	{ &vop_write_desc, (vop_t *)fifo_write },	/* write */
1143996c772fSJohn Dyson 	{ &vop_lease_desc, (vop_t *)fifo_lease_check },	/* lease */
1144f57e6547SBruce Evans 	{ &vop_ioctl_desc, (vop_t *)fifo_ioctl },	/* ioctl */
1145a6aeade2SPeter Wemm 	{ &vop_poll_desc, (vop_t *)fifo_poll },		/* poll */
1146996c772fSJohn Dyson 	{ &vop_revoke_desc, (vop_t *)fifo_revoke },	/* revoke */
1147f57e6547SBruce Evans 	{ &vop_mmap_desc, (vop_t *)fifo_mmap },		/* mmap */
1148f57e6547SBruce Evans 	{ &vop_fsync_desc, (vop_t *)fifo_fsync },	/* fsync */
1149f57e6547SBruce Evans 	{ &vop_seek_desc, (vop_t *)fifo_seek },		/* seek */
1150996c772fSJohn Dyson 	{ &vop_remove_desc, (vop_t *)fifo_remove },	/* remove */
1151996c772fSJohn Dyson 	{ &vop_link_desc, (vop_t *)fifo_link }	,	/* link */
1152996c772fSJohn Dyson 	{ &vop_rename_desc, (vop_t *)fifo_rename },	/* rename */
1153996c772fSJohn Dyson 	{ &vop_mkdir_desc, (vop_t *)fifo_mkdir },	/* mkdir */
1154996c772fSJohn Dyson 	{ &vop_rmdir_desc, (vop_t *)fifo_rmdir },	/* rmdir */
1155996c772fSJohn Dyson 	{ &vop_symlink_desc, (vop_t *)fifo_symlink },	/* symlink */
1156f57e6547SBruce Evans 	{ &vop_readdir_desc, (vop_t *)fifo_readdir },	/* readdir */
1157f57e6547SBruce Evans 	{ &vop_readlink_desc, (vop_t *)fifo_readlink },	/* readlink */
1158f57e6547SBruce Evans 	{ &vop_abortop_desc, (vop_t *)fifo_abortop },	/* abortop */
1159f57e6547SBruce Evans 	{ &vop_inactive_desc, (vop_t *)cd9660_inactive },/* inactive */
1160f57e6547SBruce Evans 	{ &vop_reclaim_desc, (vop_t *)cd9660_reclaim },	/* reclaim */
1161f57e6547SBruce Evans 	{ &vop_lock_desc, (vop_t *)cd9660_lock },	/* lock */
1162f57e6547SBruce Evans 	{ &vop_unlock_desc, (vop_t *)cd9660_unlock },	/* unlock */
1163f57e6547SBruce Evans 	{ &vop_bmap_desc, (vop_t *)fifo_bmap },		/* bmap */
1164996c772fSJohn Dyson 	{ &vop_strategy_desc, (vop_t *)fifo_strategy },	/* strategy */
1165f57e6547SBruce Evans 	{ &vop_print_desc, (vop_t *)cd9660_print },	/* print */
1166f57e6547SBruce Evans 	{ &vop_islocked_desc, (vop_t *)cd9660_islocked },/* islocked */
1167f57e6547SBruce Evans 	{ &vop_pathconf_desc, (vop_t *)fifo_pathconf },	/* pathconf */
1168f57e6547SBruce Evans 	{ &vop_advlock_desc, (vop_t *)fifo_advlock },	/* advlock */
1169f57e6547SBruce Evans 	{ &vop_blkatoff_desc, (vop_t *)fifo_blkatoff },	/* blkatoff */
1170f57e6547SBruce Evans 	{ &vop_valloc_desc, (vop_t *)fifo_valloc },	/* valloc */
1171a6aeade2SPeter Wemm /* XXX: vop_reallocpages */
1172f57e6547SBruce Evans 	{ &vop_vfree_desc, (vop_t *)fifo_vfree },	/* vfree */
1173f57e6547SBruce Evans 	{ &vop_truncate_desc, (vop_t *)fifo_truncate },	/* truncate */
1174f57e6547SBruce Evans 	{ &vop_update_desc, (vop_t *)cd9660_update },	/* update */
1175a6aeade2SPeter Wemm /* XXX: vop_getpages */
1176a6aeade2SPeter Wemm /* XXX: vop_putpages */
1177996c772fSJohn Dyson 	{ &vop_bwrite_desc, (vop_t *)vn_bwrite },
1178f57e6547SBruce Evans 	{ NULL, NULL }
1179df8bae1dSRodney W. Grimes };
1180605e9724SPoul-Henning Kamp static struct vnodeopv_desc cd9660_fifoop_opv_desc =
1181df8bae1dSRodney W. Grimes 	{ &cd9660_fifoop_p, cd9660_fifoop_entries };
1182c901836cSGarrett Wollman 
1183c901836cSGarrett Wollman VNODEOP_SET(cd9660_fifoop_opv_desc);
1184