Fix a fencepost error in the bitmap handling in extend_ifile(), and another

in lfs_freelist_prev().
This commit is contained in:
perseant 2006-04-22 00:12:45 +00:00
parent 7cd0266a27
commit 7119533fb9
1 changed files with 7 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_alloc.c,v 1.88 2006/04/10 21:20:19 perseant Exp $ */
/* $NetBSD: lfs_alloc.c,v 1.89 2006/04/22 00:12:45 perseant Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.88 2006/04/10 21:20:19 perseant Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.89 2006/04/22 00:12:45 perseant Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@ -290,19 +290,19 @@ extend_ifile(struct lfs *fs, struct ucred *cred)
if (fs->lfs_version == 1) {
for (ifp_v1 = (IFILE_V1 *)bp->b_data; i < xmax; ++ifp_v1) {
SET_BITMAP_FREE(fs, i);
ifp_v1->if_version = 1;
ifp_v1->if_daddr = LFS_UNUSED_DADDR;
ifp_v1->if_nextfree = ++i;
SET_BITMAP_FREE(fs, i);
}
ifp_v1--;
ifp_v1->if_nextfree = oldlast;
} else {
for (ifp = (IFILE *)bp->b_data; i < xmax; ++ifp) {
SET_BITMAP_FREE(fs, i);
ifp->if_version = 1;
ifp->if_daddr = LFS_UNUSED_DADDR;
ifp->if_nextfree = ++i;
SET_BITMAP_FREE(fs, i);
}
ifp--;
ifp->if_nextfree = oldlast;
@ -512,7 +512,7 @@ lfs_freelist_prev(struct lfs *fs, ino_t ino)
/* Search our own word first */
bound = ino & ~BMMASK;
for (tino = ino - 1; tino > bound && tino > LFS_UNUSED_INUM; tino--)
for (tino = ino - 1; tino >= bound && tino > LFS_UNUSED_INUM; tino--)
if (ISSET_BITMAP_FREE(fs, tino))
return tino;
/* If there are no lower words to search, just return */
@ -531,7 +531,8 @@ lfs_freelist_prev(struct lfs *fs, ino_t ino)
return LFS_UNUSED_INUM;
/* Search the word we found */
for (tino = (bb << BMSHIFT) | BMMASK; tino > LFS_UNUSED_INUM; tino--)
for (tino = (bb << BMSHIFT) | BMMASK; tino >= (bb << BMSHIFT) &&
tino > LFS_UNUSED_INUM; tino--)
if (ISSET_BITMAP_FREE(fs, tino))
break;