enum journal_location {JOURNAL_IS_INTERNAL, JOURNAL_IS_EXTERNAL};
-#define ANY_BLOCK ((blk_t) -1)
+#define ANY_BLOCK ((blk64_t) -1)
int dump_all, dump_contents, dump_descriptors;
-blk_t block_to_dump, bitmap_to_dump, inode_block_to_dump;
+blk64_t block_to_dump, bitmap_to_dump, inode_block_to_dump;
unsigned int group_to_dump, inode_offset_to_dump;
ext2_ino_t inode_to_dump;
(group_offset / inodes_per_block);
inode_offset_to_dump = ((group_offset % inodes_per_block)
* sizeof(struct ext2_inode));
- printf("Inode %u is at group %u, block %u, offset %u\n",
+ printf("Inode %u is at group %u, block %llu, offset %u\n",
inode_to_dump, inode_group,
inode_block_to_dump, inode_offset_to_dump);
}
offset = ((block_to_dump - super->s_first_data_block) %
super->s_blocks_per_group);
- fprintf(out_file, " (block bitmap for block %u: "
+ fprintf(out_file, " (block bitmap for block %llu: "
"block is %s)\n",
block_to_dump,
ext2fs_test_bit(offset, buf) ? "SET" : "CLEAR");
static errcode_t parse_bmap(struct field_set_info *info,
char *field EXT2FS_ATTR((unused)), char *arg)
{
- unsigned long num;
- blk_t blk;
+ blk64_t blk;
errcode_t retval;
char *tmp;
- num = strtoul(arg, &tmp, 0);
+ blk = strtoull(arg, &tmp, 0);
if (*tmp) {
fprintf(stderr, "Couldn't parse '%s' for field %s.\n",
arg, info->name);
return EINVAL;
}
- blk = num;
- retval = ext2fs_bmap(current_fs, set_ino,
+ retval = ext2fs_bmap2(current_fs, set_ino,
(struct ext2_inode *) &set_inode,
- 0, BMAP_SET, array_idx, &blk);
+ NULL, BMAP_SET, array_idx, NULL, &blk);
if (retval) {
com_err("set_inode", retval, "while setting block map");
}
struct dx_dirblock_info {
int type;
- blk_t phys;
+ blk64_t phys;
int flags;
- blk_t parent;
+ blk64_t parent;
ext2_dirhash_t min_hash;
ext2_dirhash_t max_hash;
ext2_dirhash_t node_min_hash;
#ifdef MTRACE
extern void mtrace_print(char *mesg);
#endif
-extern blk_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs,
+extern blk64_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs,
const char *name, io_manager manager);
extern int ext2_file_type(unsigned int mode);
extern int write_all(int fd, char *buf, size_t count);
unsigned long long start = 0;
int ext_journal = 0;
int tried_backup_jnl = 0;
+ blk64_t maxlen;
clear_problem_context(&pctx);
goto errout;
}
- journal->j_maxlen = ext2fs_blocks_count(&jsuper);
+ maxlen = ext2fs_blocks_count(&jsuper);
+ if (maxlen > 1ULL << 32)
+ maxlen = (1ULL << 32) - 1;
+ journal->j_maxlen = maxlen;
start++;
}
#endif
break;
case 'S':
- fprintf(f, "%u", get_backup_sb(NULL, fs, NULL, NULL));
+ fprintf(f, "%llu", get_backup_sb(NULL, fs, NULL, NULL));
break;
case 's':
fprintf(f, "%*s", width, ctx->str ? ctx->str : "NULL");
return 0;
}
-static void new_table_block(e2fsck_t ctx, blk_t first_block, int group,
+static void new_table_block(e2fsck_t ctx, blk64_t first_block, int group,
const char *name, int num, blk64_t *new_block)
{
ext2_filsys fs = ctx->fs;
errcode_t retval;
struct expand_dir_struct es;
struct ext2_inode inode;
+ blk64_t sz;
if (!(fs->flags & EXT2_FLAG_RW))
return EXT2_ET_RO_FILSYS;
if (retval)
return retval;
- inode.i_size = (es.last_block + 1) * fs->blocksize;
+ sz = (es.last_block + 1) * fs->blocksize;
+ inode.i_size = sz;
+ inode.i_size_high = sz >> 32;
ext2fs_iblk_add_blocks(fs, &inode, es.newblocks);
quota_data_add(ctx->qctx, &inode, dir, es.newblocks * fs->blocksize);
struct out_dir *outdir;
errcode_t err;
e2fsck_t ctx;
- int cleared;
+ blk64_t cleared;
};
/*
const char *lib_ver_date;
int my_ver, lib_ver;
e2fsck_t ctx;
- blk_t orig_superblock;
+ blk64_t orig_superblock;
struct problem_context pctx;
int flags, run_result;
int journal_size;
}
#endif
-blk_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name,
- io_manager manager)
+blk64_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name,
+ io_manager manager)
{
struct ext2_super_block *sb;
io_channel io = NULL;
void *buf = NULL;
int blocksize;
- blk_t superblock, ret_sb = 8193;
+ blk64_t superblock, ret_sb = 8193;
if (fs && fs->super) {
ret_sb = (fs->super->s_blocks_per_group +
}
static errcode_t write_backup_super(ext2_filsys fs, dgrp_t group,
- blk_t group_block,
+ blk64_t group_block,
struct ext2_super_block *super_shadow)
{
dgrp_t sgrp = group;
*/
struct ext2_inode_cache {
void * buffer;
- blk_t buffer_blk;
+ blk64_t buffer_blk;
int cache_last;
int cache_size;
int refcount;
*/
static errcode_t sync_buffer_position(ext2_file_t file)
{
- blk_t b;
+ blk64_t b;
errcode_t retval;
b = file->pos / file->fs->blocksize;
* increasing order.
*/
static errcode_t check_for_inode_bad_blocks(ext2_inode_scan scan,
- blk_t *num_blocks)
+ blk64_t *num_blocks)
{
- blk_t blk = scan->current_block;
+ blk64_t blk = scan->current_block;
badblocks_list bb = scan->fs->badblocks;
/*
*/
static errcode_t get_next_blocks(ext2_inode_scan scan)
{
- blk_t num_blocks;
+ blk64_t num_blocks;
errcode_t retval;
/*
dbg_printf("Free start %llu, free count = %u\n",
free_start, free_count);
while (free_count-- > 0) {
- ext2fs_block_alloc_stats(fs, free_start++, -1);
+ ext2fs_block_alloc_stats2(fs, free_start++, -1);
freed++;
}
next_extent:
#include "ext2_fs.h"
#include "ext2fs.h"
-blk_t test_vec[] = { 8, 12, 24, 34, 43, 44, 100, 0 };
+blk64_t test_vec[] = { 8, 12, 24, 34, 43, 44, 100, 0 };
ext2_filsys test_fs;
ext2fs_block_bitmap bad_block_map, touched_map;
printf(" (+%u)", (unsigned)(block - first_block));
} else if (fs->super->s_feature_incompat &
EXT4_FEATURE_INCOMPAT_FLEX_BG) {
- dgrp_t flex_grp = ext2fs_group_of_blk(fs, block);
+ dgrp_t flex_grp = ext2fs_group_of_blk2(fs, block);
printf(" (bg #%u + %u)", flex_grp,
(unsigned)(block-ext2fs_group_first_block(fs,flex_grp)));
}
/* We need to force out the group descriptors as well */
fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
- ext2fs_block_alloc_stats(fs, sb->s_mmp_block, -1);
+ ext2fs_block_alloc_stats2(fs, sb->s_mmp_block, -1);
mmp_error:
sb->s_mmp_block = 0;
sb->s_mmp_update_interval = 0;
return 0;
}
-static int ext2fs_is_meta_block(ext2_filsys fs, blk_t blk)
+static int ext2fs_is_meta_block(ext2_filsys fs, blk64_t blk)
{
dgrp_t group;
- group = ext2fs_group_of_blk(fs, blk);
+ group = ext2fs_group_of_blk2(fs, blk);
if (ext2fs_block_bitmap_loc(fs, group) == blk)
return 1;
if (ext2fs_inode_bitmap_loc(fs, group) == blk)
return 0;
}
-static int ext2fs_is_block_in_group(ext2_filsys fs, dgrp_t group, blk_t blk)
+static int ext2fs_is_block_in_group(ext2_filsys fs, dgrp_t group, blk64_t blk)
{
- blk_t start_blk, end_blk;
+ blk64_t start_blk, end_blk;
start_blk = fs->super->s_first_data_block +
EXT2_BLOCKS_PER_GROUP(fs->super) * group;
/*
* the respective fs metadata pointers. Otherwise
* fail
*/
- group = ext2fs_group_of_blk(fs, blk);
+ group = ext2fs_group_of_blk2(fs, blk);
goal = ext2fs_group_first_block2(fs, group);
meta_data = 1;
static int group_desc_scan_and_fix(ext2_filsys fs, ext2fs_block_bitmap bmap)
{
dgrp_t i;
- blk_t blk, new_blk;
+ blk64_t blk, new_blk;
for (i = 0; i < fs->group_desc_count; i++) {
blk = ext2fs_block_bitmap_loc(fs, i);