p = (struct process_block_struct *) priv_data;
- if (blk < fs->super->s_first_data_block ||
+ if (!blk || blk < fs->super->s_first_data_block ||
- blk >= fs->super->s_blocks_count)
+ blk >= ext2fs_blocks_count(fs->super))
return BLOCK_ABORT;
if (blockcnt >= 0)
is_dir = LINUX_S_ISDIR(pctx->inode->i_mode);
problem = 0;
- if (extent.e_pblk < ctx->fs->super->s_first_data_block ||
+ if (extent.e_pblk == 0 ||
+ extent.e_pblk < ctx->fs->super->s_first_data_block ||
- extent.e_pblk >= ctx->fs->super->s_blocks_count)
+ extent.e_pblk >= ext2fs_blocks_count(ctx->fs->super))
problem = PR_1_EXTENT_BAD_START_BLK;
else if (extent.e_lblk < start_block)
problem = PR_1_OUT_OF_ORDER_EXTENTS;
}
}
- if (!(ext2fs_test_inode_bitmap2(ctx->inode_used_map,
- dirent->inode))) {
- /*
- * If the inode is unused, offer to clear it.
- */
+ /*
+ * Offer to clear unused inodes; if we are going to be
+ * restarting the scan due to bg_itable_unused being
+ * wrong, then don't clear any inodes to avoid zapping
+ * inodes that were skipped during pass1 due to an
+ * incorrect bg_itable_unused; we'll get any real
+ * problems after we restart.
+ */
+ if (!(ctx->flags & E2F_FLAG_RESTART_LATER) &&
- !(ext2fs_test_inode_bitmap(ctx->inode_used_map,
- dirent->inode)))
++ !(ext2fs_test_inode_bitmap2(ctx->inode_used_map,
++ dirent->inode)))
problem = PR_2_UNUSED_INODE;
- }
if (problem) {
if (fix_problem(ctx, problem, &cd->pctx)) {
if ((blocksize < 0) && (use_bsize < (-blocksize)))
use_bsize = -blocksize;
blocksize = use_bsize;
- fs_param.s_blocks_count /= blocksize / 1024;
+ ext2fs_blocks_count_set(&fs_param,
+ ext2fs_blocks_count(&fs_param) /
+ (blocksize / 1024));
+ } else {
+ if (blocksize < lsector_size || /* Impossible */
+ (!force && (blocksize < psector_size))) { /* Suboptimal */
+ com_err(program_name, EINVAL,
+ _("while setting blocksize; too small "
+ "for device\n"));
+ exit(1);
+ } else if (blocksize < psector_size) {
+ fprintf(stderr, _("Warning: specified blocksize %d is "
+ "less than device physical sectorsize %d, "
+ "forced to continue\n"), blocksize,
+ psector_size);
+ }
}
if (inode_ratio == 0) {