diff --git a/sys/gnu/ext2fs/ext2_bmap.c b/sys/gnu/ext2fs/ext2_bmap.c index 14ef56ef8b4b..57cef4686d66 100644 --- a/sys/gnu/ext2fs/ext2_bmap.c +++ b/sys/gnu/ext2fs/ext2_bmap.c @@ -214,7 +214,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) ++bn, ++*runp); bn = xap->in_off; if (runb && bn) { - for(--bn; bn > 0 && *runb < maxrun && + for(--bn; bn >= 0 && *runb < maxrun && is_sequential(ump, ((daddr_t *)bp->b_data)[bn], ((daddr_t *)bp->b_data)[bn+1]); --bn, ++*runb); diff --git a/sys/gnu/fs/ext2fs/ext2_bmap.c b/sys/gnu/fs/ext2fs/ext2_bmap.c index 14ef56ef8b4b..57cef4686d66 100644 --- a/sys/gnu/fs/ext2fs/ext2_bmap.c +++ b/sys/gnu/fs/ext2fs/ext2_bmap.c @@ -214,7 +214,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) ++bn, ++*runp); bn = xap->in_off; if (runb && bn) { - for(--bn; bn > 0 && *runb < maxrun && + for(--bn; bn >= 0 && *runb < maxrun && is_sequential(ump, ((daddr_t *)bp->b_data)[bn], ((daddr_t *)bp->b_data)[bn+1]); --bn, ++*runb); diff --git a/sys/ufs/ufs/ufs_bmap.c b/sys/ufs/ufs/ufs_bmap.c index 14ef56ef8b4b..57cef4686d66 100644 --- a/sys/ufs/ufs/ufs_bmap.c +++ b/sys/ufs/ufs/ufs_bmap.c @@ -214,7 +214,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) ++bn, ++*runp); bn = xap->in_off; if (runb && bn) { - for(--bn; bn > 0 && *runb < maxrun && + for(--bn; bn >= 0 && *runb < maxrun && is_sequential(ump, ((daddr_t *)bp->b_data)[bn], ((daddr_t *)bp->b_data)[bn+1]); --bn, ++*runb); diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index a5be8e77a66f..11f2ae466e28 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -192,7 +192,7 @@ ufs_lookup(ap) */ bmask = VFSTOUFS(vdp->v_mount)->um_mountp->mnt_stat.f_iosize - 1; if (nameiop != LOOKUP || dp->i_diroff == 0 || - dp->i_diroff > dp->i_size) { + dp->i_diroff >= dp->i_size) { entryoffsetinblock = 0; dp->i_offset = 0; numdirpasses = 1; @@ -411,9 +411,9 @@ ufs_lookup(ap) * Check that directory length properly reflects presence * of this entry. */ - if (entryoffsetinblock + DIRSIZ(OFSFMT(vdp), ep) > dp->i_size) { + if (dp->i_offset + DIRSIZ(OFSFMT(vdp), ep) > dp->i_size) { ufs_dirbad(dp, dp->i_offset, "i_size too small"); - dp->i_size = entryoffsetinblock + DIRSIZ(OFSFMT(vdp), ep); + dp->i_size = dp->i_offset + DIRSIZ(OFSFMT(vdp), ep); dp->i_flag |= IN_CHANGE | IN_UPDATE; } brelse(bp);