]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
55e303ae | 2 | * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. |
1c79356b A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* $NetBSD: cd9660_vnops.c,v 1.22 1994/12/27 19:05:12 mycroft Exp $ */ | |
26 | ||
27 | /*- | |
28 | * Copyright (c) 1994 | |
29 | * The Regents of the University of California. All rights reserved. | |
30 | * | |
31 | * This code is derived from software contributed to Berkeley | |
32 | * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension | |
33 | * Support code is derived from software contributed to Berkeley | |
34 | * by Atsushi Murai (amurai@spec.co.jp). | |
35 | * | |
36 | * Redistribution and use in source and binary forms, with or without | |
37 | * modification, are permitted provided that the following conditions | |
38 | * are met: | |
39 | * 1. Redistributions of source code must retain the above copyright | |
40 | * notice, this list of conditions and the following disclaimer. | |
41 | * 2. Redistributions in binary form must reproduce the above copyright | |
42 | * notice, this list of conditions and the following disclaimer in the | |
43 | * documentation and/or other materials provided with the distribution. | |
44 | * 3. All advertising materials mentioning features or use of this software | |
45 | * must display the following acknowledgement: | |
46 | * This product includes software developed by the University of | |
47 | * California, Berkeley and its contributors. | |
48 | * 4. Neither the name of the University nor the names of its contributors | |
49 | * may be used to endorse or promote products derived from this software | |
50 | * without specific prior written permission. | |
51 | * | |
52 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
53 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
54 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
55 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
56 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
57 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
58 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
59 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
60 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
61 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
62 | * SUCH DAMAGE. | |
63 | * | |
64 | * @(#)cd9660_vnops.c 8.15 (Berkeley) 12/5/94 | |
65 | * | |
66 | * HISTORY | |
67 | * 02-Feb-00 chw Add cd9660_copyfile to return error | |
68 | * 29-Sep-98 djb Add cd9660_getattrlist VOP for VDI support. | |
69 | * 15-sep-98 added cd9660_rmdir to do proper unlocking - chw | |
70 | * 12-aug-98 added cd9660_remove which will do proper unlocking - chw | |
71 | * 17-Feb-98 radar 1669467 - changed lock protocols to use the lock manager - chw | |
72 | * 22-Jan-98 radar 1669467 - ISO 9660 CD support - jwc | |
73 | */ | |
74 | ||
75 | #include <sys/param.h> | |
76 | #include <sys/systm.h> | |
77 | #include <sys/vnode.h> | |
78 | #include <sys/mount.h> | |
79 | #include <sys/namei.h> | |
80 | #include <sys/resourcevar.h> | |
81 | #include <sys/kernel.h> | |
82 | #include <sys/file.h> | |
83 | #include <sys/stat.h> | |
84 | #include <sys/buf.h> | |
85 | #include <sys/proc.h> | |
86 | #include <sys/conf.h> | |
87 | #include <miscfs/specfs/specdev.h> | |
88 | #include <miscfs/fifofs/fifo.h> | |
89 | #include <sys/malloc.h> | |
90 | #include <sys/dir.h> | |
91 | #include <sys/attr.h> | |
92 | #include <vfs/vfs_support.h> | |
93 | #include <sys/ubc.h> | |
1c79356b | 94 | #include <sys/lock.h> |
55e303ae | 95 | #include <architecture/byte_order.h> |
1c79356b A |
96 | |
97 | #include <isofs/cd9660/iso.h> | |
98 | #include <isofs/cd9660/cd9660_node.h> | |
99 | #include <isofs/cd9660/iso_rrip.h> | |
100 | ||
101 | /* | |
102 | * Open called. | |
103 | * | |
104 | * Nothing to do. | |
105 | */ | |
106 | /* ARGSUSED */ | |
107 | int | |
108 | cd9660_open(ap) | |
109 | struct vop_open_args /* { | |
110 | struct vnode *a_vp; | |
111 | int a_mode; | |
112 | struct ucred *a_cred; | |
113 | struct proc *a_p; | |
114 | } */ *ap; | |
115 | { | |
116 | return (0); | |
117 | } | |
118 | ||
119 | /* | |
120 | * Close called | |
121 | * | |
122 | * Update the times on the inode on writeable file systems. | |
123 | */ | |
124 | /* ARGSUSED */ | |
125 | int | |
126 | cd9660_close(ap) | |
127 | struct vop_close_args /* { | |
128 | struct vnode *a_vp; | |
129 | int a_fflag; | |
130 | struct ucred *a_cred; | |
131 | struct proc *a_p; | |
132 | } */ *ap; | |
133 | { | |
134 | return (0); | |
135 | } | |
136 | ||
137 | /* | |
138 | * Check mode permission on inode pointer. Mode is READ, WRITE or EXEC. | |
139 | * The mode is shifted to select the owner/group/other fields. The | |
140 | * super user is granted all permissions. | |
141 | */ | |
142 | /* ARGSUSED */ | |
143 | int | |
144 | cd9660_access(ap) | |
145 | struct vop_access_args /* { | |
146 | struct vnode *a_vp; | |
147 | int a_mode; | |
148 | struct ucred *a_cred; | |
149 | struct proc *a_p; | |
150 | } */ *ap; | |
151 | { | |
152 | struct vnode *vp = ap->a_vp; | |
153 | struct iso_node *ip = VTOI(vp); | |
154 | struct ucred *cred = ap->a_cred; | |
155 | mode_t mask, mode = ap->a_mode; | |
156 | register gid_t *gp; | |
157 | int i, error; | |
158 | ||
159 | /* | |
160 | * Disallow write attempts on read-only file systems; | |
161 | * unless the file is a socket, fifo, or a block or | |
162 | * character device resident on the file system. | |
163 | */ | |
164 | if (mode & VWRITE) { | |
165 | switch (vp->v_type) { | |
166 | case VDIR: | |
167 | case VLNK: | |
168 | case VREG: | |
169 | return (EROFS); | |
170 | /* NOT REACHED */ | |
171 | default: | |
172 | break; | |
173 | } | |
174 | } | |
175 | ||
176 | /* If immutable bit set, nobody gets to write it. */ | |
177 | #if 0 | |
178 | if ((mode & VWRITE) && (ip->i_flag & IMMUTABLE)) | |
179 | return (EPERM); | |
180 | #endif | |
181 | /* Otherwise, user id 0 always gets access. */ | |
182 | if (cred->cr_uid == 0) | |
183 | return (0); | |
184 | ||
185 | mask = 0; | |
186 | ||
187 | /* Otherwise, check the owner. */ | |
188 | if (cred->cr_uid == ip->inode.iso_uid) { | |
189 | if (mode & VEXEC) | |
190 | mask |= S_IXUSR; | |
191 | if (mode & VREAD) | |
192 | mask |= S_IRUSR; | |
193 | if (mode & VWRITE) | |
194 | mask |= S_IWUSR; | |
195 | return ((ip->inode.iso_mode & mask) == mask ? 0 : EACCES); | |
196 | } | |
197 | ||
198 | /* Otherwise, check the groups. */ | |
199 | for (i = 0, gp = cred->cr_groups; i < cred->cr_ngroups; i++, gp++) | |
200 | if (ip->inode.iso_gid == *gp) { | |
201 | if (mode & VEXEC) | |
202 | mask |= S_IXGRP; | |
203 | if (mode & VREAD) | |
204 | mask |= S_IRGRP; | |
205 | if (mode & VWRITE) | |
206 | mask |= S_IWGRP; | |
207 | return ((ip->inode.iso_mode & mask) == mask ? 0 : EACCES); | |
208 | } | |
209 | ||
210 | /* Otherwise, check everyone else. */ | |
211 | if (mode & VEXEC) | |
212 | mask |= S_IXOTH; | |
213 | if (mode & VREAD) | |
214 | mask |= S_IROTH; | |
215 | if (mode & VWRITE) | |
216 | mask |= S_IWOTH; | |
217 | return ((ip->inode.iso_mode & mask) == mask ? 0 : EACCES); | |
218 | } | |
219 | ||
220 | int | |
221 | cd9660_getattr(ap) | |
222 | struct vop_getattr_args /* { | |
223 | struct vnode *a_vp; | |
224 | struct vattr *a_vap; | |
225 | struct ucred *a_cred; | |
226 | struct proc *a_p; | |
227 | } */ *ap; | |
228 | ||
229 | { | |
230 | struct vnode *vp = ap->a_vp; | |
231 | register struct vattr *vap = ap->a_vap; | |
232 | register struct iso_node *ip = VTOI(vp); | |
233 | ||
234 | vap->va_fsid = ip->i_dev; | |
235 | vap->va_fileid = ip->i_number; | |
236 | ||
237 | vap->va_mode = ip->inode.iso_mode; | |
238 | vap->va_nlink = ip->inode.iso_links; | |
239 | vap->va_uid = ip->inode.iso_uid; | |
240 | vap->va_gid = ip->inode.iso_gid; | |
241 | vap->va_atime = ip->inode.iso_atime; | |
242 | vap->va_mtime = ip->inode.iso_mtime; | |
243 | vap->va_ctime = ip->inode.iso_ctime; | |
244 | vap->va_rdev = ip->inode.iso_rdev; | |
245 | ||
246 | vap->va_size = (u_quad_t) ip->i_size; | |
247 | if (ip->i_size == 0 && (vap->va_mode & S_IFMT) == S_IFLNK) { | |
248 | struct vop_readlink_args rdlnk; | |
249 | struct iovec aiov; | |
250 | struct uio auio; | |
251 | char *cp; | |
252 | ||
253 | MALLOC(cp, char *, MAXPATHLEN, M_TEMP, M_WAITOK); | |
254 | aiov.iov_base = cp; | |
255 | aiov.iov_len = MAXPATHLEN; | |
256 | auio.uio_iov = &aiov; | |
257 | auio.uio_iovcnt = 1; | |
258 | auio.uio_offset = 0; | |
259 | auio.uio_rw = UIO_READ; | |
260 | auio.uio_segflg = UIO_SYSSPACE; | |
261 | auio.uio_procp = ap->a_p; | |
262 | auio.uio_resid = MAXPATHLEN; | |
263 | rdlnk.a_uio = &auio; | |
264 | rdlnk.a_vp = ap->a_vp; | |
265 | rdlnk.a_cred = ap->a_cred; | |
266 | if (cd9660_readlink(&rdlnk) == 0) | |
267 | vap->va_size = MAXPATHLEN - auio.uio_resid; | |
268 | FREE(cp, M_TEMP); | |
269 | } | |
270 | vap->va_flags = 0; | |
271 | vap->va_gen = 1; | |
272 | vap->va_blocksize = ip->i_mnt->logical_block_size; | |
273 | vap->va_bytes = (u_quad_t) (ip->i_size + ip->i_rsrcsize); | |
274 | vap->va_type = vp->v_type; | |
275 | ||
276 | return (0); | |
277 | } | |
278 | ||
279 | ||
280 | /* | |
281 | * Vnode op for reading. | |
282 | */ | |
283 | int | |
284 | cd9660_read(ap) | |
285 | struct vop_read_args /* { | |
286 | struct vnode *a_vp; | |
287 | struct uio *a_uio; | |
288 | int a_ioflag; | |
289 | struct ucred *a_cred; | |
290 | } */ *ap; | |
291 | { | |
292 | struct vnode *vp = ap->a_vp; | |
293 | register struct uio *uio = ap->a_uio; | |
294 | register struct iso_node *ip = VTOI(vp); | |
295 | register struct iso_mnt *imp; | |
296 | struct buf *bp; | |
297 | daddr_t lbn, rablock; | |
298 | off_t diff; | |
299 | int rasize, error = 0; | |
300 | long size, n, on; | |
301 | int devBlockSize = 0; | |
302 | ||
303 | if (uio->uio_resid == 0) | |
304 | return (0); | |
305 | if (uio->uio_offset < 0) | |
306 | return (EINVAL); | |
307 | ||
308 | imp = ip->i_mnt; | |
309 | VOP_DEVBLOCKSIZE(ip->i_devvp, &devBlockSize); | |
310 | ||
55e303ae A |
311 | if (UBCISVALID(vp)) { |
312 | /* | |
313 | * Copy any part of the Apple Double header. | |
314 | */ | |
315 | if ((ip->i_flag & ISO_ASSOCIATED) && (uio->uio_offset < ADH_SIZE)) { | |
316 | apple_double_header_t header; | |
317 | int bytes; | |
318 | ||
319 | if (uio->uio_offset < sizeof(apple_double_header_t)) { | |
320 | header.magic = APPLEDOUBLE_MAGIC; | |
321 | header.version = APPLEDOUBLE_VERSION; | |
322 | header.count = 2; | |
323 | header.entries[0].entryID = APPLEDOUBLE_FINDERINFO; | |
324 | header.entries[0].offset = offsetof(apple_double_header_t, finfo); | |
325 | header.entries[0].length = 32; | |
326 | header.entries[1].entryID = APPLEDOUBLE_RESFORK; | |
327 | header.entries[1].offset = ADH_SIZE; | |
328 | header.entries[1].length = ip->i_size - ADH_SIZE; | |
329 | header.finfo.fdType = ip->i_FileType; | |
330 | header.finfo.fdCreator = ip->i_Creator; | |
331 | header.finfo.fdFlags = ip->i_FinderFlags; | |
332 | header.finfo.fdLocation.v = -1; | |
333 | header.finfo.fdLocation.h = -1; | |
334 | header.finfo.fdReserved = 0; | |
335 | ||
336 | bytes = min(uio->uio_resid, sizeof(apple_double_header_t) - uio->uio_offset); | |
337 | error = uiomove(((char *) &header) + uio->uio_offset, bytes, uio); | |
338 | if (error) | |
339 | return error; | |
340 | } | |
341 | if (uio->uio_resid && uio->uio_offset < ADH_SIZE) { | |
342 | caddr_t buffer; | |
343 | ||
344 | if (kmem_alloc(kernel_map, (vm_offset_t *)&buffer, ADH_SIZE)) { | |
345 | return (ENOMEM); | |
346 | } | |
347 | bytes = min(uio->uio_resid, ADH_SIZE - uio->uio_offset); | |
348 | error = uiomove(((char *) buffer) + uio->uio_offset, bytes, uio); | |
349 | kmem_free(kernel_map, (vm_offset_t)buffer, ADH_SIZE); | |
350 | if (error) | |
351 | return error; | |
352 | } | |
353 | } | |
354 | if (uio->uio_resid > 0) | |
355 | error = cluster_read(vp, uio, (off_t)ip->i_size, devBlockSize, 0); | |
356 | } else { | |
1c79356b A |
357 | |
358 | do { | |
359 | lbn = lblkno(imp, uio->uio_offset); | |
360 | on = blkoff(imp, uio->uio_offset); | |
361 | n = min((u_int)(imp->logical_block_size - on), | |
362 | uio->uio_resid); | |
363 | diff = (off_t)ip->i_size - uio->uio_offset; | |
364 | if (diff <= 0) | |
365 | return (0); | |
366 | if (diff < n) | |
367 | n = diff; | |
368 | size = blksize(imp, ip, lbn); | |
369 | rablock = lbn + 1; | |
370 | ||
371 | if (vp->v_lastr + 1 == lbn && | |
372 | lblktosize(imp, rablock) < ip->i_size) { | |
373 | rasize = blksize(imp, ip, rablock); | |
374 | error = breadn(vp, lbn, size, &rablock, | |
375 | &rasize, 1, NOCRED, &bp); | |
376 | } else | |
377 | error = bread(vp, lbn, size, NOCRED, &bp); | |
378 | ||
379 | vp->v_lastr = lbn; | |
380 | n = min(n, size - bp->b_resid); | |
381 | if (error) { | |
382 | brelse(bp); | |
383 | return (error); | |
384 | } | |
385 | ||
386 | error = uiomove(bp->b_data + on, (int)n, uio); | |
387 | if (n + on == imp->logical_block_size || | |
388 | uio->uio_offset == (off_t)ip->i_size) | |
389 | bp->b_flags |= B_AGE; | |
390 | brelse(bp); | |
391 | } while (error == 0 && uio->uio_resid > 0 && n != 0); | |
392 | } | |
393 | ||
394 | return (error); | |
395 | } | |
396 | ||
397 | /* ARGSUSED */ | |
398 | int | |
399 | cd9660_ioctl(ap) | |
400 | struct vop_ioctl_args /* { | |
401 | struct vnode *a_vp; | |
402 | u_long a_command; | |
403 | caddr_t a_data; | |
404 | int a_fflag; | |
405 | struct ucred *a_cred; | |
406 | struct proc *a_p; | |
407 | } */ *ap; | |
408 | { | |
1c79356b A |
409 | return (ENOTTY); |
410 | } | |
411 | ||
412 | /* ARGSUSED */ | |
413 | int | |
414 | cd9660_select(ap) | |
415 | struct vop_select_args /* { | |
416 | struct vnode *a_vp; | |
417 | int a_which; | |
418 | int a_fflags; | |
419 | struct ucred *a_cred; | |
0b4e3aa0 | 420 | void *a_wql; |
1c79356b A |
421 | struct proc *a_p; |
422 | } */ *ap; | |
423 | { | |
424 | /* | |
425 | * We should really check to see if I/O is possible. | |
426 | */ | |
427 | return (1); | |
428 | } | |
429 | ||
430 | /* | |
431 | * Mmap a file | |
432 | * | |
433 | * NB Currently unsupported. | |
434 | */ | |
435 | /* ARGSUSED */ | |
436 | int | |
437 | cd9660_mmap(ap) | |
438 | struct vop_mmap_args /* { | |
439 | struct vnode *a_vp; | |
440 | int a_fflags; | |
441 | struct ucred *a_cred; | |
442 | struct proc *a_p; | |
443 | } */ *ap; | |
444 | { | |
445 | ||
446 | return (EINVAL); | |
447 | } | |
448 | ||
449 | /* | |
450 | * Seek on a file | |
451 | * | |
452 | * Nothing to do, so just return. | |
453 | */ | |
454 | /* ARGSUSED */ | |
455 | int | |
456 | cd9660_seek(ap) | |
457 | struct vop_seek_args /* { | |
458 | struct vnode *a_vp; | |
459 | off_t a_oldoff; | |
460 | off_t a_newoff; | |
461 | struct ucred *a_cred; | |
462 | } */ *ap; | |
463 | { | |
464 | ||
465 | return (0); | |
466 | } | |
467 | ||
468 | /* | |
469 | * Structure for reading directories | |
470 | */ | |
471 | struct isoreaddir { | |
472 | struct dirent saveent; | |
473 | struct dirent current; | |
474 | off_t saveoff; | |
475 | off_t curroff; | |
476 | struct uio *uio; | |
477 | off_t uio_off; | |
478 | int eofflag; | |
479 | // u_long **cookies; | |
480 | // int *ncookies; | |
481 | }; | |
482 | ||
483 | static int | |
484 | iso_uiodir(idp,dp,off) | |
485 | struct isoreaddir *idp; | |
486 | struct dirent *dp; | |
487 | off_t off; | |
488 | { | |
489 | int error; | |
490 | ||
491 | dp->d_name[dp->d_namlen] = 0; | |
492 | dp->d_reclen = DIRSIZ(dp); | |
493 | ||
494 | if (idp->uio->uio_resid < dp->d_reclen) { | |
495 | idp->eofflag = 0; | |
496 | return (-1); | |
497 | } | |
498 | ||
499 | #if 0 | |
500 | if (idp->cookies) { | |
501 | if (*idp->ncookies <= 0) { | |
502 | idp->eofflag = 0; | |
503 | return (-1); | |
504 | } | |
505 | ||
506 | **idp->cookies++ = off; | |
507 | --*idp->ncookies; | |
508 | } | |
509 | #endif | |
510 | ||
511 | if ( (error = uiomove( (caddr_t)dp, dp->d_reclen, idp->uio )) ) | |
512 | return (error); | |
513 | idp->uio_off = off; | |
514 | return (0); | |
515 | } | |
516 | ||
517 | static int | |
518 | iso_shipdir(idp) | |
519 | struct isoreaddir *idp; | |
520 | { | |
521 | struct dirent *dp; | |
522 | int cl, sl; | |
523 | int error; | |
524 | char *cname, *sname; | |
525 | ||
526 | cl = idp->current.d_namlen; | |
527 | cname = idp->current.d_name; | |
528 | ||
529 | dp = &idp->saveent; | |
530 | sname = dp->d_name; | |
531 | sl = dp->d_namlen; | |
532 | if (sl > 0) { | |
533 | if (sl != cl | |
534 | || bcmp(sname,cname,sl)) { | |
535 | if (idp->saveent.d_namlen) { | |
536 | if ( (error = iso_uiodir(idp,&idp->saveent,idp->saveoff)) ) | |
537 | return (error); | |
538 | idp->saveent.d_namlen = 0; | |
539 | } | |
540 | } | |
541 | } | |
542 | idp->current.d_reclen = DIRSIZ(&idp->current); | |
543 | idp->saveoff = idp->curroff; | |
544 | bcopy(&idp->current,&idp->saveent,idp->current.d_reclen); | |
545 | return (0); | |
546 | } | |
547 | ||
548 | /* | |
549 | * Vnode op for readdir | |
55e303ae A |
550 | * |
551 | * Note that directories are sector aligned (2K) and | |
552 | * that an entry can cross a logical block but not | |
553 | * a sector. | |
1c79356b A |
554 | */ |
555 | int | |
556 | cd9660_readdir(ap) | |
557 | struct vop_readdir_args /* { | |
558 | struct vnodeop_desc *a_desc; | |
559 | struct vnode *a_vp; | |
560 | struct uio *a_uio; | |
561 | struct ucred *a_cred; | |
562 | int *a_eofflag; | |
563 | int *a_ncookies; | |
564 | u_long **a_cookies; | |
565 | } */ *ap; | |
566 | { | |
567 | register struct uio *uio = ap->a_uio; | |
568 | off_t startingOffset = uio->uio_offset; | |
569 | size_t lost = 0; | |
570 | struct isoreaddir *idp; | |
571 | struct vnode *vdp = ap->a_vp; | |
572 | struct iso_node *dp; | |
573 | struct iso_mnt *imp; | |
574 | struct buf *bp = NULL; | |
575 | struct iso_directory_record *ep; | |
576 | int entryoffsetinblock; | |
577 | doff_t endsearch; | |
578 | u_long bmask; | |
579 | int error = 0; | |
580 | int reclen; | |
581 | u_short namelen; | |
582 | ||
583 | dp = VTOI(vdp); | |
584 | imp = dp->i_mnt; | |
55e303ae | 585 | bmask = imp->im_sector_size - 1; |
1c79356b A |
586 | |
587 | MALLOC(idp, struct isoreaddir *, sizeof(*idp), M_TEMP, M_WAITOK); | |
588 | idp->saveent.d_namlen = 0; | |
589 | /* | |
590 | * XXX | |
591 | * Is it worth trying to figure out the type? | |
592 | */ | |
593 | idp->saveent.d_type = idp->current.d_type = DT_UNKNOWN; | |
594 | idp->uio = uio; | |
595 | idp->eofflag = 1; | |
596 | idp->curroff = uio->uio_offset; | |
597 | ||
598 | if ((entryoffsetinblock = idp->curroff & bmask) && | |
55e303ae | 599 | (error = VOP_BLKATOFF(vdp, SECTOFF(imp, idp->curroff), NULL, &bp))) { |
1c79356b A |
600 | FREE(idp, M_TEMP); |
601 | return (error); | |
602 | } | |
603 | endsearch = dp->i_size; | |
604 | ||
605 | while (idp->curroff < endsearch) { | |
606 | /* | |
607 | * If offset is on a block boundary, | |
608 | * read the next directory block. | |
609 | * Release previous if it exists. | |
610 | */ | |
611 | if ((idp->curroff & bmask) == 0) { | |
612 | if (bp != NULL) | |
613 | brelse(bp); | |
55e303ae | 614 | if ((error = VOP_BLKATOFF(vdp, SECTOFF(imp, idp->curroff), NULL, &bp))) |
1c79356b A |
615 | break; |
616 | entryoffsetinblock = 0; | |
617 | } | |
618 | /* | |
619 | * Get pointer to next entry. | |
620 | */ | |
621 | ep = (struct iso_directory_record *) | |
622 | ((char *)bp->b_data + entryoffsetinblock); | |
623 | ||
624 | reclen = isonum_711(ep->length); | |
625 | if (reclen == 0) { | |
626 | /* skip to next block, if any */ | |
627 | idp->curroff = | |
55e303ae | 628 | (idp->curroff & ~bmask) + imp->im_sector_size; |
1c79356b A |
629 | continue; |
630 | } | |
631 | ||
632 | if (reclen < ISO_DIRECTORY_RECORD_SIZE) { | |
633 | error = EINVAL; | |
634 | /* illegal entry, stop */ | |
635 | break; | |
636 | } | |
637 | ||
55e303ae | 638 | if (entryoffsetinblock + reclen > imp->im_sector_size) { |
1c79356b A |
639 | error = EINVAL; |
640 | /* illegal directory, so stop looking */ | |
641 | break; | |
642 | } | |
643 | ||
644 | idp->current.d_namlen = isonum_711(ep->name_len); | |
645 | ||
646 | if (reclen < ISO_DIRECTORY_RECORD_SIZE + idp->current.d_namlen) { | |
647 | error = EINVAL; | |
648 | /* illegal entry, stop */ | |
649 | break; | |
650 | } | |
651 | ||
55e303ae A |
652 | /* |
653 | * Some poorly mastered discs have an incorrect directory | |
654 | * file size. If the '.' entry has a better size (bigger) | |
655 | * then use that instead. | |
656 | */ | |
657 | if ((uio->uio_offset == 0) && (isonum_733(ep->size) > endsearch)) { | |
658 | dp->i_size = endsearch = isonum_733(ep->size); | |
1c79356b A |
659 | } |
660 | ||
661 | if ( isonum_711(ep->flags) & directoryBit ) | |
662 | idp->current.d_fileno = isodirino(ep, imp); | |
663 | else { | |
55e303ae A |
664 | idp->current.d_fileno = (bp->b_blkno << imp->im_bshift) + |
665 | entryoffsetinblock; | |
1c79356b A |
666 | } |
667 | ||
668 | idp->curroff += reclen; | |
669 | ||
670 | switch (imp->iso_ftype) { | |
671 | case ISO_FTYPE_RRIP: | |
672 | cd9660_rrip_getname(ep,idp->current.d_name, &namelen, | |
673 | &idp->current.d_fileno,imp); | |
674 | idp->current.d_namlen = (u_char)namelen; | |
675 | if (idp->current.d_namlen) | |
676 | error = iso_uiodir(idp,&idp->current,idp->curroff); | |
677 | break; | |
678 | ||
679 | case ISO_FTYPE_JOLIET: | |
680 | ucsfntrans((u_int16_t *)ep->name, idp->current.d_namlen, | |
681 | idp->current.d_name, &namelen, | |
55e303ae A |
682 | isonum_711(ep->flags) & directoryBit, |
683 | isonum_711(ep->flags) & associatedBit); | |
1c79356b A |
684 | idp->current.d_namlen = (u_char)namelen; |
685 | if (idp->current.d_namlen) | |
686 | error = iso_uiodir(idp,&idp->current,idp->curroff); | |
687 | break; | |
688 | ||
689 | default: /* ISO_FTYPE_DEFAULT || ISO_FTYPE_9660 */ | |
690 | strcpy(idp->current.d_name,".."); | |
691 | switch (ep->name[0]) { | |
692 | case 0: | |
693 | idp->current.d_namlen = 1; | |
694 | error = iso_uiodir(idp,&idp->current,idp->curroff); | |
695 | break; | |
696 | case 1: | |
697 | idp->current.d_namlen = 2; | |
698 | error = iso_uiodir(idp,&idp->current,idp->curroff); | |
699 | break; | |
700 | default: | |
701 | isofntrans(ep->name,idp->current.d_namlen, | |
702 | idp->current.d_name, &namelen, | |
55e303ae A |
703 | imp->iso_ftype == ISO_FTYPE_9660, |
704 | isonum_711(ep->flags) & associatedBit); | |
1c79356b A |
705 | idp->current.d_namlen = (u_char)namelen; |
706 | if (imp->iso_ftype == ISO_FTYPE_DEFAULT) | |
707 | error = iso_shipdir(idp); | |
708 | else | |
709 | error = iso_uiodir(idp,&idp->current,idp->curroff); | |
710 | break; | |
711 | } | |
712 | } | |
713 | if (error) | |
714 | break; | |
715 | ||
716 | entryoffsetinblock += reclen; | |
717 | } | |
718 | ||
719 | if (!error && imp->iso_ftype == ISO_FTYPE_DEFAULT) { | |
720 | idp->current.d_namlen = 0; | |
721 | error = iso_shipdir(idp); | |
722 | } | |
723 | ||
724 | if (!error && ap->a_ncookies) { | |
725 | struct dirent *dp, *dpstart; | |
726 | off_t bufferOffset; | |
727 | u_long *cookies; | |
728 | int ncookies; | |
729 | ||
730 | /* | |
731 | * Only the NFS server uses cookies, and it loads the | |
732 | * directory block into system space, so we can just look at | |
733 | * it directly. | |
734 | * | |
735 | * We assume the entire transfer is done to a single contiguous buffer. | |
736 | */ | |
737 | if (uio->uio_segflg != UIO_SYSSPACE || uio->uio_iovcnt != 1) | |
738 | panic("ufs_readdir: lost in space"); | |
739 | ||
740 | /* | |
741 | * Make a first pass over the buffer just generated, | |
742 | * counting the number of entries: | |
743 | */ | |
744 | dpstart = (struct dirent *) (uio->uio_iov->iov_base - (uio->uio_offset - startingOffset)); | |
745 | for (dp = dpstart, bufferOffset = startingOffset, ncookies = 0; | |
746 | bufferOffset < uio->uio_offset; ) { | |
747 | if (dp->d_reclen == 0) | |
748 | break; | |
749 | bufferOffset += dp->d_reclen; | |
750 | ncookies++; | |
751 | dp = (struct dirent *)((caddr_t)dp + dp->d_reclen); | |
752 | } | |
753 | lost += uio->uio_offset - bufferOffset; | |
754 | uio->uio_offset = bufferOffset; | |
755 | ||
756 | /* | |
757 | * Allocate a buffer to hold the cookies requested: | |
758 | */ | |
759 | MALLOC(cookies, u_long *, ncookies * sizeof(u_long), M_TEMP, M_WAITOK); | |
760 | *ap->a_ncookies = ncookies; | |
761 | *ap->a_cookies = cookies; | |
762 | ||
763 | /* | |
764 | * Fill in the offsets for each entry in the buffer just allocated: | |
765 | */ | |
766 | for (bufferOffset = startingOffset, dp = dpstart; bufferOffset < uio->uio_offset; ) { | |
767 | *(cookies++) = bufferOffset; | |
768 | bufferOffset += dp->d_reclen; | |
769 | dp = (struct dirent *)((caddr_t)dp + dp->d_reclen); | |
770 | } | |
771 | } | |
772 | ||
773 | if (error < 0) | |
774 | error = 0; | |
775 | ||
776 | if (bp) | |
777 | brelse (bp); | |
778 | ||
779 | uio->uio_offset = idp->uio_off; | |
780 | *ap->a_eofflag = idp->eofflag; | |
781 | ||
782 | FREE(idp, M_TEMP); | |
783 | ||
784 | return (error); | |
785 | } | |
786 | ||
787 | /* | |
788 | * Return target name of a symbolic link | |
789 | * Shouldn't we get the parent vnode and read the data from there? | |
790 | * This could eventually result in deadlocks in cd9660_lookup. | |
791 | * But otherwise the block read here is in the block buffer two times. | |
792 | */ | |
793 | typedef struct iso_directory_record ISODIR; | |
794 | typedef struct iso_node ISONODE; | |
795 | typedef struct iso_mnt ISOMNT; | |
796 | int | |
797 | cd9660_readlink(ap) | |
798 | struct vop_readlink_args /* { | |
799 | struct vnode *a_vp; | |
800 | struct uio *a_uio; | |
801 | struct ucred *a_cred; | |
802 | } */ *ap; | |
803 | { | |
804 | ISONODE *ip; | |
805 | ISODIR *dirp; | |
806 | ISOMNT *imp; | |
807 | struct buf *bp; | |
808 | struct uio *uio; | |
809 | u_short symlen; | |
810 | int error; | |
811 | char *symname; | |
812 | ||
813 | ip = VTOI(ap->a_vp); | |
814 | imp = ip->i_mnt; | |
815 | uio = ap->a_uio; | |
816 | ||
817 | if (imp->iso_ftype != ISO_FTYPE_RRIP) | |
818 | return (EINVAL); | |
819 | ||
820 | /* | |
821 | * Get parents directory record block that this inode included. | |
822 | */ | |
823 | error = bread(imp->im_devvp, | |
824 | (ip->i_number >> imp->im_bshift), | |
825 | imp->logical_block_size, NOCRED, &bp); | |
826 | if (error) { | |
827 | brelse(bp); | |
828 | return (EINVAL); | |
829 | } | |
830 | ||
831 | /* | |
832 | * Setup the directory pointer for this inode | |
833 | */ | |
834 | dirp = (ISODIR *)(bp->b_data + (ip->i_number & imp->im_bmask)); | |
835 | ||
836 | /* | |
837 | * Just make sure, we have a right one.... | |
838 | * 1: Check not cross boundary on block | |
839 | */ | |
840 | if ((ip->i_number & imp->im_bmask) + isonum_711(dirp->length) | |
841 | > imp->logical_block_size) { | |
842 | brelse(bp); | |
843 | return (EINVAL); | |
844 | } | |
845 | ||
846 | /* | |
847 | * Now get a buffer | |
848 | * Abuse a namei buffer for now. | |
849 | */ | |
850 | if (uio->uio_segflg == UIO_SYSSPACE) | |
851 | symname = uio->uio_iov->iov_base; | |
852 | else | |
853 | MALLOC_ZONE(symname, char *, MAXPATHLEN, M_NAMEI, M_WAITOK); | |
854 | ||
855 | /* | |
856 | * Ok, we just gathering a symbolic name in SL record. | |
857 | */ | |
858 | if (cd9660_rrip_getsymname(dirp, symname, &symlen, imp) == 0) { | |
859 | if (uio->uio_segflg != UIO_SYSSPACE) | |
860 | FREE_ZONE(symname, MAXPATHLEN, M_NAMEI); | |
861 | brelse(bp); | |
862 | return (EINVAL); | |
863 | } | |
864 | /* | |
865 | * Don't forget before you leave from home ;-) | |
866 | */ | |
867 | brelse(bp); | |
868 | ||
869 | /* | |
870 | * return with the symbolic name to caller's. | |
871 | */ | |
872 | if (uio->uio_segflg != UIO_SYSSPACE) { | |
873 | error = uiomove(symname, symlen, uio); | |
874 | FREE_ZONE(symname, MAXPATHLEN, M_NAMEI); | |
875 | return (error); | |
876 | } | |
877 | uio->uio_resid -= symlen; | |
878 | uio->uio_iov->iov_base += symlen; | |
879 | uio->uio_iov->iov_len -= symlen; | |
880 | return (0); | |
881 | } | |
882 | ||
1c79356b A |
883 | /* |
884 | * Lock an inode. | |
885 | */ | |
886 | ||
887 | int | |
888 | cd9660_lock(ap) | |
889 | struct vop_lock_args /* { | |
890 | struct vnode *a_vp; | |
891 | int a_flags; | |
892 | struct proc *a_p; | |
893 | } */ *ap; | |
894 | { | |
895 | struct vnode *vp = ap->a_vp; | |
896 | ||
897 | if (VTOI(vp) == (struct iso_node *) NULL) | |
898 | panic ("cd9660_lock: null inode"); | |
899 | return (lockmgr(&VTOI(vp)->i_lock, ap->a_flags, &vp->v_interlock,ap->a_p)); | |
900 | } | |
901 | ||
902 | /* | |
903 | * Unlock an inode. | |
904 | */ | |
905 | ||
906 | int | |
907 | cd9660_unlock(ap) | |
908 | struct vop_unlock_args /* { | |
909 | struct vnode *a_vp; | |
910 | int a_flags; | |
911 | struct proc *a_p; | |
912 | } */ *ap; | |
913 | { | |
914 | struct vnode *vp = ap->a_vp; | |
915 | ||
916 | return (lockmgr(&VTOI(vp)->i_lock, ap->a_flags | LK_RELEASE, &vp->v_interlock,ap->a_p)); | |
917 | ||
918 | } | |
919 | ||
920 | /* | |
921 | * Calculate the logical to physical mapping if not done already, | |
922 | * then call the device strategy routine. | |
923 | */ | |
924 | int | |
925 | cd9660_strategy(ap) | |
926 | struct vop_strategy_args /* { | |
927 | struct buf *a_bp; | |
928 | } */ *ap; | |
929 | { | |
930 | register struct buf *bp = ap->a_bp; | |
931 | register struct vnode *vp = bp->b_vp; | |
932 | register struct iso_node *ip; | |
933 | int error; | |
934 | ||
935 | ip = VTOI(vp); | |
936 | if (vp->v_type == VBLK || vp->v_type == VCHR) | |
937 | panic("cd9660_strategy: spec"); | |
938 | if (bp->b_blkno == bp->b_lblkno) { | |
939 | if ( (error = VOP_BMAP(vp, bp->b_lblkno, NULL, &bp->b_blkno, NULL)) ) { | |
940 | bp->b_error = error; | |
941 | bp->b_flags |= B_ERROR; | |
942 | biodone(bp); | |
943 | return (error); | |
944 | } | |
945 | if ((long)bp->b_blkno == -1) | |
946 | clrbuf(bp); | |
947 | } | |
948 | if ((long)bp->b_blkno == -1) { | |
949 | biodone(bp); | |
950 | return (0); | |
951 | } | |
952 | vp = ip->i_devvp; | |
953 | bp->b_dev = vp->v_rdev; | |
954 | VOCALL (vp->v_op, VOFFSET(vop_strategy), ap); | |
955 | return (0); | |
956 | } | |
957 | ||
958 | /* | |
959 | * Print out the contents of an inode. | |
960 | */ | |
961 | int | |
962 | cd9660_print(ap) | |
963 | struct vop_print_args /* { | |
964 | struct vnode *a_vp; | |
965 | } */ *ap; | |
966 | { | |
967 | ||
968 | printf("tag VT_ISOFS, isofs vnode\n"); | |
969 | return (0); | |
970 | } | |
971 | ||
972 | /* | |
973 | * Check for a locked inode. | |
974 | */ | |
975 | int | |
976 | cd9660_islocked(ap) | |
977 | struct vop_islocked_args /* { | |
978 | struct vnode *a_vp; | |
979 | } */ *ap; | |
980 | { | |
981 | ||
982 | return (lockstatus(&VTOI(ap->a_vp)->i_lock)); | |
983 | } | |
984 | ||
985 | /* | |
986 | * Return POSIX pathconf information applicable to cd9660 filesystems. | |
987 | */ | |
988 | int | |
989 | cd9660_pathconf(ap) | |
990 | struct vop_pathconf_args /* { | |
991 | struct vnode *a_vp; | |
992 | int a_name; | |
993 | register_t *a_retval; | |
994 | } */ *ap; | |
995 | { | |
996 | ||
997 | switch (ap->a_name) { | |
998 | case _PC_LINK_MAX: | |
999 | *ap->a_retval = 1; | |
1000 | return (0); | |
1001 | case _PC_NAME_MAX: | |
1002 | switch (VTOI(ap->a_vp)->i_mnt->iso_ftype) { | |
1003 | case ISO_FTYPE_RRIP: | |
1004 | *ap->a_retval = ISO_RRIP_NAMEMAX; | |
1005 | break; | |
1006 | case ISO_FTYPE_JOLIET: | |
1007 | *ap->a_retval = ISO_JOLIET_NAMEMAX; | |
1008 | break; | |
1009 | default: | |
1010 | *ap->a_retval = ISO_NAMEMAX; | |
1011 | } | |
1012 | return (0); | |
1013 | case _PC_PATH_MAX: | |
1014 | *ap->a_retval = PATH_MAX; | |
1015 | return (0); | |
1016 | case _PC_PIPE_BUF: | |
1017 | *ap->a_retval = PIPE_BUF; | |
1018 | return (0); | |
1019 | case _PC_CHOWN_RESTRICTED: | |
1020 | *ap->a_retval = 1; | |
1021 | return (0); | |
1022 | case _PC_NO_TRUNC: | |
1023 | *ap->a_retval = 1; | |
1024 | return (0); | |
1025 | default: | |
1026 | return (EINVAL); | |
1027 | } | |
1028 | /* NOTREACHED */ | |
1029 | } | |
1030 | ||
1031 | /* | |
1032 | * Unsupported operation | |
1033 | */ | |
1034 | int | |
1035 | cd9660_enotsupp() | |
1036 | { | |
1037 | ||
1038 | return (EOPNOTSUPP); | |
1039 | } | |
1040 | /* Pagein. similar to read */ | |
1041 | int | |
1042 | cd9660_pagein(ap) | |
1043 | struct vop_pagein_args /* { | |
1044 | struct vnode *a_vp, | |
1045 | upl_t a_pl, | |
1046 | vm_offset_t a_pl_offset, | |
1047 | off_t a_f_offset, | |
1048 | size_t a_size, | |
1049 | struct ucred *a_cred, | |
1050 | int a_flags | |
1051 | } */ *ap; | |
1052 | { | |
1053 | struct vnode *vp = ap->a_vp; | |
1054 | upl_t pl = ap->a_pl; | |
55e303ae | 1055 | size_t size = ap->a_size; |
1c79356b A |
1056 | off_t f_offset = ap->a_f_offset; |
1057 | vm_offset_t pl_offset = ap->a_pl_offset; | |
1058 | int flags = ap->a_flags; | |
1059 | register struct iso_node *ip = VTOI(vp); | |
55e303ae | 1060 | int error = 0; |
1c79356b | 1061 | |
55e303ae A |
1062 | /* |
1063 | * Copy the Apple Double header. | |
1064 | */ | |
1065 | if ((ip->i_flag & ISO_ASSOCIATED) && (f_offset == 0) && (size == ADH_SIZE)) { | |
1066 | apple_double_header_t header; | |
1067 | kern_return_t kret; | |
1068 | vm_offset_t ioaddr; | |
1069 | ||
1070 | kret = ubc_upl_map(pl, &ioaddr); | |
1071 | if (kret != KERN_SUCCESS) | |
1072 | panic("cd9660_xa_pagein: ubc_upl_map error = %d", kret); | |
1073 | ioaddr += pl_offset; | |
1074 | bzero((caddr_t)ioaddr, ADH_SIZE); | |
1075 | ||
1076 | header.magic = APPLEDOUBLE_MAGIC; | |
1077 | header.version = APPLEDOUBLE_VERSION; | |
1078 | header.count = 2; | |
1079 | header.entries[0].entryID = APPLEDOUBLE_FINDERINFO; | |
1080 | header.entries[0].offset = offsetof(apple_double_header_t, finfo); | |
1081 | header.entries[0].length = 32; | |
1082 | header.entries[1].entryID = APPLEDOUBLE_RESFORK; | |
1083 | header.entries[1].offset = ADH_SIZE; | |
1084 | header.entries[1].length = ip->i_size - ADH_SIZE; | |
1085 | header.finfo.fdType = ip->i_FileType; | |
1086 | header.finfo.fdCreator = ip->i_Creator; | |
1087 | header.finfo.fdFlags = ip->i_FinderFlags; | |
1088 | header.finfo.fdLocation.v = -1; | |
1089 | header.finfo.fdLocation.h = -1; | |
1090 | header.finfo.fdReserved = 0; | |
1091 | ||
1092 | bcopy((caddr_t)&header, (caddr_t)ioaddr, sizeof(apple_double_header_t)); | |
1093 | ||
1094 | kret = ubc_upl_unmap(pl); | |
1095 | if (kret != KERN_SUCCESS) | |
1096 | panic("cd9660_xa_pagein: ubc_upl_unmap error = %d", kret); | |
1097 | ||
1098 | if ((flags & UPL_NOCOMMIT) == 0) { | |
1099 | ubc_upl_commit_range(pl, pl_offset, size, UPL_COMMIT_FREE_ON_EMPTY); | |
1100 | } | |
1101 | } else { | |
1102 | int devBlockSize = 0; | |
1c79356b | 1103 | |
55e303ae A |
1104 | /* check pageouts are for reg file only and ubc info is present*/ |
1105 | if (UBCINVALID(vp)) | |
1106 | panic("cd9660_pagein: Not a VREG"); | |
1107 | UBCINFOCHECK("cd9660_pagein", vp); | |
1108 | ||
1109 | VOP_DEVBLOCKSIZE(ip->i_devvp, &devBlockSize); | |
1c79356b | 1110 | |
55e303ae | 1111 | error = cluster_pagein(vp, pl, pl_offset, f_offset, size, |
1c79356b | 1112 | (off_t)ip->i_size, devBlockSize, flags); |
55e303ae | 1113 | } |
1c79356b A |
1114 | return (error); |
1115 | } | |
1116 | ||
1117 | /* | |
1118 | * cd9660_remove - not possible to remove a file from iso cds | |
1119 | * | |
1120 | * Locking policy: a_dvp and vp locked on entry, unlocked on exit | |
1121 | */ | |
1122 | int | |
1123 | cd9660_remove(ap) | |
1124 | struct vop_remove_args /* { struct vnode *a_dvp; struct vnode *a_vp; | |
1125 | struct componentname *a_cnp; } */ *ap; | |
1126 | { | |
1127 | if (ap->a_dvp == ap->a_vp) | |
1128 | vrele(ap->a_vp); | |
1129 | else | |
1130 | vput(ap->a_vp); | |
1131 | vput(ap->a_dvp); | |
1132 | ||
1133 | return (EROFS); | |
1134 | } | |
1135 | ||
1136 | ||
1137 | /* | |
1138 | * cd9660_rmdir - not possible to remove a directory from iso cds | |
1139 | * | |
1140 | * Locking policy: a_dvp and vp locked on entry, unlocked on exit | |
1141 | */ | |
1142 | int | |
1143 | cd9660_rmdir(ap) | |
1144 | struct vop_rmdir_args /* { struct vnode *a_dvp; struct vnode *a_vp; | |
1145 | struct componentname *a_cnp; } */ *ap; | |
1146 | { | |
1147 | (void) nop_rmdir(ap); | |
1148 | return (EROFS); | |
1149 | } | |
1150 | ||
1151 | /* | |
1152 | ||
1153 | # | |
1154 | #% getattrlist vp = = = | |
1155 | # | |
1156 | vop_getattrlist { | |
1157 | IN struct vnode *vp; | |
1158 | IN struct attrlist *alist; | |
1159 | INOUT struct uio *uio; | |
1160 | IN struct ucred *cred; | |
1161 | IN struct proc *p; | |
1162 | }; | |
1163 | ||
1164 | */ | |
1165 | int | |
1166 | cd9660_getattrlist(ap) | |
1167 | struct vop_getattrlist_args /* { | |
1168 | struct vnode *a_vp; | |
1169 | struct attrlist *a_alist | |
1170 | struct uio *a_uio; | |
1171 | struct ucred *a_cred; | |
1172 | struct proc *a_p; | |
1173 | } */ *ap; | |
1174 | { | |
1175 | struct attrlist *alist = ap->a_alist; | |
1176 | int fixedblocksize; | |
1177 | int attrblocksize; | |
1178 | int attrbufsize; | |
1179 | void *attrbufptr; | |
1180 | void *attrptr; | |
1181 | void *varptr; | |
1182 | int error = 0; | |
1183 | ||
1184 | if ((alist->bitmapcount != ATTR_BIT_MAP_COUNT) || | |
1185 | ((alist->commonattr & ~ATTR_CMN_VALIDMASK) != 0) || | |
1186 | ((alist->volattr & ~ATTR_VOL_VALIDMASK) != 0) || | |
1187 | ((alist->dirattr & ~ATTR_DIR_VALIDMASK) != 0) || | |
1188 | ((alist->fileattr & ~ATTR_FILE_VALIDMASK) != 0) || | |
1189 | ((alist->forkattr & ~ATTR_FORK_VALIDMASK) != 0)) { | |
1190 | return EINVAL; | |
1191 | }; | |
1192 | ||
1193 | /* | |
1194 | * Requesting volume information requires setting the ATTR_VOL_INFO bit and | |
1195 | * volume info requests are mutually exclusive with all other info requests: | |
1196 | */ | |
1197 | if ((alist->volattr != 0) && | |
1198 | (((alist->volattr & ATTR_VOL_INFO) == 0) || | |
1199 | (alist->dirattr != 0) || | |
1200 | (alist->fileattr != 0) || | |
1201 | (alist->forkattr != 0) )) { | |
1202 | return EINVAL; | |
1203 | }; | |
1204 | ||
1205 | /* | |
1206 | * Reject requests for unsupported options for now: | |
1207 | */ | |
1208 | if (alist->volattr & ATTR_VOL_MOUNTPOINT) return EINVAL; | |
1209 | if (alist->commonattr & (ATTR_CMN_NAMEDATTRCOUNT | ATTR_CMN_NAMEDATTRLIST)) return EINVAL; | |
1210 | if (alist->fileattr & | |
1211 | (ATTR_FILE_FILETYPE | | |
1212 | ATTR_FILE_FORKCOUNT | | |
1213 | ATTR_FILE_FORKLIST | | |
1214 | ATTR_FILE_DATAEXTENTS | | |
1215 | ATTR_FILE_RSRCEXTENTS)) { | |
1216 | return EINVAL; | |
1217 | }; | |
1218 | ||
1219 | ||
1220 | fixedblocksize = attrcalcsize(alist); | |
1221 | attrblocksize = fixedblocksize + (sizeof(u_long)); /* u_long for length longword */ | |
1222 | if (alist->commonattr & ATTR_CMN_NAME) attrblocksize += NAME_MAX; | |
1223 | if (alist->commonattr & ATTR_CMN_NAMEDATTRLIST) attrblocksize += 0; /* XXX PPD */ | |
1224 | if (alist->volattr & ATTR_VOL_MOUNTPOINT) attrblocksize += PATH_MAX; | |
1225 | if (alist->volattr & ATTR_VOL_NAME) attrblocksize += NAME_MAX; | |
1226 | if (alist->fileattr & ATTR_FILE_FORKLIST) attrblocksize += 0; /* XXX PPD */ | |
1227 | ||
1228 | attrbufsize = MIN(ap->a_uio->uio_resid, attrblocksize); | |
1229 | MALLOC(attrbufptr, void *, attrblocksize, M_TEMP, M_WAITOK); | |
1230 | attrptr = attrbufptr; | |
1231 | *((u_long *)attrptr) = 0; /* Set buffer length in case of errors */ | |
1232 | ++((u_long *)attrptr); /* Reserve space for length field */ | |
1233 | varptr = ((char *)attrptr) + fixedblocksize; /* Point to variable-length storage */ | |
1234 | ||
1235 | packattrblk(alist, ap->a_vp, &attrptr, &varptr); | |
1236 | ||
1237 | /* Store length of fixed + var block */ | |
1238 | *((u_long *)attrbufptr) = ((char*)varptr - (char*)attrbufptr); | |
1239 | /* Don't copy out more data than was generated */ | |
1240 | attrbufsize = MIN(attrbufsize, (char*)varptr - (char*)attrbufptr); | |
1241 | ||
1242 | error = uiomove((caddr_t)attrbufptr, attrbufsize, ap->a_uio); | |
1243 | ||
1244 | FREE(attrbufptr, M_TEMP); | |
1245 | ||
1246 | return error; | |
1247 | } | |
1248 | ||
55e303ae A |
1249 | /* |
1250 | * Make a RIFF file header for a CD-ROM XA media file. | |
1251 | */ | |
1252 | __private_extern__ void | |
1253 | cd9660_xa_init(struct vnode *vp, struct iso_directory_record *isodir) | |
1254 | { | |
1255 | u_long sectors; | |
1256 | struct iso_node *ip = VTOI(vp); | |
1257 | struct riff_header *header; | |
1258 | u_char name_len; | |
1259 | char *cdxa; | |
1260 | ||
1261 | MALLOC(header, struct riff_header *, sizeof(struct riff_header), M_TEMP, M_WAITOK); | |
1262 | ||
1263 | sectors = ip->i_size / 2048; | |
1264 | ||
1265 | strncpy(header->riff, "RIFF", 4); | |
1266 | header->fileSize = NXSwapHostLongToLittle(sectors * CDXA_SECTOR_SIZE + sizeof(struct riff_header) - 8); | |
1267 | strncpy(header->cdxa, "CDXA", 4); | |
1268 | strncpy(header->fmt, "fmt ", 4); | |
1269 | header->fmtSize = NXSwapHostLongToLittle(16); | |
1270 | strncpy(header->data, "data", 4); | |
1271 | header->dataSize = NXSwapHostLongToLittle(sectors * CDXA_SECTOR_SIZE); | |
1272 | ||
1273 | /* | |
1274 | * Copy the CD-ROM XA extended directory information into the header. As far as | |
1275 | * I can tell, it's always 14 bytes in the directory record, but allocated 16 bytes | |
1276 | * in the header (the last two being zeroed pad bytes). | |
1277 | */ | |
1278 | name_len = isonum_711(isodir->name_len); | |
1279 | cdxa = &isodir->name[name_len]; | |
1280 | if ((name_len & 0x01) == 0) | |
1281 | ++cdxa; /* Skip pad byte */ | |
1282 | bcopy(cdxa, header->fmtData, 14); | |
1283 | header->fmtData[14] = 0; | |
1284 | header->fmtData[15] = 0; | |
1285 | ||
1286 | /* | |
1287 | * Point this i-node to the "whole sector" device instead of the normal | |
1288 | * device. This allows cd9660_strategy to be ignorant of the block | |
1289 | * (sector) size. | |
1290 | */ | |
1291 | vrele(ip->i_devvp); | |
1292 | ip->i_devvp = ip->i_mnt->phys_devvp; | |
1293 | VREF(ip->i_devvp); | |
1294 | ||
1295 | ip->i_size = sectors * CDXA_SECTOR_SIZE + sizeof(struct riff_header); | |
1296 | ip->i_riff = header; | |
1297 | vp->v_op = cd9660_cdxaop_p; | |
1298 | } | |
1299 | ||
1300 | /* | |
1301 | * Helper routine for VOP_READ and VOP_PAGEIN of CD-ROM XA multimedia files. | |
1302 | * This routine determines the physical location of the file, then reads | |
1303 | * sectors directly from the device into a buffer. It also handles inserting | |
1304 | * the RIFF header at the beginning of the file. | |
1305 | * | |
1306 | * Exactly one of buffer or uio must be non-zero. It will either bcopy to | |
1307 | * buffer, or uiomove via uio. | |
1308 | * | |
1309 | * XXX Should this code be using breadn and vp->v_lastr to support single-block | |
1310 | * read-ahead? Should we try more aggressive read-ahead like cluster_io does? | |
1311 | * | |
1312 | * XXX This could be made to do larger I/O to the device (reading all the | |
1313 | * whole sectors directly into the buffer). That would make the code more | |
1314 | * complex, and the current code only adds 2.5% overhead compared to reading | |
1315 | * from the device directly (at least on my test machine). | |
1316 | */ | |
1317 | static int | |
1318 | cd9660_xa_read_common( | |
1319 | struct vnode *vp, | |
1320 | off_t offset, | |
1321 | size_t amount, | |
1322 | caddr_t buffer, | |
1323 | struct uio *uio) | |
1324 | { | |
1325 | struct iso_node *ip = VTOI(vp); | |
1326 | struct buf *bp; | |
1327 | off_t diff; /* number of bytes from offset to file's EOF */ | |
1328 | daddr_t block; /* physical disk block containing offset */ | |
1329 | off_t sect_off; /* starting offset into current sector */ | |
1330 | u_int count; /* number of bytes to transfer in current block */ | |
1331 | int error=0; | |
1332 | ||
1333 | /* | |
1334 | * Copy any part of the RIFF header. | |
1335 | */ | |
1336 | if (offset < sizeof(struct riff_header)) { | |
1337 | char *p; | |
1338 | ||
1339 | p = ((char *) ip->i_riff) + offset; | |
1340 | count = min(amount, sizeof(struct riff_header) - offset); | |
1341 | if (buffer) { | |
1342 | bcopy(p, buffer, count); | |
1343 | buffer += count; | |
1344 | } else { | |
1345 | error = uiomove(p, count, uio); | |
1346 | } | |
1347 | amount -= count; | |
1348 | offset += count; | |
1349 | } | |
1350 | if (error) | |
1351 | return error; | |
1352 | ||
1353 | /* | |
1354 | * Loop over (possibly partial) blocks to transfer. | |
1355 | */ | |
1356 | while (error == 0 && amount > 0) { | |
1357 | /* | |
1358 | * Determine number of bytes until EOF. If we've hit | |
1359 | * EOF then return. | |
1360 | */ | |
1361 | diff = ip->i_size - offset; | |
1362 | if (diff <= 0) | |
1363 | return 0; | |
1364 | ||
1365 | /* Get a block from the underlying device */ | |
1366 | block = ip->iso_start + (offset - sizeof(struct riff_header))/CDXA_SECTOR_SIZE; | |
1367 | error = bread(ip->i_devvp, block, CDXA_SECTOR_SIZE, NOCRED, &bp); | |
1368 | if (error) { | |
1369 | brelse(bp); | |
1370 | return error; | |
1371 | } | |
1372 | if (bp->b_resid) { | |
1373 | printf("isofs: cd9660_xa_read_common: bread didn't read full sector\n"); | |
1374 | return EIO; | |
1375 | } | |
1376 | ||
1377 | /* Figure out which part of the block to copy, and copy it */ | |
1378 | sect_off = (offset - sizeof(struct riff_header)) % CDXA_SECTOR_SIZE; | |
1379 | count = min(CDXA_SECTOR_SIZE-sect_off, amount); | |
1380 | if (diff < count) /* Pin transfer amount to EOF */ | |
1381 | count = diff; | |
1382 | ||
1383 | if (buffer) { | |
1384 | bcopy(bp->b_data+sect_off, buffer, count); | |
1385 | buffer += count; | |
1386 | } else { | |
1387 | error = uiomove(bp->b_data+sect_off, count, uio); | |
1388 | } | |
1389 | amount -= count; | |
1390 | offset += count; | |
1391 | ||
1392 | /* | |
1393 | * If we copied through the end of the block, or the end of file, then | |
1394 | * age the device block. This is optimized for sequential access. | |
1395 | */ | |
1396 | if (sect_off+count == CDXA_SECTOR_SIZE || offset == (off_t)ip->i_size) | |
1397 | bp->b_flags |= B_AGE; | |
1398 | brelse(bp); | |
1399 | } | |
1400 | ||
1401 | return error; | |
1402 | } | |
1403 | ||
1404 | /* | |
1405 | * Read from a CD-ROM XA multimedia file. | |
1406 | * | |
1407 | * This uses the same common routine as pagein for doing the actual read | |
1408 | * from the device. | |
1409 | * | |
1410 | * This routine doesn't do any caching beyond what the block device does. | |
1411 | * Even then, cd9660_xa_read_common ages the blocks once we read up to | |
1412 | * the end. | |
1413 | * | |
1414 | * We don't even take advantage if the file has been memory mapped and has | |
1415 | * valid pages already (in which case we could just uiomove from the page | |
1416 | * to the caller). Since we're a read-only filesystem, there can't be | |
1417 | * any cache coherency problems. Multimedia files are expected to be | |
1418 | * large and streamed anyway, so caching file contents probably isn't | |
1419 | * important. | |
1420 | */ | |
1421 | int | |
1422 | cd9660_xa_read(ap) | |
1423 | struct vop_read_args /* { | |
1424 | struct vnode *a_vp; | |
1425 | struct uio *a_uio; | |
1426 | int a_ioflag; | |
1427 | struct ucred *a_cred; | |
1428 | } */ *ap; | |
1429 | { | |
1430 | struct vnode *vp = ap->a_vp; | |
1431 | register struct uio *uio = ap->a_uio; | |
1432 | register struct iso_node *ip = VTOI(vp); | |
1433 | off_t offset = uio->uio_offset; | |
1434 | size_t size = uio->uio_resid; | |
1435 | ||
1436 | /* Check for some obvious parameter problems */ | |
1437 | if (offset < 0) | |
1438 | return EINVAL; | |
1439 | if (size == 0) | |
1440 | return 0; | |
1441 | if (offset >= ip->i_size) | |
1442 | return 0; | |
1443 | ||
1444 | /* Pin the size of the read to the file's EOF */ | |
1445 | if (offset + size > ip->i_size) | |
1446 | size = ip->i_size - offset; | |
1447 | ||
1448 | return cd9660_xa_read_common(vp, offset, size, NULL, uio); | |
1449 | } | |
1450 | ||
1451 | /* | |
1452 | * Page in from a CD-ROM XA media file. | |
1453 | * | |
1454 | * Since our device block size isn't a power of two, we can't use | |
1455 | * cluster_pagein. Instead, we have to map the page and read into it. | |
1456 | */ | |
1457 | static int | |
1458 | cd9660_xa_pagein(ap) | |
1459 | struct vop_pagein_args /* { | |
1460 | struct vnode *a_vp, | |
1461 | upl_t a_pl, | |
1462 | vm_offset_t a_pl_offset, | |
1463 | off_t a_f_offset, | |
1464 | size_t a_size, | |
1465 | struct ucred *a_cred, | |
1466 | int a_flags | |
1467 | } */ *ap; | |
1468 | { | |
1469 | struct vnode *vp = ap->a_vp; | |
1470 | upl_t pl = ap->a_pl; | |
1471 | size_t size= ap->a_size; | |
1472 | off_t f_offset = ap->a_f_offset; | |
1473 | vm_offset_t pl_offset = ap->a_pl_offset; | |
1474 | int flags = ap->a_flags; | |
1475 | register struct iso_node *ip = VTOI(vp); | |
1476 | int error; | |
1477 | kern_return_t kret; | |
1478 | vm_offset_t ioaddr; | |
1479 | ||
1480 | /* check pageins are for reg file only and ubc info is present*/ | |
1481 | if (UBCINVALID(vp)) | |
1482 | panic("cd9660_xa_pagein: Not a VREG"); | |
1483 | UBCINFOCHECK("cd9660_xa_pagein", vp); | |
1484 | ||
1485 | if (size <= 0) | |
1486 | panic("cd9660_xa_pagein: size = %d", size); | |
1487 | ||
1488 | kret = ubc_upl_map(pl, &ioaddr); | |
1489 | if (kret != KERN_SUCCESS) | |
1490 | panic("cd9660_xa_pagein: ubc_upl_map error = %d", kret); | |
1491 | ||
1492 | ioaddr += pl_offset; | |
1493 | ||
1494 | /* Make sure pagein doesn't extend past EOF */ | |
1495 | if (f_offset + size > ip->i_size) | |
1496 | size = ip->i_size - f_offset; /* pin size to EOF */ | |
1497 | ||
1498 | /* Read the data in using the underlying device */ | |
1499 | error = cd9660_xa_read_common(vp, f_offset, size, (caddr_t)ioaddr, NULL); | |
1500 | ||
1501 | /* Zero fill part of page past EOF */ | |
1502 | if (ap->a_size > size) | |
1503 | bzero((caddr_t)ioaddr+size, ap->a_size-size); | |
1504 | ||
1505 | kret = ubc_upl_unmap(pl); | |
1506 | if (kret != KERN_SUCCESS) | |
1507 | panic("cd9660_xa_pagein: ubc_upl_unmap error = %d", kret); | |
1508 | ||
1509 | if ((flags & UPL_NOCOMMIT) == 0) | |
1510 | { | |
1511 | if (error) | |
1512 | ubc_upl_abort_range(pl, pl_offset, ap->a_size, UPL_ABORT_FREE_ON_EMPTY); | |
1513 | else | |
1514 | ubc_upl_commit_range(pl, pl_offset, ap->a_size, UPL_COMMIT_FREE_ON_EMPTY); | |
1515 | } | |
1516 | ||
1517 | return error; | |
1518 | } | |
1519 | ||
1c79356b A |
1520 | /* |
1521 | * Global vfs data structures for isofs | |
1522 | */ | |
1523 | #define cd9660_create \ | |
1524 | ((int (*) __P((struct vop_create_args *)))err_create) | |
1525 | #define cd9660_mknod ((int (*) __P((struct vop_mknod_args *)))err_mknod) | |
1526 | #define cd9660_setattr \ | |
1527 | ((int (*) __P((struct vop_setattr_args *)))cd9660_enotsupp) | |
1528 | #define cd9660_write ((int (*) __P((struct vop_write_args *)))cd9660_enotsupp) | |
1529 | #if NFSSERVER | |
1530 | int lease_check __P((struct vop_lease_args *)); | |
1531 | #define cd9660_lease_check lease_check | |
1532 | #else | |
1533 | #define cd9660_lease_check ((int (*) __P((struct vop_lease_args *)))nullop) | |
1534 | #endif | |
1535 | #define cd9660_fsync ((int (*) __P((struct vop_fsync_args *)))nullop) | |
1536 | #define cd9660_rename \ | |
1537 | ((int (*) __P((struct vop_rename_args *)))err_rename) | |
1538 | #define cd9660_copyfile \ | |
1539 | ((int (*) __P((struct vop_copyfile_args *)))err_copyfile) | |
1540 | #define cd9660_link ((int (*) __P((struct vop_link_args *)))err_link) | |
1541 | #define cd9660_mkdir ((int (*) __P((struct vop_mkdir_args *)))err_mkdir) | |
1542 | #define cd9660_symlink \ | |
1543 | ((int (*) __P((struct vop_symlink_args *)))err_symlink) | |
1544 | #define cd9660_advlock \ | |
1545 | ((int (*) __P((struct vop_advlock_args *)))cd9660_enotsupp) | |
1546 | #define cd9660_valloc ((int(*) __P(( \ | |
1547 | struct vnode *pvp, \ | |
1548 | int mode, \ | |
1549 | struct ucred *cred, \ | |
1550 | struct vnode **vpp))) cd9660_enotsupp) | |
1551 | #define cd9660_vfree ((int (*) __P((struct vop_vfree_args *)))cd9660_enotsupp) | |
1552 | #define cd9660_truncate \ | |
1553 | ((int (*) __P((struct vop_truncate_args *)))cd9660_enotsupp) | |
1554 | #define cd9660_update \ | |
1555 | ((int (*) __P((struct vop_update_args *)))cd9660_enotsupp) | |
1556 | #define cd9660_bwrite \ | |
1557 | ((int (*) __P((struct vop_bwrite_args *)))cd9660_enotsupp) | |
1558 | #define cd9660_pageout \ | |
1559 | ((int (*) __P((struct vop_pageout_args *)))cd9660_enotsupp) | |
1560 | int cd9660_blktooff(struct vop_blktooff_args *ap); | |
1561 | int cd9660_offtoblk(struct vop_offtoblk_args *ap); | |
1562 | int cd9660_cmap(struct vop_cmap_args *ap); | |
1563 | ||
1564 | #define VOPFUNC int (*)(void *) | |
1565 | /* | |
1566 | * Global vfs data structures for cd9660 | |
1567 | */ | |
1568 | int (**cd9660_vnodeop_p)(void *); | |
1569 | struct vnodeopv_entry_desc cd9660_vnodeop_entries[] = { | |
1570 | { &vop_default_desc, (VOPFUNC)vn_default_error }, | |
1571 | { &vop_lookup_desc, (VOPFUNC)cd9660_lookup }, /* lookup */ | |
1572 | { &vop_create_desc, (VOPFUNC)cd9660_create }, /* create */ | |
1573 | { &vop_mknod_desc, (VOPFUNC)cd9660_mknod }, /* mknod */ | |
1574 | { &vop_open_desc, (VOPFUNC)cd9660_open }, /* open */ | |
1575 | { &vop_close_desc, (VOPFUNC)cd9660_close }, /* close */ | |
1576 | { &vop_access_desc, (VOPFUNC)cd9660_access }, /* access */ | |
1577 | { &vop_getattr_desc, (VOPFUNC)cd9660_getattr }, /* getattr */ | |
1578 | { &vop_setattr_desc, (VOPFUNC)cd9660_setattr }, /* setattr */ | |
1579 | { &vop_read_desc, (VOPFUNC)cd9660_read }, /* read */ | |
1580 | { &vop_write_desc, (VOPFUNC)cd9660_write }, /* write */ | |
1581 | { &vop_lease_desc, (VOPFUNC)cd9660_lease_check },/* lease */ | |
1582 | { &vop_ioctl_desc, (VOPFUNC)cd9660_ioctl }, /* ioctl */ | |
1583 | { &vop_select_desc, (VOPFUNC)cd9660_select }, /* select */ | |
1584 | { &vop_mmap_desc, (VOPFUNC)cd9660_mmap }, /* mmap */ | |
1585 | { &vop_fsync_desc, (VOPFUNC)cd9660_fsync }, /* fsync */ | |
1586 | { &vop_seek_desc, (VOPFUNC)cd9660_seek }, /* seek */ | |
1587 | { &vop_remove_desc, (VOPFUNC)cd9660_remove }, /* remove */ | |
1588 | { &vop_link_desc, (VOPFUNC)cd9660_link }, /* link */ | |
1589 | { &vop_rename_desc, (VOPFUNC)cd9660_rename }, /* rename */ | |
1590 | { &vop_copyfile_desc, (VOPFUNC)cd9660_copyfile },/* copyfile */ | |
1591 | { &vop_mkdir_desc, (VOPFUNC)cd9660_mkdir }, /* mkdir */ | |
1592 | { &vop_rmdir_desc, (VOPFUNC)cd9660_rmdir }, /* rmdir */ | |
1593 | { &vop_symlink_desc, (VOPFUNC)cd9660_symlink }, /* symlink */ | |
1594 | { &vop_readdir_desc, (VOPFUNC)cd9660_readdir }, /* readdir */ | |
1595 | { &vop_readlink_desc, (VOPFUNC)cd9660_readlink },/* readlink */ | |
55e303ae | 1596 | { &vop_abortop_desc, (VOPFUNC)nop_abortop }, /* abortop */ |
1c79356b A |
1597 | { &vop_inactive_desc, (VOPFUNC)cd9660_inactive },/* inactive */ |
1598 | { &vop_reclaim_desc, (VOPFUNC)cd9660_reclaim }, /* reclaim */ | |
1599 | { &vop_lock_desc, (VOPFUNC)cd9660_lock }, /* lock */ | |
1600 | { &vop_unlock_desc, (VOPFUNC)cd9660_unlock }, /* unlock */ | |
1601 | { &vop_bmap_desc, (VOPFUNC)cd9660_bmap }, /* bmap */ | |
1602 | { &vop_strategy_desc, (VOPFUNC)cd9660_strategy },/* strategy */ | |
1603 | { &vop_print_desc, (VOPFUNC)cd9660_print }, /* print */ | |
1604 | { &vop_islocked_desc, (VOPFUNC)cd9660_islocked },/* islocked */ | |
1605 | { &vop_pathconf_desc, (VOPFUNC)cd9660_pathconf },/* pathconf */ | |
1606 | { &vop_advlock_desc, (VOPFUNC)cd9660_advlock }, /* advlock */ | |
1607 | { &vop_blkatoff_desc, (VOPFUNC)cd9660_blkatoff },/* blkatoff */ | |
1608 | { &vop_valloc_desc, (VOPFUNC)cd9660_valloc }, /* valloc */ | |
1609 | { &vop_vfree_desc, (VOPFUNC)cd9660_vfree }, /* vfree */ | |
1610 | { &vop_truncate_desc, (VOPFUNC)cd9660_truncate },/* truncate */ | |
1611 | { &vop_update_desc, (VOPFUNC)cd9660_update }, /* update */ | |
1612 | { &vop_bwrite_desc, (VOPFUNC)vn_bwrite }, | |
1613 | { &vop_pagein_desc, (VOPFUNC)cd9660_pagein }, /* Pagein */ | |
1614 | { &vop_pageout_desc, (VOPFUNC)cd9660_pageout }, /* Pageout */ | |
1615 | { &vop_getattrlist_desc, (VOPFUNC)cd9660_getattrlist }, /* getattrlist */ | |
1616 | { &vop_blktooff_desc, (VOPFUNC)cd9660_blktooff }, /* blktooff */ | |
1617 | { &vop_offtoblk_desc, (VOPFUNC)cd9660_offtoblk }, /* offtoblk */ | |
1618 | { &vop_cmap_desc, (VOPFUNC)cd9660_cmap }, /* cmap */ | |
1619 | { (struct vnodeop_desc*)NULL, (VOPFUNC)NULL } | |
1620 | }; | |
1621 | struct vnodeopv_desc cd9660_vnodeop_opv_desc = | |
1622 | { &cd9660_vnodeop_p, cd9660_vnodeop_entries }; | |
1623 | ||
55e303ae A |
1624 | /* |
1625 | * The VOP table for CD-ROM XA (media) files is almost the same | |
1626 | * as for ordinary files, except for read, and pagein. | |
1627 | * Note that cd9660_xa_read doesn't use cluster I/O, so cmap | |
1628 | * isn't needed, and isn't implemented. Similarly, it doesn't | |
1629 | * do bread() on CD XA vnodes, so bmap, blktooff, offtoblk | |
1630 | * aren't needed. | |
1631 | */ | |
1632 | int (**cd9660_cdxaop_p)(void *); | |
1633 | struct vnodeopv_entry_desc cd9660_cdxaop_entries[] = { | |
1634 | { &vop_default_desc, (VOPFUNC)vn_default_error }, | |
1635 | { &vop_lookup_desc, (VOPFUNC)cd9660_lookup }, /* lookup */ | |
1636 | { &vop_create_desc, (VOPFUNC)cd9660_create }, /* create */ | |
1637 | { &vop_mknod_desc, (VOPFUNC)cd9660_mknod }, /* mknod */ | |
1638 | { &vop_open_desc, (VOPFUNC)cd9660_open }, /* open */ | |
1639 | { &vop_close_desc, (VOPFUNC)cd9660_close }, /* close */ | |
1640 | { &vop_access_desc, (VOPFUNC)cd9660_access }, /* access */ | |
1641 | { &vop_getattr_desc, (VOPFUNC)cd9660_getattr }, /* getattr */ | |
1642 | { &vop_setattr_desc, (VOPFUNC)cd9660_setattr }, /* setattr */ | |
1643 | { &vop_read_desc, (VOPFUNC)cd9660_xa_read }, /* read */ | |
1644 | { &vop_write_desc, (VOPFUNC)cd9660_write }, /* write */ | |
1645 | { &vop_lease_desc, (VOPFUNC)cd9660_lease_check },/* lease */ | |
1646 | { &vop_ioctl_desc, (VOPFUNC)cd9660_ioctl }, /* ioctl */ | |
1647 | { &vop_select_desc, (VOPFUNC)cd9660_select }, /* select */ | |
1648 | { &vop_mmap_desc, (VOPFUNC)cd9660_mmap }, /* mmap */ | |
1649 | { &vop_fsync_desc, (VOPFUNC)cd9660_fsync }, /* fsync */ | |
1650 | { &vop_seek_desc, (VOPFUNC)cd9660_seek }, /* seek */ | |
1651 | { &vop_remove_desc, (VOPFUNC)cd9660_remove }, /* remove */ | |
1652 | { &vop_link_desc, (VOPFUNC)cd9660_link }, /* link */ | |
1653 | { &vop_rename_desc, (VOPFUNC)cd9660_rename }, /* rename */ | |
1654 | { &vop_copyfile_desc, (VOPFUNC)cd9660_copyfile },/* copyfile */ | |
1655 | { &vop_mkdir_desc, (VOPFUNC)cd9660_mkdir }, /* mkdir */ | |
1656 | { &vop_rmdir_desc, (VOPFUNC)cd9660_rmdir }, /* rmdir */ | |
1657 | { &vop_symlink_desc, (VOPFUNC)cd9660_symlink }, /* symlink */ | |
1658 | { &vop_readdir_desc, (VOPFUNC)cd9660_readdir }, /* readdir */ | |
1659 | { &vop_readlink_desc, (VOPFUNC)cd9660_readlink },/* readlink */ | |
1660 | { &vop_inactive_desc, (VOPFUNC)cd9660_inactive },/* inactive */ | |
1661 | { &vop_reclaim_desc, (VOPFUNC)cd9660_reclaim }, /* reclaim */ | |
1662 | { &vop_lock_desc, (VOPFUNC)cd9660_lock }, /* lock */ | |
1663 | { &vop_unlock_desc, (VOPFUNC)cd9660_unlock }, /* unlock */ | |
1664 | { &vop_strategy_desc, (VOPFUNC)cd9660_strategy },/* strategy */ | |
1665 | { &vop_print_desc, (VOPFUNC)cd9660_print }, /* print */ | |
1666 | { &vop_islocked_desc, (VOPFUNC)cd9660_islocked },/* islocked */ | |
1667 | { &vop_pathconf_desc, (VOPFUNC)cd9660_pathconf },/* pathconf */ | |
1668 | { &vop_advlock_desc, (VOPFUNC)cd9660_advlock }, /* advlock */ | |
1669 | { &vop_blkatoff_desc, (VOPFUNC)cd9660_blkatoff },/* blkatoff */ | |
1670 | { &vop_valloc_desc, (VOPFUNC)cd9660_valloc }, /* valloc */ | |
1671 | { &vop_vfree_desc, (VOPFUNC)cd9660_vfree }, /* vfree */ | |
1672 | { &vop_truncate_desc, (VOPFUNC)cd9660_truncate },/* truncate */ | |
1673 | { &vop_update_desc, (VOPFUNC)cd9660_update }, /* update */ | |
1674 | { &vop_bwrite_desc, (VOPFUNC)vn_bwrite }, | |
1675 | { &vop_pagein_desc, (VOPFUNC)cd9660_xa_pagein }, /* Pagein */ | |
1676 | { &vop_pageout_desc, (VOPFUNC)cd9660_pageout }, /* Pageout */ | |
1677 | { &vop_getattrlist_desc, (VOPFUNC)cd9660_getattrlist }, /* getattrlist */ | |
1678 | { (struct vnodeop_desc*)NULL, (VOPFUNC)NULL } | |
1679 | }; | |
1680 | struct vnodeopv_desc cd9660_cdxaop_opv_desc = | |
1681 | { &cd9660_cdxaop_p, cd9660_cdxaop_entries }; | |
1682 | ||
1c79356b A |
1683 | /* |
1684 | * Special device vnode ops | |
1685 | */ | |
1686 | int (**cd9660_specop_p)(void *); | |
1687 | struct vnodeopv_entry_desc cd9660_specop_entries[] = { | |
1688 | { &vop_default_desc, (VOPFUNC)vn_default_error }, | |
1689 | { &vop_lookup_desc, (VOPFUNC)spec_lookup }, /* lookup */ | |
1690 | { &vop_create_desc, (VOPFUNC)spec_create }, /* create */ | |
1691 | { &vop_mknod_desc, (VOPFUNC)spec_mknod }, /* mknod */ | |
1692 | { &vop_open_desc, (VOPFUNC)spec_open }, /* open */ | |
1693 | { &vop_close_desc, (VOPFUNC)spec_close }, /* close */ | |
1694 | { &vop_access_desc, (VOPFUNC)cd9660_access }, /* access */ | |
1695 | { &vop_getattr_desc, (VOPFUNC)cd9660_getattr }, /* getattr */ | |
1696 | { &vop_setattr_desc, (VOPFUNC)cd9660_setattr }, /* setattr */ | |
1697 | { &vop_read_desc, (VOPFUNC)spec_read }, /* read */ | |
1698 | { &vop_write_desc, (VOPFUNC)spec_write }, /* write */ | |
1699 | { &vop_lease_desc, (VOPFUNC)spec_lease_check }, /* lease */ | |
1700 | { &vop_ioctl_desc, (VOPFUNC)spec_ioctl }, /* ioctl */ | |
1701 | { &vop_select_desc, (VOPFUNC)spec_select }, /* select */ | |
1702 | { &vop_mmap_desc, (VOPFUNC)spec_mmap }, /* mmap */ | |
1703 | { &vop_fsync_desc, (VOPFUNC)spec_fsync }, /* fsync */ | |
1704 | { &vop_seek_desc, (VOPFUNC)spec_seek }, /* seek */ | |
1705 | { &vop_remove_desc, (VOPFUNC)spec_remove }, /* remove */ | |
1706 | { &vop_link_desc, (VOPFUNC)spec_link }, /* link */ | |
1707 | { &vop_rename_desc, (VOPFUNC)spec_rename }, /* rename */ | |
1708 | { &vop_mkdir_desc, (VOPFUNC)spec_mkdir }, /* mkdir */ | |
1709 | { &vop_rmdir_desc, (VOPFUNC)spec_rmdir }, /* rmdir */ | |
1710 | { &vop_symlink_desc, (VOPFUNC)spec_symlink }, /* symlink */ | |
1711 | { &vop_readdir_desc, (VOPFUNC)spec_readdir }, /* readdir */ | |
1712 | { &vop_readlink_desc, (VOPFUNC)spec_readlink }, /* readlink */ | |
1713 | { &vop_abortop_desc, (VOPFUNC)spec_abortop }, /* abortop */ | |
1714 | { &vop_inactive_desc, (VOPFUNC)cd9660_inactive },/* inactive */ | |
1715 | { &vop_reclaim_desc, (VOPFUNC)cd9660_reclaim }, /* reclaim */ | |
1716 | { &vop_lock_desc, (VOPFUNC)cd9660_lock }, /* lock */ | |
1717 | { &vop_unlock_desc, (VOPFUNC)cd9660_unlock }, /* unlock */ | |
1718 | { &vop_bmap_desc, (VOPFUNC)spec_bmap }, /* bmap */ | |
1719 | { &vop_strategy_desc, (VOPFUNC)spec_strategy }, /* strategy */ | |
1720 | { &vop_print_desc, (VOPFUNC)cd9660_print }, /* print */ | |
1721 | { &vop_islocked_desc, (VOPFUNC)cd9660_islocked },/* islocked */ | |
1722 | { &vop_pathconf_desc, (VOPFUNC)spec_pathconf }, /* pathconf */ | |
1723 | { &vop_advlock_desc, (VOPFUNC)spec_advlock }, /* advlock */ | |
1724 | { &vop_blkatoff_desc, (VOPFUNC)spec_blkatoff }, /* blkatoff */ | |
1725 | { &vop_valloc_desc, (VOPFUNC)spec_valloc }, /* valloc */ | |
1726 | { &vop_vfree_desc, (VOPFUNC)spec_vfree }, /* vfree */ | |
1727 | { &vop_truncate_desc, (VOPFUNC)spec_truncate }, /* truncate */ | |
1728 | { &vop_update_desc, (VOPFUNC)cd9660_update }, /* update */ | |
1729 | { &vop_bwrite_desc, (VOPFUNC)vn_bwrite }, | |
1730 | { &vop_devblocksize_desc, (VOPFUNC)spec_devblocksize }, /* devblocksize */ | |
1731 | { &vop_pagein_desc, (VOPFUNC)cd9660_pagein }, /* Pagein */ | |
1732 | { &vop_pageout_desc, (VOPFUNC)cd9660_pageout }, /* Pageout */ | |
1733 | { &vop_blktooff_desc, (VOPFUNC)cd9660_blktooff }, /* blktooff */ | |
1734 | { &vop_offtoblk_desc, (VOPFUNC)cd9660_offtoblk }, /* offtoblk */ | |
1735 | { &vop_cmap_desc, (VOPFUNC)cd9660_cmap }, /* cmap */ | |
1736 | { (struct vnodeop_desc*)NULL, (VOPFUNC)NULL } | |
1737 | }; | |
1738 | struct vnodeopv_desc cd9660_specop_opv_desc = | |
1739 | { &cd9660_specop_p, cd9660_specop_entries }; | |
1740 | ||
1741 | #if FIFO | |
1742 | int (**cd9660_fifoop_p)(void *); | |
1743 | struct vnodeopv_entry_desc cd9660_fifoop_entries[] = { | |
1744 | { &vop_default_desc, (VOPFUNC)vn_default_error }, | |
1745 | { &vop_lookup_desc, (VOPFUNC)fifo_lookup }, /* lookup */ | |
1746 | { &vop_create_desc, (VOPFUNC)fifo_create }, /* create */ | |
1747 | { &vop_mknod_desc, (VOPFUNC)fifo_mknod }, /* mknod */ | |
1748 | { &vop_open_desc, (VOPFUNC)fifo_open }, /* open */ | |
1749 | { &vop_close_desc, (VOPFUNC)fifo_close }, /* close */ | |
1750 | { &vop_access_desc, (VOPFUNC)cd9660_access }, /* access */ | |
1751 | { &vop_getattr_desc, (VOPFUNC)cd9660_getattr }, /* getattr */ | |
1752 | { &vop_setattr_desc, (VOPFUNC)cd9660_setattr }, /* setattr */ | |
1753 | { &vop_read_desc, (VOPFUNC)fifo_read }, /* read */ | |
1754 | { &vop_write_desc, (VOPFUNC)fifo_write }, /* write */ | |
1755 | { &vop_lease_desc, (VOPFUNC)fifo_lease_check }, /* lease */ | |
1756 | { &vop_ioctl_desc, (VOPFUNC)fifo_ioctl }, /* ioctl */ | |
1757 | { &vop_select_desc, (VOPFUNC)fifo_select }, /* select */ | |
1758 | { &vop_mmap_desc, (VOPFUNC)fifo_mmap }, /* mmap */ | |
1759 | { &vop_fsync_desc, (VOPFUNC)fifo_fsync }, /* fsync */ | |
1760 | { &vop_seek_desc, (VOPFUNC)fifo_seek }, /* seek */ | |
1761 | { &vop_remove_desc, (VOPFUNC)fifo_remove }, /* remove */ | |
1762 | { &vop_link_desc, (VOPFUNC)fifo_link } , /* link */ | |
1763 | { &vop_rename_desc, (VOPFUNC)fifo_rename }, /* rename */ | |
1764 | { &vop_mkdir_desc, (VOPFUNC)fifo_mkdir }, /* mkdir */ | |
1765 | { &vop_rmdir_desc, (VOPFUNC)fifo_rmdir }, /* rmdir */ | |
1766 | { &vop_symlink_desc, (VOPFUNC)fifo_symlink }, /* symlink */ | |
1767 | { &vop_readdir_desc, (VOPFUNC)fifo_readdir }, /* readdir */ | |
1768 | { &vop_readlink_desc, (VOPFUNC)fifo_readlink }, /* readlink */ | |
1769 | { &vop_abortop_desc, (VOPFUNC)fifo_abortop }, /* abortop */ | |
1770 | { &vop_inactive_desc, (VOPFUNC)cd9660_inactive },/* inactive */ | |
1771 | { &vop_reclaim_desc, (VOPFUNC)cd9660_reclaim }, /* reclaim */ | |
1772 | { &vop_lock_desc, (VOPFUNC)cd9660_lock }, /* lock */ | |
1773 | { &vop_unlock_desc, (VOPFUNC)cd9660_unlock }, /* unlock */ | |
1774 | { &vop_bmap_desc, (VOPFUNC)fifo_bmap }, /* bmap */ | |
1775 | { &vop_strategy_desc, (VOPFUNC)fifo_strategy }, /* strategy */ | |
1776 | { &vop_print_desc, (VOPFUNC)cd9660_print }, /* print */ | |
1777 | { &vop_islocked_desc, (VOPFUNC)cd9660_islocked },/* islocked */ | |
1778 | { &vop_pathconf_desc, (VOPFUNC)fifo_pathconf }, /* pathconf */ | |
1779 | { &vop_advlock_desc, (VOPFUNC)fifo_advlock }, /* advlock */ | |
1780 | { &vop_blkatoff_desc, (VOPFUNC)fifo_blkatoff }, /* blkatoff */ | |
1781 | { &vop_valloc_desc, (VOPFUNC)fifo_valloc }, /* valloc */ | |
1782 | { &vop_vfree_desc, (VOPFUNC)fifo_vfree }, /* vfree */ | |
1783 | { &vop_truncate_desc, (VOPFUNC)fifo_truncate }, /* truncate */ | |
1784 | { &vop_update_desc, (VOPFUNC)cd9660_update }, /* update */ | |
1785 | { &vop_bwrite_desc, (VOPFUNC)vn_bwrite }, | |
1786 | { &vop_pagein_desc, (VOPFUNC)cd9660_pagein }, /* Pagein */ | |
1787 | { &vop_pageout_desc, (VOPFUNC)cd9660_pageout }, /* Pageout */ | |
1788 | { &vop_blktooff_desc, (VOPFUNC)cd9660_blktooff }, /* blktooff */ | |
1789 | { &vop_offtoblk_desc, (VOPFUNC)cd9660_offtoblk }, /* offtoblk */ | |
1790 | { (struct vnodeop_desc*)NULL, (VOPFUNC)NULL } | |
1791 | }; | |
1792 | struct vnodeopv_desc cd9660_fifoop_opv_desc = | |
1793 | { &cd9660_fifoop_p, cd9660_fifoop_entries }; | |
1794 | #endif /* FIFO */ |