]> git.saurik.com Git - apple/xnu.git/blob - bsd/isofs/cd9660/cd9660_vnops.c
xnu-1228.15.4.tar.gz
[apple/xnu.git] / bsd / isofs / cd9660 / cd9660_vnops.c
1 /*
2 * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /* $NetBSD: cd9660_vnops.c,v 1.22 1994/12/27 19:05:12 mycroft Exp $ */
29
30 /*-
31 * Copyright (c) 1994
32 * The Regents of the University of California. All rights reserved.
33 *
34 * This code is derived from software contributed to Berkeley
35 * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
36 * Support code is derived from software contributed to Berkeley
37 * by Atsushi Murai (amurai@spec.co.jp).
38 *
39 * Redistribution and use in source and binary forms, with or without
40 * modification, are permitted provided that the following conditions
41 * are met:
42 * 1. Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer.
44 * 2. Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in the
46 * documentation and/or other materials provided with the distribution.
47 * 3. All advertising materials mentioning features or use of this software
48 * must display the following acknowledgement:
49 * This product includes software developed by the University of
50 * California, Berkeley and its contributors.
51 * 4. Neither the name of the University nor the names of its contributors
52 * may be used to endorse or promote products derived from this software
53 * without specific prior written permission.
54 *
55 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
56 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
58 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
59 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
60 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
61 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
62 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
63 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
64 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
65 * SUCH DAMAGE.
66 *
67 * @(#)cd9660_vnops.c 8.15 (Berkeley) 12/5/94
68 *
69 * HISTORY
70 * 02-Feb-00 chw Add cd9660_copyfile to return error
71 * 29-Sep-98 djb Add cd9660_getattrlist VOP for VDI support.
72 * 15-sep-98 added cd9660_rmdir to do proper unlocking - chw
73 * 12-aug-98 added cd9660_remove which will do proper unlocking - chw
74 * 17-Feb-98 radar 1669467 - changed lock protocols to use the lock manager - chw
75 * 22-Jan-98 radar 1669467 - ISO 9660 CD support - jwc
76 */
77
78 #include <sys/param.h>
79 #include <sys/systm.h>
80 #include <sys/vnode.h>
81 #include <sys/mount.h>
82 #include <sys/namei.h>
83 #include <sys/resourcevar.h>
84 #include <sys/kernel.h>
85 #include <sys/file.h>
86 #include <sys/stat.h>
87 #include <sys/buf.h>
88 #include <sys/proc.h>
89 #include <sys/kauth.h>
90 #include <sys/conf.h>
91 #include <miscfs/specfs/specdev.h>
92 #include <miscfs/fifofs/fifo.h>
93 #include <sys/malloc.h>
94 #include <sys/dir.h>
95 #include <sys/attr.h>
96 #include <vfs/vfs_support.h>
97 #include <vm/vm_kern.h>
98 #include <sys/ubc.h>
99 #include <sys/lock.h>
100 #include <sys/ubc_internal.h>
101 #include <sys/uio_internal.h>
102 #include <libkern/OSByteOrder.h>
103
104 #include <vm/vm_map.h>
105 #include <vm/vm_kern.h> /* kmem_alloc, kmem_free */
106
107 #include <isofs/cd9660/iso.h>
108 #include <isofs/cd9660/cd9660_node.h>
109 #include <isofs/cd9660/iso_rrip.h>
110
111 /*
112 * Open called.
113 *
114 * Nothing to do.
115 */
116 int
117 cd9660_open(__unused struct vnop_open_args *ap)
118 {
119 return (0);
120 }
121
122 /*
123 * Close called
124 *
125 * Update the times on the inode on writeable file systems.
126 */
127 int
128 cd9660_close(__unused struct vnop_close_args *ap)
129 {
130 return (0);
131 }
132
133 int
134 cd9660_getattr(struct vnop_getattr_args *ap)
135 {
136 struct vnode *vp = ap->a_vp;
137 register struct vnode_attr *vap = ap->a_vap;
138 register struct iso_node *ip = VTOI(vp);
139
140 VATTR_RETURN(vap, va_fsid, ip->i_dev);
141 VATTR_RETURN(vap, va_fileid, ip->i_number);
142
143 VATTR_RETURN(vap, va_mode, ip->inode.iso_mode);
144 VATTR_RETURN(vap, va_nlink, ip->inode.iso_links);
145 VATTR_RETURN(vap, va_uid, ip->inode.iso_uid);
146 VATTR_RETURN(vap, va_gid, ip->inode.iso_gid);
147 VATTR_RETURN(vap, va_access_time, ip->inode.iso_atime);
148 VATTR_RETURN(vap, va_modify_time, ip->inode.iso_mtime);
149 VATTR_RETURN(vap, va_change_time, ip->inode.iso_ctime);
150 VATTR_RETURN(vap, va_rdev, ip->inode.iso_rdev);
151
152 VATTR_RETURN(vap, va_data_size, (off_t)ip->i_size);
153 if (ip->i_size == 0 && (vap->va_mode & S_IFMT) == S_IFLNK) {
154 struct vnop_readlink_args rdlnk;
155 uio_t auio;
156 char uio_buf[ UIO_SIZEOF(1) ];
157 char *cp;
158
159 MALLOC(cp, char *, MAXPATHLEN, M_TEMP, M_WAITOK);
160 auio = uio_createwithbuffer(1, 0, UIO_SYSSPACE, UIO_READ,
161 &uio_buf[0], sizeof(uio_buf));
162 uio_addiov(auio, CAST_USER_ADDR_T(cp), MAXPATHLEN);
163
164 rdlnk.a_uio = auio;
165 rdlnk.a_vp = ap->a_vp;
166 rdlnk.a_context = ap->a_context;
167 if (cd9660_readlink(&rdlnk) == 0)
168 // LP64todo - fix this!
169 VATTR_RETURN(vap, va_data_size, MAXPATHLEN - uio_resid(auio));
170 FREE(cp, M_TEMP);
171 }
172 VATTR_RETURN(vap, va_flags, 0);
173 VATTR_RETURN(vap, va_gen, 1);
174 VATTR_RETURN(vap, va_iosize, ip->i_mnt->logical_block_size);
175 VATTR_RETURN(vap, va_total_size, ip->i_size + ip->i_rsrcsize);
176
177 return (0);
178 }
179
180
181 /*
182 * Vnode op for reading.
183 */
184 int
185 cd9660_read(struct vnop_read_args *ap)
186 {
187 struct vnode *vp = ap->a_vp;
188 register struct uio *uio = ap->a_uio;
189 register struct iso_node *ip = VTOI(vp);
190 register struct iso_mnt *imp;
191 struct buf *bp;
192 daddr_t lbn;
193 daddr64_t rablock;
194 off_t diff;
195 int rasize, error = 0;
196 int32_t size, n, on;
197
198 if (uio_resid(uio) == 0)
199 return (0);
200 if (uio->uio_offset < 0)
201 return (EINVAL);
202
203 imp = ip->i_mnt;
204
205 if (UBCINFOEXISTS(vp)) {
206 /*
207 * Copy any part of the Apple Double header.
208 */
209 if ((ip->i_flag & ISO_ASSOCIATED) && (uio->uio_offset < ADH_SIZE)) {
210 apple_double_header_t header;
211 int bytes;
212
213 if (uio->uio_offset < sizeof(apple_double_header_t)) {
214 header.magic = APPLEDOUBLE_MAGIC;
215 header.version = APPLEDOUBLE_VERSION;
216 header.count = 2;
217 header.entries[0].entryID = APPLEDOUBLE_FINDERINFO;
218 header.entries[0].offset = offsetof(apple_double_header_t, finfo);
219 header.entries[0].length = 32;
220 header.entries[1].entryID = APPLEDOUBLE_RESFORK;
221 header.entries[1].offset = ADH_SIZE;
222 header.entries[1].length = ip->i_size - ADH_SIZE;
223 header.finfo.fdType = ip->i_FileType;
224 header.finfo.fdCreator = ip->i_Creator;
225 header.finfo.fdFlags = ip->i_FinderFlags;
226 header.finfo.fdLocation.v = -1;
227 header.finfo.fdLocation.h = -1;
228 header.finfo.fdReserved = 0;
229
230 bytes = min(uio_resid(uio), sizeof(apple_double_header_t) - uio->uio_offset);
231 error = uiomove(((char *) &header) + uio->uio_offset, bytes, uio);
232 if (error)
233 return error;
234 }
235 if (uio_resid(uio) && uio->uio_offset < ADH_SIZE) {
236 caddr_t buffer;
237
238 if (kmem_alloc(kernel_map, (vm_offset_t *)&buffer, ADH_SIZE)) {
239 return (ENOMEM);
240 }
241 bytes = min(uio_resid(uio), ADH_SIZE - uio->uio_offset);
242 error = uiomove(((char *) buffer) + uio->uio_offset, bytes, uio);
243 kmem_free(kernel_map, (vm_offset_t)buffer, ADH_SIZE);
244 if (error)
245 return error;
246 }
247 }
248 if (uio_resid(uio) > 0)
249 error = cluster_read(vp, uio, (off_t)ip->i_size, ap->a_ioflag);
250 } else {
251
252 do {
253 lbn = lblkno(imp, uio->uio_offset);
254 on = blkoff(imp, uio->uio_offset);
255 n = min((u_int)(imp->logical_block_size - on),
256 uio_resid(uio));
257 diff = (off_t)ip->i_size - uio->uio_offset;
258 if (diff <= 0)
259 return (0);
260 if (diff < n)
261 n = diff;
262 size = blksize(imp, ip, lbn);
263 rablock = (daddr64_t)lbn + 1;
264
265 if (ip->i_lastr + 1 == lbn &&
266 lblktosize(imp, rablock) < ip->i_size) {
267 rasize = blksize(imp, ip, (daddr_t)rablock);
268 error = (int)buf_breadn(vp, (daddr64_t)((unsigned)lbn), size, &rablock,
269 &rasize, 1, NOCRED, &bp);
270 } else
271 error = (int)buf_bread(vp, (daddr64_t)((unsigned)lbn), size, NOCRED, &bp);
272
273 ip->i_lastr = lbn;
274 n = min(n, size - buf_resid(bp));
275 if (error) {
276 buf_brelse(bp);
277 return (error);
278 }
279
280 error = uiomove((caddr_t)(buf_dataptr(bp) + on), (int)n, uio);
281 if (n + on == imp->logical_block_size ||
282 uio->uio_offset == (off_t)ip->i_size)
283 buf_markaged(bp);
284 buf_brelse(bp);
285 } while (error == 0 && uio_resid(uio) > 0 && n != 0);
286 }
287
288 return (error);
289 }
290
291 int
292 cd9660_ioctl(__unused struct vnop_ioctl_args *ap)
293 {
294 return (ENOTTY);
295 }
296
297 int
298 cd9660_select(__unused struct vnop_select_args *ap)
299 {
300 /*
301 * We should really check to see if I/O is possible.
302 */
303 return (1);
304 }
305
306 /*
307 * Mmap a file
308 *
309 * NB Currently unsupported.
310 */
311 int
312 cd9660_mmap(__unused struct vnop_mmap_args *ap)
313 {
314
315 return (EINVAL);
316 }
317
318 /*
319 * Structure for reading directories
320 */
321 struct isoreaddir {
322 struct dirent saveent;
323 struct dirent current;
324 off_t saveoff;
325 off_t curroff;
326 struct uio *uio;
327 off_t uio_off;
328 int eofflag;
329 // u_long **cookies;
330 // int *ncookies;
331 };
332
333 static int
334 iso_uiodir(struct isoreaddir *idp, struct dirent *dp, off_t off)
335 {
336 int error;
337
338 dp->d_name[dp->d_namlen] = 0;
339 dp->d_reclen = DIRSIZ(dp);
340
341 if (uio_resid(idp->uio) < dp->d_reclen) {
342 idp->eofflag = 0;
343 return (-1);
344 }
345
346 #if 0
347 if (idp->cookies) {
348 if (*idp->ncookies <= 0) {
349 idp->eofflag = 0;
350 return (-1);
351 }
352
353 **idp->cookies++ = off;
354 --*idp->ncookies;
355 }
356 #endif
357
358 if ( (error = uiomove( (caddr_t)dp, dp->d_reclen, idp->uio )) )
359 return (error);
360 idp->uio_off = off;
361 return (0);
362 }
363
364 static int
365 iso_shipdir(struct isoreaddir *idp)
366 {
367 struct dirent *dp;
368 int cl, sl;
369 int error;
370 char *cname, *sname;
371
372 cl = idp->current.d_namlen;
373 cname = idp->current.d_name;
374
375 dp = &idp->saveent;
376 sname = dp->d_name;
377 sl = dp->d_namlen;
378 if (sl > 0) {
379 if (sl != cl
380 || bcmp(sname,cname,sl)) {
381 if (idp->saveent.d_namlen) {
382 if ( (error = iso_uiodir(idp,&idp->saveent,idp->saveoff)) )
383 return (error);
384 idp->saveent.d_namlen = 0;
385 }
386 }
387 }
388 idp->current.d_reclen = DIRSIZ(&idp->current);
389 idp->saveoff = idp->curroff;
390 bcopy(&idp->current,&idp->saveent,idp->current.d_reclen);
391 return (0);
392 }
393
394 /*
395 * Vnode op for readdir
396 *
397 * Note that directories are sector aligned (2K) and
398 * that an entry can cross a logical block but not
399 * a sector.
400 */
401 int
402 cd9660_readdir(struct vnop_readdir_args *ap)
403 {
404 register struct uio *uio = ap->a_uio;
405 #if 0
406 off_t startingOffset = uio->uio_offset;
407 size_t lost = 0;
408 #endif /* 0 */
409 struct isoreaddir *idp;
410 struct vnode *vdp = ap->a_vp;
411 struct iso_node *dp;
412 struct iso_mnt *imp;
413 struct buf *bp = NULL;
414 struct iso_directory_record *ep;
415 int entryoffsetinblock;
416 doff_t endsearch;
417 uint32_t bmask;
418 int error = 0;
419 int reclen;
420 u_short namelen;
421
422 if (ap->a_flags & (VNODE_READDIR_EXTENDED | VNODE_READDIR_REQSEEKOFF))
423 return (EINVAL);
424
425 dp = VTOI(vdp);
426 imp = dp->i_mnt;
427 bmask = imp->im_sector_size - 1;
428
429 MALLOC(idp, struct isoreaddir *, sizeof(*idp), M_TEMP, M_WAITOK);
430 idp->saveent.d_namlen = 0;
431 /*
432 * XXX
433 * Is it worth trying to figure out the type?
434 */
435 idp->saveent.d_type = idp->current.d_type = DT_UNKNOWN;
436 idp->uio = uio;
437 idp->eofflag = 1;
438 idp->curroff = uio->uio_offset;
439
440 if ((entryoffsetinblock = idp->curroff & bmask) &&
441 (error = cd9660_blkatoff(vdp, SECTOFF(imp, idp->curroff), NULL, &bp))) {
442 FREE(idp, M_TEMP);
443 return (error);
444 }
445 endsearch = dp->i_size;
446
447 while (idp->curroff < endsearch) {
448 /*
449 * If offset is on a block boundary,
450 * read the next directory block.
451 * Release previous if it exists.
452 */
453 if ((idp->curroff & bmask) == 0) {
454 if (bp != NULL)
455 buf_brelse(bp);
456 if ((error = cd9660_blkatoff(vdp, SECTOFF(imp, idp->curroff), NULL, &bp)))
457 break;
458 entryoffsetinblock = 0;
459 }
460 /*
461 * Get pointer to next entry.
462 */
463 ep = (struct iso_directory_record *)
464 (buf_dataptr(bp) + entryoffsetinblock);
465
466 reclen = isonum_711(ep->length);
467 if (reclen == 0) {
468 /* skip to next block, if any */
469 idp->curroff =
470 (idp->curroff & ~bmask) + imp->im_sector_size;
471 continue;
472 }
473
474 if (reclen < ISO_DIRECTORY_RECORD_SIZE) {
475 error = EINVAL;
476 /* illegal entry, stop */
477 break;
478 }
479
480 if (entryoffsetinblock + reclen > imp->im_sector_size) {
481 error = EINVAL;
482 /* illegal directory, so stop looking */
483 break;
484 }
485
486 idp->current.d_namlen = isonum_711(ep->name_len);
487
488 if (reclen < ISO_DIRECTORY_RECORD_SIZE + idp->current.d_namlen) {
489 error = EINVAL;
490 /* illegal entry, stop */
491 break;
492 }
493
494 /*
495 * Some poorly mastered discs have an incorrect directory
496 * file size. If the '.' entry has a better size (bigger)
497 * then use that instead.
498 */
499 if ((uio->uio_offset == 0) && (isonum_733(ep->size) > endsearch)) {
500 dp->i_size = endsearch = isonum_733(ep->size);
501 }
502
503 if ( isonum_711(ep->flags) & directoryBit )
504 idp->current.d_fileno = isodirino(ep, imp);
505 else {
506 idp->current.d_fileno = ((daddr_t)buf_blkno(bp) << imp->im_bshift) +
507 entryoffsetinblock;
508 }
509
510 idp->curroff += reclen;
511
512 switch (imp->iso_ftype) {
513 case ISO_FTYPE_RRIP:
514 cd9660_rrip_getname(ep,idp->current.d_name, &namelen,
515 &idp->current.d_fileno,imp);
516 idp->current.d_namlen = (u_char)namelen;
517 if (idp->current.d_namlen)
518 error = iso_uiodir(idp,&idp->current,idp->curroff);
519 break;
520
521 case ISO_FTYPE_JOLIET:
522 ucsfntrans((u_int16_t *)ep->name, idp->current.d_namlen,
523 idp->current.d_name, &namelen,
524 isonum_711(ep->flags) & directoryBit,
525 isonum_711(ep->flags) & associatedBit);
526 idp->current.d_namlen = (u_char)namelen;
527 if (idp->current.d_namlen)
528 error = iso_uiodir(idp,&idp->current,idp->curroff);
529 break;
530
531 default: /* ISO_FTYPE_DEFAULT || ISO_FTYPE_9660 */
532 strlcpy(idp->current.d_name, "..",
533 __DARWIN_MAXNAMLEN + 1);
534 switch (ep->name[0]) {
535 case 0:
536 idp->current.d_namlen = 1;
537 error = iso_uiodir(idp,&idp->current,idp->curroff);
538 break;
539 case 1:
540 idp->current.d_namlen = 2;
541 error = iso_uiodir(idp,&idp->current,idp->curroff);
542 break;
543 default:
544 isofntrans(ep->name,idp->current.d_namlen,
545 idp->current.d_name, &namelen,
546 imp->iso_ftype == ISO_FTYPE_9660,
547 isonum_711(ep->flags) & associatedBit);
548 idp->current.d_namlen = (u_char)namelen;
549 if (imp->iso_ftype == ISO_FTYPE_DEFAULT)
550 error = iso_shipdir(idp);
551 else
552 error = iso_uiodir(idp,&idp->current,idp->curroff);
553 break;
554 }
555 }
556 if (error)
557 break;
558
559 entryoffsetinblock += reclen;
560 }
561
562 if (!error && imp->iso_ftype == ISO_FTYPE_DEFAULT) {
563 idp->current.d_namlen = 0;
564 error = iso_shipdir(idp);
565 }
566 #if 0
567 if (!error && ap->a_ncookies) {
568 struct dirent *dirp, *dpstart;
569 off_t bufferOffset;
570 u_long *cookies;
571 int ncookies;
572
573 /*
574 * Only the NFS server uses cookies, and it loads the
575 * directory block into system space, so we can just look at
576 * it directly.
577 *
578 * We assume the entire transfer is done to a single contiguous buffer.
579 */
580 if (UIO_SEG_IS_USER_SPACE(uio->uio_segflg) || uio->uio_iovcnt != 1)
581 panic("ufs_readdir: lost in space");
582
583 /*
584 * Make a first pass over the buffer just generated,
585 * counting the number of entries:
586 */
587 // LP64todo - fix this!
588 dpstart = (struct dirent *)
589 CAST_DOWN(caddr_t, (uio_iov_base(uio) - (uio->uio_offset - startingOffset)));
590 for (dirp = dpstart, bufferOffset = startingOffset, ncookies = 0;
591 bufferOffset < uio->uio_offset; ) {
592 if (dirp->d_reclen == 0)
593 break;
594 bufferOffset += dirp->d_reclen;
595 ncookies++;
596 dirp = (struct dirent *)((caddr_t)dirp + dirp->d_reclen);
597 }
598 lost += uio->uio_offset - bufferOffset;
599 uio->uio_offset = bufferOffset;
600
601 /*
602 * Allocate a buffer to hold the cookies requested:
603 */
604 MALLOC(cookies, u_long *, ncookies * sizeof(u_long), M_TEMP, M_WAITOK);
605 *ap->a_ncookies = ncookies;
606 *ap->a_cookies = cookies;
607
608 /*
609 * Fill in the offsets for each entry in the buffer just allocated:
610 */
611 for (bufferOffset = startingOffset, dirp = dpstart; bufferOffset < uio->uio_offset; ) {
612 *(cookies++) = bufferOffset;
613 bufferOffset += dirp->d_reclen;
614 dirp = (struct dirent *)((caddr_t)dirp + dirp->d_reclen);
615 }
616 }
617 #endif
618 if (error < 0)
619 error = 0;
620
621 if (bp)
622 buf_brelse (bp);
623
624 uio->uio_offset = idp->uio_off;
625 *ap->a_eofflag = idp->eofflag;
626
627 FREE(idp, M_TEMP);
628
629 return (error);
630 }
631
632 /*
633 * Return target name of a symbolic link
634 * Shouldn't we get the parent vnode and read the data from there?
635 * This could eventually result in deadlocks in cd9660_lookup.
636 * But otherwise the block read here is in the block buffer two times.
637 */
638 typedef struct iso_directory_record ISODIR;
639 typedef struct iso_node ISONODE;
640 typedef struct iso_mnt ISOMNT;
641 int
642 cd9660_readlink(struct vnop_readlink_args *ap)
643 {
644 ISONODE *ip;
645 ISODIR *dirp;
646 ISOMNT *imp;
647 struct buf *bp;
648 struct uio *uio;
649 u_short symlen;
650 int error;
651 char *symname;
652
653 ip = VTOI(ap->a_vp);
654 imp = ip->i_mnt;
655 uio = ap->a_uio;
656
657 if (imp->iso_ftype != ISO_FTYPE_RRIP)
658 return (EINVAL);
659
660 /*
661 * Get parents directory record block that this inode included.
662 */
663 error = (int)buf_bread(imp->im_devvp,
664 (daddr64_t)((unsigned)(ip->i_number >> imp->im_bshift)),
665 imp->logical_block_size, NOCRED, &bp);
666 if (error) {
667 buf_brelse(bp);
668 return (EINVAL);
669 }
670
671 /*
672 * Setup the directory pointer for this inode
673 */
674 dirp = (ISODIR *)(buf_dataptr(bp) + (ip->i_number & imp->im_bmask));
675
676 /*
677 * Just make sure, we have a right one....
678 * 1: Check not cross boundary on block
679 */
680 if ((ip->i_number & imp->im_bmask) + isonum_711(dirp->length)
681 > imp->logical_block_size) {
682 buf_brelse(bp);
683 return (EINVAL);
684 }
685
686 /*
687 * Now get a buffer
688 * Abuse a namei buffer for now.
689 */
690 if (UIO_SEG_IS_USER_SPACE(uio->uio_segflg))
691 MALLOC_ZONE(symname, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
692 else
693 // LP64todo - fix this!
694 symname = CAST_DOWN(caddr_t, uio_iov_base(uio));
695
696 /*
697 * Ok, we just gathering a symbolic name in SL record.
698 */
699 if (cd9660_rrip_getsymname(dirp, symname, &symlen, imp) == 0) {
700 if (UIO_SEG_IS_USER_SPACE(uio->uio_segflg))
701 FREE_ZONE(symname, MAXPATHLEN, M_NAMEI);
702 buf_brelse(bp);
703 return (EINVAL);
704 }
705 /*
706 * Don't forget before you leave from home ;-)
707 */
708 buf_brelse(bp);
709
710 /*
711 * return with the symbolic name to caller's.
712 */
713 if (UIO_SEG_IS_USER_SPACE(uio->uio_segflg)) {
714 error = uiomove(symname, symlen, uio);
715 FREE_ZONE(symname, MAXPATHLEN, M_NAMEI);
716 return (error);
717 }
718 #if LP64KERN
719 uio_setresid(uio, (uio_resid(uio) - symlen));
720 uio_iov_len_add(uio, -((int64_t)symlen));
721 #else
722 uio_setresid(uio, (uio_resid(uio) - symlen));
723 uio_iov_len_add(uio, -((int)symlen));
724 #endif
725 uio_iov_base_add(uio, symlen);
726 return (0);
727 }
728
729
730 /*
731 * prepare and issue the I/O
732 */
733 int
734 cd9660_strategy(struct vnop_strategy_args *ap)
735 {
736 buf_t bp = ap->a_bp;
737 vnode_t vp = buf_vnode(bp);
738 struct iso_node *ip = VTOI(vp);
739
740 return (buf_strategy(ip->i_devvp, ap));
741 }
742
743
744 /*
745 * Return POSIX pathconf information applicable to cd9660 filesystems.
746 */
747 int
748 cd9660_pathconf(struct vnop_pathconf_args *ap)
749 {
750
751 switch (ap->a_name) {
752 case _PC_LINK_MAX:
753 *ap->a_retval = 1;
754 return (0);
755 case _PC_NAME_MAX:
756 switch (VTOI(ap->a_vp)->i_mnt->iso_ftype) {
757 case ISO_FTYPE_RRIP:
758 *ap->a_retval = ISO_RRIP_NAMEMAX;
759 break;
760 case ISO_FTYPE_JOLIET:
761 *ap->a_retval = ISO_JOLIET_NAMEMAX;
762 break;
763 default:
764 *ap->a_retval = ISO_NAMEMAX;
765 }
766 return (0);
767 case _PC_PATH_MAX:
768 *ap->a_retval = PATH_MAX;
769 return (0);
770 case _PC_PIPE_BUF:
771 *ap->a_retval = PIPE_BUF;
772 return (0);
773 case _PC_CHOWN_RESTRICTED:
774 *ap->a_retval = 200112; /* _POSIX_CHOWN_RESTRICTED */
775 return (0);
776 case _PC_NO_TRUNC:
777 *ap->a_retval = 200112; /* _POSIX_NO_TRUNC */
778 return (0);
779 default:
780 return (EINVAL);
781 }
782 /* NOTREACHED */
783 }
784
785 /*
786 * Unsupported operation
787 */
788 int
789 cd9660_enotsupp(void)
790 {
791 return (ENOTSUP);
792 }
793 /* Pagein. similar to read */
794 int
795 cd9660_pagein(struct vnop_pagein_args *ap)
796 {
797 struct vnode *vp = ap->a_vp;
798 upl_t pl = ap->a_pl;
799 size_t size = ap->a_size;
800 off_t f_offset = ap->a_f_offset;
801 vm_offset_t pl_offset = ap->a_pl_offset;
802 int flags = ap->a_flags;
803 register struct iso_node *ip = VTOI(vp);
804 int error = 0;
805
806 /*
807 * Copy the Apple Double header.
808 */
809 if ((ip->i_flag & ISO_ASSOCIATED) && (f_offset == 0) && (size == ADH_SIZE)) {
810 apple_double_header_t header;
811 kern_return_t kret;
812 vm_offset_t ioaddr;
813
814 kret = ubc_upl_map(pl, &ioaddr);
815 if (kret != KERN_SUCCESS)
816 panic("cd9660_xa_pagein: ubc_upl_map error = %d", kret);
817 ioaddr += pl_offset;
818 bzero((caddr_t)ioaddr, ADH_SIZE);
819
820 header.magic = APPLEDOUBLE_MAGIC;
821 header.version = APPLEDOUBLE_VERSION;
822 header.count = 2;
823 header.entries[0].entryID = APPLEDOUBLE_FINDERINFO;
824 header.entries[0].offset = offsetof(apple_double_header_t, finfo);
825 header.entries[0].length = 32;
826 header.entries[1].entryID = APPLEDOUBLE_RESFORK;
827 header.entries[1].offset = ADH_SIZE;
828 header.entries[1].length = ip->i_size - ADH_SIZE;
829 header.finfo.fdType = ip->i_FileType;
830 header.finfo.fdCreator = ip->i_Creator;
831 header.finfo.fdFlags = ip->i_FinderFlags;
832 header.finfo.fdLocation.v = -1;
833 header.finfo.fdLocation.h = -1;
834 header.finfo.fdReserved = 0;
835
836 bcopy((caddr_t)&header, (caddr_t)ioaddr, sizeof(apple_double_header_t));
837
838 kret = ubc_upl_unmap(pl);
839 if (kret != KERN_SUCCESS)
840 panic("cd9660_xa_pagein: ubc_upl_unmap error = %d", kret);
841
842 if ((flags & UPL_NOCOMMIT) == 0) {
843 ubc_upl_commit_range(pl, pl_offset, size, UPL_COMMIT_FREE_ON_EMPTY);
844 }
845 } else {
846 /* check pageouts are for reg file only and ubc info is present*/
847 error = cluster_pagein(vp, pl, pl_offset, f_offset, size,
848 (off_t)ip->i_size, flags);
849 }
850 return (error);
851 }
852
853 /*
854 * cd9660_remove - not possible to remove a file from iso cds
855 *
856 * Locking policy: a_dvp and vp locked on entry, unlocked on exit
857 */
858 int
859 cd9660_remove(__unused struct vnop_remove_args *ap)
860 {
861 return (EROFS);
862 }
863
864
865 /*
866 * cd9660_rmdir - not possible to remove a directory from iso cds
867 *
868 * Locking policy: a_dvp and vp locked on entry, unlocked on exit
869 */
870 int
871 cd9660_rmdir(struct vnop_rmdir_args *ap)
872 {
873 (void) nop_rmdir(ap);
874 return (EROFS);
875 }
876
877 /*
878 * Make a RIFF file header for a CD-ROM XA media file.
879 */
880 __private_extern__ void
881 cd9660_xa_init(struct iso_node *ip, struct iso_directory_record *isodir)
882 {
883 uint32_t sectors;
884 struct riff_header *header;
885 u_char name_len;
886 char *cdxa;
887
888 MALLOC(header, struct riff_header *, sizeof(struct riff_header), M_TEMP, M_WAITOK);
889
890 sectors = ip->i_size / 2048;
891
892 strncpy(header->riff, "RIFF", 4);
893 header->fileSize = OSSwapHostToLittleInt32(sectors * CDXA_SECTOR_SIZE + sizeof(struct riff_header) - 8);
894 strncpy(header->cdxa, "CDXA", 4);
895 strncpy(header->fmt, "fmt ", 4);
896 header->fmtSize = OSSwapHostToLittleConstInt32(16);
897 strncpy(header->data, "data", 4);
898 header->dataSize = OSSwapHostToLittleInt32(sectors * CDXA_SECTOR_SIZE);
899
900 /*
901 * Copy the CD-ROM XA extended directory information into the header. As far as
902 * I can tell, it's always 14 bytes in the directory record, but allocated 16 bytes
903 * in the header (the last two being zeroed pad bytes).
904 */
905 name_len = isonum_711(isodir->name_len);
906 cdxa = &isodir->name[name_len];
907 if ((name_len & 0x01) == 0)
908 ++cdxa; /* Skip pad byte */
909 bcopy(cdxa, header->fmtData, 14);
910 header->fmtData[14] = 0;
911 header->fmtData[15] = 0;
912
913 /*
914 * Point this i-node to the "whole sector" device instead of the normal
915 * device. This allows cd9660_strategy to be ignorant of the block
916 * (sector) size.
917 */
918 ip->i_devvp = ip->i_mnt->phys_devvp;
919
920 ip->i_size = sectors * CDXA_SECTOR_SIZE + sizeof(struct riff_header);
921 ip->i_riff = header;
922 }
923
924 /*
925 * Helper routine for vnop_read and vnop_pagein of CD-ROM XA multimedia files.
926 * This routine determines the physical location of the file, then reads
927 * sectors directly from the device into a buffer. It also handles inserting
928 * the RIFF header at the beginning of the file.
929 *
930 * Exactly one of buffer or uio must be non-zero. It will either bcopy to
931 * buffer, or uiomove via uio.
932 *
933 * XXX Should this code be using buf_breadn and ip->i_lastr to support single-block
934 * read-ahead? Should we try more aggressive read-ahead like cluster_io does?
935 *
936 * XXX This could be made to do larger I/O to the device (reading all the
937 * whole sectors directly into the buffer). That would make the code more
938 * complex, and the current code only adds 2.5% overhead compared to reading
939 * from the device directly (at least on my test machine).
940 */
941 static int
942 cd9660_xa_read_common(
943 struct vnode *vp,
944 off_t offset,
945 size_t amount,
946 caddr_t buffer,
947 struct uio *uio)
948 {
949 struct iso_node *ip = VTOI(vp);
950 struct buf *bp;
951 off_t diff; /* number of bytes from offset to file's EOF */
952 daddr_t block; /* physical disk block containing offset */
953 off_t sect_off; /* starting offset into current sector */
954 u_int count; /* number of bytes to transfer in current block */
955 int error=0;
956
957 /*
958 * Copy any part of the RIFF header.
959 */
960 if (offset < sizeof(struct riff_header)) {
961 char *p;
962
963 p = ((char *) ip->i_riff) + offset;
964 count = min(amount, sizeof(struct riff_header) - offset);
965 if (buffer) {
966 bcopy(p, buffer, count);
967 buffer += count;
968 } else {
969 error = uiomove(p, count, uio);
970 }
971 amount -= count;
972 offset += count;
973 }
974 if (error)
975 return error;
976
977 /*
978 * Loop over (possibly partial) blocks to transfer.
979 */
980 while (error == 0 && amount > 0) {
981 /*
982 * Determine number of bytes until EOF. If we've hit
983 * EOF then return.
984 */
985 diff = ip->i_size - offset;
986 if (diff <= 0)
987 return 0;
988
989 /* Get a block from the underlying device */
990 block = ip->iso_start + (offset - sizeof(struct riff_header))/CDXA_SECTOR_SIZE;
991 error = (int)buf_bread(ip->i_devvp, (daddr64_t)((unsigned)block), CDXA_SECTOR_SIZE, NOCRED, &bp);
992 if (error) {
993 buf_brelse(bp);
994 return error;
995 }
996 if (buf_resid(bp)) {
997 printf("isofs: cd9660_xa_read_common: buf_bread didn't read full sector\n");
998 return EIO;
999 }
1000
1001 /* Figure out which part of the block to copy, and copy it */
1002 sect_off = (offset - sizeof(struct riff_header)) % CDXA_SECTOR_SIZE;
1003 count = min(CDXA_SECTOR_SIZE-sect_off, amount);
1004 if (diff < count) /* Pin transfer amount to EOF */
1005 count = diff;
1006
1007 if (buffer) {
1008 bcopy(CAST_DOWN(caddr_t, (buf_dataptr(bp)+sect_off)), buffer, count);
1009 buffer += count;
1010 } else {
1011 error = uiomove(CAST_DOWN(caddr_t, (buf_dataptr(bp)+sect_off)), count, uio);
1012 }
1013 amount -= count;
1014 offset += count;
1015
1016 /*
1017 * If we copied through the end of the block, or the end of file, then
1018 * age the device block. This is optimized for sequential access.
1019 */
1020 if (sect_off+count == CDXA_SECTOR_SIZE || offset == (off_t)ip->i_size)
1021 buf_markaged(bp);
1022 buf_brelse(bp);
1023 }
1024
1025 return error;
1026 }
1027
1028 /*
1029 * Read from a CD-ROM XA multimedia file.
1030 *
1031 * This uses the same common routine as pagein for doing the actual read
1032 * from the device.
1033 *
1034 * This routine doesn't do any caching beyond what the block device does.
1035 * Even then, cd9660_xa_read_common ages the blocks once we read up to
1036 * the end.
1037 *
1038 * We don't even take advantage if the file has been memory mapped and has
1039 * valid pages already (in which case we could just uiomove from the page
1040 * to the caller). Since we're a read-only filesystem, there can't be
1041 * any cache coherency problems. Multimedia files are expected to be
1042 * large and streamed anyway, so caching file contents probably isn't
1043 * important.
1044 */
1045 int
1046 cd9660_xa_read(struct vnop_read_args *ap)
1047 {
1048 struct vnode *vp = ap->a_vp;
1049 register struct uio *uio = ap->a_uio;
1050 register struct iso_node *ip = VTOI(vp);
1051 off_t offset = uio->uio_offset;
1052 // LP64todo - fix this!
1053 size_t size = uio_resid(uio);
1054
1055 /* Check for some obvious parameter problems */
1056 if (offset < 0)
1057 return EINVAL;
1058 if (size == 0)
1059 return 0;
1060 if (offset >= ip->i_size)
1061 return 0;
1062
1063 /* Pin the size of the read to the file's EOF */
1064 if (offset + size > ip->i_size)
1065 size = ip->i_size - offset;
1066
1067 return cd9660_xa_read_common(vp, offset, size, NULL, uio);
1068 }
1069
1070 /*
1071 * Page in from a CD-ROM XA media file.
1072 *
1073 * Since our device block size isn't a power of two, we can't use
1074 * cluster_pagein. Instead, we have to map the page and read into it.
1075 */
1076 static int
1077 cd9660_xa_pagein(struct vnop_pagein_args *ap)
1078 {
1079 struct vnode *vp = ap->a_vp;
1080 upl_t pl = ap->a_pl;
1081 size_t size= ap->a_size;
1082 off_t f_offset = ap->a_f_offset;
1083 vm_offset_t pl_offset = ap->a_pl_offset;
1084 int flags = ap->a_flags;
1085 register struct iso_node *ip = VTOI(vp);
1086 int error;
1087 kern_return_t kret;
1088 vm_offset_t ioaddr;
1089
1090 if (size <= 0)
1091 panic("cd9660_xa_pagein: size = %d", size);
1092
1093 kret = ubc_upl_map(pl, &ioaddr);
1094 if (kret != KERN_SUCCESS)
1095 panic("cd9660_xa_pagein: ubc_upl_map error = %d", kret);
1096
1097 ioaddr += pl_offset;
1098
1099 /* Make sure pagein doesn't extend past EOF */
1100 if (f_offset + size > ip->i_size)
1101 size = ip->i_size - f_offset; /* pin size to EOF */
1102
1103 /* Read the data in using the underlying device */
1104 error = cd9660_xa_read_common(vp, f_offset, size, (caddr_t)ioaddr, NULL);
1105
1106 /* Zero fill part of page past EOF */
1107 if (ap->a_size > size)
1108 bzero((caddr_t)ioaddr+size, ap->a_size-size);
1109
1110 kret = ubc_upl_unmap(pl);
1111 if (kret != KERN_SUCCESS)
1112 panic("cd9660_xa_pagein: ubc_upl_unmap error = %d", kret);
1113
1114 if ((flags & UPL_NOCOMMIT) == 0)
1115 {
1116 if (error)
1117 ubc_upl_abort_range(pl, pl_offset, ap->a_size, UPL_ABORT_FREE_ON_EMPTY);
1118 else
1119 ubc_upl_commit_range(pl, pl_offset, ap->a_size, UPL_COMMIT_FREE_ON_EMPTY);
1120 }
1121
1122 return error;
1123 }
1124
1125 /*
1126 * Global vfs data structures for isofs
1127 */
1128 #define cd9660_create \
1129 ((int (*)(struct vnop_create_args *))err_create)
1130 #define cd9660_mknod ((int (*)(struct vnop_mknod_args *))err_mknod)
1131 #define cd9660_write ((int (*)(struct vnop_write_args *))cd9660_enotsupp)
1132 #define cd9660_fsync ((int (*)(struct vnop_fsync_args *))nullop)
1133 #define cd9660_rename \
1134 ((int (*)(struct vnop_rename_args *))err_rename)
1135 #define cd9660_copyfile \
1136 ((int (*)(struct vnop_copyfile_args *))err_copyfile)
1137 #define cd9660_link ((int (*)(struct vnop_link_args *))err_link)
1138 #define cd9660_mkdir ((int (*)(struct vnop_mkdir_args *))err_mkdir)
1139 #define cd9660_symlink \
1140 ((int (*)(struct vnop_symlink_args *))err_symlink)
1141 #define cd9660_advlock \
1142 ((int (*)(struct vnop_advlock_args *))cd9660_enotsupp)
1143 #define cd9660_bwrite \
1144 ((int (*)(struct vnop_bwrite_args *))cd9660_enotsupp)
1145 #define cd9660_pageout \
1146 ((int (*)(struct vnop_pageout_args *))cd9660_enotsupp)
1147 int cd9660_blktooff(struct vnop_blktooff_args *ap);
1148 int cd9660_offtoblk(struct vnop_offtoblk_args *ap);
1149 int cd9660_blockmap(struct vnop_blockmap_args *ap);
1150
1151 #define VOPFUNC int (*)(void *)
1152 /*
1153 * Global vfs data structures for cd9660
1154 */
1155 int (**cd9660_vnodeop_p)(void *);
1156 struct vnodeopv_entry_desc cd9660_vnodeop_entries[] = {
1157 { &vnop_default_desc, (VOPFUNC)vn_default_error },
1158 { &vnop_lookup_desc, (VOPFUNC)cd9660_lookup }, /* lookup */
1159 { &vnop_create_desc, (VOPFUNC)cd9660_create }, /* create */
1160 { &vnop_mknod_desc, (VOPFUNC)cd9660_mknod }, /* mknod */
1161 { &vnop_open_desc, (VOPFUNC)cd9660_open }, /* open */
1162 { &vnop_close_desc, (VOPFUNC)cd9660_close }, /* close */
1163 { &vnop_getattr_desc, (VOPFUNC)cd9660_getattr }, /* getattr */
1164 { &vnop_read_desc, (VOPFUNC)cd9660_read }, /* read */
1165 { &vnop_write_desc, (VOPFUNC)cd9660_write }, /* write */
1166 { &vnop_ioctl_desc, (VOPFUNC)cd9660_ioctl }, /* ioctl */
1167 { &vnop_select_desc, (VOPFUNC)cd9660_select }, /* select */
1168 { &vnop_mmap_desc, (VOPFUNC)cd9660_mmap }, /* mmap */
1169 { &vnop_fsync_desc, (VOPFUNC)cd9660_fsync }, /* fsync */
1170 { &vnop_remove_desc, (VOPFUNC)cd9660_remove }, /* remove */
1171 { &vnop_link_desc, (VOPFUNC)cd9660_link }, /* link */
1172 { &vnop_rename_desc, (VOPFUNC)cd9660_rename }, /* rename */
1173 { &vnop_copyfile_desc, (VOPFUNC)cd9660_copyfile },/* copyfile */
1174 { &vnop_mkdir_desc, (VOPFUNC)cd9660_mkdir }, /* mkdir */
1175 { &vnop_rmdir_desc, (VOPFUNC)cd9660_rmdir }, /* rmdir */
1176 { &vnop_symlink_desc, (VOPFUNC)cd9660_symlink }, /* symlink */
1177 { &vnop_readdir_desc, (VOPFUNC)cd9660_readdir }, /* readdir */
1178 { &vnop_readlink_desc, (VOPFUNC)cd9660_readlink },/* readlink */
1179 { &vnop_inactive_desc, (VOPFUNC)cd9660_inactive },/* inactive */
1180 { &vnop_reclaim_desc, (VOPFUNC)cd9660_reclaim }, /* reclaim */
1181 { &vnop_strategy_desc, (VOPFUNC)cd9660_strategy },/* strategy */
1182 { &vnop_pathconf_desc, (VOPFUNC)cd9660_pathconf },/* pathconf */
1183 { &vnop_advlock_desc, (VOPFUNC)cd9660_advlock }, /* advlock */
1184 { &vnop_bwrite_desc, (VOPFUNC)vn_bwrite },
1185 { &vnop_pagein_desc, (VOPFUNC)cd9660_pagein }, /* Pagein */
1186 { &vnop_pageout_desc, (VOPFUNC)cd9660_pageout }, /* Pageout */
1187 { &vnop_blktooff_desc, (VOPFUNC)cd9660_blktooff }, /* blktooff */
1188 { &vnop_offtoblk_desc, (VOPFUNC)cd9660_offtoblk }, /* offtoblk */
1189 { &vnop_blockmap_desc, (VOPFUNC)cd9660_blockmap }, /* blockmap */
1190 { (struct vnodeop_desc*)NULL, (VOPFUNC)NULL }
1191 };
1192 struct vnodeopv_desc cd9660_vnodeop_opv_desc =
1193 { &cd9660_vnodeop_p, cd9660_vnodeop_entries };
1194
1195 /*
1196 * The VOP table for CD-ROM XA (media) files is almost the same
1197 * as for ordinary files, except for read, and pagein.
1198 * Note that cd9660_xa_read doesn't use cluster I/O, so blockmap
1199 * isn't needed, and isn't implemented. Similarly, it doesn't
1200 * do buf_bread() on CD XA vnodes, so bmap, blktooff, offtoblk
1201 * aren't needed.
1202 */
1203 int (**cd9660_cdxaop_p)(void *);
1204 struct vnodeopv_entry_desc cd9660_cdxaop_entries[] = {
1205 { &vnop_default_desc, (VOPFUNC)vn_default_error },
1206 { &vnop_lookup_desc, (VOPFUNC)cd9660_lookup }, /* lookup */
1207 { &vnop_create_desc, (VOPFUNC)cd9660_create }, /* create */
1208 { &vnop_mknod_desc, (VOPFUNC)cd9660_mknod }, /* mknod */
1209 { &vnop_open_desc, (VOPFUNC)cd9660_open }, /* open */
1210 { &vnop_close_desc, (VOPFUNC)cd9660_close }, /* close */
1211 { &vnop_getattr_desc, (VOPFUNC)cd9660_getattr }, /* getattr */
1212 { &vnop_read_desc, (VOPFUNC)cd9660_xa_read }, /* read */
1213 { &vnop_write_desc, (VOPFUNC)cd9660_write }, /* write */
1214 { &vnop_ioctl_desc, (VOPFUNC)cd9660_ioctl }, /* ioctl */
1215 { &vnop_select_desc, (VOPFUNC)cd9660_select }, /* select */
1216 { &vnop_mmap_desc, (VOPFUNC)cd9660_mmap }, /* mmap */
1217 { &vnop_fsync_desc, (VOPFUNC)cd9660_fsync }, /* fsync */
1218 { &vnop_remove_desc, (VOPFUNC)cd9660_remove }, /* remove */
1219 { &vnop_link_desc, (VOPFUNC)cd9660_link }, /* link */
1220 { &vnop_rename_desc, (VOPFUNC)cd9660_rename }, /* rename */
1221 { &vnop_copyfile_desc, (VOPFUNC)cd9660_copyfile },/* copyfile */
1222 { &vnop_mkdir_desc, (VOPFUNC)cd9660_mkdir }, /* mkdir */
1223 { &vnop_rmdir_desc, (VOPFUNC)cd9660_rmdir }, /* rmdir */
1224 { &vnop_symlink_desc, (VOPFUNC)cd9660_symlink }, /* symlink */
1225 { &vnop_readdir_desc, (VOPFUNC)cd9660_readdir }, /* readdir */
1226 { &vnop_readlink_desc, (VOPFUNC)cd9660_readlink },/* readlink */
1227 { &vnop_inactive_desc, (VOPFUNC)cd9660_inactive },/* inactive */
1228 { &vnop_reclaim_desc, (VOPFUNC)cd9660_reclaim }, /* reclaim */
1229 { &vnop_strategy_desc, (VOPFUNC)cd9660_strategy },/* strategy */
1230 { &vnop_pathconf_desc, (VOPFUNC)cd9660_pathconf },/* pathconf */
1231 { &vnop_advlock_desc, (VOPFUNC)cd9660_advlock }, /* advlock */
1232 { &vnop_bwrite_desc, (VOPFUNC)vn_bwrite },
1233 { &vnop_pagein_desc, (VOPFUNC)cd9660_xa_pagein }, /* Pagein */
1234 { &vnop_pageout_desc, (VOPFUNC)cd9660_pageout }, /* Pageout */
1235 { (struct vnodeop_desc*)NULL, (VOPFUNC)NULL }
1236 };
1237 struct vnodeopv_desc cd9660_cdxaop_opv_desc =
1238 { &cd9660_cdxaop_p, cd9660_cdxaop_entries };
1239
1240 /*
1241 * Special device vnode ops
1242 */
1243 int (**cd9660_specop_p)(void *);
1244 struct vnodeopv_entry_desc cd9660_specop_entries[] = {
1245 { &vnop_default_desc, (VOPFUNC)vn_default_error },
1246 { &vnop_lookup_desc, (VOPFUNC)spec_lookup }, /* lookup */
1247 { &vnop_create_desc, (VOPFUNC)spec_create }, /* create */
1248 { &vnop_mknod_desc, (VOPFUNC)spec_mknod }, /* mknod */
1249 { &vnop_open_desc, (VOPFUNC)spec_open }, /* open */
1250 { &vnop_close_desc, (VOPFUNC)spec_close }, /* close */
1251 { &vnop_getattr_desc, (VOPFUNC)cd9660_getattr }, /* getattr */
1252 { &vnop_read_desc, (VOPFUNC)spec_read }, /* read */
1253 { &vnop_write_desc, (VOPFUNC)spec_write }, /* write */
1254 { &vnop_ioctl_desc, (VOPFUNC)spec_ioctl }, /* ioctl */
1255 { &vnop_select_desc, (VOPFUNC)spec_select }, /* select */
1256 { &vnop_mmap_desc, (VOPFUNC)spec_mmap }, /* mmap */
1257 { &vnop_fsync_desc, (VOPFUNC)spec_fsync }, /* fsync */
1258 { &vnop_remove_desc, (VOPFUNC)spec_remove }, /* remove */
1259 { &vnop_link_desc, (VOPFUNC)spec_link }, /* link */
1260 { &vnop_rename_desc, (VOPFUNC)spec_rename }, /* rename */
1261 { &vnop_mkdir_desc, (VOPFUNC)spec_mkdir }, /* mkdir */
1262 { &vnop_rmdir_desc, (VOPFUNC)spec_rmdir }, /* rmdir */
1263 { &vnop_symlink_desc, (VOPFUNC)spec_symlink }, /* symlink */
1264 { &vnop_readdir_desc, (VOPFUNC)spec_readdir }, /* readdir */
1265 { &vnop_readlink_desc, (VOPFUNC)spec_readlink }, /* readlink */
1266 { &vnop_inactive_desc, (VOPFUNC)cd9660_inactive },/* inactive */
1267 { &vnop_reclaim_desc, (VOPFUNC)cd9660_reclaim }, /* reclaim */
1268 { &vnop_strategy_desc, (VOPFUNC)spec_strategy }, /* strategy */
1269 { &vnop_pathconf_desc, (VOPFUNC)spec_pathconf }, /* pathconf */
1270 { &vnop_advlock_desc, (VOPFUNC)spec_advlock }, /* advlock */
1271 { &vnop_bwrite_desc, (VOPFUNC)vn_bwrite },
1272 { &vnop_pagein_desc, (VOPFUNC)cd9660_pagein }, /* Pagein */
1273 { &vnop_pageout_desc, (VOPFUNC)cd9660_pageout }, /* Pageout */
1274 { &vnop_blktooff_desc, (VOPFUNC)cd9660_blktooff }, /* blktooff */
1275 { &vnop_offtoblk_desc, (VOPFUNC)cd9660_offtoblk }, /* offtoblk */
1276 { &vnop_blockmap_desc, (VOPFUNC)cd9660_blockmap }, /* blockmap */
1277 { (struct vnodeop_desc*)NULL, (VOPFUNC)NULL }
1278 };
1279 struct vnodeopv_desc cd9660_specop_opv_desc =
1280 { &cd9660_specop_p, cd9660_specop_entries };
1281
1282 #if FIFO
1283 int (**cd9660_fifoop_p)(void *);
1284 struct vnodeopv_entry_desc cd9660_fifoop_entries[] = {
1285 { &vnop_default_desc, (VOPFUNC)vn_default_error },
1286 { &vnop_lookup_desc, (VOPFUNC)fifo_lookup }, /* lookup */
1287 { &vnop_create_desc, (VOPFUNC)fifo_create }, /* create */
1288 { &vnop_mknod_desc, (VOPFUNC)fifo_mknod }, /* mknod */
1289 { &vnop_open_desc, (VOPFUNC)fifo_open }, /* open */
1290 { &vnop_close_desc, (VOPFUNC)fifo_close }, /* close */
1291 { &vnop_getattr_desc, (VOPFUNC)cd9660_getattr }, /* getattr */
1292 { &vnop_read_desc, (VOPFUNC)fifo_read }, /* read */
1293 { &vnop_write_desc, (VOPFUNC)fifo_write }, /* write */
1294 { &vnop_ioctl_desc, (VOPFUNC)fifo_ioctl }, /* ioctl */
1295 { &vnop_select_desc, (VOPFUNC)fifo_select }, /* select */
1296 { &vnop_mmap_desc, (VOPFUNC)fifo_mmap }, /* mmap */
1297 { &vnop_fsync_desc, (VOPFUNC)fifo_fsync }, /* fsync */
1298 { &vnop_remove_desc, (VOPFUNC)fifo_remove }, /* remove */
1299 { &vnop_link_desc, (VOPFUNC)fifo_link } , /* link */
1300 { &vnop_rename_desc, (VOPFUNC)fifo_rename }, /* rename */
1301 { &vnop_mkdir_desc, (VOPFUNC)fifo_mkdir }, /* mkdir */
1302 { &vnop_rmdir_desc, (VOPFUNC)fifo_rmdir }, /* rmdir */
1303 { &vnop_symlink_desc, (VOPFUNC)fifo_symlink }, /* symlink */
1304 { &vnop_readdir_desc, (VOPFUNC)fifo_readdir }, /* readdir */
1305 { &vnop_readlink_desc, (VOPFUNC)fifo_readlink }, /* readlink */
1306 { &vnop_inactive_desc, (VOPFUNC)cd9660_inactive },/* inactive */
1307 { &vnop_reclaim_desc, (VOPFUNC)cd9660_reclaim }, /* reclaim */
1308 { &vnop_strategy_desc, (VOPFUNC)fifo_strategy }, /* strategy */
1309 { &vnop_pathconf_desc, (VOPFUNC)fifo_pathconf }, /* pathconf */
1310 { &vnop_advlock_desc, (VOPFUNC)fifo_advlock }, /* advlock */
1311 { &vnop_bwrite_desc, (VOPFUNC)vn_bwrite },
1312 { &vnop_pagein_desc, (VOPFUNC)cd9660_pagein }, /* Pagein */
1313 { &vnop_pageout_desc, (VOPFUNC)cd9660_pageout }, /* Pageout */
1314 { &vnop_blktooff_desc, (VOPFUNC)cd9660_blktooff }, /* blktooff */
1315 { &vnop_offtoblk_desc, (VOPFUNC)cd9660_offtoblk }, /* offtoblk */
1316 { (struct vnodeop_desc*)NULL, (VOPFUNC)NULL }
1317 };
1318 struct vnodeopv_desc cd9660_fifoop_opv_desc =
1319 { &cd9660_fifoop_p, cd9660_fifoop_entries };
1320 #endif /* FIFO */