Deleted Added
full compact
cd9660_vnops.c (111741) cd9660_vnops.c (111742)
1/*-
2 * Copyright (c) 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley
6 * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
7 * Support code is derived from software contributed to Berkeley
8 * by Atsushi Murai (amurai@spec.co.jp).

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)cd9660_vnops.c 8.19 (Berkeley) 5/27/95
1/*-
2 * Copyright (c) 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley
6 * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
7 * Support code is derived from software contributed to Berkeley
8 * by Atsushi Murai (amurai@spec.co.jp).

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)cd9660_vnops.c 8.19 (Berkeley) 5/27/95
39 * $FreeBSD: head/sys/fs/cd9660/cd9660_vnops.c 111741 2003-03-02 15:50:23Z des $
39 * $FreeBSD: head/sys/fs/cd9660/cd9660_vnops.c 111742 2003-03-02 15:56:49Z des $
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/namei.h>
45#include <sys/kernel.h>
46#include <sys/stat.h>
47#include <sys/bio.h>

--- 38 unchanged lines hidden (view full) ---

86 struct vattr *a_vap;
87 struct ucred *a_cred;
88 struct thread *a_td;
89 } */ *ap;
90{
91 struct vnode *vp = ap->a_vp;
92 struct vattr *vap = ap->a_vap;
93
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/namei.h>
45#include <sys/kernel.h>
46#include <sys/stat.h>
47#include <sys/bio.h>

--- 38 unchanged lines hidden (view full) ---

86 struct vattr *a_vap;
87 struct ucred *a_cred;
88 struct thread *a_td;
89 } */ *ap;
90{
91 struct vnode *vp = ap->a_vp;
92 struct vattr *vap = ap->a_vap;
93
94 if (vap->va_flags != (u_long)VNOVAL || vap->va_uid != (uid_t)VNOVAL ||
94 if (vap->va_flags != (u_long)VNOVAL || vap->va_uid != (uid_t)VNOVAL ||
95 vap->va_gid != (gid_t)VNOVAL || vap->va_atime.tv_sec != VNOVAL ||
96 vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL)
97 return (EROFS);
98 if (vap->va_size != (u_quad_t)VNOVAL) {
95 vap->va_gid != (gid_t)VNOVAL || vap->va_atime.tv_sec != VNOVAL ||
96 vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL)
97 return (EROFS);
98 if (vap->va_size != (u_quad_t)VNOVAL) {
99 switch (vp->v_type) {
100 case VDIR:
101 return (EISDIR);
99 switch (vp->v_type) {
100 case VDIR:
101 return (EISDIR);
102 case VLNK:
103 case VREG:
104 return (EROFS);
102 case VLNK:
103 case VREG:
104 return (EROFS);
105 case VCHR:
106 case VBLK:
107 case VSOCK:
108 case VFIFO:
105 case VCHR:
106 case VBLK:
107 case VSOCK:
108 case VFIFO:
109 case VNON:
110 case VBAD:
111 return (0);
112 }
113 }
114 return (0);
115}
116

--- 43 unchanged lines hidden (view full) ---

160 struct vnode *a_vp;
161 struct vattr *a_vap;
162 struct ucred *a_cred;
163 struct thread *a_td;
164 } */ *ap;
165
166{
167 struct vnode *vp = ap->a_vp;
109 case VNON:
110 case VBAD:
111 return (0);
112 }
113 }
114 return (0);
115}
116

--- 43 unchanged lines hidden (view full) ---

160 struct vnode *a_vp;
161 struct vattr *a_vap;
162 struct ucred *a_cred;
163 struct thread *a_td;
164 } */ *ap;
165
166{
167 struct vnode *vp = ap->a_vp;
168 register struct vattr *vap = ap->a_vap;
169 register struct iso_node *ip = VTOI(vp);
168 struct vattr *vap = ap->a_vap;
169 struct iso_node *ip = VTOI(vp);
170
171 vap->va_fsid = dev2udev(ip->i_dev);
172
173 /*
174 * Don't use ip->i_ino for this since it is wrong for hard links.
175 * ip->i_ino should be the same as ip->iso_start (or not exist),
176 * but this currently doesn't work since we abuse it to look up
177 * parent directories from inodes.

--- 54 unchanged lines hidden (view full) ---

232 int a_fflag;
233 struct ucred *a_cred;
234 struct thread *a_td;
235 } */ *ap;
236{
237 struct vnode *vp = ap->a_vp;
238 struct iso_node *ip = VTOI(vp);
239
170
171 vap->va_fsid = dev2udev(ip->i_dev);
172
173 /*
174 * Don't use ip->i_ino for this since it is wrong for hard links.
175 * ip->i_ino should be the same as ip->iso_start (or not exist),
176 * but this currently doesn't work since we abuse it to look up
177 * parent directories from inodes.

--- 54 unchanged lines hidden (view full) ---

232 int a_fflag;
233 struct ucred *a_cred;
234 struct thread *a_td;
235 } */ *ap;
236{
237 struct vnode *vp = ap->a_vp;
238 struct iso_node *ip = VTOI(vp);
239
240 switch (ap->a_command) {
240 switch (ap->a_command) {
241
241
242 case FIOGETLBA:
242 case FIOGETLBA:
243 *(int *)(ap->a_data) = ip->iso_start;
244 return 0;
243 *(int *)(ap->a_data) = ip->iso_start;
244 return 0;
245 default:
246 return (ENOTTY);
247 }
245 default:
246 return (ENOTTY);
247 }
248}
249
250/*
251 * Vnode op for reading.
252 */
253static int
254cd9660_read(ap)
255 struct vop_read_args /* {
256 struct vnode *a_vp;
257 struct uio *a_uio;
258 int a_ioflag;
259 struct ucred *a_cred;
260 } */ *ap;
261{
262 struct vnode *vp = ap->a_vp;
248}
249
250/*
251 * Vnode op for reading.
252 */
253static int
254cd9660_read(ap)
255 struct vop_read_args /* {
256 struct vnode *a_vp;
257 struct uio *a_uio;
258 int a_ioflag;
259 struct ucred *a_cred;
260 } */ *ap;
261{
262 struct vnode *vp = ap->a_vp;
263 register struct uio *uio = ap->a_uio;
264 register struct iso_node *ip = VTOI(vp);
265 register struct iso_mnt *imp;
263 struct uio *uio = ap->a_uio;
264 struct iso_node *ip = VTOI(vp);
265 struct iso_mnt *imp;
266 struct buf *bp;
267 daddr_t lbn, rablock;
268 off_t diff;
269 int rasize, error = 0;
270 int seqcount;
271 long size, n, on;
272
273 seqcount = ap->a_ioflag >> 16;

--- 14 unchanged lines hidden (view full) ---

288 return (0);
289 if (diff < n)
290 n = diff;
291 size = blksize(imp, ip, lbn);
292 rablock = lbn + 1;
293 if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) {
294 if (lblktosize(imp, rablock) < ip->i_size)
295 error = cluster_read(vp, (off_t)ip->i_size,
266 struct buf *bp;
267 daddr_t lbn, rablock;
268 off_t diff;
269 int rasize, error = 0;
270 int seqcount;
271 long size, n, on;
272
273 seqcount = ap->a_ioflag >> 16;

--- 14 unchanged lines hidden (view full) ---

288 return (0);
289 if (diff < n)
290 n = diff;
291 size = blksize(imp, ip, lbn);
292 rablock = lbn + 1;
293 if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) {
294 if (lblktosize(imp, rablock) < ip->i_size)
295 error = cluster_read(vp, (off_t)ip->i_size,
296 lbn, size, NOCRED, uio->uio_resid,
296 lbn, size, NOCRED, uio->uio_resid,
297 (ap->a_ioflag >> 16), &bp);
298 else
299 error = bread(vp, lbn, size, NOCRED, &bp);
300 } else {
301 if (seqcount > 1 &&
302 lblktosize(imp, rablock) < ip->i_size) {
303 rasize = blksize(imp, ip, rablock);
304 error = breadn(vp, lbn, size, &rablock,

--- 121 unchanged lines hidden (view full) ---

426 struct vnode *a_vp;
427 struct uio *a_uio;
428 struct ucred *a_cred;
429 int *a_eofflag;
430 int *a_ncookies;
431 u_long *a_cookies;
432 } */ *ap;
433{
297 (ap->a_ioflag >> 16), &bp);
298 else
299 error = bread(vp, lbn, size, NOCRED, &bp);
300 } else {
301 if (seqcount > 1 &&
302 lblktosize(imp, rablock) < ip->i_size) {
303 rasize = blksize(imp, ip, rablock);
304 error = breadn(vp, lbn, size, &rablock,

--- 121 unchanged lines hidden (view full) ---

426 struct vnode *a_vp;
427 struct uio *a_uio;
428 struct ucred *a_cred;
429 int *a_eofflag;
430 int *a_ncookies;
431 u_long *a_cookies;
432 } */ *ap;
433{
434 register struct uio *uio = ap->a_uio;
434 struct uio *uio = ap->a_uio;
435 struct isoreaddir *idp;
436 struct vnode *vdp = ap->a_vp;
437 struct iso_node *dp;
438 struct iso_mnt *imp;
439 struct buf *bp = NULL;
440 struct iso_directory_record *ep;
441 int entryoffsetinblock;
442 doff_t endsearch;

--- 224 unchanged lines hidden (view full) ---

667 /*
668 * Now get a buffer
669 * Abuse a namei buffer for now.
670 */
671 if (uio->uio_segflg == UIO_SYSSPACE)
672 symname = uio->uio_iov->iov_base;
673 else
674 symname = uma_zalloc(namei_zone, M_WAITOK);
435 struct isoreaddir *idp;
436 struct vnode *vdp = ap->a_vp;
437 struct iso_node *dp;
438 struct iso_mnt *imp;
439 struct buf *bp = NULL;
440 struct iso_directory_record *ep;
441 int entryoffsetinblock;
442 doff_t endsearch;

--- 224 unchanged lines hidden (view full) ---

667 /*
668 * Now get a buffer
669 * Abuse a namei buffer for now.
670 */
671 if (uio->uio_segflg == UIO_SYSSPACE)
672 symname = uio->uio_iov->iov_base;
673 else
674 symname = uma_zalloc(namei_zone, M_WAITOK);
675
675
676 /*
677 * Ok, we just gathering a symbolic name in SL record.
678 */
679 if (cd9660_rrip_getsymname(dirp, symname, &symlen, imp) == 0) {
680 if (uio->uio_segflg != UIO_SYSSPACE)
681 uma_zfree(namei_zone, symname);
682 brelse(bp);
683 return (EINVAL);

--- 23 unchanged lines hidden (view full) ---

707 */
708static int
709cd9660_strategy(ap)
710 struct vop_strategy_args /* {
711 struct buf *a_vp;
712 struct buf *a_bp;
713 } */ *ap;
714{
676 /*
677 * Ok, we just gathering a symbolic name in SL record.
678 */
679 if (cd9660_rrip_getsymname(dirp, symname, &symlen, imp) == 0) {
680 if (uio->uio_segflg != UIO_SYSSPACE)
681 uma_zfree(namei_zone, symname);
682 brelse(bp);
683 return (EINVAL);

--- 23 unchanged lines hidden (view full) ---

707 */
708static int
709cd9660_strategy(ap)
710 struct vop_strategy_args /* {
711 struct buf *a_vp;
712 struct buf *a_bp;
713 } */ *ap;
714{
715 register struct buf *bp = ap->a_bp;
716 register struct vnode *vp = bp->b_vp;
717 register struct iso_node *ip;
715 struct buf *bp = ap->a_bp;
716 struct vnode *vp = bp->b_vp;
717 struct iso_node *ip;
718
719 ip = VTOI(vp);
720 if (vp->v_type == VBLK || vp->v_type == VCHR)
721 panic("cd9660_strategy: spec");
722 if (bp->b_blkno == bp->b_lblkno) {
718
719 ip = VTOI(vp);
720 if (vp->v_type == VBLK || vp->v_type == VCHR)
721 panic("cd9660_strategy: spec");
722 if (bp->b_blkno == bp->b_lblkno) {
723 bp->b_blkno = (ip->iso_start + bp->b_lblkno) <<
723 bp->b_blkno = (ip->iso_start + bp->b_lblkno) <<
724 (ip->i_mnt->im_bshift - DEV_BSHIFT);
725 if ((long)bp->b_blkno == -1) /* XXX: cut&paste junk ? */
726 clrbuf(bp);
727 }
728 if ((long)bp->b_blkno == -1) { /* XXX: cut&paste junk ? */
729 bufdone(bp);
730 return (0);
731 }

--- 106 unchanged lines hidden ---
724 (ip->i_mnt->im_bshift - DEV_BSHIFT);
725 if ((long)bp->b_blkno == -1) /* XXX: cut&paste junk ? */
726 clrbuf(bp);
727 }
728 if ((long)bp->b_blkno == -1) { /* XXX: cut&paste junk ? */
729 bufdone(bp);
730 return (0);
731 }

--- 106 unchanged lines hidden ---