Пример #1
0
void e2fsck_write_bitmaps(e2fsck_t ctx)
{
	ext2_filsys fs = ctx->fs;
	errcode_t	retval;

	if (ext2fs_test_bb_dirty(fs)) {
		ehandler_operation(_("writing block bitmaps"));
		retval = ext2fs_write_block_bitmap(fs);
		ehandler_operation(0);
		if (retval) {
			com_err(ctx->program_name, retval,
			    _("while retrying to write block bitmaps for %s"),
				ctx->device_name);
			fatal_error(ctx, 0);
		}
	}

	if (ext2fs_test_ib_dirty(fs)) {
		ehandler_operation(_("writing inode bitmaps"));
		retval = ext2fs_write_inode_bitmap(fs);
		ehandler_operation(0);
		if (retval) {
			com_err(ctx->program_name, retval,
			    _("while retrying to write inode bitmaps for %s"),
				ctx->device_name);
			fatal_error(ctx, 0);
		}
	}
}
Пример #2
0
errcode_t ext2fs_write_bitmaps(ext2_filsys fs)
{
	int do_inode = fs->inode_map && ext2fs_test_ib_dirty(fs);
	int do_block = fs->block_map && ext2fs_test_bb_dirty(fs);

	if (!do_inode && !do_block)
		return 0;

	return write_bitmaps(fs, do_inode, do_block);
}
Пример #3
0
static void check_inode_bitmap_checksum(e2fsck_t ctx)
{
	struct problem_context	pctx;
	char		*buf;
	dgrp_t		i;
	int		nbytes;
	ext2_ino_t	ino_itr;
	errcode_t	retval;

	if (!EXT2_HAS_RO_COMPAT_FEATURE(ctx->fs->super,
					EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
		return;

	/* If bitmap is dirty from being fixed, checksum will be corrected */
	if (ext2fs_test_ib_dirty(ctx->fs))
		return;

	nbytes = (size_t)(EXT2_INODES_PER_GROUP(ctx->fs->super) / 8);
	retval = ext2fs_get_memalign(ctx->fs->blocksize, ctx->fs->blocksize,
				     &buf);
	if (retval) {
		com_err(ctx->program_name, 0,
		    _("check_inode_bitmap_checksum: Memory allocation error"));
		fatal_error(ctx, 0);
	}

	clear_problem_context(&pctx);
	for (i = 0; i < ctx->fs->group_desc_count; i++) {
		if (ext2fs_bg_flags_test(ctx->fs, i, EXT2_BG_INODE_UNINIT))
			continue;

		ino_itr = 1 + (i * (nbytes << 3));
		retval = ext2fs_get_inode_bitmap_range2(ctx->fs->inode_map,
							ino_itr, nbytes << 3,
							buf);
		if (retval)
			break;

		if (ext2fs_inode_bitmap_csum_verify(ctx->fs, i, buf, nbytes))
			continue;
		pctx.group = i;
		if (!fix_problem(ctx, PR_5_INODE_BITMAP_CSUM_INVALID, &pctx))
			continue;

		/*
		 * Fixing one checksum will rewrite all of them.  The bitmap
		 * will be checked against the one we made during pass1 for
		 * discrepancies, and fixed if need be.
		 */
		ext2fs_mark_ib_dirty(ctx->fs);
		break;
	}

	ext2fs_free_mem(&buf);
}
Пример #4
0
errcode_t ext2fs_write_bitmaps(ext2_filsys fs)
{
	errcode_t	retval;

	EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);

	if (fs->block_map && ext2fs_test_bb_dirty(fs)) {
		retval = ext2fs_write_block_bitmap(fs);
		if (retval)
			return retval;
	}
	if (fs->inode_map && ext2fs_test_ib_dirty(fs)) {
		retval = ext2fs_write_inode_bitmap(fs);
		if (retval)
			return retval;
	}
	return 0;
}