From 06e79831b175c3ca61f6b5d22d6b712cd42b9f7a Mon Sep 17 00:00:00 2001 From: Doug Rabson Date: Fri, 9 Sep 1994 11:11:01 +0000 Subject: [PATCH] Fixed some confusion between the size of a logical block and the size of a device block which was stopping symbolic links working. cd9660_readdir was incorrectly casting a pointer to the d_namlen field of a struct dirent to a (u_short*) which caused the directory entries "." and ".." to read incorrectly. Submitted by: dfr --- sys/fs/cd9660/cd9660_rrip.c | 4 ++-- sys/fs/cd9660/cd9660_vnops.c | 8 +++++--- sys/fs/cd9660/iso.h | 5 ++++- sys/isofs/cd9660/cd9660_rrip.c | 4 ++-- sys/isofs/cd9660/cd9660_vnops.c | 8 +++++--- sys/isofs/cd9660/iso.h | 5 ++++- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/sys/fs/cd9660/cd9660_rrip.c b/sys/fs/cd9660/cd9660_rrip.c index 6d73374c708c..78410a54f239 100644 --- a/sys/fs/cd9660/cd9660_rrip.c +++ b/sys/fs/cd9660/cd9660_rrip.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)cd9660_rrip.c 8.2 (Berkeley) 1/23/94 - * $Id$ + * $Id: cd9660_rrip.c,v 1.2 1994/08/02 07:41:26 davidg Exp $ */ #include @@ -521,7 +521,7 @@ cd9660_rrip_loop(isodir,ana,table) if (ana->iso_ce_blk >= ana->imp->volume_space_size || ana->iso_ce_off + ana->iso_ce_len > ana->imp->logical_block_size || bread(ana->imp->im_devvp, - ana->iso_ce_blk * ana->imp->logical_block_size / DEV_BSIZE, + iso_lblktodaddr(ana->imp, ana->iso_ce_blk), ana->imp->logical_block_size,NOCRED,&bp)) /* what to do now? */ break; diff --git a/sys/fs/cd9660/cd9660_vnops.c b/sys/fs/cd9660/cd9660_vnops.c index 368a66d333b0..2c913f2b0ac4 100644 --- a/sys/fs/cd9660/cd9660_vnops.c +++ b/sys/fs/cd9660/cd9660_vnops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)cd9660_vnops.c 8.3 (Berkeley) 1/23/94 - * $Id: cd9660_vnops.c,v 1.3 1994/08/02 07:41:36 davidg Exp $ + * $Id: cd9660_vnops.c,v 1.4 1994/08/08 09:11:18 davidg Exp $ */ #include @@ -479,6 +479,7 @@ cd9660_readdir(ap) struct iso_mnt *imp; struct iso_node *ip; struct buf *bp = NULL; + u_short tmplen; ip = VTOI(ap->a_vp); imp = ip->i_mnt; @@ -567,8 +568,9 @@ cd9660_readdir(ap) switch (imp->iso_ftype) { case ISO_FTYPE_RRIP: cd9660_rrip_getname(ep,idp->current.d_name, - (u_short *)&idp->current.d_namlen, + &tmplen, &idp->current.d_fileno,imp); + idp->current.d_namlen = tmplen; if (idp->current.d_namlen) error = iso_uiodir(idp,&idp->current,idp->curroff); break; @@ -658,7 +660,7 @@ cd9660_readlink(ap) * Get parents directory record block that this inode included. */ error = bread(imp->im_devvp, - (daddr_t)(ip->i_number / DEV_BSIZE), + iso_dblkno(imp, ip->i_number), imp->logical_block_size, NOCRED, &bp); diff --git a/sys/fs/cd9660/iso.h b/sys/fs/cd9660/iso.h index a329afa3f9e0..04b9accd1705 100644 --- a/sys/fs/cd9660/iso.h +++ b/sys/fs/cd9660/iso.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)iso.h 8.2 (Berkeley) 1/23/94 - * $Id$ + * $Id: iso.h,v 1.2 1994/08/02 07:41:38 davidg Exp $ */ #define ISODCL(from, to) (to - from + 1) @@ -165,6 +165,9 @@ struct iso_mnt { #define iso_lblkno(imp, loc) ((loc) >> (imp)->im_bshift) #define iso_blksize(imp, ip, lbn) ((imp)->logical_block_size) #define iso_lblktosize(imp, blk) ((blk) << (imp)->im_bshift) +#define iso_lblktodaddr(imp, lbn) btodb(iso_lblktosize(imp, lbn)) +#define iso_dblkinc(imp, lbn) ((lbn) + iso_lblktodaddr(imp, 1)) +#define iso_dblkno(imp, loc) iso_lblktodaddr(imp, iso_lblkno(imp, loc)) int cd9660_mount __P((struct mount *, char *, caddr_t, struct nameidata *, struct proc *)); diff --git a/sys/isofs/cd9660/cd9660_rrip.c b/sys/isofs/cd9660/cd9660_rrip.c index 6d73374c708c..78410a54f239 100644 --- a/sys/isofs/cd9660/cd9660_rrip.c +++ b/sys/isofs/cd9660/cd9660_rrip.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)cd9660_rrip.c 8.2 (Berkeley) 1/23/94 - * $Id$ + * $Id: cd9660_rrip.c,v 1.2 1994/08/02 07:41:26 davidg Exp $ */ #include @@ -521,7 +521,7 @@ cd9660_rrip_loop(isodir,ana,table) if (ana->iso_ce_blk >= ana->imp->volume_space_size || ana->iso_ce_off + ana->iso_ce_len > ana->imp->logical_block_size || bread(ana->imp->im_devvp, - ana->iso_ce_blk * ana->imp->logical_block_size / DEV_BSIZE, + iso_lblktodaddr(ana->imp, ana->iso_ce_blk), ana->imp->logical_block_size,NOCRED,&bp)) /* what to do now? */ break; diff --git a/sys/isofs/cd9660/cd9660_vnops.c b/sys/isofs/cd9660/cd9660_vnops.c index 368a66d333b0..2c913f2b0ac4 100644 --- a/sys/isofs/cd9660/cd9660_vnops.c +++ b/sys/isofs/cd9660/cd9660_vnops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)cd9660_vnops.c 8.3 (Berkeley) 1/23/94 - * $Id: cd9660_vnops.c,v 1.3 1994/08/02 07:41:36 davidg Exp $ + * $Id: cd9660_vnops.c,v 1.4 1994/08/08 09:11:18 davidg Exp $ */ #include @@ -479,6 +479,7 @@ cd9660_readdir(ap) struct iso_mnt *imp; struct iso_node *ip; struct buf *bp = NULL; + u_short tmplen; ip = VTOI(ap->a_vp); imp = ip->i_mnt; @@ -567,8 +568,9 @@ cd9660_readdir(ap) switch (imp->iso_ftype) { case ISO_FTYPE_RRIP: cd9660_rrip_getname(ep,idp->current.d_name, - (u_short *)&idp->current.d_namlen, + &tmplen, &idp->current.d_fileno,imp); + idp->current.d_namlen = tmplen; if (idp->current.d_namlen) error = iso_uiodir(idp,&idp->current,idp->curroff); break; @@ -658,7 +660,7 @@ cd9660_readlink(ap) * Get parents directory record block that this inode included. */ error = bread(imp->im_devvp, - (daddr_t)(ip->i_number / DEV_BSIZE), + iso_dblkno(imp, ip->i_number), imp->logical_block_size, NOCRED, &bp); diff --git a/sys/isofs/cd9660/iso.h b/sys/isofs/cd9660/iso.h index a329afa3f9e0..04b9accd1705 100644 --- a/sys/isofs/cd9660/iso.h +++ b/sys/isofs/cd9660/iso.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)iso.h 8.2 (Berkeley) 1/23/94 - * $Id$ + * $Id: iso.h,v 1.2 1994/08/02 07:41:38 davidg Exp $ */ #define ISODCL(from, to) (to - from + 1) @@ -165,6 +165,9 @@ struct iso_mnt { #define iso_lblkno(imp, loc) ((loc) >> (imp)->im_bshift) #define iso_blksize(imp, ip, lbn) ((imp)->logical_block_size) #define iso_lblktosize(imp, blk) ((blk) << (imp)->im_bshift) +#define iso_lblktodaddr(imp, lbn) btodb(iso_lblktosize(imp, lbn)) +#define iso_dblkinc(imp, lbn) ((lbn) + iso_lblktodaddr(imp, 1)) +#define iso_dblkno(imp, loc) iso_lblktodaddr(imp, iso_lblkno(imp, loc)) int cd9660_mount __P((struct mount *, char *, caddr_t, struct nameidata *, struct proc *));