]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - fs/ext4/ext4_common.c
ext4: Correct block number handling, empty block vs. error code
[people/ms/u-boot.git] / fs / ext4 / ext4_common.c
index 5e874afc70cfcdb3a9c25d05b655ee1d4ecad3d0..5f21dc794805ea7d3f32778fb0293db07c84530f 100644 (file)
@@ -534,7 +534,7 @@ static int search_dir(struct ext2_inode *parent_inode, char *dirname)
        /* get the block no allocated to a file */
        for (blk_idx = 0; blk_idx < directory_blocks; blk_idx++) {
                blknr = read_allocated_block(parent_inode, blk_idx);
-               if (blknr == 0)
+               if (blknr <= 0)
                        goto fail;
 
                /* read the directory block */
@@ -828,7 +828,7 @@ int ext4fs_filename_unlink(char *filename)
        /* read the block no allocated to a file */
        for (blk_idx = 0; blk_idx < directory_blocks; blk_idx++) {
                blknr = read_allocated_block(g_parent_inode, blk_idx);
-               if (blknr == 0)
+               if (blknr <= 0)
                        break;
                inodeno = unlink_filename(filename, blknr);
                if (inodeno != -1)
@@ -1590,7 +1590,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock)
                        if (status == 0) {
                                printf("** SI ext2fs read block (indir 1)"
                                        "failed. **\n");
-                               return 0;
+                               return -1;
                        }
                        ext4fs_indir1_blkno =
                                le32_to_cpu(inode->b.blocks.