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