diff --git a/Makefile.in b/Makefile.in index 34e2048..b951c01 100644 --- a/Makefile.in +++ b/Makefile.in @@ -13,6 +13,7 @@ INSTALL = @INSTALL@ @DEBUGFS_CMT@DEBUGFS_DIR= debugfs @UUID_CMT@UUID_LIB_SUBDIR= lib/uuid @BLKID_CMT@BLKID_LIB_SUBDIR= lib/blkid +@E2SCRUB_CMT@E2SCRUB_DIR= scrub @ALL_CMT@SUPPORT_LIB_SUBDIR= lib/support @ALL_CMT@E2P_LIB_SUBDIR= lib/e2p @ALL_CMT@EXT2FS_LIB_SUBDIR= lib/ext2fs @@ -20,7 +21,8 @@ INSTALL = @INSTALL@ LIB_SUBDIRS=lib/et lib/ss $(E2P_LIB_SUBDIR) $(UUID_LIB_SUBDIR) \ $(BLKID_LIB_SUBDIR) $(SUPPORT_LIB_SUBDIR) $(EXT2FS_LIB_SUBDIR) intl -PROG_SUBDIRS=e2fsck $(DEBUGFS_DIR) misc $(RESIZE_DIR) tests/progs po +PROG_SUBDIRS=e2fsck $(DEBUGFS_DIR) misc $(RESIZE_DIR) tests/progs po \ + $(E2SCRUB_DIR) SUBDIRS=util $(LIB_SUBDIRS) $(PROG_SUBDIRS) tests diff --git a/debian/fuse2fs.install b/debian/fuse2fs.install index cd37a70..2ed4c3c 100644 --- a/debian/fuse2fs.install +++ b/debian/fuse2fs.install @@ -1,2 +1,2 @@ -/usr/sbin/fuse2fs +/usr/bin/fuse2fs /usr/share/man/man1/fuse2fs.1 diff --git a/e2fsck/pass1b.c b/e2fsck/pass1b.c index bca701c..5693b9c 100644 --- a/e2fsck/pass1b.c +++ b/e2fsck/pass1b.c @@ -705,10 +705,6 @@ static void delete_file(e2fsck_t ctx, ext2_ino_t ino, fix_problem(ctx, PR_1B_BLOCK_ITERATE, &pctx); if (ctx->inode_bad_map) ext2fs_unmark_inode_bitmap2(ctx->inode_bad_map, ino); - if (ctx->inode_reg_map) - ext2fs_unmark_inode_bitmap2(ctx->inode_reg_map, ino); - ext2fs_unmark_inode_bitmap2(ctx->inode_dir_map, ino); - ext2fs_unmark_inode_bitmap2(ctx->inode_used_map, ino); ext2fs_inode_alloc_stats2(fs, ino, -1, LINUX_S_ISDIR(dp->inode.i_mode)); quota_data_sub(ctx->qctx, &dp->inode, ino, pb.dup_blocks * fs->blocksize); diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c index 54bc680..a5fc1be 100644 --- a/e2fsck/rehash.c +++ b/e2fsck/rehash.c @@ -160,10 +160,6 @@ static int fill_dir_block(ext2_filsys fs, dir_offset += rec_len; if (dirent->inode == 0) continue; - if ((name_len) == 0) { - fd->err = EXT2_ET_DIR_CORRUPTED; - return BLOCK_ABORT; - } if (!fd->compress && (name_len == 1) && (dirent->name[0] == '.')) continue; @@ -276,11 +272,7 @@ static errcode_t alloc_size_dir(ext2_filsys fs, struct out_dir *outdir, outdir->hashes = new_mem; } else { outdir->buf = malloc(blocks * fs->blocksize); - if (!outdir->buf) - return ENOMEM; outdir->hashes = malloc(blocks * sizeof(ext2_dirhash_t)); - if (!outdir->hashes) - return ENOMEM; outdir->num = 0; } outdir->max = blocks; @@ -301,11 +293,7 @@ static errcode_t get_next_block(ext2_filsys fs, struct out_dir *outdir, errcode_t retval; if (outdir->num >= outdir->max) { - int increment = outdir->max / 10; - - if (increment < 50) - increment = 50; - retval = alloc_size_dir(fs, outdir, outdir->max + increment); + retval = alloc_size_dir(fs, outdir, outdir->max + 50); if (retval) return retval; } @@ -413,11 +401,6 @@ static int duplicate_search_and_fix(e2fsck_t ctx, ext2_filsys fs, continue; } new_len = ext2fs_dirent_name_len(ent->dir); - if (new_len == 0) { - /* should never happen */ - ext2fs_unmark_valid(fs); - continue; - } memcpy(new_name, ent->dir->name, new_len); mutate_name(new_name, &new_len); for (j=0; j < fd->num_array; j++) { @@ -649,9 +632,6 @@ static int alloc_blocks(ext2_filsys fs, if (retval) return retval; - /* outdir->buf might be reallocated */ - *prev_ent = (struct ext2_dx_entry *) (outdir->buf + *prev_offset); - *next_ent = set_int_node(fs, block_start); *limit = (struct ext2_dx_countlimit *)(*next_ent); if (next_offset) @@ -741,9 +721,6 @@ static errcode_t calculate_tree(ext2_filsys fs, return retval; } if (c3 == 0) { - int delta1 = (char *)int_limit - outdir->buf; - int delta2 = (char *)root - outdir->buf; - retval = alloc_blocks(fs, &limit, &int_ent, &dx_ent, &int_offset, NULL, outdir, i, &c2, @@ -751,11 +728,6 @@ static errcode_t calculate_tree(ext2_filsys fs, if (retval) return retval; - /* outdir->buf might be reallocated */ - int_limit = (struct ext2_dx_countlimit *) - (outdir->buf + delta1); - root = (struct ext2_dx_entry *) - (outdir->buf + delta2); } dx_ent->block = ext2fs_cpu_to_le32(i); if (c3 != limit->limit) @@ -1047,8 +1019,6 @@ void e2fsck_rehash_directories(e2fsck_t ctx) if (!ext2fs_u32_list_iterate(iter, &ino)) break; } - if (!ext2fs_test_inode_bitmap2(ctx->inode_dir_map, ino)) - continue; pctx.dir = ino; if (first) { diff --git a/e2fsck/super.c b/e2fsck/super.c index 18affcf..e5932be 100644 --- a/e2fsck/super.c +++ b/e2fsck/super.c @@ -1038,7 +1038,7 @@ void check_super_block(e2fsck_t ctx) * Check to see if the superblock last mount time or last * write time is in the future. */ - if (!broken_system_clock && fs->super->s_checkinterval && + if (!broken_system_clock && !(ctx->flags & E2F_FLAG_TIME_INSANE) && fs->super->s_mtime > (__u32) ctx->now) { pctx.num = fs->super->s_mtime; @@ -1050,7 +1050,7 @@ void check_super_block(e2fsck_t ctx) fs->flags |= EXT2_FLAG_DIRTY; } } - if (!broken_system_clock && fs->super->s_checkinterval && + if (!broken_system_clock && !(ctx->flags & E2F_FLAG_TIME_INSANE) && fs->super->s_wtime > (__u32) ctx->now) { pctx.num = fs->super->s_wtime; diff --git a/lib/ext2fs/bitmaps.c b/lib/ext2fs/bitmaps.c index 8402191..e25db2c 100644 --- a/lib/ext2fs/bitmaps.c +++ b/lib/ext2fs/bitmaps.c @@ -125,6 +125,7 @@ errcode_t ext2fs_allocate_subcluster_bitmap(ext2_filsys fs, { __u64 start, end, real_end; ext2fs_generic_bitmap bmap; + ext2fs_generic_bitmap_64 bmap64; errcode_t retval; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); @@ -147,14 +148,15 @@ errcode_t ext2fs_allocate_subcluster_bitmap(ext2_filsys fs, end, real_end, descr, &bmap); if (retval) return retval; - bmap->cluster_bits = 0; + bmap64 = (ext2fs_generic_bitmap_64) bmap; + bmap64->cluster_bits = 0; *ret = bmap; return 0; } int ext2fs_get_bitmap_granularity(ext2fs_block_bitmap bitmap) { - ext2fs_generic_bitmap bmap = bitmap; + ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) bitmap; if (!EXT2FS_IS_64_BITMAP(bmap)) return 0; diff --git a/lib/ext2fs/blkmap64_ba.c b/lib/ext2fs/blkmap64_ba.c index 3707a61..85cb38d 100644 --- a/lib/ext2fs/blkmap64_ba.c +++ b/lib/ext2fs/blkmap64_ba.c @@ -40,7 +40,7 @@ struct ext2fs_ba_private_struct { typedef struct ext2fs_ba_private_struct *ext2fs_ba_private; -static errcode_t ba_alloc_private_data (ext2fs_generic_bitmap bitmap) +static errcode_t ba_alloc_private_data (ext2fs_generic_bitmap_64 bitmap) { ext2fs_ba_private bp; errcode_t retval; @@ -69,7 +69,7 @@ static errcode_t ba_alloc_private_data (ext2fs_generic_bitmap bitmap) } static errcode_t ba_new_bmap(ext2_filsys fs EXT2FS_ATTR((unused)), - ext2fs_generic_bitmap bitmap) + ext2fs_generic_bitmap_64 bitmap) { ext2fs_ba_private bp; errcode_t retval; @@ -86,7 +86,7 @@ static errcode_t ba_new_bmap(ext2_filsys fs EXT2FS_ATTR((unused)), return 0; } -static void ba_free_bmap(ext2fs_generic_bitmap bitmap) +static void ba_free_bmap(ext2fs_generic_bitmap_64 bitmap) { ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private; @@ -101,8 +101,8 @@ static void ba_free_bmap(ext2fs_generic_bitmap bitmap) bp = 0; } -static errcode_t ba_copy_bmap(ext2fs_generic_bitmap src, - ext2fs_generic_bitmap dest) +static errcode_t ba_copy_bmap(ext2fs_generic_bitmap_64 src, + ext2fs_generic_bitmap_64 dest) { ext2fs_ba_private src_bp = (ext2fs_ba_private) src->private; ext2fs_ba_private dest_bp; @@ -121,7 +121,7 @@ static errcode_t ba_copy_bmap(ext2fs_generic_bitmap src, return 0; } -static errcode_t ba_resize_bmap(ext2fs_generic_bitmap bmap, +static errcode_t ba_resize_bmap(ext2fs_generic_bitmap_64 bmap, __u64 new_end, __u64 new_real_end) { ext2fs_ba_private bp = (ext2fs_ba_private) bmap->private; @@ -162,7 +162,7 @@ static errcode_t ba_resize_bmap(ext2fs_generic_bitmap bmap, } -static int ba_mark_bmap(ext2fs_generic_bitmap bitmap, __u64 arg) +static int ba_mark_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg) { ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private; blk64_t bitno = (blk64_t) arg; @@ -170,7 +170,7 @@ static int ba_mark_bmap(ext2fs_generic_bitmap bitmap, __u64 arg) return ext2fs_set_bit64(bitno - bitmap->start, bp->bitarray); } -static int ba_unmark_bmap(ext2fs_generic_bitmap bitmap, __u64 arg) +static int ba_unmark_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg) { ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private; blk64_t bitno = (blk64_t) arg; @@ -178,7 +178,7 @@ static int ba_unmark_bmap(ext2fs_generic_bitmap bitmap, __u64 arg) return ext2fs_clear_bit64(bitno - bitmap->start, bp->bitarray); } -static int ba_test_bmap(ext2fs_generic_bitmap bitmap, __u64 arg) +static int ba_test_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg) { ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private; blk64_t bitno = (blk64_t) arg; @@ -186,7 +186,7 @@ static int ba_test_bmap(ext2fs_generic_bitmap bitmap, __u64 arg) return ext2fs_test_bit64(bitno - bitmap->start, bp->bitarray); } -static void ba_mark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg, +static void ba_mark_bmap_extent(ext2fs_generic_bitmap_64 bitmap, __u64 arg, unsigned int num) { ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private; @@ -197,7 +197,7 @@ static void ba_mark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg, ext2fs_fast_set_bit64(bitno + i - bitmap->start, bp->bitarray); } -static void ba_unmark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg, +static void ba_unmark_bmap_extent(ext2fs_generic_bitmap_64 bitmap, __u64 arg, unsigned int num) { ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private; @@ -208,7 +208,7 @@ static void ba_unmark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg, ext2fs_fast_clear_bit64(bitno + i - bitmap->start, bp->bitarray); } -static int ba_test_clear_bmap_extent(ext2fs_generic_bitmap bitmap, +static int ba_test_clear_bmap_extent(ext2fs_generic_bitmap_64 bitmap, __u64 start, unsigned int len) { ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private; @@ -282,7 +282,7 @@ static int ba_test_clear_bmap_extent(ext2fs_generic_bitmap bitmap, } -static errcode_t ba_set_bmap_range(ext2fs_generic_bitmap bitmap, +static errcode_t ba_set_bmap_range(ext2fs_generic_bitmap_64 bitmap, __u64 start, size_t num, void *in) { ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private; @@ -292,7 +292,7 @@ static errcode_t ba_set_bmap_range(ext2fs_generic_bitmap bitmap, return 0; } -static errcode_t ba_get_bmap_range(ext2fs_generic_bitmap bitmap, +static errcode_t ba_get_bmap_range(ext2fs_generic_bitmap_64 bitmap, __u64 start, size_t num, void *out) { ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private; @@ -302,7 +302,7 @@ static errcode_t ba_get_bmap_range(ext2fs_generic_bitmap bitmap, return 0; } -static void ba_clear_bmap(ext2fs_generic_bitmap bitmap) +static void ba_clear_bmap(ext2fs_generic_bitmap_64 bitmap) { ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private; @@ -311,20 +311,20 @@ static void ba_clear_bmap(ext2fs_generic_bitmap bitmap) } #ifdef ENABLE_BMAP_STATS -static void ba_print_stats(ext2fs_generic_bitmap bitmap) +static void ba_print_stats(ext2fs_generic_bitmap_64 bitmap) { fprintf(stderr, "%16llu Bytes used by bitarray\n", ((bitmap->real_end - bitmap->start) >> 3) + 1 + sizeof(struct ext2fs_ba_private_struct)); } #else -static void ba_print_stats(ext2fs_generic_bitmap bitmap EXT2FS_ATTR((unused))) +static void ba_print_stats(ext2fs_generic_bitmap_64 bitmap EXT2FS_ATTR((unused))) { } #endif /* Find the first zero bit between start and end, inclusive. */ -static errcode_t ba_find_first_zero(ext2fs_generic_bitmap bitmap, +static errcode_t ba_find_first_zero(ext2fs_generic_bitmap_64 bitmap, __u64 start, __u64 end, __u64 *out) { ext2fs_ba_private bp = (ext2fs_ba_private)bitmap->private; @@ -398,7 +398,7 @@ static errcode_t ba_find_first_zero(ext2fs_generic_bitmap bitmap, } /* Find the first one bit between start and end, inclusive. */ -static errcode_t ba_find_first_set(ext2fs_generic_bitmap bitmap, +static errcode_t ba_find_first_set(ext2fs_generic_bitmap_64 bitmap, __u64 start, __u64 end, __u64 *out) { ext2fs_ba_private bp = (ext2fs_ba_private)bitmap->private; diff --git a/lib/ext2fs/blkmap64_rb.c b/lib/ext2fs/blkmap64_rb.c index 4cbfb1e..1fd5527 100644 --- a/lib/ext2fs/blkmap64_rb.c +++ b/lib/ext2fs/blkmap64_rb.c @@ -177,7 +177,7 @@ static void rb_free_extent(struct ext2fs_rb_private *bp, ext2fs_free_mem(&ext); } -static errcode_t rb_alloc_private_data (ext2fs_generic_bitmap bitmap) +static errcode_t rb_alloc_private_data (ext2fs_generic_bitmap_64 bitmap) { struct ext2fs_rb_private *bp; errcode_t retval; @@ -201,7 +201,7 @@ static errcode_t rb_alloc_private_data (ext2fs_generic_bitmap bitmap) } static errcode_t rb_new_bmap(ext2_filsys fs EXT2FS_ATTR((unused)), - ext2fs_generic_bitmap bitmap) + ext2fs_generic_bitmap_64 bitmap) { errcode_t retval; @@ -225,7 +225,7 @@ static void rb_free_tree(struct rb_root *root) } } -static void rb_free_bmap(ext2fs_generic_bitmap bitmap) +static void rb_free_bmap(ext2fs_generic_bitmap_64 bitmap) { struct ext2fs_rb_private *bp; @@ -236,8 +236,8 @@ static void rb_free_bmap(ext2fs_generic_bitmap bitmap) bp = 0; } -static errcode_t rb_copy_bmap(ext2fs_generic_bitmap src, - ext2fs_generic_bitmap dest) +static errcode_t rb_copy_bmap(ext2fs_generic_bitmap_64 src, + ext2fs_generic_bitmap_64 dest) { struct ext2fs_rb_private *src_bp, *dest_bp; struct bmap_rb_extent *src_ext, *dest_ext; @@ -302,7 +302,7 @@ static void rb_truncate(__u64 new_max, struct rb_root *root) } } -static errcode_t rb_resize_bmap(ext2fs_generic_bitmap bmap, +static errcode_t rb_resize_bmap(ext2fs_generic_bitmap_64 bmap, __u64 new_end, __u64 new_real_end) { struct ext2fs_rb_private *bp; @@ -575,7 +575,7 @@ static int rb_remove_extent(__u64 start, __u64 count, return retval; } -static int rb_mark_bmap(ext2fs_generic_bitmap bitmap, __u64 arg) +static int rb_mark_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg) { struct ext2fs_rb_private *bp; int retval; @@ -588,7 +588,7 @@ static int rb_mark_bmap(ext2fs_generic_bitmap bitmap, __u64 arg) return retval; } -static int rb_unmark_bmap(ext2fs_generic_bitmap bitmap, __u64 arg) +static int rb_unmark_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg) { struct ext2fs_rb_private *bp; int retval; @@ -603,7 +603,7 @@ static int rb_unmark_bmap(ext2fs_generic_bitmap bitmap, __u64 arg) } inline -static int rb_test_bmap(ext2fs_generic_bitmap bitmap, __u64 arg) +static int rb_test_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg) { struct ext2fs_rb_private *bp; @@ -613,7 +613,7 @@ static int rb_test_bmap(ext2fs_generic_bitmap bitmap, __u64 arg) return rb_test_bit(bp, arg); } -static void rb_mark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg, +static void rb_mark_bmap_extent(ext2fs_generic_bitmap_64 bitmap, __u64 arg, unsigned int num) { struct ext2fs_rb_private *bp; @@ -625,7 +625,7 @@ static void rb_mark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg, check_tree(&bp->root, __func__); } -static void rb_unmark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg, +static void rb_unmark_bmap_extent(ext2fs_generic_bitmap_64 bitmap, __u64 arg, unsigned int num) { struct ext2fs_rb_private *bp; @@ -637,7 +637,7 @@ static void rb_unmark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg, check_tree(&bp->root, __func__); } -static int rb_test_clear_bmap_extent(ext2fs_generic_bitmap bitmap, +static int rb_test_clear_bmap_extent(ext2fs_generic_bitmap_64 bitmap, __u64 start, unsigned int len) { struct rb_node *parent = NULL, **n; @@ -693,7 +693,7 @@ static int rb_test_clear_bmap_extent(ext2fs_generic_bitmap bitmap, return retval; } -static errcode_t rb_set_bmap_range(ext2fs_generic_bitmap bitmap, +static errcode_t rb_set_bmap_range(ext2fs_generic_bitmap_64 bitmap, __u64 start, size_t num, void *in) { struct ext2fs_rb_private *bp; @@ -739,7 +739,7 @@ static errcode_t rb_set_bmap_range(ext2fs_generic_bitmap bitmap, return 0; } -static errcode_t rb_get_bmap_range(ext2fs_generic_bitmap bitmap, +static errcode_t rb_get_bmap_range(ext2fs_generic_bitmap_64 bitmap, __u64 start, size_t num, void *out) { @@ -804,7 +804,7 @@ static errcode_t rb_get_bmap_range(ext2fs_generic_bitmap bitmap, return 0; } -static void rb_clear_bmap(ext2fs_generic_bitmap bitmap) +static void rb_clear_bmap(ext2fs_generic_bitmap_64 bitmap) { struct ext2fs_rb_private *bp; @@ -817,7 +817,7 @@ static void rb_clear_bmap(ext2fs_generic_bitmap bitmap) check_tree(&bp->root, __func__); } -static errcode_t rb_find_first_zero(ext2fs_generic_bitmap bitmap, +static errcode_t rb_find_first_zero(ext2fs_generic_bitmap_64 bitmap, __u64 start, __u64 end, __u64 *out) { struct rb_node *parent = NULL, **n; @@ -853,7 +853,7 @@ static errcode_t rb_find_first_zero(ext2fs_generic_bitmap bitmap, return 0; } -static errcode_t rb_find_first_set(ext2fs_generic_bitmap bitmap, +static errcode_t rb_find_first_set(ext2fs_generic_bitmap_64 bitmap, __u64 start, __u64 end, __u64 *out) { struct rb_node *parent = NULL, **n; @@ -902,7 +902,7 @@ static errcode_t rb_find_first_set(ext2fs_generic_bitmap bitmap, } #ifdef ENABLE_BMAP_STATS -static void rb_print_stats(ext2fs_generic_bitmap bitmap) +static void rb_print_stats(ext2fs_generic_bitmap_64 bitmap) { struct ext2fs_rb_private *bp; struct rb_node *node = NULL; @@ -963,7 +963,7 @@ static void rb_print_stats(ext2fs_generic_bitmap bitmap) eff); } #else -static void rb_print_stats(ext2fs_generic_bitmap bitmap EXT2FS_ATTR((unused))) +static void rb_print_stats(ext2fs_generic_bitmap_64 bitmap EXT2FS_ATTR((unused))) { } #endif diff --git a/lib/ext2fs/bmap64.h b/lib/ext2fs/bmap64.h index d8c7a3c..de33454 100644 --- a/lib/ext2fs/bmap64.h +++ b/lib/ext2fs/bmap64.h @@ -37,7 +37,7 @@ struct ext2_bmap_statistics { }; -struct ext2fs_struct_generic_bitmap { +struct ext2fs_struct_generic_bitmap_64 { errcode_t magic; ext2_filsys fs; struct ext2_bitmap_ops *bitmap_ops; @@ -53,6 +53,8 @@ struct ext2fs_struct_generic_bitmap { #endif }; +typedef struct ext2fs_struct_generic_bitmap_64 *ext2fs_generic_bitmap_64; + #define EXT2FS_IS_32_BITMAP(bmap) \ (((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP) || \ ((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP) || \ @@ -66,37 +68,37 @@ struct ext2fs_struct_generic_bitmap { struct ext2_bitmap_ops { int type; /* Generic bmap operators */ - errcode_t (*new_bmap)(ext2_filsys fs, ext2fs_generic_bitmap bmap); - void (*free_bmap)(ext2fs_generic_bitmap bitmap); - errcode_t (*copy_bmap)(ext2fs_generic_bitmap src, - ext2fs_generic_bitmap dest); - errcode_t (*resize_bmap)(ext2fs_generic_bitmap bitmap, + errcode_t (*new_bmap)(ext2_filsys fs, ext2fs_generic_bitmap_64 bmap); + void (*free_bmap)(ext2fs_generic_bitmap_64 bitmap); + errcode_t (*copy_bmap)(ext2fs_generic_bitmap_64 src, + ext2fs_generic_bitmap_64 dest); + errcode_t (*resize_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 new_end, __u64 new_real_end); /* bit set/test operators */ - int (*mark_bmap)(ext2fs_generic_bitmap bitmap, __u64 arg); - int (*unmark_bmap)(ext2fs_generic_bitmap bitmap, __u64 arg); - int (*test_bmap)(ext2fs_generic_bitmap bitmap, __u64 arg); - void (*mark_bmap_extent)(ext2fs_generic_bitmap bitmap, __u64 arg, + int (*mark_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg); + int (*unmark_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg); + int (*test_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg); + void (*mark_bmap_extent)(ext2fs_generic_bitmap_64 bitmap, __u64 arg, unsigned int num); - void (*unmark_bmap_extent)(ext2fs_generic_bitmap bitmap, __u64 arg, + void (*unmark_bmap_extent)(ext2fs_generic_bitmap_64 bitmap, __u64 arg, unsigned int num); - int (*test_clear_bmap_extent)(ext2fs_generic_bitmap bitmap, + int (*test_clear_bmap_extent)(ext2fs_generic_bitmap_64 bitmap, __u64 arg, unsigned int num); - errcode_t (*set_bmap_range)(ext2fs_generic_bitmap bitmap, + errcode_t (*set_bmap_range)(ext2fs_generic_bitmap_64 bitmap, __u64 start, size_t num, void *in); - errcode_t (*get_bmap_range)(ext2fs_generic_bitmap bitmap, + errcode_t (*get_bmap_range)(ext2fs_generic_bitmap_64 bitmap, __u64 start, size_t num, void *out); - void (*clear_bmap)(ext2fs_generic_bitmap bitmap); - void (*print_stats)(ext2fs_generic_bitmap); + void (*clear_bmap)(ext2fs_generic_bitmap_64 bitmap); + void (*print_stats)(ext2fs_generic_bitmap_64); /* Find the first zero bit between start and end, inclusive. * May be NULL, in which case a generic function is used. */ - errcode_t (*find_first_zero)(ext2fs_generic_bitmap bitmap, + errcode_t (*find_first_zero)(ext2fs_generic_bitmap_64 bitmap, __u64 start, __u64 end, __u64 *out); /* Find the first set bit between start and end, inclusive. * May be NULL, in which case a generic function is used. */ - errcode_t (*find_first_set)(ext2fs_generic_bitmap bitmap, + errcode_t (*find_first_set)(ext2fs_generic_bitmap_64 bitmap, __u64 start, __u64 end, __u64 *out); }; diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 5bb9133..59fd974 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -111,9 +111,14 @@ typedef struct struct_ext2_filsys *ext2_filsys; #define EXT2FS_UNMARK_ERROR 1 #define EXT2FS_TEST_ERROR 2 -typedef struct ext2fs_struct_generic_bitmap *ext2fs_generic_bitmap; -typedef struct ext2fs_struct_generic_bitmap *ext2fs_inode_bitmap; -typedef struct ext2fs_struct_generic_bitmap *ext2fs_block_bitmap; +struct ext2fs_struct_generic_bitmap_base { + errcode_t magic; + ext2_filsys fs; +}; + +typedef struct ext2fs_struct_generic_bitmap_base *ext2fs_generic_bitmap; +typedef struct ext2fs_struct_generic_bitmap_base *ext2fs_inode_bitmap; +typedef struct ext2fs_struct_generic_bitmap_base *ext2fs_block_bitmap; #define EXT2_FIRST_INODE(s) EXT2_FIRST_INO(s) @@ -250,17 +255,10 @@ struct struct_ext2_filsys { int cluster_ratio_bits; __u16 default_bitmap_type; __u16 pad; - - /* - * RedHat specific change to prevent ABI change by using 8 - * reserved bytes - */ - const struct ext2fs_nls_table *encoding; - /* * Reserved for future expansion */ - __u32 reserved[5 - (sizeof(long int)/4)]; + __u32 reserved[5]; /* * Reserved for the use of the calling application. @@ -311,6 +309,8 @@ struct struct_ext2_filsys { /* hashmap for SHA of data blocks */ struct ext2fs_hashmap* block_sha_map; + + const struct ext2fs_nls_table *encoding; }; #if EXT2_FLAT_INCLUDES diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c index affc1a8..78a823a 100644 --- a/lib/ext2fs/ext_attr.c +++ b/lib/ext2fs/ext_attr.c @@ -1550,15 +1550,14 @@ errcode_t ext2fs_xattr_set(struct ext2_xattr_handle *h, new_value, &value_len); if (ret) goto out; - } else if (value_len) + } else memcpy(new_value, value, value_len); /* Imitate kernel behavior by skipping update if value is the same. */ for (x = h->attrs; x < h->attrs + h->count; x++) { if (!strcmp(x->name, name)) { if (!x->ea_ino && x->value_len == value_len && - (!value_len || - !memcmp(x->value, new_value, value_len))) { + !memcmp(x->value, new_value, value_len)) { ret = 0; goto out; } diff --git a/lib/ext2fs/gen_bitmap.c b/lib/ext2fs/gen_bitmap.c index 674baa3..c94c21b 100644 --- a/lib/ext2fs/gen_bitmap.c +++ b/lib/ext2fs/gen_bitmap.c @@ -28,7 +28,7 @@ #include "ext2_fs.h" #include "ext2fsP.h" -struct ext2fs_struct_generic_bitmap { +struct ext2fs_struct_generic_bitmap_32 { errcode_t magic; ext2_filsys fs; __u32 start, end; @@ -39,6 +39,8 @@ struct ext2fs_struct_generic_bitmap { __u32 reserved[7]; }; +typedef struct ext2fs_struct_generic_bitmap_32 *ext2fs_generic_bitmap_32; + #define EXT2FS_IS_32_BITMAP(bmap) \ (((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP) || \ ((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP) || \ @@ -53,9 +55,11 @@ struct ext2fs_struct_generic_bitmap { * Used by previously inlined function, so we have to export this and * not change the function signature */ -void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap, +void ext2fs_warn_bitmap2(ext2fs_generic_bitmap gen_bitmap, int code, unsigned long arg) { + ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap; + #ifndef OMIT_COM_ERR if (bitmap->description) com_err(0, bitmap->base_error_code+code, @@ -79,11 +83,11 @@ errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs, const char *descr, char *init_map, ext2fs_generic_bitmap *ret) { - ext2fs_generic_bitmap bitmap; + ext2fs_generic_bitmap_32 bitmap; errcode_t retval; size_t size; - retval = ext2fs_get_mem(sizeof(struct ext2fs_struct_generic_bitmap), + retval = ext2fs_get_mem(sizeof(struct ext2fs_struct_generic_bitmap_32), &bitmap); if (retval) return retval; @@ -127,7 +131,7 @@ errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs, memcpy(bitmap->bitmap, init_map, size); else memset(bitmap->bitmap, 0, size); - *ret = bitmap; + *ret = (ext2fs_generic_bitmap) bitmap; return 0; } @@ -141,9 +145,11 @@ errcode_t ext2fs_allocate_generic_bitmap(__u32 start, start, end, real_end, descr, 0, ret); } -errcode_t ext2fs_copy_generic_bitmap(ext2fs_generic_bitmap src, +errcode_t ext2fs_copy_generic_bitmap(ext2fs_generic_bitmap gen_src, ext2fs_generic_bitmap *dest) { + ext2fs_generic_bitmap_32 src = (ext2fs_generic_bitmap_32) gen_src; + return (ext2fs_make_generic_bitmap(src->magic, src->fs, src->start, src->end, src->real_end, @@ -151,9 +157,11 @@ errcode_t ext2fs_copy_generic_bitmap(ext2fs_generic_bitmap src, dest)); } -void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap) +void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap gen_bitmap) { - if (check_magic(bitmap)) + ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap; + + if (check_magic(gen_bitmap)) return; bitmap->magic = 0; @@ -171,6 +179,8 @@ void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap) int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap, blk_t bitno) { + ext2fs_generic_bitmap_32 bitmap32 = (ext2fs_generic_bitmap_32) bitmap; + if (!EXT2FS_IS_32_BITMAP(bitmap)) { if (EXT2FS_IS_64_BITMAP(bitmap)) { ext2fs_warn_bitmap32(bitmap, __func__); @@ -183,16 +193,18 @@ int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap, return 0; } - if ((bitno < bitmap->start) || (bitno > bitmap->end)) { + if ((bitno < bitmap32->start) || (bitno > bitmap32->end)) { ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, bitno); return 0; } - return ext2fs_test_bit(bitno - bitmap->start, bitmap->bitmap); + return ext2fs_test_bit(bitno - bitmap32->start, bitmap32->bitmap); } int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap, __u32 bitno) { + ext2fs_generic_bitmap_32 bitmap32 = (ext2fs_generic_bitmap_32) bitmap; + if (!EXT2FS_IS_32_BITMAP(bitmap)) { if (EXT2FS_IS_64_BITMAP(bitmap)) { ext2fs_warn_bitmap32(bitmap, __func__); @@ -205,16 +217,18 @@ int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap, return 0; } - if ((bitno < bitmap->start) || (bitno > bitmap->end)) { + if ((bitno < bitmap32->start) || (bitno > bitmap32->end)) { ext2fs_warn_bitmap2(bitmap, EXT2FS_MARK_ERROR, bitno); return 0; } - return ext2fs_set_bit(bitno - bitmap->start, bitmap->bitmap); + return ext2fs_set_bit(bitno - bitmap32->start, bitmap32->bitmap); } int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap, blk_t bitno) { + ext2fs_generic_bitmap_32 bitmap32 = (ext2fs_generic_bitmap_32) bitmap; + if (!EXT2FS_IS_32_BITMAP(bitmap)) { if (EXT2FS_IS_64_BITMAP(bitmap)) { ext2fs_warn_bitmap32(bitmap, __func__); @@ -227,15 +241,17 @@ int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap, return 0; } - if ((bitno < bitmap->start) || (bitno > bitmap->end)) { + if ((bitno < bitmap32->start) || (bitno > bitmap32->end)) { ext2fs_warn_bitmap2(bitmap, EXT2FS_UNMARK_ERROR, bitno); return 0; } - return ext2fs_clear_bit(bitno - bitmap->start, bitmap->bitmap); + return ext2fs_clear_bit(bitno - bitmap32->start, bitmap32->bitmap); } __u32 ext2fs_get_generic_bitmap_start(ext2fs_generic_bitmap bitmap) { + ext2fs_generic_bitmap_32 bitmap32 = (ext2fs_generic_bitmap_32) bitmap; + if (!EXT2FS_IS_32_BITMAP(bitmap)) { if (EXT2FS_IS_64_BITMAP(bitmap)) { ext2fs_warn_bitmap32(bitmap, __func__); @@ -248,11 +264,13 @@ __u32 ext2fs_get_generic_bitmap_start(ext2fs_generic_bitmap bitmap) return 0; } - return bitmap->start; + return bitmap32->start; } __u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap) { + ext2fs_generic_bitmap_32 bitmap32 = (ext2fs_generic_bitmap_32) bitmap; + if (!EXT2FS_IS_32_BITMAP(bitmap)) { if (EXT2FS_IS_64_BITMAP(bitmap)) { ext2fs_warn_bitmap32(bitmap, __func__); @@ -264,11 +282,13 @@ __u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap) #endif return 0; } - return bitmap->end; + return bitmap32->end; } void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap) { + ext2fs_generic_bitmap_32 bitmap32 = (ext2fs_generic_bitmap_32) bitmap; + if (!EXT2FS_IS_32_BITMAP(bitmap)) { if (EXT2FS_IS_64_BITMAP(bitmap)) { ext2fs_warn_bitmap32(bitmap, __func__); @@ -282,14 +302,16 @@ void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap) return; } - memset(bitmap->bitmap, 0, - (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1)); + memset(bitmap32->bitmap, 0, + (size_t) (((bitmap32->real_end - bitmap32->start) / 8) + 1)); } -errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap bitmap, +errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap gen_bitmap, errcode_t magic, errcode_t neq, ext2_ino_t end, ext2_ino_t *oend) { + ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap; + EXT2_CHECK_MAGIC(bitmap, magic); if (end > bitmap->real_end) @@ -302,8 +324,9 @@ errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap bitmap, errcode_t ext2fs_resize_generic_bitmap(errcode_t magic, __u32 new_end, __u32 new_real_end, - ext2fs_generic_bitmap bmap) + ext2fs_generic_bitmap gen_bmap) { + ext2fs_generic_bitmap_32 bmap = (ext2fs_generic_bitmap_32) gen_bmap; errcode_t retval; size_t size, new_size; __u32 bitno; @@ -344,9 +367,11 @@ errcode_t ext2fs_resize_generic_bitmap(errcode_t magic, } errcode_t ext2fs_compare_generic_bitmap(errcode_t magic, errcode_t neq, - ext2fs_generic_bitmap bm1, - ext2fs_generic_bitmap bm2) + ext2fs_generic_bitmap gen_bm1, + ext2fs_generic_bitmap gen_bm2) { + ext2fs_generic_bitmap_32 bm1 = (ext2fs_generic_bitmap_32) gen_bm1; + ext2fs_generic_bitmap_32 bm2 = (ext2fs_generic_bitmap_32) gen_bm2; blk_t i; if (!bm1 || bm1->magic != magic) @@ -361,15 +386,16 @@ errcode_t ext2fs_compare_generic_bitmap(errcode_t magic, errcode_t neq, return neq; for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++) - if (ext2fs_fast_test_block_bitmap(bm1, i) != - ext2fs_fast_test_block_bitmap(bm2, i)) + if (ext2fs_fast_test_block_bitmap(gen_bm1, i) != + ext2fs_fast_test_block_bitmap(gen_bm2, i)) return neq; return 0; } -void ext2fs_set_generic_bitmap_padding(ext2fs_generic_bitmap map) +void ext2fs_set_generic_bitmap_padding(ext2fs_generic_bitmap gen_map) { + ext2fs_generic_bitmap_32 map = (ext2fs_generic_bitmap_32) gen_map; __u32 i, j; /* Protect loop from wrap-around if map->real_end is maxed */ @@ -379,11 +405,13 @@ void ext2fs_set_generic_bitmap_padding(ext2fs_generic_bitmap map) ext2fs_set_bit(j, map->bitmap); } -errcode_t ext2fs_get_generic_bitmap_range(ext2fs_generic_bitmap bmap, +errcode_t ext2fs_get_generic_bitmap_range(ext2fs_generic_bitmap gen_bmap, errcode_t magic, __u32 start, __u32 num, void *out) { + ext2fs_generic_bitmap_32 bmap = (ext2fs_generic_bitmap_32) gen_bmap; + if (!bmap || (bmap->magic != magic)) return magic; @@ -394,11 +422,13 @@ errcode_t ext2fs_get_generic_bitmap_range(ext2fs_generic_bitmap bmap, return 0; } -errcode_t ext2fs_set_generic_bitmap_range(ext2fs_generic_bitmap bmap, +errcode_t ext2fs_set_generic_bitmap_range(ext2fs_generic_bitmap gen_bmap, errcode_t magic, __u32 start, __u32 num, void *in) { + ext2fs_generic_bitmap_32 bmap = (ext2fs_generic_bitmap_32) gen_bmap; + if (!bmap || (bmap->magic != magic)) return magic; @@ -432,10 +462,11 @@ int ext2fs_mem_is_zero(const char *mem, size_t len) /* * Return true if all of the bits in a specified range are clear */ -static int ext2fs_test_clear_generic_bitmap_range(ext2fs_generic_bitmap bitmap, +static int ext2fs_test_clear_generic_bitmap_range(ext2fs_generic_bitmap gen_bitmap, unsigned int start, unsigned int len) { + ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap; size_t start_byte, len_byte = len >> 3; unsigned int start_bit, len_bit = len % 8; int first_bit = 0; @@ -504,14 +535,15 @@ static int ext2fs_test_clear_generic_bitmap_range(ext2fs_generic_bitmap bitmap, return ext2fs_mem_is_zero(ADDR + start_byte, len_byte); } -errcode_t ext2fs_find_first_zero_generic_bitmap(ext2fs_generic_bitmap bitmap, +errcode_t ext2fs_find_first_zero_generic_bitmap(ext2fs_generic_bitmap gen_bitmap, __u32 start, __u32 end, __u32 *out) { + ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap; blk_t b; if (start < bitmap->start || end > bitmap->end || start > end) { - ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, start); + ext2fs_warn_bitmap2(gen_bitmap, EXT2FS_TEST_ERROR, start); return EINVAL; } @@ -527,14 +559,15 @@ errcode_t ext2fs_find_first_zero_generic_bitmap(ext2fs_generic_bitmap bitmap, return ENOENT; } -errcode_t ext2fs_find_first_set_generic_bitmap(ext2fs_generic_bitmap bitmap, +errcode_t ext2fs_find_first_set_generic_bitmap(ext2fs_generic_bitmap gen_bitmap, __u32 start, __u32 end, __u32 *out) { + ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap; blk_t b; if (start < bitmap->start || end > bitmap->end || start > end) { - ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, start); + ext2fs_warn_bitmap2(gen_bitmap, EXT2FS_TEST_ERROR, start); return EINVAL; } @@ -550,9 +583,11 @@ errcode_t ext2fs_find_first_set_generic_bitmap(ext2fs_generic_bitmap bitmap, return ENOENT; } -int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap, +int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap gen_bitmap, blk_t block, int num) { + ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap; + EXT2_CHECK_MAGIC(bitmap, EXT2_ET_MAGIC_BLOCK_BITMAP); if ((block < bitmap->start) || (block > bitmap->real_end) || (block+num-1 > bitmap->real_end)) { @@ -564,9 +599,11 @@ int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap, bitmap, block, num); } -int ext2fs_test_inode_bitmap_range(ext2fs_inode_bitmap bitmap, +int ext2fs_test_inode_bitmap_range(ext2fs_inode_bitmap gen_bitmap, ext2_ino_t inode, int num) { + ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap; + EXT2_CHECK_MAGIC(bitmap, EXT2_ET_MAGIC_INODE_BITMAP); if ((inode < bitmap->start) || (inode > bitmap->real_end) || (inode+num-1 > bitmap->real_end)) { @@ -578,9 +615,10 @@ int ext2fs_test_inode_bitmap_range(ext2fs_inode_bitmap bitmap, bitmap, inode, num); } -void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap, +void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap gen_bitmap, blk_t block, int num) { + ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap; int i; if ((block < bitmap->start) || (block > bitmap->end) || @@ -593,9 +631,10 @@ void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap, ext2fs_fast_set_bit(block + i - bitmap->start, bitmap->bitmap); } -void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap, - blk_t block, int num) +void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap gen_bitmap, + blk_t block, int num) { + ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap; int i; if ((block < bitmap->start) || (block > bitmap->end) || diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c index 47ba2ba..6e4d8b7 100644 --- a/lib/ext2fs/gen_bitmap64.c +++ b/lib/ext2fs/gen_bitmap64.c @@ -68,7 +68,7 @@ * e2fsck can request an encoding which is optimized for that. */ -static void warn_bitmap(ext2fs_generic_bitmap bitmap, +static void warn_bitmap(ext2fs_generic_bitmap_64 bitmap, int code, __u64 arg) { #ifndef OMIT_COM_ERR @@ -93,7 +93,7 @@ errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic, const char *descr, ext2fs_generic_bitmap *ret) { - ext2fs_generic_bitmap bitmap; + ext2fs_generic_bitmap_64 bitmap; struct ext2_bitmap_ops *ops; ext2_ino_t num_dirs; errcode_t retval; @@ -119,7 +119,7 @@ errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic, return EINVAL; } - retval = ext2fs_get_memzero(sizeof(struct ext2fs_struct_generic_bitmap), + retval = ext2fs_get_memzero(sizeof(struct ext2fs_struct_generic_bitmap_64), &bitmap); if (retval) return retval; @@ -170,12 +170,12 @@ errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic, return retval; } - *ret = bitmap; + *ret = (ext2fs_generic_bitmap) bitmap; return 0; } #ifdef ENABLE_BMAP_STATS -static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap bitmap) +static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap_64 bitmap) { struct ext2_bmap_statistics *stats = &bitmap->stats; #ifdef ENABLE_BMAP_STATS_OPS @@ -241,13 +241,15 @@ static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap bitmap) } #endif -void ext2fs_free_generic_bmap(ext2fs_generic_bitmap bmap) +void ext2fs_free_generic_bmap(ext2fs_generic_bitmap gen_bmap) { + ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) gen_bmap; + if (!bmap) return; if (EXT2FS_IS_32_BITMAP(bmap)) { - ext2fs_free_generic_bitmap(bmap); + ext2fs_free_generic_bitmap(gen_bmap); return; } @@ -271,24 +273,25 @@ void ext2fs_free_generic_bmap(ext2fs_generic_bitmap bmap) ext2fs_free_mem(&bmap); } -errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap src, +errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap gen_src, ext2fs_generic_bitmap *dest) { + ext2fs_generic_bitmap_64 src = (ext2fs_generic_bitmap_64) gen_src; char *descr, *new_descr; - ext2fs_generic_bitmap new_bmap; + ext2fs_generic_bitmap_64 new_bmap; errcode_t retval; if (!src) return EINVAL; if (EXT2FS_IS_32_BITMAP(src)) - return ext2fs_copy_generic_bitmap(src, dest); + return ext2fs_copy_generic_bitmap(gen_src, dest); if (!EXT2FS_IS_64_BITMAP(src)) return EINVAL; /* Allocate a new bitmap struct */ - retval = ext2fs_get_memzero(sizeof(struct ext2fs_struct_generic_bitmap), + retval = ext2fs_get_memzero(sizeof(struct ext2fs_struct_generic_bitmap_64), &new_bmap); if (retval) return retval; @@ -336,21 +339,23 @@ errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap src, return retval; } - *dest = new_bmap; + *dest = (ext2fs_generic_bitmap) new_bmap; return 0; } -errcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap bmap, +errcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap gen_bmap, __u64 new_end, __u64 new_real_end) { + ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) gen_bmap; + if (!bmap) return EINVAL; if (EXT2FS_IS_32_BITMAP(bmap)) - return ext2fs_resize_generic_bitmap(bmap->magic, new_end, - new_real_end, bmap); + return ext2fs_resize_generic_bitmap(gen_bmap->magic, new_end, + new_real_end, gen_bmap); if (!EXT2FS_IS_64_BITMAP(bmap)) return EINVAL; @@ -360,10 +365,12 @@ errcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap bmap, return bmap->bitmap_ops->resize_bmap(bmap, new_end, new_real_end); } -errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap bitmap, +errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap gen_bitmap, errcode_t neq, __u64 end, __u64 *oend) { + ext2fs_generic_bitmap_64 bitmap = (ext2fs_generic_bitmap_64) gen_bitmap; + if (!bitmap) return EINVAL; @@ -371,7 +378,8 @@ errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap bitmap, ext2_ino_t tmp_oend; int retval; - retval = ext2fs_fudge_generic_bitmap_end(bitmap, bitmap->magic, + retval = ext2fs_fudge_generic_bitmap_end(gen_bitmap, + bitmap->magic, neq, end, &tmp_oend); if (oend) *oend = tmp_oend; @@ -389,13 +397,15 @@ errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap bitmap, return 0; } -__u64 ext2fs_get_generic_bmap_start(ext2fs_generic_bitmap bitmap) +__u64 ext2fs_get_generic_bmap_start(ext2fs_generic_bitmap gen_bitmap) { + ext2fs_generic_bitmap_64 bitmap = (ext2fs_generic_bitmap_64) gen_bitmap; + if (!bitmap) return EINVAL; if (EXT2FS_IS_32_BITMAP(bitmap)) - return ext2fs_get_generic_bitmap_start(bitmap); + return ext2fs_get_generic_bitmap_start(gen_bitmap); if (!EXT2FS_IS_64_BITMAP(bitmap)) return EINVAL; @@ -403,13 +413,15 @@ __u64 ext2fs_get_generic_bmap_start(ext2fs_generic_bitmap bitmap) return bitmap->start; } -__u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap bitmap) +__u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap gen_bitmap) { + ext2fs_generic_bitmap_64 bitmap = (ext2fs_generic_bitmap_64) gen_bitmap; + if (!bitmap) return EINVAL; if (EXT2FS_IS_32_BITMAP(bitmap)) - return ext2fs_get_generic_bitmap_end(bitmap); + return ext2fs_get_generic_bitmap_end(gen_bitmap); if (!EXT2FS_IS_64_BITMAP(bitmap)) return EINVAL; @@ -417,27 +429,31 @@ __u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap bitmap) return bitmap->end; } -void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap bitmap) +void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap gen_bitmap) { + ext2fs_generic_bitmap_64 bitmap = (ext2fs_generic_bitmap_64) gen_bitmap; + if (EXT2FS_IS_32_BITMAP(bitmap)) - ext2fs_clear_generic_bitmap(bitmap); + ext2fs_clear_generic_bitmap(gen_bitmap); else - bitmap->bitmap_ops->clear_bmap (bitmap); + bitmap->bitmap_ops->clear_bmap(bitmap); } -int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap, +int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap gen_bitmap, __u64 arg) { + ext2fs_generic_bitmap_64 bitmap = (ext2fs_generic_bitmap_64) gen_bitmap; + if (!bitmap) return 0; if (EXT2FS_IS_32_BITMAP(bitmap)) { if (arg & ~0xffffffffULL) { - ext2fs_warn_bitmap2(bitmap, + ext2fs_warn_bitmap2(gen_bitmap, EXT2FS_MARK_ERROR, 0xffffffff); return 0; } - return ext2fs_mark_generic_bitmap(bitmap, arg); + return ext2fs_mark_generic_bitmap(gen_bitmap, arg); } if (!EXT2FS_IS_64_BITMAP(bitmap)) @@ -462,19 +478,21 @@ int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap, return bitmap->bitmap_ops->mark_bmap(bitmap, arg); } -int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap, +int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap gen_bitmap, __u64 arg) { + ext2fs_generic_bitmap_64 bitmap = (ext2fs_generic_bitmap_64) gen_bitmap; + if (!bitmap) return 0; if (EXT2FS_IS_32_BITMAP(bitmap)) { if (arg & ~0xffffffffULL) { - ext2fs_warn_bitmap2(bitmap, EXT2FS_UNMARK_ERROR, + ext2fs_warn_bitmap2(gen_bitmap, EXT2FS_UNMARK_ERROR, 0xffffffff); return 0; } - return ext2fs_unmark_generic_bitmap(bitmap, arg); + return ext2fs_unmark_generic_bitmap(gen_bitmap, arg); } if (!EXT2FS_IS_64_BITMAP(bitmap)) @@ -492,19 +510,20 @@ int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap, return bitmap->bitmap_ops->unmark_bmap(bitmap, arg); } -int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap, +int ext2fs_test_generic_bmap(ext2fs_generic_bitmap gen_bitmap, __u64 arg) { + ext2fs_generic_bitmap_64 bitmap = (ext2fs_generic_bitmap_64) gen_bitmap; if (!bitmap) return 0; if (EXT2FS_IS_32_BITMAP(bitmap)) { if (arg & ~0xffffffffULL) { - ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, + ext2fs_warn_bitmap2(gen_bitmap, EXT2FS_TEST_ERROR, 0xffffffff); return 0; } - return ext2fs_test_generic_bitmap(bitmap, arg); + return ext2fs_test_generic_bitmap(gen_bitmap, arg); } if (!EXT2FS_IS_64_BITMAP(bitmap)) @@ -529,20 +548,22 @@ int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap, return bitmap->bitmap_ops->test_bmap(bitmap, arg); } -errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bmap, +errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap gen_bmap, __u64 start, unsigned int num, void *in) { + ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) gen_bmap; + if (!bmap) return EINVAL; if (EXT2FS_IS_32_BITMAP(bmap)) { if ((start+num-1) & ~0xffffffffULL) { - ext2fs_warn_bitmap2(bmap, EXT2FS_UNMARK_ERROR, + ext2fs_warn_bitmap2(gen_bmap, EXT2FS_UNMARK_ERROR, 0xffffffff); return EINVAL; } - return ext2fs_set_generic_bitmap_range(bmap, bmap->magic, + return ext2fs_set_generic_bitmap_range(gen_bmap, bmap->magic, start, num, in); } @@ -554,20 +575,22 @@ errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bmap, return bmap->bitmap_ops->set_bmap_range(bmap, start, num, in); } -errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bmap, +errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap gen_bmap, __u64 start, unsigned int num, void *out) { + ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) gen_bmap; + if (!bmap) return EINVAL; if (EXT2FS_IS_32_BITMAP(bmap)) { if ((start+num-1) & ~0xffffffffULL) { - ext2fs_warn_bitmap2(bmap, + ext2fs_warn_bitmap2(gen_bmap, EXT2FS_UNMARK_ERROR, 0xffffffff); return EINVAL; } - return ext2fs_get_generic_bitmap_range(bmap, bmap->magic, + return ext2fs_get_generic_bitmap_range(gen_bmap, bmap->magic, start, num, out); } @@ -580,9 +603,11 @@ errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bmap, } errcode_t ext2fs_compare_generic_bmap(errcode_t neq, - ext2fs_generic_bitmap bm1, - ext2fs_generic_bitmap bm2) + ext2fs_generic_bitmap gen_bm1, + ext2fs_generic_bitmap gen_bm2) { + ext2fs_generic_bitmap_64 bm1 = (ext2fs_generic_bitmap_64) gen_bm1; + ext2fs_generic_bitmap_64 bm2 = (ext2fs_generic_bitmap_64) gen_bm2; blk64_t i; if (!bm1 || !bm2) @@ -592,7 +617,8 @@ errcode_t ext2fs_compare_generic_bmap(errcode_t neq, /* Now we know both bitmaps have the same magic */ if (EXT2FS_IS_32_BITMAP(bm1)) - return ext2fs_compare_generic_bitmap(bm1->magic, neq, bm1, bm2); + return ext2fs_compare_generic_bitmap(bm1->magic, neq, + gen_bm1, gen_bm2); if (!EXT2FS_IS_64_BITMAP(bm1)) return EINVAL; @@ -602,19 +628,20 @@ errcode_t ext2fs_compare_generic_bmap(errcode_t neq, return neq; for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++) - if (ext2fs_test_generic_bmap(bm1, i) != - ext2fs_test_generic_bmap(bm2, i)) + if (ext2fs_test_generic_bmap(gen_bm1, i) != + ext2fs_test_generic_bmap(gen_bm2, i)) return neq; return 0; } -void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap bmap) +void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap gen_bmap) { + ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) gen_bmap; __u64 start, num; if (EXT2FS_IS_32_BITMAP(bmap)) { - ext2fs_set_generic_bitmap_padding(bmap); + ext2fs_set_generic_bitmap_padding(gen_bmap); return; } @@ -624,9 +651,10 @@ void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap bmap) /* XXX ought to warn on error */ } -int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bmap, +int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap gen_bmap, blk64_t block, unsigned int num) { + ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) gen_bmap; __u64 end = block + num; if (!bmap) @@ -668,9 +696,10 @@ int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bmap, return bmap->bitmap_ops->test_clear_bmap_extent(bmap, block, num); } -void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap bmap, +void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap gen_bmap, blk64_t block, unsigned int num) { + ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) gen_bmap; __u64 end = block + num; if (!bmap) @@ -708,9 +737,10 @@ void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap bmap, bmap->bitmap_ops->mark_bmap_extent(bmap, block, num); } -void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap bmap, +void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap gen_bmap, blk64_t block, unsigned int num) { + ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) gen_bmap; __u64 end = block + num; if (!bmap) @@ -748,8 +778,10 @@ void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap bmap, bmap->bitmap_ops->unmark_bmap_extent(bmap, block, num); } -void ext2fs_warn_bitmap32(ext2fs_generic_bitmap bitmap, const char *func) +void ext2fs_warn_bitmap32(ext2fs_generic_bitmap gen_bitmap, const char *func) { + ext2fs_generic_bitmap_64 bitmap = (ext2fs_generic_bitmap_64) gen_bitmap; + #ifndef OMIT_COM_ERR if (bitmap && bitmap->description) com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP, @@ -764,21 +796,22 @@ void ext2fs_warn_bitmap32(ext2fs_generic_bitmap bitmap, const char *func) errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs, ext2fs_block_bitmap *bitmap) { - ext2fs_block_bitmap cmap, bmap; + ext2fs_generic_bitmap_64 bmap, cmap; + ext2fs_block_bitmap gen_bmap = *bitmap, gen_cmap; errcode_t retval; blk64_t i, b_end, c_end; int n, ratio; - bmap = *bitmap; - - if (fs->cluster_ratio_bits == ext2fs_get_bitmap_granularity(bmap)) + bmap = (ext2fs_generic_bitmap_64) gen_bmap; + if (fs->cluster_ratio_bits == ext2fs_get_bitmap_granularity(gen_bmap)) return 0; /* Nothing to do */ retval = ext2fs_allocate_block_bitmap(fs, "converted cluster bitmap", - &cmap); + &gen_cmap); if (retval) return retval; + cmap = (ext2fs_generic_bitmap_64) gen_cmap; i = bmap->start; b_end = bmap->end; bmap->end = bmap->real_end; @@ -787,8 +820,8 @@ errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs, n = 0; ratio = 1 << fs->cluster_ratio_bits; while (i < bmap->real_end) { - if (ext2fs_test_block_bitmap2(bmap, i)) { - ext2fs_mark_block_bitmap2(cmap, i); + if (ext2fs_test_block_bitmap2(gen_bmap, i)) { + ext2fs_mark_block_bitmap2(gen_cmap, i); i += ratio - n; n = 0; continue; @@ -799,14 +832,15 @@ errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs, } bmap->end = b_end; cmap->end = c_end; - ext2fs_free_block_bitmap(bmap); - *bitmap = cmap; + ext2fs_free_block_bitmap(gen_bmap); + *bitmap = (ext2fs_block_bitmap) cmap; return 0; } errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap, __u64 start, __u64 end, __u64 *out) { + ext2fs_generic_bitmap_64 bmap64 = (ext2fs_generic_bitmap_64) bitmap; __u64 cstart, cend, cout; errcode_t retval; @@ -832,27 +866,27 @@ errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap, if (!EXT2FS_IS_64_BITMAP(bitmap)) return EINVAL; - cstart = start >> bitmap->cluster_bits; - cend = end >> bitmap->cluster_bits; + cstart = start >> bmap64->cluster_bits; + cend = end >> bmap64->cluster_bits; - if (cstart < bitmap->start || cend > bitmap->end || start > end) { - warn_bitmap(bitmap, EXT2FS_TEST_ERROR, start); + if (cstart < bmap64->start || cend > bmap64->end || start > end) { + warn_bitmap(bmap64, EXT2FS_TEST_ERROR, start); return EINVAL; } - if (bitmap->bitmap_ops->find_first_zero) { - retval = bitmap->bitmap_ops->find_first_zero(bitmap, cstart, + if (bmap64->bitmap_ops->find_first_zero) { + retval = bmap64->bitmap_ops->find_first_zero(bmap64, cstart, cend, &cout); if (retval) return retval; found: - cout <<= bitmap->cluster_bits; + cout <<= bmap64->cluster_bits; *out = (cout >= start) ? cout : start; return 0; } for (cout = cstart; cout <= cend; cout++) - if (!bitmap->bitmap_ops->test_bmap(bitmap, cout)) + if (!bmap64->bitmap_ops->test_bmap(bmap64, cout)) goto found; return ENOENT; @@ -861,6 +895,7 @@ errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap, errcode_t ext2fs_find_first_set_generic_bmap(ext2fs_generic_bitmap bitmap, __u64 start, __u64 end, __u64 *out) { + ext2fs_generic_bitmap_64 bmap64 = (ext2fs_generic_bitmap_64) bitmap; __u64 cstart, cend, cout; errcode_t retval; @@ -886,27 +921,27 @@ errcode_t ext2fs_find_first_set_generic_bmap(ext2fs_generic_bitmap bitmap, if (!EXT2FS_IS_64_BITMAP(bitmap)) return EINVAL; - cstart = start >> bitmap->cluster_bits; - cend = end >> bitmap->cluster_bits; + cstart = start >> bmap64->cluster_bits; + cend = end >> bmap64->cluster_bits; - if (cstart < bitmap->start || cend > bitmap->end || start > end) { - warn_bitmap(bitmap, EXT2FS_TEST_ERROR, start); + if (cstart < bmap64->start || cend > bmap64->end || start > end) { + warn_bitmap(bmap64, EXT2FS_TEST_ERROR, start); return EINVAL; } - if (bitmap->bitmap_ops->find_first_set) { - retval = bitmap->bitmap_ops->find_first_set(bitmap, cstart, + if (bmap64->bitmap_ops->find_first_set) { + retval = bmap64->bitmap_ops->find_first_set(bmap64, cstart, cend, &cout); if (retval) return retval; found: - cout <<= bitmap->cluster_bits; + cout <<= bmap64->cluster_bits; *out = (cout >= start) ? cout : start; return 0; } for (cout = cstart; cout <= cend; cout++) - if (bitmap->bitmap_ops->test_bmap(bitmap, cout)) + if (bmap64->bitmap_ops->test_bmap(bmap64, cout)) goto found; return ENOENT; diff --git a/lib/ext2fs/hashmap.c b/lib/ext2fs/hashmap.c index 3d8ee81..ffe61ce 100644 --- a/lib/ext2fs/hashmap.c +++ b/lib/ext2fs/hashmap.c @@ -1,6 +1,22 @@ #include "hashmap.h" #include +struct ext2fs_hashmap { + uint32_t size; + uint32_t(*hash)(const void *key, size_t len); + void(*free)(void*); + struct ext2fs_hashmap_entry *first; + struct ext2fs_hashmap_entry *last; +#if __GNUC_PREREQ (4, 8) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" +#endif + struct ext2fs_hashmap_entry *entries[0]; +#if __GNUC_PREREQ (4, 8) +#pragma GCC diagnostic pop +#endif +}; + uint32_t ext2fs_djb2_hash(const void *str, size_t size) { int c; diff --git a/lib/ext2fs/hashmap.h b/lib/ext2fs/hashmap.h index 656d3d9..dcfa745 100644 --- a/lib/ext2fs/hashmap.h +++ b/lib/ext2fs/hashmap.h @@ -13,27 +13,15 @@ #endif #endif -struct ext2fs_hashmap { - uint32_t size; - uint32_t(*hash)(const void *key, size_t len); - void(*free)(void*); - struct ext2fs_hashmap_entry *first; - struct ext2fs_hashmap_entry *last; - struct ext2fs_hashmap_entry { - void *data; - const void *key; - size_t key_len; - struct ext2fs_hashmap_entry *next; - struct ext2fs_hashmap_entry *list_next; - struct ext2fs_hashmap_entry *list_prev; -#if __GNUC_PREREQ (4, 8) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpedantic" -#endif - } *entries[0]; -#if __GNUC_PREREQ (4, 8) -#pragma GCC diagnostic pop -#endif +struct ext2fs_hashmap; + +struct ext2fs_hashmap_entry { + void *data; + const void *key; + size_t key_len; + struct ext2fs_hashmap_entry *next; + struct ext2fs_hashmap_entry *list_next; + struct ext2fs_hashmap_entry *list_prev; }; struct ext2fs_hashmap *ext2fs_hashmap_create( diff --git a/lib/ext2fs/qcow2.h b/lib/ext2fs/qcow2.h index b649c9c..5576348 100644 --- a/lib/ext2fs/qcow2.h +++ b/lib/ext2fs/qcow2.h @@ -30,8 +30,8 @@ #define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb) #define QCOW_VERSION 2 -#define QCOW_OFLAG_COPIED (1ULL << 63) -#define QCOW_OFLAG_COMPRESSED (1ULL << 62) +#define QCOW_OFLAG_COPIED (1LL << 63) +#define QCOW_OFLAG_COMPRESSED (1LL << 62) #define QCOW_COMPRESSED 1 #define QCOW_ENCRYPTED 2 diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c index d80c9eb..f1c4188 100644 --- a/lib/ext2fs/rw_bitmaps.c +++ b/lib/ext2fs/rw_bitmaps.c @@ -306,10 +306,9 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) for (i = 0; i < fs->group_desc_count; i++) { if (block_bitmap) { blk = ext2fs_block_bitmap_loc(fs, i); - if ((csum_flag && - ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT) && - ext2fs_group_desc_csum_verify(fs, i)) || - (blk >= ext2fs_blocks_count(fs->super))) + if (csum_flag && + ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT) && + ext2fs_group_desc_csum_verify(fs, i)) blk = 0; if (blk) { retval = io_channel_read_blk64(fs->io, blk, @@ -341,10 +340,9 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) } if (inode_bitmap) { blk = ext2fs_inode_bitmap_loc(fs, i); - if ((csum_flag && - ext2fs_bg_flags_test(fs, i, EXT2_BG_INODE_UNINIT) && - ext2fs_group_desc_csum_verify(fs, i)) || - (blk >= ext2fs_blocks_count(fs->super))) + if (csum_flag && + ext2fs_bg_flags_test(fs, i, EXT2_BG_INODE_UNINIT) && + ext2fs_group_desc_csum_verify(fs, i)) blk = 0; if (blk) { retval = io_channel_read_blk64(fs->io, blk, @@ -398,11 +396,11 @@ success_cleanup: cleanup: if (do_block) { - ext2fs_free_block_bitmap(fs->block_map); + ext2fs_free_mem(&fs->block_map); fs->block_map = 0; } if (do_inode) { - ext2fs_free_inode_bitmap(fs->inode_map); + ext2fs_free_mem(&fs->inode_map); fs->inode_map = 0; } if (inode_bitmap) diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index 628e60c..74fc8a7 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -166,7 +166,7 @@ static errcode_t raw_read_blk(io_channel channel, unsigned char *buf = bufv; ssize_t really_read = 0; - size = (count < 0) ? -count : (ext2_loff_t) count * channel->block_size; + size = (count < 0) ? -count : count * channel->block_size; data->io_stats.bytes_read += size; location = ((ext2_loff_t) block * channel->block_size) + data->offset; @@ -275,7 +275,7 @@ static errcode_t raw_write_blk(io_channel channel, if (count < 0) size = -count; else - size = (ext2_loff_t) count * channel->block_size; + size = count * channel->block_size; } data->io_stats.bytes_written += size; diff --git a/misc/Makefile.in b/misc/Makefile.in index 22c9848..f255444 100644 --- a/misc/Makefile.in +++ b/misc/Makefile.in @@ -35,7 +35,7 @@ INSTALL = @INSTALL@ SPROGS= mke2fs badblocks tune2fs dumpe2fs $(BLKID_PROG) logsave \ $(E2IMAGE_PROG) @FSCK_PROG@ e2undo USPROGS= mklost+found filefrag e2freefrag $(UUIDD_PROG) \ - $(E4DEFRAG_PROG) $(E4CRYPT_PROG) $(FUSE_PROG) + $(E4DEFRAG_PROG) $(E4CRYPT_PROG) SMANPAGES= tune2fs.8 mklost+found.8 mke2fs.8 dumpe2fs.8 badblocks.8 \ e2label.8 $(FINDFS_MAN) $(BLKID_MAN) $(E2IMAGE_MAN) \ logsave.8 filefrag.8 e2freefrag.8 e2undo.8 \ @@ -43,7 +43,7 @@ SMANPAGES= tune2fs.8 mklost+found.8 mke2fs.8 dumpe2fs.8 badblocks.8 \ e2mmpstatus.8 FMANPAGES= mke2fs.conf.5 ext4.5 -UPROGS= chattr lsattr @UUID_CMT@ uuidgen +UPROGS= chattr lsattr $(FUSE_PROG) @UUID_CMT@ uuidgen UMANPAGES= chattr.1 lsattr.1 @UUID_CMT@ uuidgen.1 UMANPAGES+= @FUSE_CMT@ fuse2fs.1 diff --git a/misc/e2image.c b/misc/e2image.c index 30f2543..3c881fe 100644 --- a/misc/e2image.c +++ b/misc/e2image.c @@ -54,7 +54,7 @@ extern int optind; #include "support/plausible.h" #include "../version.h" -#define QCOW_OFLAG_COPIED (1ULL << 63) +#define QCOW_OFLAG_COPIED (1LL << 63) #define NO_BLK ((blk64_t) -1) /* Image types */ diff --git a/misc/ext4.5.in b/misc/ext4.5.in index 39b1412..1db61a5 100644 --- a/misc/ext4.5.in +++ b/misc/ext4.5.in @@ -19,54 +19,6 @@ previously intended for use with the ext2 and ext3 file systems can be mounted using the ext4 file system driver, and indeed in many modern Linux distributions, the ext4 file system driver has been configured to handle mount requests for ext2 and ext3 file systems. -.SH RED HAT ENTERPRISE LINUX 8 -The Ext4 file system is fully supported by Red Hat when using default -mke2fs and mount options. In addition, the following non-default mke2fs -features and mount options are also fully supported. -.SH "Non-default features:" -project -.br -quota -.br -mmp -.br -.SH "Non-default mount options:" -bsddf|minixdf -.br -grpid|bsdgroups and nogrpid|sysvgroups -.br -resgid=n and resuid=n -.br -errors={continue|remount-ro|panic} -.br -commit=nrsec -.br -max_batch_time=usec -.br -min_batch_time=usec -.br -grpquota|noquota|quota|usrquota -.br -prjquota -.br -dax -.br -lazytime|nolazytime -.br -discard|nodiscard -.br -init_itable|noinit_itable -.br -jqfmt={vfsold|vfsv0|vfsv1} -.br -usrjquota=aquota.user|grpjquota=aquota.group -.PP -For more information on features and mount options, see the -.BR ext4 -man page. Ext4 features and mount options not listed above may not be -fully supported by Red Hat. If your workload requires a feature or mount -option that is not fully in this Red Hat release, contact Red Hat support -to evaluate it for inclusion in our supported list. .SH FILE SYSTEM FEATURES A file system formatted for ext2, ext3, or ext4 can have some collection of the following file system feature flags enabled. Some of diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in index 8297bc5..5bcee25 100644 --- a/misc/mke2fs.8.in +++ b/misc/mke2fs.8.in @@ -204,54 +204,6 @@ overridden by the options listed below, are controlled by the configuration file. See the .BR mke2fs.conf (5) manual page for more details. -.SH RED HAT ENTERPRISE LINUX 8 -The Ext4 file system is fully supported by Red Hat when using default -mke2fs and mount options. In addition, the following non-default mke2fs -features and mount options are also fully supported. -.SH "Non-default features:" -project -.br -quota -.br -mmp -.br -.SH "Non-default mount options:" -bsddf|minixdf -.br -grpid|bsdgroups and nogrpid|sysvgroups -.br -resgid=n and resuid=n -.br -errors={continue|remount-ro|panic} -.br -commit=nrsec -.br -max_batch_time=usec -.br -min_batch_time=usec -.br -grpquota|noquota|quota|usrquota -.br -prjquota -.br -dax -.br -lazytime|nolazytime -.br -discard|nodiscard -.br -init_itable|noinit_itable -.br -jqfmt={vfsold|vfsv0|vfsv1} -.br -usrjquota=aquota.user|grpjquota=aquota.group -.PP -For more information on features and mount options, see the -.BR ext4 -man page. Ext4 features and mount options not listed above may not be -fully supported by Red Hat. If your workload requires a feature or mount -option that is not fully in this Red Hat release, contact Red Hat support -to evaluate it for inclusion in our supported list. .SH OPTIONS .TP .BI \-b " block-size" diff --git a/misc/mke2fs.conf.in b/misc/mke2fs.conf.in index a533b21..00afd91 100644 --- a/misc/mke2fs.conf.in +++ b/misc/mke2fs.conf.in @@ -14,16 +14,6 @@ features = has_journal,extent,huge_file,flex_bg,metadata_csum,64bit,dir_nlink,extra_isize inode_size = 256 } - rhel6_ext4 = { - features = has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize - inode_size = 256 - enable_periodic_fsck = 1 - default_mntopts = "" - } - rhel7_ext4 = { - features = has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,64bit - inode_size = 256 - } small = { blocksize = 1024 inode_size = 128 @@ -55,3 +45,6 @@ blocksize = 4096 inode_size = 128 } + +[options] + fname_encoding = utf8 diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 301cf38..7d2d38d 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -1308,12 +1308,6 @@ mmp_error: if (FEATURE_ON(E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) { - if (mount_flags & EXT2_MF_MOUNTED) { - fputs(_("Cannot enable uninit_bg on a mounted " - "filesystem!\n"), stderr); - exit(1); - } - /* Do not enable uninit_bg when metadata_csum enabled */ if (ext2fs_has_feature_metadata_csum(fs->super)) ext2fs_clear_feature_gdt_csum(fs->super); @@ -1323,12 +1317,6 @@ mmp_error: if (FEATURE_OFF(E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) { - if (mount_flags & EXT2_MF_MOUNTED) { - fputs(_("Cannot disable uninit_bg on a mounted " - "filesystem!\n"), stderr); - exit(1); - } - err = disable_uninit_bg(fs, EXT4_FEATURE_RO_COMPAT_GDT_CSUM); if (err)