2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 /* $NetBSD: cd9660_vnops.c,v 1.22 1994/12/27 19:05:12 mycroft Exp $ */
26 * The Regents of the University of California. All rights reserved.
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).
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
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.
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
61 * @(#)cd9660_vnops.c 8.15 (Berkeley) 12/5/94
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
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>
84 #include <miscfs/specfs/specdev.h>
85 #include <miscfs/fifofs/fifo.h>
86 #include <sys/malloc.h>
89 #include <vfs/vfs_support.h>
94 #include <isofs/cd9660/iso.h>
95 #include <isofs/cd9660/cd9660_node.h>
96 #include <isofs/cd9660/iso_rrip.h>
106 struct vop_open_args
/* {
109 struct ucred *a_cred;
119 * Update the times on the inode on writeable file systems.
124 struct vop_close_args
/* {
127 struct ucred *a_cred;
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.
142 struct vop_access_args
/* {
145 struct ucred *a_cred;
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
;
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.
162 switch (vp
->v_type
) {
173 /* If immutable bit set, nobody gets to write it. */
175 if ((mode
& VWRITE
) && (ip
->i_flag
& IMMUTABLE
))
178 /* Otherwise, user id 0 always gets access. */
179 if (cred
->cr_uid
== 0)
184 /* Otherwise, check the owner. */
185 if (cred
->cr_uid
== ip
->inode
.iso_uid
) {
192 return ((ip
->inode
.iso_mode
& mask
) == mask
? 0 : EACCES
);
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
) {
204 return ((ip
->inode
.iso_mode
& mask
) == mask
? 0 : EACCES
);
207 /* Otherwise, check everyone else. */
214 return ((ip
->inode
.iso_mode
& mask
) == mask
? 0 : EACCES
);
219 struct vop_getattr_args
/* {
222 struct ucred *a_cred;
227 struct vnode
*vp
= ap
->a_vp
;
228 register struct vattr
*vap
= ap
->a_vap
;
229 register struct iso_node
*ip
= VTOI(vp
);
231 vap
->va_fsid
= ip
->i_dev
;
232 vap
->va_fileid
= ip
->i_number
;
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
;
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
;
250 MALLOC(cp
, char *, MAXPATHLEN
, M_TEMP
, M_WAITOK
);
252 aiov
.iov_len
= MAXPATHLEN
;
253 auio
.uio_iov
= &aiov
;
256 auio
.uio_rw
= UIO_READ
;
257 auio
.uio_segflg
= UIO_SYSSPACE
;
258 auio
.uio_procp
= ap
->a_p
;
259 auio
.uio_resid
= MAXPATHLEN
;
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
;
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
;
278 * Vnode op for reading.
282 struct vop_read_args
/* {
286 struct ucred *a_cred;
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
;
294 daddr_t lbn
, rablock
;
296 int rasize
, error
= 0;
298 int devBlockSize
= 0;
300 if (uio
->uio_resid
== 0)
302 if (uio
->uio_offset
< 0)
306 VOP_DEVBLOCKSIZE(ip
->i_devvp
, &devBlockSize
);
309 error
= cluster_read(vp
, uio
, (off_t
)ip
->i_size
, devBlockSize
, 0);
313 lbn
= lblkno(imp
, uio
->uio_offset
);
314 on
= blkoff(imp
, uio
->uio_offset
);
315 n
= min((u_int
)(imp
->logical_block_size
- on
),
317 diff
= (off_t
)ip
->i_size
- uio
->uio_offset
;
322 size
= blksize(imp
, ip
, lbn
);
325 if (vp
->v_lastr
+ 1 == lbn
&&
326 lblktosize(imp
, rablock
) < ip
->i_size
) {
327 rasize
= blksize(imp
, ip
, rablock
);
328 error
= breadn(vp
, lbn
, size
, &rablock
,
329 &rasize
, 1, NOCRED
, &bp
);
331 error
= bread(vp
, lbn
, size
, NOCRED
, &bp
);
334 n
= min(n
, size
- bp
->b_resid
);
340 error
= uiomove(bp
->b_data
+ on
, (int)n
, uio
);
341 if (n
+ on
== imp
->logical_block_size
||
342 uio
->uio_offset
== (off_t
)ip
->i_size
)
343 bp
->b_flags
|= B_AGE
;
345 } while (error
== 0 && uio
->uio_resid
> 0 && n
!= 0);
354 struct vop_ioctl_args
/* {
359 struct ucred *a_cred;
363 printf("You did ioctl for isofs !!\n");
370 struct vop_select_args
/* {
374 struct ucred *a_cred;
379 * We should really check to see if I/O is possible.
387 * NB Currently unsupported.
392 struct vop_mmap_args
/* {
395 struct ucred *a_cred;
406 * Nothing to do, so just return.
411 struct vop_seek_args
/* {
415 struct ucred *a_cred;
423 * Structure for reading directories
426 struct dirent saveent
;
427 struct dirent current
;
438 iso_uiodir(idp
,dp
,off
)
439 struct isoreaddir
*idp
;
445 dp
->d_name
[dp
->d_namlen
] = 0;
446 dp
->d_reclen
= DIRSIZ(dp
);
448 if (idp
->uio
->uio_resid
< dp
->d_reclen
) {
455 if (*idp
->ncookies
<= 0) {
460 **idp
->cookies
++ = off
;
465 if ( (error
= uiomove( (caddr_t
)dp
, dp
->d_reclen
, idp
->uio
)) )
473 struct isoreaddir
*idp
;
480 cl
= idp
->current
.d_namlen
;
481 cname
= idp
->current
.d_name
;
488 || bcmp(sname
,cname
,sl
)) {
489 if (idp
->saveent
.d_namlen
) {
490 if ( (error
= iso_uiodir(idp
,&idp
->saveent
,idp
->saveoff
)) )
492 idp
->saveent
.d_namlen
= 0;
496 idp
->current
.d_reclen
= DIRSIZ(&idp
->current
);
497 idp
->saveoff
= idp
->curroff
;
498 bcopy(&idp
->current
,&idp
->saveent
,idp
->current
.d_reclen
);
503 * Vnode op for readdir
507 struct vop_readdir_args
/* {
508 struct vnodeop_desc *a_desc;
511 struct ucred *a_cred;
517 register struct uio
*uio
= ap
->a_uio
;
518 off_t startingOffset
= uio
->uio_offset
;
520 struct isoreaddir
*idp
;
521 struct vnode
*vdp
= ap
->a_vp
;
524 struct buf
*bp
= NULL
;
525 struct iso_directory_record
*ep
;
526 int entryoffsetinblock
;
535 bmask
= imp
->im_bmask
;
537 MALLOC(idp
, struct isoreaddir
*, sizeof(*idp
), M_TEMP
, M_WAITOK
);
538 idp
->saveent
.d_namlen
= 0;
541 * Is it worth trying to figure out the type?
543 idp
->saveent
.d_type
= idp
->current
.d_type
= DT_UNKNOWN
;
546 idp
->curroff
= uio
->uio_offset
;
548 if ((entryoffsetinblock
= idp
->curroff
& bmask
) &&
549 (error
= VOP_BLKATOFF(vdp
, (off_t
)idp
->curroff
, NULL
, &bp
))) {
553 endsearch
= dp
->i_size
;
555 while (idp
->curroff
< endsearch
) {
557 * If offset is on a block boundary,
558 * read the next directory block.
559 * Release previous if it exists.
561 if ((idp
->curroff
& bmask
) == 0) {
564 if ( (error
= VOP_BLKATOFF(vdp
, (off_t
)idp
->curroff
, NULL
, &bp
)) )
566 entryoffsetinblock
= 0;
569 * Get pointer to next entry.
571 ep
= (struct iso_directory_record
*)
572 ((char *)bp
->b_data
+ entryoffsetinblock
);
574 reclen
= isonum_711(ep
->length
);
576 /* skip to next block, if any */
578 (idp
->curroff
& ~bmask
) + imp
->logical_block_size
;
582 if (reclen
< ISO_DIRECTORY_RECORD_SIZE
) {
584 /* illegal entry, stop */
588 if (entryoffsetinblock
+ reclen
> imp
->logical_block_size
) {
590 /* illegal directory, so stop looking */
594 idp
->current
.d_namlen
= isonum_711(ep
->name_len
);
596 if (reclen
< ISO_DIRECTORY_RECORD_SIZE
+ idp
->current
.d_namlen
) {
598 /* illegal entry, stop */
602 /* skip over associated files (Mac OS resource fork) */
603 if (isonum_711(ep
->flags
) & associatedBit
) {
604 idp
->curroff
+= reclen
;
605 entryoffsetinblock
+= reclen
;
609 if ( isonum_711(ep
->flags
) & directoryBit
)
610 idp
->current
.d_fileno
= isodirino(ep
, imp
);
612 idp
->current
.d_fileno
= (bp
->b_blkno
<< imp
->im_bshift
) + entryoffsetinblock
;
615 idp
->curroff
+= reclen
;
617 switch (imp
->iso_ftype
) {
619 cd9660_rrip_getname(ep
,idp
->current
.d_name
, &namelen
,
620 &idp
->current
.d_fileno
,imp
);
621 idp
->current
.d_namlen
= (u_char
)namelen
;
622 if (idp
->current
.d_namlen
)
623 error
= iso_uiodir(idp
,&idp
->current
,idp
->curroff
);
626 case ISO_FTYPE_JOLIET
:
627 ucsfntrans((u_int16_t
*)ep
->name
, idp
->current
.d_namlen
,
628 idp
->current
.d_name
, &namelen
,
629 isonum_711(ep
->flags
) & directoryBit
);
630 idp
->current
.d_namlen
= (u_char
)namelen
;
631 if (idp
->current
.d_namlen
)
632 error
= iso_uiodir(idp
,&idp
->current
,idp
->curroff
);
635 default: /* ISO_FTYPE_DEFAULT || ISO_FTYPE_9660 */
636 strcpy(idp
->current
.d_name
,"..");
637 switch (ep
->name
[0]) {
639 idp
->current
.d_namlen
= 1;
640 error
= iso_uiodir(idp
,&idp
->current
,idp
->curroff
);
643 idp
->current
.d_namlen
= 2;
644 error
= iso_uiodir(idp
,&idp
->current
,idp
->curroff
);
647 isofntrans(ep
->name
,idp
->current
.d_namlen
,
648 idp
->current
.d_name
, &namelen
,
649 imp
->iso_ftype
== ISO_FTYPE_9660
);
650 idp
->current
.d_namlen
= (u_char
)namelen
;
651 if (imp
->iso_ftype
== ISO_FTYPE_DEFAULT
)
652 error
= iso_shipdir(idp
);
654 error
= iso_uiodir(idp
,&idp
->current
,idp
->curroff
);
661 entryoffsetinblock
+= reclen
;
664 if (!error
&& imp
->iso_ftype
== ISO_FTYPE_DEFAULT
) {
665 idp
->current
.d_namlen
= 0;
666 error
= iso_shipdir(idp
);
669 if (!error
&& ap
->a_ncookies
) {
670 struct dirent
*dp
, *dpstart
;
676 * Only the NFS server uses cookies, and it loads the
677 * directory block into system space, so we can just look at
680 * We assume the entire transfer is done to a single contiguous buffer.
682 if (uio
->uio_segflg
!= UIO_SYSSPACE
|| uio
->uio_iovcnt
!= 1)
683 panic("ufs_readdir: lost in space");
686 * Make a first pass over the buffer just generated,
687 * counting the number of entries:
689 dpstart
= (struct dirent
*) (uio
->uio_iov
->iov_base
- (uio
->uio_offset
- startingOffset
));
690 for (dp
= dpstart
, bufferOffset
= startingOffset
, ncookies
= 0;
691 bufferOffset
< uio
->uio_offset
; ) {
692 if (dp
->d_reclen
== 0)
694 bufferOffset
+= dp
->d_reclen
;
696 dp
= (struct dirent
*)((caddr_t
)dp
+ dp
->d_reclen
);
698 lost
+= uio
->uio_offset
- bufferOffset
;
699 uio
->uio_offset
= bufferOffset
;
702 * Allocate a buffer to hold the cookies requested:
704 MALLOC(cookies
, u_long
*, ncookies
* sizeof(u_long
), M_TEMP
, M_WAITOK
);
705 *ap
->a_ncookies
= ncookies
;
706 *ap
->a_cookies
= cookies
;
709 * Fill in the offsets for each entry in the buffer just allocated:
711 for (bufferOffset
= startingOffset
, dp
= dpstart
; bufferOffset
< uio
->uio_offset
; ) {
712 *(cookies
++) = bufferOffset
;
713 bufferOffset
+= dp
->d_reclen
;
714 dp
= (struct dirent
*)((caddr_t
)dp
+ dp
->d_reclen
);
724 uio
->uio_offset
= idp
->uio_off
;
725 *ap
->a_eofflag
= idp
->eofflag
;
733 * Return target name of a symbolic link
734 * Shouldn't we get the parent vnode and read the data from there?
735 * This could eventually result in deadlocks in cd9660_lookup.
736 * But otherwise the block read here is in the block buffer two times.
738 typedef struct iso_directory_record ISODIR
;
739 typedef struct iso_node ISONODE
;
740 typedef struct iso_mnt ISOMNT
;
743 struct vop_readlink_args
/* {
746 struct ucred *a_cred;
762 if (imp
->iso_ftype
!= ISO_FTYPE_RRIP
)
766 * Get parents directory record block that this inode included.
768 error
= bread(imp
->im_devvp
,
769 (ip
->i_number
>> imp
->im_bshift
),
770 imp
->logical_block_size
, NOCRED
, &bp
);
777 * Setup the directory pointer for this inode
779 dirp
= (ISODIR
*)(bp
->b_data
+ (ip
->i_number
& imp
->im_bmask
));
782 * Just make sure, we have a right one....
783 * 1: Check not cross boundary on block
785 if ((ip
->i_number
& imp
->im_bmask
) + isonum_711(dirp
->length
)
786 > imp
->logical_block_size
) {
793 * Abuse a namei buffer for now.
795 if (uio
->uio_segflg
== UIO_SYSSPACE
)
796 symname
= uio
->uio_iov
->iov_base
;
798 MALLOC_ZONE(symname
, char *, MAXPATHLEN
, M_NAMEI
, M_WAITOK
);
801 * Ok, we just gathering a symbolic name in SL record.
803 if (cd9660_rrip_getsymname(dirp
, symname
, &symlen
, imp
) == 0) {
804 if (uio
->uio_segflg
!= UIO_SYSSPACE
)
805 FREE_ZONE(symname
, MAXPATHLEN
, M_NAMEI
);
810 * Don't forget before you leave from home ;-)
815 * return with the symbolic name to caller's.
817 if (uio
->uio_segflg
!= UIO_SYSSPACE
) {
818 error
= uiomove(symname
, symlen
, uio
);
819 FREE_ZONE(symname
, MAXPATHLEN
, M_NAMEI
);
822 uio
->uio_resid
-= symlen
;
823 uio
->uio_iov
->iov_base
+= symlen
;
824 uio
->uio_iov
->iov_len
-= symlen
;
829 * Ufs abort op, called after namei() when a CREATE/DELETE isn't actually
830 * done. If a buffer has been saved in anticipation of a CREATE, delete it.
834 struct vop_abortop_args
/* {
836 struct componentname *a_cnp;
839 if ((ap
->a_cnp
->cn_flags
& (HASBUF
| SAVESTART
)) == HASBUF
)
840 FREE_ZONE(ap
->a_cnp
->cn_pnbuf
, ap
->a_cnp
->cn_pnlen
, M_NAMEI
);
850 struct vop_lock_args
/* {
856 struct vnode
*vp
= ap
->a_vp
;
858 if (VTOI(vp
) == (struct iso_node
*) NULL
)
859 panic ("cd9660_lock: null inode");
860 return (lockmgr(&VTOI(vp
)->i_lock
, ap
->a_flags
, &vp
->v_interlock
,ap
->a_p
));
869 struct vop_unlock_args
/* {
875 struct vnode
*vp
= ap
->a_vp
;
877 return (lockmgr(&VTOI(vp
)->i_lock
, ap
->a_flags
| LK_RELEASE
, &vp
->v_interlock
,ap
->a_p
));
882 * Calculate the logical to physical mapping if not done already,
883 * then call the device strategy routine.
887 struct vop_strategy_args
/* {
891 register struct buf
*bp
= ap
->a_bp
;
892 register struct vnode
*vp
= bp
->b_vp
;
893 register struct iso_node
*ip
;
897 if (vp
->v_type
== VBLK
|| vp
->v_type
== VCHR
)
898 panic("cd9660_strategy: spec");
899 if (bp
->b_blkno
== bp
->b_lblkno
) {
900 if ( (error
= VOP_BMAP(vp
, bp
->b_lblkno
, NULL
, &bp
->b_blkno
, NULL
)) ) {
902 bp
->b_flags
|= B_ERROR
;
906 if ((long)bp
->b_blkno
== -1)
909 if ((long)bp
->b_blkno
== -1) {
914 bp
->b_dev
= vp
->v_rdev
;
915 VOCALL (vp
->v_op
, VOFFSET(vop_strategy
), ap
);
920 * Print out the contents of an inode.
924 struct vop_print_args
/* {
929 printf("tag VT_ISOFS, isofs vnode\n");
934 * Check for a locked inode.
938 struct vop_islocked_args
/* {
943 return (lockstatus(&VTOI(ap
->a_vp
)->i_lock
));
947 * Return POSIX pathconf information applicable to cd9660 filesystems.
951 struct vop_pathconf_args
/* {
954 register_t *a_retval;
958 switch (ap
->a_name
) {
963 switch (VTOI(ap
->a_vp
)->i_mnt
->iso_ftype
) {
965 *ap
->a_retval
= ISO_RRIP_NAMEMAX
;
967 case ISO_FTYPE_JOLIET
:
968 *ap
->a_retval
= ISO_JOLIET_NAMEMAX
;
971 *ap
->a_retval
= ISO_NAMEMAX
;
975 *ap
->a_retval
= PATH_MAX
;
978 *ap
->a_retval
= PIPE_BUF
;
980 case _PC_CHOWN_RESTRICTED
:
993 * Unsupported operation
1001 /* Pagein. similar to read */
1004 struct vop_pagein_args
/* {
1007 vm_offset_t a_pl_offset,
1010 struct ucred *a_cred,
1014 struct vnode
*vp
= ap
->a_vp
;
1015 upl_t pl
= ap
->a_pl
;
1016 size_t size
= ap
->a_size
;
1017 off_t f_offset
= ap
->a_f_offset
;
1018 vm_offset_t pl_offset
= ap
->a_pl_offset
;
1019 int flags
= ap
->a_flags
;
1020 register struct iso_node
*ip
= VTOI(vp
);
1021 int devBlockSize
=0, error
;
1023 /* check pageouts are for reg file only and ubc info is present*/
1025 panic("cd9660_pagein: Not a VREG");
1026 UBCINFOCHECK("cd9660_pagein", vp
);
1028 VOP_DEVBLOCKSIZE(ip
->i_devvp
, &devBlockSize
);
1030 error
= cluster_pagein(vp
, pl
, pl_offset
, f_offset
, size
,
1031 (off_t
)ip
->i_size
, devBlockSize
, flags
);
1036 * cd9660_remove - not possible to remove a file from iso cds
1038 * Locking policy: a_dvp and vp locked on entry, unlocked on exit
1042 struct vop_remove_args
/* { struct vnode *a_dvp; struct vnode *a_vp;
1043 struct componentname *a_cnp; } */ *ap
;
1045 if (ap
->a_dvp
== ap
->a_vp
)
1056 * cd9660_rmdir - not possible to remove a directory from iso cds
1058 * Locking policy: a_dvp and vp locked on entry, unlocked on exit
1062 struct vop_rmdir_args
/* { struct vnode *a_dvp; struct vnode *a_vp;
1063 struct componentname *a_cnp; } */ *ap
;
1065 (void) nop_rmdir(ap
);
1072 #% getattrlist vp = = =
1075 IN struct vnode *vp;
1076 IN struct attrlist *alist;
1077 INOUT struct uio *uio;
1078 IN struct ucred *cred;
1084 cd9660_getattrlist(ap
)
1085 struct vop_getattrlist_args
/* {
1087 struct attrlist *a_alist
1089 struct ucred *a_cred;
1093 struct attrlist
*alist
= ap
->a_alist
;
1102 if ((alist
->bitmapcount
!= ATTR_BIT_MAP_COUNT
) ||
1103 ((alist
->commonattr
& ~ATTR_CMN_VALIDMASK
) != 0) ||
1104 ((alist
->volattr
& ~ATTR_VOL_VALIDMASK
) != 0) ||
1105 ((alist
->dirattr
& ~ATTR_DIR_VALIDMASK
) != 0) ||
1106 ((alist
->fileattr
& ~ATTR_FILE_VALIDMASK
) != 0) ||
1107 ((alist
->forkattr
& ~ATTR_FORK_VALIDMASK
) != 0)) {
1112 * Requesting volume information requires setting the ATTR_VOL_INFO bit and
1113 * volume info requests are mutually exclusive with all other info requests:
1115 if ((alist
->volattr
!= 0) &&
1116 (((alist
->volattr
& ATTR_VOL_INFO
) == 0) ||
1117 (alist
->dirattr
!= 0) ||
1118 (alist
->fileattr
!= 0) ||
1119 (alist
->forkattr
!= 0) )) {
1124 * Reject requests for unsupported options for now:
1126 if (alist
->volattr
& ATTR_VOL_MOUNTPOINT
) return EINVAL
;
1127 if (alist
->commonattr
& (ATTR_CMN_NAMEDATTRCOUNT
| ATTR_CMN_NAMEDATTRLIST
)) return EINVAL
;
1128 if (alist
->fileattr
&
1129 (ATTR_FILE_FILETYPE
|
1130 ATTR_FILE_FORKCOUNT
|
1131 ATTR_FILE_FORKLIST
|
1132 ATTR_FILE_DATAEXTENTS
|
1133 ATTR_FILE_RSRCEXTENTS
)) {
1138 fixedblocksize
= attrcalcsize(alist
);
1139 attrblocksize
= fixedblocksize
+ (sizeof(u_long
)); /* u_long for length longword */
1140 if (alist
->commonattr
& ATTR_CMN_NAME
) attrblocksize
+= NAME_MAX
;
1141 if (alist
->commonattr
& ATTR_CMN_NAMEDATTRLIST
) attrblocksize
+= 0; /* XXX PPD */
1142 if (alist
->volattr
& ATTR_VOL_MOUNTPOINT
) attrblocksize
+= PATH_MAX
;
1143 if (alist
->volattr
& ATTR_VOL_NAME
) attrblocksize
+= NAME_MAX
;
1144 if (alist
->fileattr
& ATTR_FILE_FORKLIST
) attrblocksize
+= 0; /* XXX PPD */
1146 attrbufsize
= MIN(ap
->a_uio
->uio_resid
, attrblocksize
);
1147 MALLOC(attrbufptr
, void *, attrblocksize
, M_TEMP
, M_WAITOK
);
1148 attrptr
= attrbufptr
;
1149 *((u_long
*)attrptr
) = 0; /* Set buffer length in case of errors */
1150 ++((u_long
*)attrptr
); /* Reserve space for length field */
1151 varptr
= ((char *)attrptr
) + fixedblocksize
; /* Point to variable-length storage */
1153 packattrblk(alist
, ap
->a_vp
, &attrptr
, &varptr
);
1155 /* Store length of fixed + var block */
1156 *((u_long
*)attrbufptr
) = ((char*)varptr
- (char*)attrbufptr
);
1157 /* Don't copy out more data than was generated */
1158 attrbufsize
= MIN(attrbufsize
, (char*)varptr
- (char*)attrbufptr
);
1160 error
= uiomove((caddr_t
)attrbufptr
, attrbufsize
, ap
->a_uio
);
1162 FREE(attrbufptr
, M_TEMP
);
1168 * Global vfs data structures for isofs
1170 #define cd9660_create \
1171 ((int (*) __P((struct vop_create_args *)))err_create)
1172 #define cd9660_mknod ((int (*) __P((struct vop_mknod_args *)))err_mknod)
1173 #define cd9660_setattr \
1174 ((int (*) __P((struct vop_setattr_args *)))cd9660_enotsupp)
1175 #define cd9660_write ((int (*) __P((struct vop_write_args *)))cd9660_enotsupp)
1177 int lease_check
__P((struct vop_lease_args
*));
1178 #define cd9660_lease_check lease_check
1180 #define cd9660_lease_check ((int (*) __P((struct vop_lease_args *)))nullop)
1182 #define cd9660_fsync ((int (*) __P((struct vop_fsync_args *)))nullop)
1183 #define cd9660_rename \
1184 ((int (*) __P((struct vop_rename_args *)))err_rename)
1185 #define cd9660_copyfile \
1186 ((int (*) __P((struct vop_copyfile_args *)))err_copyfile)
1187 #define cd9660_link ((int (*) __P((struct vop_link_args *)))err_link)
1188 #define cd9660_mkdir ((int (*) __P((struct vop_mkdir_args *)))err_mkdir)
1189 #define cd9660_symlink \
1190 ((int (*) __P((struct vop_symlink_args *)))err_symlink)
1191 #define cd9660_advlock \
1192 ((int (*) __P((struct vop_advlock_args *)))cd9660_enotsupp)
1193 #define cd9660_valloc ((int(*) __P(( \
1194 struct vnode *pvp, \
1196 struct ucred *cred, \
1197 struct vnode **vpp))) cd9660_enotsupp)
1198 #define cd9660_vfree ((int (*) __P((struct vop_vfree_args *)))cd9660_enotsupp)
1199 #define cd9660_truncate \
1200 ((int (*) __P((struct vop_truncate_args *)))cd9660_enotsupp)
1201 #define cd9660_update \
1202 ((int (*) __P((struct vop_update_args *)))cd9660_enotsupp)
1203 #define cd9660_bwrite \
1204 ((int (*) __P((struct vop_bwrite_args *)))cd9660_enotsupp)
1205 #define cd9660_pageout \
1206 ((int (*) __P((struct vop_pageout_args *)))cd9660_enotsupp)
1207 int cd9660_blktooff(struct vop_blktooff_args
*ap
);
1208 int cd9660_offtoblk(struct vop_offtoblk_args
*ap
);
1209 int cd9660_cmap(struct vop_cmap_args
*ap
);
1211 #define VOPFUNC int (*)(void *)
1213 * Global vfs data structures for cd9660
1215 int (**cd9660_vnodeop_p
)(void *);
1216 struct vnodeopv_entry_desc cd9660_vnodeop_entries
[] = {
1217 { &vop_default_desc
, (VOPFUNC
)vn_default_error
},
1218 { &vop_lookup_desc
, (VOPFUNC
)cd9660_lookup
}, /* lookup */
1219 { &vop_create_desc
, (VOPFUNC
)cd9660_create
}, /* create */
1220 { &vop_mknod_desc
, (VOPFUNC
)cd9660_mknod
}, /* mknod */
1221 { &vop_open_desc
, (VOPFUNC
)cd9660_open
}, /* open */
1222 { &vop_close_desc
, (VOPFUNC
)cd9660_close
}, /* close */
1223 { &vop_access_desc
, (VOPFUNC
)cd9660_access
}, /* access */
1224 { &vop_getattr_desc
, (VOPFUNC
)cd9660_getattr
}, /* getattr */
1225 { &vop_setattr_desc
, (VOPFUNC
)cd9660_setattr
}, /* setattr */
1226 { &vop_read_desc
, (VOPFUNC
)cd9660_read
}, /* read */
1227 { &vop_write_desc
, (VOPFUNC
)cd9660_write
}, /* write */
1228 { &vop_lease_desc
, (VOPFUNC
)cd9660_lease_check
},/* lease */
1229 { &vop_ioctl_desc
, (VOPFUNC
)cd9660_ioctl
}, /* ioctl */
1230 { &vop_select_desc
, (VOPFUNC
)cd9660_select
}, /* select */
1231 { &vop_mmap_desc
, (VOPFUNC
)cd9660_mmap
}, /* mmap */
1232 { &vop_fsync_desc
, (VOPFUNC
)cd9660_fsync
}, /* fsync */
1233 { &vop_seek_desc
, (VOPFUNC
)cd9660_seek
}, /* seek */
1234 { &vop_remove_desc
, (VOPFUNC
)cd9660_remove
}, /* remove */
1235 { &vop_link_desc
, (VOPFUNC
)cd9660_link
}, /* link */
1236 { &vop_rename_desc
, (VOPFUNC
)cd9660_rename
}, /* rename */
1237 { &vop_copyfile_desc
, (VOPFUNC
)cd9660_copyfile
},/* copyfile */
1238 { &vop_mkdir_desc
, (VOPFUNC
)cd9660_mkdir
}, /* mkdir */
1239 { &vop_rmdir_desc
, (VOPFUNC
)cd9660_rmdir
}, /* rmdir */
1240 { &vop_symlink_desc
, (VOPFUNC
)cd9660_symlink
}, /* symlink */
1241 { &vop_readdir_desc
, (VOPFUNC
)cd9660_readdir
}, /* readdir */
1242 { &vop_readlink_desc
, (VOPFUNC
)cd9660_readlink
},/* readlink */
1243 { &vop_abortop_desc
, (VOPFUNC
)cd9660_abortop
}, /* abortop */
1244 { &vop_inactive_desc
, (VOPFUNC
)cd9660_inactive
},/* inactive */
1245 { &vop_reclaim_desc
, (VOPFUNC
)cd9660_reclaim
}, /* reclaim */
1246 { &vop_lock_desc
, (VOPFUNC
)cd9660_lock
}, /* lock */
1247 { &vop_unlock_desc
, (VOPFUNC
)cd9660_unlock
}, /* unlock */
1248 { &vop_bmap_desc
, (VOPFUNC
)cd9660_bmap
}, /* bmap */
1249 { &vop_strategy_desc
, (VOPFUNC
)cd9660_strategy
},/* strategy */
1250 { &vop_print_desc
, (VOPFUNC
)cd9660_print
}, /* print */
1251 { &vop_islocked_desc
, (VOPFUNC
)cd9660_islocked
},/* islocked */
1252 { &vop_pathconf_desc
, (VOPFUNC
)cd9660_pathconf
},/* pathconf */
1253 { &vop_advlock_desc
, (VOPFUNC
)cd9660_advlock
}, /* advlock */
1254 { &vop_blkatoff_desc
, (VOPFUNC
)cd9660_blkatoff
},/* blkatoff */
1255 { &vop_valloc_desc
, (VOPFUNC
)cd9660_valloc
}, /* valloc */
1256 { &vop_vfree_desc
, (VOPFUNC
)cd9660_vfree
}, /* vfree */
1257 { &vop_truncate_desc
, (VOPFUNC
)cd9660_truncate
},/* truncate */
1258 { &vop_update_desc
, (VOPFUNC
)cd9660_update
}, /* update */
1259 { &vop_bwrite_desc
, (VOPFUNC
)vn_bwrite
},
1260 { &vop_pagein_desc
, (VOPFUNC
)cd9660_pagein
}, /* Pagein */
1261 { &vop_pageout_desc
, (VOPFUNC
)cd9660_pageout
}, /* Pageout */
1262 { &vop_getattrlist_desc
, (VOPFUNC
)cd9660_getattrlist
}, /* getattrlist */
1263 { &vop_blktooff_desc
, (VOPFUNC
)cd9660_blktooff
}, /* blktooff */
1264 { &vop_offtoblk_desc
, (VOPFUNC
)cd9660_offtoblk
}, /* offtoblk */
1265 { &vop_cmap_desc
, (VOPFUNC
)cd9660_cmap
}, /* cmap */
1266 { (struct vnodeop_desc
*)NULL
, (VOPFUNC
)NULL
}
1268 struct vnodeopv_desc cd9660_vnodeop_opv_desc
=
1269 { &cd9660_vnodeop_p
, cd9660_vnodeop_entries
};
1272 * Special device vnode ops
1274 int (**cd9660_specop_p
)(void *);
1275 struct vnodeopv_entry_desc cd9660_specop_entries
[] = {
1276 { &vop_default_desc
, (VOPFUNC
)vn_default_error
},
1277 { &vop_lookup_desc
, (VOPFUNC
)spec_lookup
}, /* lookup */
1278 { &vop_create_desc
, (VOPFUNC
)spec_create
}, /* create */
1279 { &vop_mknod_desc
, (VOPFUNC
)spec_mknod
}, /* mknod */
1280 { &vop_open_desc
, (VOPFUNC
)spec_open
}, /* open */
1281 { &vop_close_desc
, (VOPFUNC
)spec_close
}, /* close */
1282 { &vop_access_desc
, (VOPFUNC
)cd9660_access
}, /* access */
1283 { &vop_getattr_desc
, (VOPFUNC
)cd9660_getattr
}, /* getattr */
1284 { &vop_setattr_desc
, (VOPFUNC
)cd9660_setattr
}, /* setattr */
1285 { &vop_read_desc
, (VOPFUNC
)spec_read
}, /* read */
1286 { &vop_write_desc
, (VOPFUNC
)spec_write
}, /* write */
1287 { &vop_lease_desc
, (VOPFUNC
)spec_lease_check
}, /* lease */
1288 { &vop_ioctl_desc
, (VOPFUNC
)spec_ioctl
}, /* ioctl */
1289 { &vop_select_desc
, (VOPFUNC
)spec_select
}, /* select */
1290 { &vop_mmap_desc
, (VOPFUNC
)spec_mmap
}, /* mmap */
1291 { &vop_fsync_desc
, (VOPFUNC
)spec_fsync
}, /* fsync */
1292 { &vop_seek_desc
, (VOPFUNC
)spec_seek
}, /* seek */
1293 { &vop_remove_desc
, (VOPFUNC
)spec_remove
}, /* remove */
1294 { &vop_link_desc
, (VOPFUNC
)spec_link
}, /* link */
1295 { &vop_rename_desc
, (VOPFUNC
)spec_rename
}, /* rename */
1296 { &vop_mkdir_desc
, (VOPFUNC
)spec_mkdir
}, /* mkdir */
1297 { &vop_rmdir_desc
, (VOPFUNC
)spec_rmdir
}, /* rmdir */
1298 { &vop_symlink_desc
, (VOPFUNC
)spec_symlink
}, /* symlink */
1299 { &vop_readdir_desc
, (VOPFUNC
)spec_readdir
}, /* readdir */
1300 { &vop_readlink_desc
, (VOPFUNC
)spec_readlink
}, /* readlink */
1301 { &vop_abortop_desc
, (VOPFUNC
)spec_abortop
}, /* abortop */
1302 { &vop_inactive_desc
, (VOPFUNC
)cd9660_inactive
},/* inactive */
1303 { &vop_reclaim_desc
, (VOPFUNC
)cd9660_reclaim
}, /* reclaim */
1304 { &vop_lock_desc
, (VOPFUNC
)cd9660_lock
}, /* lock */
1305 { &vop_unlock_desc
, (VOPFUNC
)cd9660_unlock
}, /* unlock */
1306 { &vop_bmap_desc
, (VOPFUNC
)spec_bmap
}, /* bmap */
1307 { &vop_strategy_desc
, (VOPFUNC
)spec_strategy
}, /* strategy */
1308 { &vop_print_desc
, (VOPFUNC
)cd9660_print
}, /* print */
1309 { &vop_islocked_desc
, (VOPFUNC
)cd9660_islocked
},/* islocked */
1310 { &vop_pathconf_desc
, (VOPFUNC
)spec_pathconf
}, /* pathconf */
1311 { &vop_advlock_desc
, (VOPFUNC
)spec_advlock
}, /* advlock */
1312 { &vop_blkatoff_desc
, (VOPFUNC
)spec_blkatoff
}, /* blkatoff */
1313 { &vop_valloc_desc
, (VOPFUNC
)spec_valloc
}, /* valloc */
1314 { &vop_vfree_desc
, (VOPFUNC
)spec_vfree
}, /* vfree */
1315 { &vop_truncate_desc
, (VOPFUNC
)spec_truncate
}, /* truncate */
1316 { &vop_update_desc
, (VOPFUNC
)cd9660_update
}, /* update */
1317 { &vop_bwrite_desc
, (VOPFUNC
)vn_bwrite
},
1318 { &vop_devblocksize_desc
, (VOPFUNC
)spec_devblocksize
}, /* devblocksize */
1319 { &vop_pagein_desc
, (VOPFUNC
)cd9660_pagein
}, /* Pagein */
1320 { &vop_pageout_desc
, (VOPFUNC
)cd9660_pageout
}, /* Pageout */
1321 { &vop_blktooff_desc
, (VOPFUNC
)cd9660_blktooff
}, /* blktooff */
1322 { &vop_offtoblk_desc
, (VOPFUNC
)cd9660_offtoblk
}, /* offtoblk */
1323 { &vop_cmap_desc
, (VOPFUNC
)cd9660_cmap
}, /* cmap */
1324 { (struct vnodeop_desc
*)NULL
, (VOPFUNC
)NULL
}
1326 struct vnodeopv_desc cd9660_specop_opv_desc
=
1327 { &cd9660_specop_p
, cd9660_specop_entries
};
1330 int (**cd9660_fifoop_p
)(void *);
1331 struct vnodeopv_entry_desc cd9660_fifoop_entries
[] = {
1332 { &vop_default_desc
, (VOPFUNC
)vn_default_error
},
1333 { &vop_lookup_desc
, (VOPFUNC
)fifo_lookup
}, /* lookup */
1334 { &vop_create_desc
, (VOPFUNC
)fifo_create
}, /* create */
1335 { &vop_mknod_desc
, (VOPFUNC
)fifo_mknod
}, /* mknod */
1336 { &vop_open_desc
, (VOPFUNC
)fifo_open
}, /* open */
1337 { &vop_close_desc
, (VOPFUNC
)fifo_close
}, /* close */
1338 { &vop_access_desc
, (VOPFUNC
)cd9660_access
}, /* access */
1339 { &vop_getattr_desc
, (VOPFUNC
)cd9660_getattr
}, /* getattr */
1340 { &vop_setattr_desc
, (VOPFUNC
)cd9660_setattr
}, /* setattr */
1341 { &vop_read_desc
, (VOPFUNC
)fifo_read
}, /* read */
1342 { &vop_write_desc
, (VOPFUNC
)fifo_write
}, /* write */
1343 { &vop_lease_desc
, (VOPFUNC
)fifo_lease_check
}, /* lease */
1344 { &vop_ioctl_desc
, (VOPFUNC
)fifo_ioctl
}, /* ioctl */
1345 { &vop_select_desc
, (VOPFUNC
)fifo_select
}, /* select */
1346 { &vop_mmap_desc
, (VOPFUNC
)fifo_mmap
}, /* mmap */
1347 { &vop_fsync_desc
, (VOPFUNC
)fifo_fsync
}, /* fsync */
1348 { &vop_seek_desc
, (VOPFUNC
)fifo_seek
}, /* seek */
1349 { &vop_remove_desc
, (VOPFUNC
)fifo_remove
}, /* remove */
1350 { &vop_link_desc
, (VOPFUNC
)fifo_link
} , /* link */
1351 { &vop_rename_desc
, (VOPFUNC
)fifo_rename
}, /* rename */
1352 { &vop_mkdir_desc
, (VOPFUNC
)fifo_mkdir
}, /* mkdir */
1353 { &vop_rmdir_desc
, (VOPFUNC
)fifo_rmdir
}, /* rmdir */
1354 { &vop_symlink_desc
, (VOPFUNC
)fifo_symlink
}, /* symlink */
1355 { &vop_readdir_desc
, (VOPFUNC
)fifo_readdir
}, /* readdir */
1356 { &vop_readlink_desc
, (VOPFUNC
)fifo_readlink
}, /* readlink */
1357 { &vop_abortop_desc
, (VOPFUNC
)fifo_abortop
}, /* abortop */
1358 { &vop_inactive_desc
, (VOPFUNC
)cd9660_inactive
},/* inactive */
1359 { &vop_reclaim_desc
, (VOPFUNC
)cd9660_reclaim
}, /* reclaim */
1360 { &vop_lock_desc
, (VOPFUNC
)cd9660_lock
}, /* lock */
1361 { &vop_unlock_desc
, (VOPFUNC
)cd9660_unlock
}, /* unlock */
1362 { &vop_bmap_desc
, (VOPFUNC
)fifo_bmap
}, /* bmap */
1363 { &vop_strategy_desc
, (VOPFUNC
)fifo_strategy
}, /* strategy */
1364 { &vop_print_desc
, (VOPFUNC
)cd9660_print
}, /* print */
1365 { &vop_islocked_desc
, (VOPFUNC
)cd9660_islocked
},/* islocked */
1366 { &vop_pathconf_desc
, (VOPFUNC
)fifo_pathconf
}, /* pathconf */
1367 { &vop_advlock_desc
, (VOPFUNC
)fifo_advlock
}, /* advlock */
1368 { &vop_blkatoff_desc
, (VOPFUNC
)fifo_blkatoff
}, /* blkatoff */
1369 { &vop_valloc_desc
, (VOPFUNC
)fifo_valloc
}, /* valloc */
1370 { &vop_vfree_desc
, (VOPFUNC
)fifo_vfree
}, /* vfree */
1371 { &vop_truncate_desc
, (VOPFUNC
)fifo_truncate
}, /* truncate */
1372 { &vop_update_desc
, (VOPFUNC
)cd9660_update
}, /* update */
1373 { &vop_bwrite_desc
, (VOPFUNC
)vn_bwrite
},
1374 { &vop_pagein_desc
, (VOPFUNC
)cd9660_pagein
}, /* Pagein */
1375 { &vop_pageout_desc
, (VOPFUNC
)cd9660_pageout
}, /* Pageout */
1376 { &vop_blktooff_desc
, (VOPFUNC
)cd9660_blktooff
}, /* blktooff */
1377 { &vop_offtoblk_desc
, (VOPFUNC
)cd9660_offtoblk
}, /* offtoblk */
1378 { (struct vnodeop_desc
*)NULL
, (VOPFUNC
)NULL
}
1380 struct vnodeopv_desc cd9660_fifoop_opv_desc
=
1381 { &cd9660_fifoop_p
, cd9660_fifoop_entries
};