inode_modified:1;
blk64_t num_blocks;
blk64_t max_blocks;
- e2_blkcnt_t last_block;
+ blk64_t last_block;
e2_blkcnt_t last_init_lblock;
e2_blkcnt_t last_db_block;
int num_illegal_blocks;
* line up.
*/
static int has_unaligned_cluster_map(e2fsck_t ctx,
- blk64_t last_pblk, e2_blkcnt_t last_lblk,
+ blk64_t last_pblk, blk64_t last_lblk,
blk64_t pblk, blk64_t lblk)
{
blk64_t cluster_mask;
problem = PR_1_EXTENT_ENDS_BEYOND;
else if (is_leaf && is_dir &&
((extent.e_lblk + extent.e_len) >
- (1 << (21 - ctx->fs->super->s_log_block_size))))
+ (1U << (21 - ctx->fs->super->s_log_block_size))))
problem = PR_1_TOOBIG_DIR;
if (is_leaf && problem == 0 && extent.e_len > 0 &&
* pass 3 allocating empty directory blocks to fill the hole.
*/
if (try_repairs && is_dir &&
- pb->last_block + 1 < (e2_blkcnt_t)extent.e_lblk) {
+ pb->last_block + 1 < extent.e_lblk) {
blk64_t new_lblk;
new_lblk = pb->last_block + 1;
pb.ino = ino;
pb.num_blocks = 0;
- pb.last_block = -1;
+ pb.last_block = ~0;
pb.last_init_lblock = -1;
pb.last_db_block = -1;
pb.num_illegal_blocks = 0;
pb.num_blocks *= (fs->blocksize / 512);
pb.num_blocks *= EXT2FS_CLUSTER_RATIO(fs);
#if 0
- printf("inode %u, i_size = %u, last_block = %lld, i_blocks=%llu, num_blocks = %llu\n",
+ printf("inode %u, i_size = %u, last_block = %llu, i_blocks=%llu, num_blocks = %llu\n",
ino, inode->i_size, pb.last_block, ext2fs_inode_i_blocks(fs, inode),
pb.num_blocks);
#endif
if (pb.is_dir) {
- int nblock = inode->i_size >> EXT2_BLOCK_SIZE_BITS(fs->super);
+ unsigned nblock = inode->i_size >> EXT2_BLOCK_SIZE_BITS(fs->super);
if (inode->i_flags & EXT4_INLINE_DATA_FL) {
int flags;
- size_t size;
+ size_t sz = 0;
errcode_t err;
- size = 0;
flags = ctx->fs->flags;
ctx->fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS;
err = ext2fs_inline_data_size(ctx->fs, pctx->ino,
- &size);
+ &sz);
ctx->fs->flags = (flags &
EXT2_FLAG_IGNORE_CSUM_ERRORS) |
(ctx->fs->flags &
~EXT2_FLAG_IGNORE_CSUM_ERRORS);
- if (err || size != inode->i_size) {
+ if (err || sz != inode->i_size) {
bad_size = 7;
- pctx->num = size;
+ pctx->num = sz;
}
} else if (inode->i_size & (fs->blocksize - 1))
bad_size = 5;
d = NEXT_DIRENT(d);
if (d != top) {
- size_t min_size = EXT2_DIR_REC_LEN(
+ unsigned int min_size = EXT2_DIR_REC_LEN(
ext2fs_dirent_name_len(dirbuf));
- if (min_size > top - (void *)d)
+ if (min_size > (char *)top - (char *)d)
return EXT2_ET_DIR_NO_SPACE_FOR_CSUM;
- d->rec_len = top - (void *)d;
+ d->rec_len = (char *)top - (char *)d;
}
t = (struct ext2_dir_entry_tail *)top;
if ((offset + rec_len > max_block_size) ||
(rec_len < 12) ||
((rec_len % 4) != 0) ||
- ((ext2fs_dirent_name_len(dirent) + EXT2_DIR_ENTRY_HEADER_LEN) > rec_len)) {
+ (((unsigned) ext2fs_dirent_name_len(dirent) + EXT2_DIR_ENTRY_HEADER_LEN) > rec_len)) {
if (fix_problem(ctx, PR_2_DIR_CORRUPTED,
&cd->pctx)) {
#ifdef WORDS_BIGENDIAN
* Update the inode block count
*/
ext2fs_iblk_add_blocks(fs, &inode, 1);
- if (EXT2_I_SIZE(&inode) < (db->blockcnt+1) * fs->blocksize) {
+ if (EXT2_I_SIZE(&inode) < ((__u64) db->blockcnt+1) * fs->blocksize) {
pctx->errcode = ext2fs_inode_size_set(fs, &inode,
(db->blockcnt+1) * fs->blocksize);
if (pctx->errcode) {
* to do a discard operation.
*/
if (!first_block_in_bg ||
- (group == (int)fs->group_desc_count - 1) ||
+ (group == fs->group_desc_count - 1) ||
(ctx->options & E2F_OPT_DISCARD))
goto no_optimize;
{
const struct hash_entry *he_a = (const struct hash_entry *) a;
const struct hash_entry *he_b = (const struct hash_entry *) b;
- unsigned int he_a_len, he_b_len;
+ unsigned int he_a_len, he_b_len, min_len;
int ret;
- int min_len;
he_a_len = ext2fs_dirent_name_len(he_a->dir);
he_b_len = ext2fs_dirent_name_len(he_b->dir);
*/
static void mutate_name(char *str, unsigned int *len)
{
- int i;
+ int i;
unsigned int l = *len;
/*
if (!isdigit(str[i]))
break;
}
- if ((i == l-1) || (str[i] != '~')) {
+ if ((i == (int)l - 1) || (str[i] != '~')) {
if (((l-1) & 3) < 2)
l += 2;
else
for (j=0; j < fd->num_array; j++) {
if ((i==j) ||
(new_len !=
- ext2fs_dirent_name_len(fd->harray[j].dir)) ||
+ (unsigned) ext2fs_dirent_name_len(fd->harray[j].dir)) ||
strncmp(new_name, fd->harray[j].dir->name, new_len))
continue;
mutate_name(new_name, &new_len);
void *priv_data)
{
struct write_dir_struct *wd = (struct write_dir_struct *) priv_data;
- blk64_t blk;
char *dir, *buf = 0;
#ifdef REHASH_DEBUG
}
}
-static int resize2fs_setup_tdb(const char *device_name, char *undo_file,
+static int resize2fs_setup_tdb(const char *device, char *undo_file,
io_manager *io_ptr)
{
errcode_t retval = ENOMEM;
- char *tdb_dir = NULL, *tdb_file = NULL;
+ const char *tdb_dir = NULL;
+ char *tdb_file = NULL;
char *dev_name, *tmp_name;
/* (re)open a specific undo file */
printf(_("Overwriting existing filesystem; this can be undone "
"using the command:\n"
" e2undo %s %s\n\n"),
- undo_file, device_name);
+ undo_file, device);
return retval;
}
access(tdb_dir, W_OK))
return 0;
- tmp_name = strdup(device_name);
+ tmp_name = strdup(device);
if (!tmp_name)
goto errout;
dev_name = basename(tmp_name);
goto errout;
printf(_("Overwriting existing filesystem; this can be undone "
"using the command:\n"
- " e2undo %s %s\n\n"), tdb_file, device_name);
+ " e2undo %s %s\n\n"), tdb_file, device);
free(tdb_file);
return 0;
return blk == ext2fs_inode_bitmap_loc(fs, grp);
}
-static inline int is_inode_tb(ext2_filsys fs, unsigned int grp, blk64_t blk)
+static int is_inode_tb(ext2_filsys fs, unsigned int grp, blk64_t blk)
{
return blk >= ext2fs_inode_table_loc(fs, grp) &&
blk < (ext2fs_inode_table_loc(fs, grp) +
copy_size = EXT2_DESC_SIZE(rfs->new_fs->super);
for (i = 0; i < rfs->old_fs->group_desc_count; i++) {
memcpy(n, o, copy_size);
- n += EXT2_DESC_SIZE(rfs->new_fs->super);
- o += EXT2_DESC_SIZE(rfs->old_fs->super);
+ n = (char *)n + EXT2_DESC_SIZE(rfs->new_fs->super);
+ o = (char *)o + EXT2_DESC_SIZE(rfs->old_fs->super);
}
ext2fs_free_mem(&rfs->new_fs->group_desc);
{
blk64_t blk, lblk;
dgrp_t g;
- int i;
+ unsigned int i;
if (!ext2fs_has_group_desc_csum(fs))
return;
ext2fs_mark_block_bitmap2(fs->block_map,
ext2fs_inode_bitmap_loc(fs, g));
for (i = 0, blk = ext2fs_inode_table_loc(fs, g);
- i < (unsigned int) fs->inode_blocks_per_group;
+ i < fs->inode_blocks_per_group;
i++, blk++)
ext2fs_mark_block_bitmap2(fs->block_map, blk);
}
ext2_filsys old_fs,
dgrp_t group)
{
- blk64_t blk;
- int j;
- dgrp_t i;
+ blk64_t blk;
+ unsigned int j;
+ dgrp_t i;
ext2fs_block_bitmap bg_map = NULL;
- errcode_t retval = 0;
- dgrp_t count = old_fs->group_desc_count - fs->group_desc_count;
+ errcode_t retval = 0;
+ dgrp_t count = old_fs->group_desc_count - fs->group_desc_count;
/* If bigalloc, don't free metadata living in the same cluster */
if (EXT2FS_CLUSTER_RATIO(fs) > 1) {
*/
static errcode_t blocks_to_move(ext2_resize_t rfs)
{
- int j, has_super;
+ unsigned int j;
+ int has_super;
dgrp_t i, max_groups, g;
blk64_t blk, group_blk;
blk64_t old_blocks, new_blocks, group_end, cluster_freed;
ext2_filsys fs = rfs->new_fs;
ext2_filsys old_fs = rfs->old_fs;
errcode_t retval;
- __u64 size;
- int c;
+ __u64 c, size;
int to_move, moved;
ext2_badblocks_list badblock_list = 0;
int bb_modified = 0;
char *cp;
blk64_t old_blk, new_blk, blk, cluster_freed;
errcode_t retval;
- int j, to_move, moved;
+ int to_move, moved;
+ unsigned int j;
ext2fs_block_bitmap new_bmap = NULL;
max_groups = fs->group_desc_count;