summaryrefslogtreecommitdiff
path: root/lib/ext2fs/alloc.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>1997-04-29 21:26:48 +0000
committerTheodore Ts'o <tytso@mit.edu>1997-04-29 21:26:48 +0000
commita29f4d30f24d68f1f1c75548e020689ede532c05 (patch)
treef74e57c6188bc586c912a79da833236ad28f7233 /lib/ext2fs/alloc.c
parentae85148246952016865e2792b49d6b68649b6063 (diff)
downloade2fsprogs-a29f4d30f24d68f1f1c75548e020689ede532c05.tar.gz
Many files:
Checkin of e2fsprogs 1.10
Diffstat (limited to 'lib/ext2fs/alloc.c')
-rw-r--r--lib/ext2fs/alloc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/ext2fs/alloc.c b/lib/ext2fs/alloc.c
index 0bc637db..50cee77c 100644
--- a/lib/ext2fs/alloc.c
+++ b/lib/ext2fs/alloc.c
@@ -73,7 +73,7 @@ errcode_t ext2fs_new_inode(ext2_filsys fs, ino_t dir, int mode,
errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal,
ext2fs_block_bitmap map, blk_t *ret)
{
- blk_t i = goal;
+ blk_t i;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -81,8 +81,9 @@ errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal,
map = fs->block_map;
if (!map)
return EXT2_ET_NO_BLOCK_BITMAP;
- if (!i)
- i = fs->super->s_first_data_block;
+ if (!goal || (goal >= fs->super->s_blocks_count))
+ goal = fs->super->s_first_data_block;
+ i = goal;
do {
if (!ext2fs_test_block_bitmap(map, i)) {
*ret = i;