@@ -469,7 +469,8 @@ errcode_t ext2fs_block_iterate3(ext2_filsys fs,
j = blockcnt - lblk;
blk += j;
for (blockcnt = lblk, j = 0;
- j < (extent.e_len << fs->cluster_ratio_bits);
+ j < (extent.e_len << fs->cluster_ratio_bits) &&
+ ((j * (fs->blocksize)) < (inode.i_size));
blk++, blockcnt++, j++) {
new_blk = blk;
r = (*ctx.func)(fs, &new_blk, blockcnt,
@@ -40,7 +40,9 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
ext2_ino_t ino = inum;
ext2_ino_t scratch_ino;
blk64_t blk;
+ int i = 0;
char *block = 0;
+ char *empty_block = 0;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -69,6 +71,13 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
goto cleanup;
/*
+ * Create a empty dir block
+ */
+ retval = ext2fs_new_dir_block(fs, 0, 0, &empty_block);
+ if (retval)
+ goto cleanup;
+
+ /*
* Get the parent's inode, if necessary
*/
if (parent != ino) {
@@ -98,6 +107,14 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
retval = ext2fs_write_dir_block(fs, blk, block);
if (retval)
goto cleanup;
+ if (fs->cluster_ratio_bits > 0) {
+ for (i = 1; i < (1 << fs->cluster_ratio_bits); i++) {
+ retval = ext2fs_write_dir_block(fs, blk + i,
+ empty_block);
+ if (retval)
+ goto cleanup;
+ }
+ }
retval = ext2fs_write_new_inode(fs, ino, &inode);
if (retval)
goto cleanup;
@@ -149,6 +166,8 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
cleanup:
if (block)
ext2fs_free_mem(&block);
+ if (empty_block)
+ ext2fs_free_mem(&empty_block);
return retval;
}
@@ -392,6 +392,7 @@ static void create_lost_and_found(ext2_filsys fs)
unsigned int lpf_size = 0;
errcode_t retval;
ext2_ino_t ino;
+ struct ext2_inode inode;
const char *name = "lost+found";
int i;
@@ -410,6 +411,13 @@ static void create_lost_and_found(ext2_filsys fs)
exit(1);
}
+ if (fs->cluster_ratio_bits > 0) {
+ retval = ext2fs_read_inode(fs, ino, &inode);
+ inode.i_size = 16*1024;
+ ext2fs_write_inode(fs, ino, &inode);
+ return;
+ }
+
for (i=1; i < EXT2_NDIR_BLOCKS; i++) {
/* Ensure that lost+found is at least 2 blocks, so we always
* test large empty blocks for big-block filesystems. */