NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/48797



The following reply was made to PR kern/48797; it has been noted by GNATS.

From: "Thomas Schmitt" <scdbackup%gmx.net@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: kern/48797
Date: Fri, 09 May 2014 20:21:12 +0200

 --- sys/fs/cd9660/cd9660_lookup.c.orig 2014-05-05 11:56:09.000000000 +0000
 +++ sys/fs/cd9660/cd9660_lookup.c      2014-05-06 21:17:36.000000000 +0000
 @@ -267,8 +267,9 @@ searchloop:
                                        if (isonum_711(ep->flags)&2)
                                                ino = isodirino(ep, imp);
                                        else
 -                                              ino = dbtob(bp->b_blkno)
 -                                                      + entryoffsetinblock;
 +                                              ino = CD9660_COMPUTE_INO_DB(
 +                                                      bp->b_blkno,
 +                                                      entryoffsetinblock);
                                        saveoffset = dp->i_offset;
                                } else if (ino)
                                        goto foundino;
 @@ -284,7 +285,8 @@ searchloop:
                        if (isonum_711(ep->flags)&2)
                                ino = isodirino(ep, imp);
                        else
 -                              ino = dbtob(bp->b_blkno) + entryoffsetinblock;
 +                              ino = CD9660_COMPUTE_INO_DB(bp->b_blkno,
 +                                                      entryoffsetinblock);
                        dp->i_ino = ino;
                        cd9660_rrip_getname(ep,altname,&namelen,&dp->i_ino,imp);
                        if (namelen == cnp->cn_namelen) {
 --- sys/fs/cd9660/cd9660_node.h.orig   2008-02-27 19:43:36.000000000 +0000
 +++ sys/fs/cd9660/cd9660_node.h        2014-05-06 20:52:22.000000000 +0000
 @@ -136,6 +136,29 @@ int       cd9660_tstamp_conv17(const u_char *,
  int   cd9660_vget_internal(struct mount *, ino_t, struct vnode **, int,
                              struct iso_directory_record *);
  
 +/* A directory record has at least 34 bytes. So the byte address
 + * divided by 32 is still unique. Idea learned from Linux isofs.
 + * We need lossless forth and back translation of block aligned addresses.
 + * All operands are forced to 64 bit in order to surely avoid 32 bit rollover.
 + * May the compiler pick the conversions which are really needed.
 + */
 +/* Must be 5 or smaller. */
 +#define CD9660_COMPUTE_INO_SHIFT 5
 +
 +/* This is for ISO 9660 block size */
 +#define CD9660_COMPUTE_INO(blockno, bshift, byteoffset) \
 +              (((((uint64_t) (blockno)) << (uint64_t) (bshift)) \
 +                + (int64_t) (byteoffset)) \
 +               >> (uint64_t) CD9660_COMPUTE_INO_SHIFT)
 +
 +/* This is for DEV_BSHIFT block size */
 +#define CD9660_COMPUTE_INO_DB(blockno, byteoffset) \
 +              ((dbtob((uint64_t) (blockno)) + (int64_t) (byteoffset)) \
 +               >> (uint64_t) CD9660_COMPUTE_INO_SHIFT)
 +
 +#define CD9660_BLOCK_FROM_INO(ino, bshift) \
 +              ((ino) >> ((bshift) - CD9660_COMPUTE_INO_SHIFT))
 +
  extern kmutex_t cd9660_hashlock;
  
  #endif /* _KERNEL */
 --- sys/fs/cd9660/cd9660_rrip.c.orig   2014-05-05 11:56:09.000000000 +0000
 +++ sys/fs/cd9660/cd9660_rrip.c        2014-05-06 20:05:53.000000000 +0000
 @@ -314,7 +314,8 @@ cd9660_rrip_pclink(void *v, ISO_RRIP_ANA
  {
        ISO_RRIP_CLINK  *p = v;
  
 -      *ana->inump = isonum_733(p->dir_loc) << ana->imp->im_bshift;
 +      *ana->inump = CD9660_COMPUTE_INO(isonum_733(p->dir_loc),
 +                                       ana->imp->im_bshift, 0);
        ana->fields &= ~(ISO_SUSP_CLINK | ISO_SUSP_PLINK);
        return *p->h.type == 'C' ? ISO_SUSP_CLINK : ISO_SUSP_PLINK;
  }
 --- sys/fs/cd9660/cd9660_vfsops.c.orig 2014-04-16 18:55:18.000000000 +0000
 +++ sys/fs/cd9660/cd9660_vfsops.c      2014-05-06 21:09:33.000000000 +0000
 @@ -812,7 +812,7 @@ cd9660_vget_internal(struct mount *mp, i
                 * On relocated directories we must
                 * read the `.' entry out of a dir.
                 */
 -              ip->iso_start = ino >> imp->im_bshift;
 +              ip->iso_start = CD9660_BLOCK_FROM_INO(ino, imp->im_bshift);
                if (bp != 0)
                        brelse(bp, 0);
                if ((error = cd9660_blkatoff(vp, (off_t)0, NULL, &bp)) != 0) {
 --- sys/fs/cd9660/cd9660_vnops.c.orig  2014-05-05 11:56:09.000000000 +0000
 +++ sys/fs/cd9660/cd9660_vnops.c       2014-05-06 21:18:49.000000000 +0000
 @@ -478,8 +478,10 @@ cd9660_readdir(void *v)
                if (isonum_711(ep->flags)&2)
                        idp->current.d_fileno = isodirino(ep, imp);
                else
 -                      idp->current.d_fileno = dbtob(bp->b_blkno) +
 -                              entryoffsetinblock;
 +                      idp->current.d_fileno = CD9660_COMPUTE_INO(
 +                                                      bp->b_blkno,
 +                                                      imp->im_bshift,
 +                                                      entryoffsetinblock);
  
                idp->curroff += reclen;
  
 --- sys/fs/cd9660/cd9660_node.c.patch_001      2014-05-06 08:20:51.000000000 
+0000
 +++ sys/fs/cd9660/cd9660_node.c        2014-05-06 21:07:26.000000000 +0000
 @@ -445,7 +445,9 @@ isodirino(struct iso_directory_record *i
         * number back from ino_t by:
         *   ip->iso_start = ino >> imp->im_bshift;
         */
 -      ino = (((uint64_t) isonum_733(isodir->extent)) +
 -              isonum_711(isodir->ext_attr_length)) << imp->im_bshift;
 +      ino = CD9660_COMPUTE_INO(isonum_733(isodir->extent) +
 +                                      isonum_711(isodir->ext_attr_length),
 +                              imp->im_bshift,
 +                              isonum_711(isodir->ext_attr_length));
        return (ino);
  }
 


Home | Main Index | Thread Index | Old Index