#include "e2fsck.h"
#include <ext2fs/ext2_ext_attr.h>
+#include <e2p/e2p.h>
#include "problem.h"
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;
/*
errcode_t retval;
char *tdb_dir;
int enable;
- int full_map;
*ret = 0;
const char *old_op;
int imagic_fs, extent_fs, inlinedata_fs;
int low_dtime_check = 1;
- int inode_size = EXT2_INODE_SIZE(fs->super);
- int bufsize;
+ unsigned int inode_size = EXT2_INODE_SIZE(fs->super);
+ unsigned int bufsize;
int failed_csum = 0;
ext2_ino_t ino_threshold = 0;
dgrp_t ra_group = 0;
(ino >= EXT2_FIRST_INODE(fs->super))) {
size_t size = 0;
- pctx.errcode = ext2fs_inline_data_size(fs, ino, &size);
- if (!pctx.errcode && size &&
+ pctx.errcode = get_inline_data_ea_size(fs, ino, &size);
+ if (!pctx.errcode &&
fix_problem(ctx, PR_1_INLINE_DATA_FEATURE, &pctx)) {
ext2fs_set_feature_inline_data(sb);
ext2fs_mark_super_dirty(fs);
clear_problem_context(&pctx);
if (ext2fs_fast_test_block_bitmap2(ctx->block_found_map, block)) {
+ 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"),
if (ext2fs_test_block_bitmap_range2(ctx->block_found_map, block, num))
ext2fs_mark_block_bitmap_range2(ctx->block_found_map, block, num);
else {
- int i;
+ unsigned int i;
+
for (i = 0; i < num; i += EXT2FS_CLUSTER_RATIO(ctx->fs))
mark_block_used(ctx, block + i);
}
return 0;
}
- if (quota_blocks != EXT2FS_C2B(fs, 1)) {
+ if (quota_blocks != EXT2FS_C2B(fs, 1U)) {
if (!ctx->ea_block_quota_blocks) {
pctx->errcode = ea_refcount_create(0,
&ctx->ea_block_quota_blocks);
inode->i_flags &= ~EXT2_INDEX_FL;
dirty_inode++;
} else {
- e2fsck_add_dx_dir(ctx, ino, pb.last_block+1);
+ e2fsck_add_dx_dir(ctx, ino, inode, pb.last_block+1);
}
}
bad_size = 2;
}
} else {
- e2_blkcnt_t blkpg = ctx->blocks_per_page;
-
size = EXT2_I_SIZE(inode);
if ((pb.last_init_lblock >= 0) &&
- /* allow allocated blocks to end of PAGE_SIZE */
+ /* Do not allow initialized allocated blocks past i_size*/
(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)) *
- fs->blocksize))
+ !(inode->i_flags & EXT4_VERITY_FL))
bad_size = 3;
else if (!(extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) &&
size > ext2_max_sizes[fs->super->s_log_block_size])
}
}
- if (p->is_dir && blockcnt > (1 << (21 - fs->super->s_log_block_size)))
+ if (p->is_dir && !ext2fs_has_feature_largedir(fs->super) &&
+ blockcnt > (1 << (21 - fs->super->s_log_block_size)))
+ problem = PR_1_TOOBIG_DIR;
+ if (p->is_dir && p->num_blocks + 1 >= p->max_blocks)
problem = PR_1_TOOBIG_DIR;
- if (p->is_reg && p->num_blocks+1 >= p->max_blocks)
+ if (p->is_reg && p->num_blocks + 1 >= p->max_blocks)
problem = PR_1_TOOBIG_REG;
if (!p->is_dir && !p->is_reg && blockcnt > 0)
problem = PR_1_TOOBIG_SYMLINK;