]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blobdiff - e2fsck/pass1.c
e2fsck: mark device inodes with EXT4_EXTENTS_FL bad
[thirdparty/e2fsprogs.git] / e2fsck / pass1.c
index 35a05037cac536fab07f11ca93202c3eb543fb1a..8dfa82a078fe07fc1d67ad2aa19e04479ffaaa12 100644 (file)
@@ -151,10 +151,10 @@ int e2fsck_pass1_check_device_inode(ext2_filsys fs EXT2FS_ATTR((unused)),
        int     i;
 
        /*
-        * If the index flag is set, then this is a bogus
+        * If the index or extents flag is set, then this is a bogus
         * device/fifo/socket
         */
-       if (inode->i_flags & EXT2_INDEX_FL)
+       if (inode->i_flags & (EXT2_INDEX_FL | EXT4_EXTENTS_FL))
                return 0;
 
        /*
@@ -2261,8 +2261,10 @@ static _INLINE_ void mark_block_used(e2fsck_t ctx, blk64_t block)
        clear_problem_context(&pctx);
 
        if (ext2fs_fast_test_block_bitmap2(ctx->block_found_map, block)) {
-               if (ext2fs_has_feature_shared_blocks(ctx->fs->super))
+               if (ext2fs_has_feature_shared_blocks(ctx->fs->super) &&
+                   !(ctx->options & E2F_OPT_UNSHARE_BLOCKS)) {
                        return;
+               }
                if (!ctx->block_dup_map) {
                        pctx.errcode = e2fsck_allocate_block_bitmap(ctx->fs,
                                        _("multiply claimed block map"),
@@ -3446,10 +3448,15 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
 
                size = EXT2_I_SIZE(inode);
                if ((pb.last_init_lblock >= 0) &&
-                   /* allow allocated blocks to end of PAGE_SIZE */
+                   /* if size is smaller than expected by the block count,
+                    * allow allocated blocks to end of PAGE_SIZE.
+                    * last_init_lblock is the last in-use block, so it is
+                    * the minimum expected file size, but +1 because it is
+                    * the base-zero block number and not the block count. */
                    (size < (__u64)pb.last_init_lblock * fs->blocksize) &&
-                   (pb.last_init_lblock / blkpg * blkpg != pb.last_init_lblock ||
-                    size < (__u64)(pb.last_init_lblock & ~(blkpg-1)) *
+                   ((pb.last_init_lblock + 1) / blkpg * blkpg !=
+                    (pb.last_init_lblock + 1) ||
+                    size < (__u64)(pb.last_init_lblock & ~(blkpg - 1)) *
                     fs->blocksize))
                        bad_size = 3;
                else if (!(extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) &&