More redux.

This commit is contained in:
mycroft 1994-07-19 15:07:36 +00:00
parent 1656a89476
commit f8fae0f555
4 changed files with 54 additions and 50 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd9660_lookup.c,v 1.6 1994/07/19 14:14:10 mycroft Exp $ */
/* $NetBSD: cd9660_lookup.c,v 1.7 1994/07/19 15:07:36 mycroft Exp $ */
/*-
* Copyright (c) 1989, 1993, 1994
@ -108,6 +108,7 @@ cd9660_lookup(ap)
doff_t endsearch; /* offset to end directory search */
struct vnode *pdp; /* saved dp during symlink work */
struct vnode *tdp; /* returned by cd9660_vget_internal */
u_long bmask; /* block offset mask */
int lockparent; /* 1 => lockparent flag is set */
int wantparent; /* 1 => wantparent or lockparent flag */
int error;
@ -217,6 +218,7 @@ cd9660_lookup(ap)
* profiling time and hence has been removed in the interest
* of simplicity.
*/
bmask = imp->im_bmask;
if (nameiop != LOOKUP || dp->i_diroff == 0 ||
dp->i_diroff > dp->i_size) {
entryoffsetinblock = 0;
@ -224,9 +226,8 @@ cd9660_lookup(ap)
numdirpasses = 1;
} else {
dp->i_offset = dp->i_diroff;
entryoffsetinblock = blkoff(imp, dp->i_offset);
if (entryoffsetinblock != 0) {
if (error = VOP_BLKATOFF(vdp, dp->i_offset, NULL, &bp))
if ((entryoffsetinblock = dp->i_offset & bmask) &&
(error = VOP_BLKATOFF(vdp, (off_t)dp->i_offset, NULL, &bp)))
return (error);
}
numdirpasses = 2;
@ -241,10 +242,11 @@ searchloop:
* read the next directory block.
* Release previous if it exists.
*/
if (blkoff(imp, dp->i_offset) == 0) {
if ((dp->i_offset & bmask) == 0)
if (bp != NULL)
brelse(bp);
if (error = VOP_BLKATOFF(vdp, dp->i_offset, NULL, &bp))
if (error =
VOP_BLKATOFF(vdp, (off_t)dp->i_offset, NULL, &bp))
return (error);
entryoffsetinblock = 0;
}
@ -252,13 +254,12 @@ searchloop:
* Get pointer to next entry.
*/
ep = (struct iso_directory_record *)
(bp->b_data + entryoffsetinblock);
((char *)bp->b_data + entryoffsetinblock);
reclen = isonum_711 (ep->length);
reclen = isonum_711(ep->length);
if (reclen == 0) {
/* skip to next block, if any */
dp->i_offset =
(dp->i_offset + imp->im_bmask) & ~imp->im_bmask;
dp->i_offset = (dp->i_offset + bmask) & ~bmask;
continue;
}
@ -270,15 +271,15 @@ searchloop:
/* entries are not allowed to cross boundaries */
break;
/*
* Check for a name match.
*/
namelen = isonum_711(ep->name_len);
if (reclen < ISO_DIRECTORY_RECORD_SIZE + namelen)
/* illegal entry, stop */
break;
/*
* Check for a name match.
*/
switch (imp->iso_ftype) {
default:
if ((!(isonum_711(ep->flags)&4)) == !assoc) {
@ -340,8 +341,8 @@ foundino:
lblkno(imp, saveoffset)) {
if (bp != NULL)
brelse(bp);
if (error = VOP_BLKATOFF(vdp, saveoffset, NULL,
&bp))
if (error = VOP_BLKATOFF(vdp,
(off_t)saveoffset, NULL, &bp))
return (error);
}
ep = (struct iso_directory_record *)

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd9660_node.c,v 1.7 1994/07/19 14:14:12 mycroft Exp $ */
/* $NetBSD: cd9660_node.c,v 1.8 1994/07/19 15:07:37 mycroft Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1994
@ -298,7 +298,8 @@ cd9660_defattr(isodir, inop, bp)
if (!bp
&& ((imp = inop->i_mnt)->im_flags & ISOFSMNT_EXTATT)
&& (off = isonum_711(isodir->ext_attr_length))) {
VOP_BLKATOFF(ITOV(inop), -off << imp->im_bshift, NULL, &bp2);
VOP_BLKATOFF(ITOV(inop), (off_t)(-off << imp->im_bshift), NULL,
&bp2);
bp = bp2;
}
if (bp) {
@ -348,7 +349,8 @@ cd9660_deftstamp(isodir,inop,bp)
if (!bp
&& ((imp = inop->i_mnt)->im_flags & ISOFSMNT_EXTATT)
&& (off = isonum_711(isodir->ext_attr_length))) {
VOP_BLKATOFF(ITOV(inop), -off << imp->im_bshift, NULL, &bp2);
VOP_BLKATOFF(ITOV(inop), (off_t)(-off << imp->im_bshift), NULL,
&bp2);
bp = bp2;
}
if (bp) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd9660_vfsops.c,v 1.7 1994/07/19 14:14:16 mycroft Exp $ */
/* $NetBSD: cd9660_vfsops.c,v 1.8 1994/07/19 15:07:39 mycroft Exp $ */
/*-
* Copyright (c) 1994
@ -708,7 +708,7 @@ cd9660_vget_internal(mp, ino, vpp, relocated, isodir)
ip->iso_start = ino >> imp->im_bshift;
if (bp != 0)
brelse(bp);
if (error = VOP_BLKATOFF(vp, 0, NULL, &bp)) {
if (error = VOP_BLKATOFF(vp, (off_t)0, NULL, &bp)) {
vput(vp);
return (error);
}
@ -730,7 +730,8 @@ cd9660_vget_internal(mp, ino, vpp, relocated, isodir)
int off;
if ((imp->im_flags & ISOFSMNT_EXTATT)
&& (off = isonum_711(isodir->ext_attr_length)))
VOP_BLKATOFF(vp, -off << imp->im_bshift, NULL, &bp2);
VOP_BLKATOFF(vp, (off_t)(-off << imp->im_bshift), NULL,
&bp2);
else
bp2 = NULL;
cd9660_defattr(isodir, ip, bp2);

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd9660_vnops.c,v 1.9 1994/07/19 14:14:18 mycroft Exp $ */
/* $NetBSD: cd9660_vnops.c,v 1.10 1994/07/19 15:07:41 mycroft Exp $ */
/*-
* Copyright (c) 1994
@ -513,21 +513,23 @@ cd9660_readdir(ap)
int a_ncookies;
} */ *ap;
{
struct vnode *vp = ap->a_vp;
register struct uio *uio = ap->a_uio;
struct isoreaddir *idp;
int entryoffsetinblock;
int error = 0;
int endsearch;
struct iso_directory_record *ep;
u_short elen;
int reclen;
struct vnode *vdp = ap->a_vp;
struct iso_node *dp;
struct iso_mnt *imp;
struct iso_node *ip;
struct buf *bp = NULL;
struct iso_directory_record *ep;
int entryoffsetinblock;
doff_t endsearch;
u_long bmask;
int error = 0;
int reclen;
u_short namelen;
ip = VTOI(vp);
imp = ip->i_mnt;
dp = VTOI(vdp);
imp = dp->i_mnt;
bmask = imp->im_bmask;
MALLOC(idp, struct isoreaddir *, sizeof(*idp), M_TEMP, M_WAITOK);
idp->saveent.d_namlen = idp->assocent.d_namlen = 0;
@ -543,14 +545,12 @@ cd9660_readdir(ap)
idp->ncookies = ap->a_ncookies;
idp->curroff = uio->uio_offset;
entryoffsetinblock = blkoff(imp, idp->curroff);
if (entryoffsetinblock != 0) {
if (error = VOP_BLKATOFF(vp, idp->curroff, NULL, &bp)) {
FREE(idp,M_TEMP);
return (error);
}
if ((entryoffsetinblock = idp->curroff & bmask) &&
(error = VOP_BLKATOFF(vdp, (off_t)idp->curroff, NULL, &bp))) {
FREE(idp, M_TEMP);
return (error);
}
endsearch = ip->i_size;
endsearch = dp->i_size;
while (idp->curroff < endsearch) {
/*
@ -558,10 +558,11 @@ cd9660_readdir(ap)
* read the next directory block.
* Release previous if it exists.
*/
if (blkoff(imp, idp->curroff) == 0) {
if ((idp->curroff & bmask) == 0)
if (bp != NULL)
brelse(bp);
if (error = VOP_BLKATOFF(vp, idp->curroff, NULL, &bp))
if (error =
VOP_BLKATOFF(vdp, (off_t)idp->curroff, NULL, &bp))
break;
entryoffsetinblock = 0;
}
@ -569,13 +570,12 @@ cd9660_readdir(ap)
* Get pointer to next entry.
*/
ep = (struct iso_directory_record *)
(bp->b_data + entryoffsetinblock);
((char *)bp->b_data + entryoffsetinblock);
reclen = isonum_711 (ep->length);
reclen = isonum_711(ep->length);
if (reclen == 0) {
/* skip to next block, if any */
idp->curroff =
(idp->curroff + imp->im_bmask) & ~imp->im_bmask;
idp->curroff = (idp->curroff + bmask) & ~bmask;
continue;
}
@ -609,9 +609,9 @@ cd9660_readdir(ap)
switch (imp->iso_ftype) {
case ISO_FTYPE_RRIP:
cd9660_rrip_getname(ep,idp->current.d_name, &elen,
cd9660_rrip_getname(ep,idp->current.d_name, &namelen,
&idp->current.d_fileno,imp);
idp->current.d_namlen = (u_char)elen;
idp->current.d_namlen = (u_char)namelen;
if (idp->current.d_namlen)
error = iso_uiodir(idp,&idp->current,idp->curroff);
break;
@ -628,10 +628,10 @@ cd9660_readdir(ap)
break;
default:
isofntrans(ep->name,idp->current.d_namlen,
idp->current.d_name, &elen,
idp->current.d_name, &namelen,
imp->iso_ftype == ISO_FTYPE_9660,
isonum_711(ep->flags)&4);
idp->current.d_namlen = (u_char)elen;
idp->current.d_namlen = (u_char)namelen;
if (imp->iso_ftype == ISO_FTYPE_DEFAULT)
error = iso_shipdir(idp);
else
@ -658,7 +658,7 @@ cd9660_readdir(ap)
uio->uio_offset = idp->uio_off;
*ap->a_eofflag = idp->eofflag;
FREE(idp,M_TEMP);
FREE(idp, M_TEMP);
return (error);
}