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