summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValerie Aurora Henson <vaurora@redhat.com>2010-06-13 17:00:00 -0400
committerTheodore Ts'o <tytso@mit.edu>2010-06-13 17:00:00 -0400
commit6dc64392c052839f373b7bbbb58efa3048bfb355 (patch)
tree694a7e88b59a639e00c29c7bf75f2411a4e4ebde
parent7117f8d6c5fc851a393a970e71337ef61bf0a8f0 (diff)
downloade2fsprogs-6dc64392c052839f373b7bbbb58efa3048bfb355.tar.gz
e2fsck: Fix up to be 64-bit block number safe
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: Nick Dokos <nicholas.dokos@hp.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--e2fsck/e2fsck.h4
-rw-r--r--e2fsck/emptydir.c32
-rw-r--r--e2fsck/jfs_user.h4
-rw-r--r--e2fsck/journal.c18
-rw-r--r--e2fsck/pass1.c89
-rw-r--r--e2fsck/pass1b.c16
-rw-r--r--e2fsck/pass2.c40
-rw-r--r--e2fsck/pass3.c16
-rw-r--r--e2fsck/pass5.c6
-rw-r--r--e2fsck/rehash.c18
-rw-r--r--e2fsck/super.c26
-rw-r--r--e2fsck/unix.c13
12 files changed, 141 insertions, 141 deletions
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index 79266581..d4df5f35 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -210,8 +210,8 @@ struct e2fsck_struct {
char *io_options;
int flags; /* E2fsck internal flags */
int options;
- blk_t use_superblock; /* sb requested by user */
- blk_t superblock; /* sb used to open fs */
+ blk64_t use_superblock; /* sb requested by user */
+ blk64_t superblock; /* sb used to open fs */
int blocksize; /* blocksize */
blk64_t num_blocks; /* Total number of blocks */
int mount_flags;
diff --git a/e2fsck/emptydir.c b/e2fsck/emptydir.c
index b2ce41cd..cf9b521e 100644
--- a/e2fsck/emptydir.c
+++ b/e2fsck/emptydir.c
@@ -25,8 +25,8 @@ struct empty_dir_info_struct {
char *block_buf;
ext2_ino_t ino;
struct ext2_inode inode;
- blk_t logblk;
- blk_t freed_blocks;
+ blk64_t logblk;
+ blk64_t freed_blocks;
};
typedef struct empty_dir_info_struct *empty_dir_info;
@@ -34,7 +34,7 @@ typedef struct empty_dir_info_struct *empty_dir_info;
extern empty_dir_info init_empty_dir(e2fsck_t ctx);
extern void free_empty_dirblock(empty_dir_info edi);
extern void add_empty_dirblock(empty_dir_info edi,
- struct ext2_db_entry *db);
+ struct ext2_db_entry2 *db);
extern void process_empty_dirblock(e2fsck_t ctx, empty_dir_info edi);
@@ -86,7 +86,7 @@ void free_empty_dirblock(empty_dir_info edi)
}
void add_empty_dirblock(empty_dir_info edi,
- struct ext2_db_entry *db)
+ struct ext2_db_entry2 *db)
{
if (!edi || !db)
return;
@@ -102,8 +102,8 @@ void add_empty_dirblock(empty_dir_info edi,
return;
ext2fs_mark_inode_bitmap(edi->dir_map, db->ino);
- ext2fs_add_dir_block(edi->empty_dblist, db->ino,
- db->blk, db->blockcnt);
+ ext2fs_add_dir_block2(edi->empty_dblist, db->ino,
+ db->blk, db->blockcnt);
}
/*
@@ -116,20 +116,20 @@ void add_empty_dirblock(empty_dir_info edi,
*
* Also question --- how to free the indirect blocks.
*/
-int empty_pass1(ext2_filsys fs, blk_t *block_nr, e2_blkcnt_t blockcnt,
- blk_t ref_block, int ref_offset, void *priv_data)
+int empty_pass1(ext2_filsys fs, blk64_t *block_nr, e2_blkcnt_t blockcnt,
+ blk64_t ref_block, int ref_offset, void *priv_data)
{
empty_dir_info edi = (empty_dir_info) priv_data;
- blk_t block, new_block;
+ blk64_t block, new_block;
errcode_t retval;
if (blockcnt < 0)
return 0;
block = *block_nr;
do {
- retval = ext2fs_bmap(fs, edi->ino, &edi->inode,
- edi->block_buf, 0, edi->logblk,
- &new_block);
+ retval = ext2fs_bmap2(fs, edi->ino, &edi->inode,
+ edi->block_buf, 0, edi->logblk, 0,
+ &new_block);
if (retval)
return DIRENT_ABORT; /* XXX what to do? */
if (new_block == 0)
@@ -146,7 +146,7 @@ int empty_pass1(ext2_filsys fs, blk_t *block_nr, e2_blkcnt_t blockcnt,
}
static int fix_directory(ext2_filsys fs,
- struct ext2_db_entry *db,
+ struct ext2_db_entry2 *db,
void *priv_data)
{
errcode_t retval;
@@ -161,7 +161,7 @@ static int fix_directory(ext2_filsys fs,
if (retval)
return 0;
- retval = ext2fs_block_iterate2(fs, db->ino, 0, edi->block_buf,
+ retval = ext2fs_block_iterate3(fs, db->ino, 0, edi->block_buf,
empty_pass1, edi);
if (retval)
return 0;
@@ -184,8 +184,8 @@ void process_empty_dirblock(e2fsck_t ctx, empty_dir_info edi)
edi->block_buf = malloc(ctx->fs->blocksize * 3);
if (edi->block_buf) {
- (void) ext2fs_dblist_iterate(edi->empty_dblist,
- fix_directory, &edi);
+ (void) ext2fs_dblist_iterate2(edi->empty_dblist,
+ fix_directory, &edi);
}
free(edi->block_buf);
free_empty_dirblock(edi);
diff --git a/e2fsck/jfs_user.h b/e2fsck/jfs_user.h
index 60cc682b..2bb71c38 100644
--- a/e2fsck/jfs_user.h
+++ b/e2fsck/jfs_user.h
@@ -120,8 +120,8 @@ _INLINE_ size_t journal_tag_bytes(journal_t *journal)
/*
* Kernel compatibility functions are defined in journal.c
*/
-int journal_bmap(journal_t *journal, blk_t block, unsigned long *phys);
-struct buffer_head *getblk(kdev_t ctx, blk_t blocknr, int blocksize);
+int journal_bmap(journal_t *journal, blk64_t block, unsigned long *phys);
+struct buffer_head *getblk(kdev_t ctx, blk64_t blocknr, int blocksize);
void sync_blockdev(kdev_t kdev);
void ll_rw_block(int rw, int dummy, struct buffer_head *bh[]);
void mark_buffer_dirty(struct buffer_head *bh);
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index c2f8951a..75dafa66 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -43,7 +43,7 @@ static int bh_count = 0;
* to use the recovery.c file virtually unchanged from the kernel, so we
* don't have to do much to keep kernel and user recovery in sync.
*/
-int journal_bmap(journal_t *journal, blk_t block, unsigned long *phys)
+int journal_bmap(journal_t *journal, blk64_t block, unsigned long *phys)
{
#ifdef USE_INODE_IO
*phys = block;
@@ -51,21 +51,21 @@ int journal_bmap(journal_t *journal, blk_t block, unsigned long *phys)
#else
struct inode *inode = journal->j_inode;
errcode_t retval;
- blk_t pblk;
+ blk64_t pblk;
if (!inode) {
*phys = block;
return 0;
}
- retval= ext2fs_bmap(inode->i_ctx->fs, inode->i_ino,
- &inode->i_ext2, NULL, 0, block, &pblk);
+ retval= ext2fs_bmap2(inode->i_ctx->fs, inode->i_ino,
+ &inode->i_ext2, NULL, 0, block, 0, &pblk);
*phys = pblk;
return (retval);
#endif
}
-struct buffer_head *getblk(kdev_t kdev, blk_t blocknr, int blocksize)
+struct buffer_head *getblk(kdev_t kdev, blk64_t blocknr, int blocksize)
{
struct buffer_head *bh;
int bufsize = sizeof(*bh) + kdev->k_ctx->fs->blocksize -
@@ -203,14 +203,14 @@ struct process_block_struct {
};
static int process_journal_block(ext2_filsys fs,
- blk_t *block_nr,
+ blk64_t *block_nr,
e2_blkcnt_t blockcnt,
- blk_t ref_block EXT2FS_ATTR((unused)),
+ blk64_t ref_block EXT2FS_ATTR((unused)),
int ref_offset EXT2FS_ATTR((unused)),
void *priv_data)
{
struct process_block_struct *p;
- blk_t blk = *block_nr;
+ blk64_t blk = *block_nr;
p = (struct process_block_struct *) priv_data;
@@ -307,7 +307,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
goto try_backup_journal;
}
pb.last_block = -1;
- retval = ext2fs_block_iterate2(ctx->fs, j_inode->i_ino,
+ retval = ext2fs_block_iterate3(ctx->fs, j_inode->i_ino,
BLOCK_FLAG_HOLE, 0,
process_journal_block, &pb);
if ((pb.last_block+1) * ctx->fs->blocksize <
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index ade5ff65..93763cd8 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -55,11 +55,11 @@
#define _INLINE_ inline
#endif
-static int process_block(ext2_filsys fs, blk_t *blocknr,
- e2_blkcnt_t blockcnt, blk_t ref_blk,
+static int process_block(ext2_filsys fs, blk64_t *blocknr,
+ e2_blkcnt_t blockcnt, blk64_t ref_blk,
int ref_offset, void *priv_data);
-static int process_bad_block(ext2_filsys fs, blk_t *block_nr,
- e2_blkcnt_t blockcnt, blk_t ref_blk,
+static int process_bad_block(ext2_filsys fs, blk64_t *block_nr,
+ e2_blkcnt_t blockcnt, blk64_t ref_blk,
int ref_offset, void *priv_data);
static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
char *block_buf);
@@ -74,18 +74,18 @@ static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan,
dgrp_t group, void * priv_data);
static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount,
char *block_buf, int adjust_sign);
-/* static char *describe_illegal_block(ext2_filsys fs, blk_t block); */
+/* static char *describe_illegal_block(ext2_filsys fs, blk64_t block); */
struct process_block_struct {
ext2_ino_t ino;
unsigned is_dir:1, is_reg:1, clear:1, suppress:1,
fragmented:1, compressed:1, bbcheck:1;
blk64_t num_blocks;
- blk_t max_blocks;
+ blk64_t max_blocks;
e2_blkcnt_t last_block;
e2_blkcnt_t last_db_block;
int num_illegal_blocks;
- blk_t previous_block;
+ blk64_t previous_block;
struct ext2_inode *inode;
struct problem_context *pctx;
ext2fs_block_bitmap fs_meta_blocks;
@@ -169,7 +169,7 @@ int e2fsck_pass1_check_symlink(ext2_filsys fs, ext2_ino_t ino,
{
unsigned int len;
int i;
- blk_t blocks;
+ blk64_t blocks;
ext2_extent_handle_t handle;
struct ext2_extent_info info;
struct ext2fs_extent extent;
@@ -200,7 +200,7 @@ int e2fsck_pass1_check_symlink(ext2_filsys fs, ext2_ino_t ino,
return i;
}
- blocks = ext2fs_inode_data_blocks(fs, inode);
+ blocks = ext2fs_inode_data_blocks2(fs, inode);
if (blocks) {
if ((inode->i_size >= fs->blocksize) ||
(blocks != fs->blocksize >> 9) ||
@@ -404,8 +404,7 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx,
struct ext2_dir_entry *dirent;
const char *old_op;
errcode_t retval;
- blk_t blk;
- blk64_t first_dir_blk;
+ blk64_t blk, first_dir_blk;
unsigned int i, rec_len, not_device = 0;
int extent_fs;
@@ -440,7 +439,7 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx,
extent_fs = (ctx->fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS);
if (extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) {
/* extent mapped */
- if (ext2fs_bmap(ctx->fs, pctx->ino, inode, 0, 0, 0,
+ if (ext2fs_bmap2(ctx->fs, pctx->ino, inode, 0, 0, 0, 0,
&blk))
return;
/* device files are never extent mapped */
@@ -473,7 +472,7 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx,
/* read the first block */
old_op = ehandler_operation(_("reading directory block"));
- retval = ext2fs_read_dir_block(ctx->fs, blk, buf);
+ retval = ext2fs_read_dir_block3(ctx->fs, blk, buf, 0);
ehandler_operation(0);
if (retval)
return;
@@ -819,7 +818,7 @@ void e2fsck_pass1(e2fsck_t ctx)
pb.inode = inode;
pb.pctx = &pctx;
pb.ctx = ctx;
- pctx.errcode = ext2fs_block_iterate2(fs, ino, 0,
+ pctx.errcode = ext2fs_block_iterate3(fs, ino, 0,
block_buf, process_bad_block, &pb);
ext2fs_free_block_bitmap(pb.fs_meta_blocks);
if (pctx.errcode) {
@@ -874,7 +873,7 @@ void e2fsck_pass1(e2fsck_t ctx)
check_blocks(ctx, &pctx, block_buf);
continue;
}
- if ((inode->i_links_count || inode->i_blocks ||
+ if ((inode->i_links_count ||
inode->i_blocks || inode->i_block[0]) &&
fix_problem(ctx, PR_1_JOURNAL_INODE_NOT_CLEAR,
&pctx)) {
@@ -1332,7 +1331,7 @@ static void alloc_imagic_map(e2fsck_t ctx)
* WARNING: Assumes checks have already been done to make sure block
* is valid. This is true in both process_block and process_bad_block.
*/
-static _INLINE_ void mark_block_used(e2fsck_t ctx, blk_t block)
+static _INLINE_ void mark_block_used(e2fsck_t ctx, blk64_t block)
{
struct problem_context pctx;
@@ -1371,7 +1370,7 @@ static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount,
struct ext2_ext_attr_header *header;
struct problem_context pctx;
ext2_filsys fs = ctx->fs;
- blk_t blk;
+ blk64_t blk;
__u32 should_be;
int count;
@@ -1382,7 +1381,7 @@ static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount,
if ((blk = ea_refcount_intr_next(refcount, &count)) == 0)
break;
pctx.blk = blk;
- pctx.errcode = ext2fs_read_ext_attr(fs, blk, block_buf);
+ pctx.errcode = ext2fs_read_ext_attr2(fs, blk, block_buf);
if (pctx.errcode) {
fix_problem(ctx, PR_1_EXTATTR_READ_ABORT, &pctx);
return;
@@ -1393,7 +1392,7 @@ static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount,
pctx.num = should_be;
if (fix_problem(ctx, PR_1_EXTATTR_REFCOUNT, &pctx)) {
header->h_refcount = should_be;
- pctx.errcode = ext2fs_write_ext_attr(fs, blk,
+ pctx.errcode = ext2fs_write_ext_attr2(fs, blk,
block_buf);
if (pctx.errcode) {
fix_problem(ctx, PR_1_EXTATTR_WRITE_ABORT,
@@ -1413,7 +1412,7 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx,
ext2_filsys fs = ctx->fs;
ext2_ino_t ino = pctx->ino;
struct ext2_inode *inode = pctx->inode;
- blk_t blk;
+ blk64_t blk;
char * end;
struct ext2_ext_attr_header *header;
struct ext2_ext_attr_entry *entry;
@@ -1491,7 +1490,7 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx,
* validate it
*/
pctx->blk = blk;
- pctx->errcode = ext2fs_read_ext_attr(fs, blk, block_buf);
+ pctx->errcode = ext2fs_read_ext_attr2(fs, blk, block_buf);
if (pctx->errcode && fix_problem(ctx, PR_1_READ_EA_BLOCK, pctx))
goto clear_extattr;
header = (struct ext2_ext_attr_header *) block_buf;
@@ -1596,7 +1595,7 @@ static int handle_htree(e2fsck_t ctx, struct problem_context *pctx,
struct ext2_dx_root_info *root;
ext2_filsys fs = ctx->fs;
errcode_t retval;
- blk_t blk;
+ blk64_t blk;
if ((!LINUX_S_ISDIR(inode->i_mode) &&
fix_problem(ctx, PR_1_HTREE_NODIR, pctx)) ||
@@ -1604,7 +1603,7 @@ static int handle_htree(e2fsck_t ctx, struct problem_context *pctx,
fix_problem(ctx, PR_1_HTREE_SET, pctx)))
return 1;
- pctx->errcode = ext2fs_bmap(fs, ino, inode, 0, 0, 0, &blk);
+ pctx->errcode = ext2fs_bmap2(fs, ino, inode, 0, 0, 0, 0, &blk);
if ((pctx->errcode) ||
(blk == 0) ||
@@ -1677,7 +1676,7 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
ext2_extent_handle_t ehandle)
{
struct ext2fs_extent extent;
- blk_t blk;
+ blk64_t blk;
e2_blkcnt_t blockcnt;
unsigned int i;
int is_dir, is_leaf;
@@ -1778,9 +1777,9 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
pb->fragmented = 1;
}
while (is_dir && ++pb->last_db_block < extent.e_lblk) {
- pctx->errcode = ext2fs_add_dir_block(ctx->fs->dblist,
- pb->ino, 0,
- pb->last_db_block);
+ pctx->errcode = ext2fs_add_dir_block2(ctx->fs->dblist,
+ pb->ino, 0,
+ pb->last_db_block);
if (pctx->errcode) {
pctx->blk = 0;
pctx->num = pb->last_db_block;
@@ -1793,7 +1792,7 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
mark_block_used(ctx, blk);
if (is_dir) {
- pctx->errcode = ext2fs_add_dir_block(ctx->fs->dblist, pctx->ino, blk, blockcnt);
+ pctx->errcode = ext2fs_add_dir_block2(ctx->fs->dblist, pctx->ino, blk, blockcnt);
if (pctx->errcode) {
pctx->blk = blk;
pctx->num = blockcnt;
@@ -1917,7 +1916,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
if (extent_fs && (inode->i_flags & EXT4_EXTENTS_FL))
check_blocks_extents(ctx, pctx, &pb);
else
- pctx->errcode = ext2fs_block_iterate2(fs, ino,
+ pctx->errcode = ext2fs_block_iterate3(fs, ino,
pb.is_dir ? BLOCK_FLAG_HOLE : 0,
block_buf, process_block, &pb);
}
@@ -1966,7 +1965,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
pb.num_blocks *= (fs->blocksize / 512);
#if 0
printf("inode %u, i_size = %lu, last_block = %lld, i_blocks=%lu, num_blocks = %lu\n",
- ino, inode->i_size, pb.last_block, inode->i_blocks,
+ ino, inode->i_size, pb.last_block, ext2fs_inode_i_blocks(fs, inode),
pb.num_blocks);
#endif
if (pb.is_dir) {
@@ -2058,9 +2057,9 @@ out:
* Helper function called by process block when an illegal block is
* found. It returns a description about why the block is illegal
*/
-static char *describe_illegal_block(ext2_filsys fs, blk_t block)
+static char *describe_illegal_block(ext2_filsys fs, blk64_t block)
{
- blk_t super;
+ blk64_t super;
int i;
static char problem[80];
@@ -2109,15 +2108,15 @@ static char *describe_illegal_block(ext2_filsys fs, blk_t block)
* This is a helper function for check_blocks().
*/
static int process_block(ext2_filsys fs,
- blk_t *block_nr,
+ blk64_t *block_nr,
e2_blkcnt_t blockcnt,
- blk_t ref_block EXT2FS_ATTR((unused)),
+ blk64_t ref_block EXT2FS_ATTR((unused)),
int ref_offset EXT2FS_ATTR((unused)),
void *priv_data)
{
struct process_block_struct *p;
struct problem_context *pctx;
- blk_t blk = *block_nr;
+ blk64_t blk = *block_nr;
int ret_code = 0;
int problem = 0;
e2fsck_t ctx;
@@ -2235,17 +2234,17 @@ static int process_block(ext2_filsys fs,
mark_dir:
if (p->is_dir && (blockcnt >= 0)) {
while (++p->last_db_block < blockcnt) {
- pctx->errcode = ext2fs_add_dir_block(fs->dblist,
- p->ino, 0,
- p->last_db_block);
+ pctx->errcode = ext2fs_add_dir_block2(fs->dblist,
+ p->ino, 0,
+ p->last_db_block);
if (pctx->errcode) {
pctx->blk = 0;
pctx->num = p->last_db_block;
goto failed_add_dir_block;
}
}
- pctx->errcode = ext2fs_add_dir_block(fs->dblist, p->ino,
- blk, blockcnt);
+ pctx->errcode = ext2fs_add_dir_block2(fs->dblist, p->ino,
+ blk, blockcnt);
if (pctx->errcode) {
pctx->blk = blk;
pctx->num = blockcnt;
@@ -2260,15 +2259,15 @@ mark_dir:
}
static int process_bad_block(ext2_filsys fs,
- blk_t *block_nr,
+ blk64_t *block_nr,
e2_blkcnt_t blockcnt,
- blk_t ref_block EXT2FS_ATTR((unused)),
+ blk64_t ref_block EXT2FS_ATTR((unused)),
int ref_offset EXT2FS_ATTR((unused)),
void *priv_data)
{
struct process_block_struct *p;
- blk_t blk = *block_nr;
- blk_t first_block;
+ blk64_t blk = *block_nr;
+ blk64_t first_block;
dgrp_t i;
struct problem_context *pctx;
e2fsck_t ctx;
@@ -2554,7 +2553,7 @@ static void handle_fs_bad_blocks(e2fsck_t ctx)
static void mark_table_blocks(e2fsck_t ctx)
{
ext2_filsys fs = ctx->fs;
- blk_t b;
+ blk64_t b;
dgrp_t i;
int j;
struct problem_context pctx;
diff --git a/e2fsck/pass1b.c b/e2fsck/pass1b.c
index 0c8cefa5..155fcba4 100644
--- a/e2fsck/pass1b.c
+++ b/e2fsck/pass1b.c
@@ -54,7 +54,7 @@ typedef long intptr_t;
#define BLOCK_COUNT_EXTATTR (-5)
struct block_el {
- blk_t block;
+ blk64_t block;
struct block_el *next;
};
@@ -89,7 +89,7 @@ static void delete_file(e2fsck_t ctx, ext2_ino_t ino,
struct dup_inode *dp, char *block_buf);
static int clone_file(e2fsck_t ctx, ext2_ino_t ino,
struct dup_inode *dp, char* block_buf);
-static int check_if_fs_block(e2fsck_t ctx, blk_t test_blk);
+static int check_if_fs_block(e2fsck_t ctx, blk64_t test_blk);
static void pass1b(e2fsck_t ctx, char *block_buf);
static void pass1c(e2fsck_t ctx, char *block_buf);
@@ -115,7 +115,7 @@ static int dict_int_cmp(const void *a, const void *b)
/*
* Add a duplicate block record
*/
-static void add_dupe(e2fsck_t ctx, ext2_ino_t ino, blk_t blk,
+static void add_dupe(e2fsck_t ctx, ext2_ino_t ino, blk64_t blk,
struct ext2_inode *inode)
{
dnode_t *n;
@@ -548,7 +548,7 @@ static void pass1d(e2fsck_t ctx, char *block_buf)
* Drop the refcount on the dup_block structure, and clear the entry
* in the block_dup_map if appropriate.
*/
-static void decrement_badcount(e2fsck_t ctx, blk_t block, struct dup_block *p)
+static void decrement_badcount(e2fsck_t ctx, blk64_t block, struct dup_block *p)
{
p->num_bad--;
if (p->num_bad <= 0 ||
@@ -622,7 +622,7 @@ static void delete_file(e2fsck_t ctx, ext2_ino_t ino,
if (ext2fs_file_acl_block(&inode) &&
(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_EXT_ATTR)) {
count = 1;
- pctx.errcode = ext2fs_adjust_ea_refcount(fs,
+ pctx.errcode = ext2fs_adjust_ea_refcount2(fs,
ext2fs_file_acl_block(&inode),
block_buf, -1, &count);
if (pctx.errcode == EXT2_ET_BAD_EA_BLOCK_NUM) {
@@ -687,7 +687,7 @@ static int clone_file_block(ext2_filsys fs,
return BLOCK_ABORT;
}
if (cs->dir && (blockcnt >= 0)) {
- retval = ext2fs_set_dir_block(fs->dblist,
+ retval = ext2fs_set_dir_block2(fs->dblist,
cs->dir, new_block, blockcnt);
if (retval) {
cs->errcode = retval;
@@ -820,10 +820,10 @@ errout:
* This routine returns 1 if a block overlaps with one of the superblocks,
* group descriptors, inode bitmaps, or block bitmaps.
*/
-static int check_if_fs_block(e2fsck_t ctx, blk_t test_block)
+static int check_if_fs_block(e2fsck_t ctx, blk64_t test_block)
{
ext2_filsys fs = ctx->fs;
- blk_t first_block;
+ blk64_t first_block;
dgrp_t i;
first_block = fs->super->s_first_data_block;
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index 1300e387..8d1cbc6c 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -61,10 +61,10 @@
*/
static void deallocate_inode(e2fsck_t ctx, ext2_ino_t ino, char* block_buf);
static int check_dir_block(ext2_filsys fs,
- struct ext2_db_entry *dir_blocks_info,
+ struct ext2_db_entry2 *dir_blocks_info,
void *priv_data);
static int allocate_dir_block(e2fsck_t ctx,
- struct ext2_db_entry *dir_blocks_info,
+ struct ext2_db_entry2 *dir_blocks_info,
char *buf, struct problem_context *pctx);
static void clear_htree(e2fsck_t ctx, ext2_ino_t ino);
static int htree_depth(struct dx_dir_info *dx_dir,
@@ -132,16 +132,16 @@ void e2fsck_pass2(e2fsck_t ctx)
cd.buf = buf;
cd.ctx = ctx;
cd.count = 1;
- cd.max = ext2fs_dblist_count(fs->dblist);
+ cd.max = ext2fs_dblist_count2(fs->dblist);
if (ctx->progress)
(void) (ctx->progress)(ctx, 2, 0, cd.max);
if (fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX)
- ext2fs_dblist_sort(fs->dblist, special_dir_block_cmp);
+ ext2fs_dblist_sort2(fs->dblist, special_dir_block_cmp);
- cd.pctx.errcode = ext2fs_dblist_iterate(fs->dblist, check_dir_block,
- &cd);
+ cd.pctx.errcode = ext2fs_dblist_iterate2(fs->dblist, check_dir_block,
+ &cd);
if (ctx->flags & E2F_FLAG_SIGNAL_MASK || ctx->flags & E2F_FLAG_RESTART)
return;
@@ -314,10 +314,10 @@ static int dict_de_cmp(const void *a, const void *b)
*/
static EXT2_QSORT_TYPE special_dir_block_cmp(const void *a, const void *b)
{
- const struct ext2_db_entry *db_a =
- (const struct ext2_db_entry *) a;
- const struct ext2_db_entry *db_b =
- (const struct ext2_db_entry *) b;
+ const struct ext2_db_entry2 *db_a =
+ (const struct ext2_db_entry2 *) a;
+ const struct ext2_db_entry2 *db_b =
+ (const struct ext2_db_entry2 *) b;
if (db_a->blockcnt && !db_b->blockcnt)
return 1;
@@ -517,7 +517,7 @@ static _INLINE_ int check_filetype(e2fsck_t ctx,
#ifdef ENABLE_HTREE
static void parse_int_node(ext2_filsys fs,
- struct ext2_db_entry *db,
+ struct ext2_db_entry2 *db,
struct check_dir_struct *cd,
struct dx_dir_info *dx_dir,
char *block_buf)
@@ -700,7 +700,7 @@ static void salvage_directory(ext2_filsys fs,
}
static int check_dir_block(ext2_filsys fs,
- struct ext2_db_entry *db,
+ struct ext2_db_entry2 *db,
void *priv_data)
{
struct dx_dir_info *dx_dir;
@@ -714,7 +714,7 @@ static int check_dir_block(ext2_filsys fs,
int dir_modified = 0;
int dot_state;
unsigned int rec_len;
- blk_t block_nr = db->blk;
+ blk64_t block_nr = db->blk;
ext2_ino_t ino = db->ino;
ext2_ino_t subdir_parent;
__u16 links;
@@ -774,7 +774,7 @@ static int check_dir_block(ext2_filsys fs,
#endif
old_op = ehandler_operation(_("reading directory block"));
- cd->pctx.errcode = ext2fs_read_dir_block(fs, block_nr, buf);
+ cd->pctx.errcode = ext2fs_read_dir_block3(fs, block_nr, buf, 0);
ehandler_operation(0);
if (cd->pctx.errcode == EXT2_ET_DIR_CORRUPTED)
cd->pctx.errcode = 0; /* We'll handle this ourselves */
@@ -1153,9 +1153,9 @@ abort_free_dict:
* functioned called by deallocate inode via ext2fs_iterate_block().
*/
static int deallocate_inode_block(ext2_filsys fs,
- blk_t *block_nr,
+ blk64_t *block_nr,
e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)),
- blk_t ref_block EXT2FS_ATTR((unused)),
+ blk64_t ref_block EXT2FS_ATTR((unused)),
int ref_offset EXT2FS_ATTR((unused)),
void *priv_data)
{
@@ -1194,7 +1194,7 @@ static void deallocate_inode(e2fsck_t ctx, ext2_ino_t ino, char* block_buf)
if (ext2fs_file_acl_block(&inode) &&
(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_EXT_ATTR)) {
- pctx.errcode = ext2fs_adjust_ea_refcount(fs, ext2fs_file_acl_block(&inode),
+ pctx.errcode = ext2fs_adjust_ea_refcount2(fs, ext2fs_file_acl_block(&inode),
block_buf, -1, &count);
if (pctx.errcode == EXT2_ET_BAD_EA_BLOCK_NUM) {
pctx.errcode = 0;
@@ -1223,8 +1223,8 @@ static void deallocate_inode(e2fsck_t ctx, ext2_ino_t ino, char* block_buf)
(inode.i_size_high || inode.i_size & 0x80000000UL))
ctx->large_files--;
- pctx.errcode = ext2fs_block_iterate2(fs, ino, 0, block_buf,
- deallocate_inode_block, ctx);
+ pctx.errcode = ext2fs_block_iterate3(fs, ino, 0, block_buf,
+ deallocate_inode_block, ctx);
if (pctx.errcode) {
fix_problem(ctx, PR_2_DEALLOC_INODE, &pctx);
ctx->flags |= E2F_FLAG_ABORT;
@@ -1397,7 +1397,7 @@ extern int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir,
* that was zeroed out and now needs to be replaced.
*/
static int allocate_dir_block(e2fsck_t ctx,
- struct ext2_db_entry *db,
+ struct ext2_db_entry2 *db,
char *buf EXT2FS_ATTR((unused)),
struct problem_context *pctx)
{
diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c
index fc5374f1..c0671643 100644
--- a/e2fsck/pass3.c
+++ b/e2fsck/pass3.c
@@ -675,24 +675,24 @@ static void fix_dotdot(e2fsck_t ctx, ext2_ino_t ino, ext2_ino_t parent)
*/
struct expand_dir_struct {
- int num;
- int guaranteed_size;
- int newblocks;
- int last_block;
+ blk64_t num;
+ e2_blkcnt_t guaranteed_size;
+ blk64_t newblocks;
+ blk64_t last_block;
errcode_t err;
e2fsck_t ctx;
};
static int expand_dir_proc(ext2_filsys fs,
- blk_t *blocknr,
+ blk64_t *blocknr,
e2_blkcnt_t blockcnt,
- blk_t ref_block EXT2FS_ATTR((unused)),
+ blk64_t ref_block EXT2FS_ATTR((unused)),
int ref_offset EXT2FS_ATTR((unused)),
void *priv_data)
{
struct expand_dir_struct *es = (struct expand_dir_struct *) priv_data;
blk64_t new_blk;
- static blk_t last_blk = 0;
+ static blk64_t last_blk = 0;
char *block;
errcode_t retval;
e2fsck_t ctx;
@@ -775,7 +775,7 @@ errcode_t e2fsck_expand_directory(e2fsck_t ctx, ext2_ino_t dir,
es.newblocks = 0;
es.ctx = ctx;
- retval = ext2fs_block_iterate2(fs, dir, BLOCK_FLAG_APPEND,
+ retval = ext2fs_block_iterate3(fs, dir, BLOCK_FLAG_APPEND,
0, expand_dir_proc, &es);
if (es.err)
diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c
index b22a838d..cbc12f39 100644
--- a/e2fsck/pass5.c
+++ b/e2fsck/pass5.c
@@ -64,7 +64,7 @@ void e2fsck_pass5(e2fsck_t ctx)
print_resource_track(ctx, _("Pass 5"), &rtrack, ctx->fs->io);
}
-#define NO_BLK ((blk_t) -1)
+#define NO_BLK ((blk64_t) -1)
static void print_bitmap_problem(e2fsck_t ctx, int problem,
struct problem_context *pctx)
@@ -106,8 +106,8 @@ static void check_block_bitmaps(e2fsck_t ctx)
blk64_t i;
int *free_array;
int group = 0;
- blk_t blocks = 0;
- blk_t free_blocks = 0;
+ int blocks = 0;
+ blk64_t free_blocks = 0;
int group_free = 0;
int actual, bitmap;
struct problem_context pctx;
diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
index c0944a92..5543134a 100644
--- a/e2fsck/rehash.c
+++ b/e2fsck/rehash.c
@@ -78,9 +78,9 @@ struct out_dir {
};
static int fill_dir_block(ext2_filsys fs,
- blk_t *block_nr,
+ blk64_t *block_nr,
e2_blkcnt_t blockcnt,
- blk_t ref_block EXT2FS_ATTR((unused)),
+ blk64_t ref_block EXT2FS_ATTR((unused)),
int ref_offset EXT2FS_ATTR((unused)),
void *priv_data)
{
@@ -105,7 +105,7 @@ static int fill_dir_block(ext2_filsys fs,
dirent = (struct ext2_dir_entry *) dir;
(void) ext2fs_set_rec_len(fs, fs->blocksize, dirent);
} else {
- fd->err = ext2fs_read_dir_block(fs, *block_nr, dir);
+ fd->err = ext2fs_read_dir_block3(fs, *block_nr, dir, 0);
if (fd->err)
return BLOCK_ABORT;
}
@@ -632,14 +632,14 @@ struct write_dir_struct {
* Helper function which writes out a directory block.
*/
static int write_dir_block(ext2_filsys fs,
- blk_t *block_nr,
+ blk64_t *block_nr,
e2_blkcnt_t blockcnt,
- blk_t ref_block EXT2FS_ATTR((unused)),
+ blk64_t ref_block EXT2FS_ATTR((unused)),
int ref_offset EXT2FS_ATTR((unused)),
void *priv_data)
{
struct write_dir_struct *wd = (struct write_dir_struct *) priv_data;
- blk_t blk;
+ blk64_t blk;
char *dir;
if (*block_nr == 0)
@@ -657,7 +657,7 @@ static int write_dir_block(ext2_filsys fs,
return 0;
dir = wd->outdir->buf + (blockcnt * fs->blocksize);
- wd->err = ext2fs_write_dir_block(fs, *block_nr, dir);
+ wd->err = ext2fs_write_dir_block3(fs, *block_nr, dir, 0);
if (wd->err)
return BLOCK_ABORT;
return 0;
@@ -680,7 +680,7 @@ static errcode_t write_directory(e2fsck_t ctx, ext2_filsys fs,
wd.ctx = ctx;
wd.cleared = 0;
- retval = ext2fs_block_iterate2(fs, ino, 0, 0,
+ retval = ext2fs_block_iterate3(fs, ino, 0, 0,
write_dir_block, &wd);
if (retval)
return retval;
@@ -738,7 +738,7 @@ errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino)
retry_nohash:
/* Read in the entire directory into memory */
- retval = ext2fs_block_iterate2(fs, ino, 0, 0,
+ retval = ext2fs_block_iterate3(fs, ino, 0, 0,
fill_dir_block, &fd);
if (fd.err) {
retval = fd.err;
diff --git a/e2fsck/super.c b/e2fsck/super.c
index caba72cd..b6923c64 100644
--- a/e2fsck/super.c
+++ b/e2fsck/super.c
@@ -54,16 +54,16 @@ struct process_block_struct {
};
static int release_inode_block(ext2_filsys fs,
- blk_t *block_nr,
+ blk64_t *block_nr,
e2_blkcnt_t blockcnt,
- blk_t ref_blk EXT2FS_ATTR((unused)),
+ blk64_t ref_blk EXT2FS_ATTR((unused)),
int ref_offset EXT2FS_ATTR((unused)),
void *priv_data)
{
struct process_block_struct *pb;
e2fsck_t ctx;
struct problem_context *pctx;
- blk_t blk = *block_nr;
+ blk64_t blk = *block_nr;
int retval = 0;
pb = (struct process_block_struct *) priv_data;
@@ -180,7 +180,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
pb.truncate_offset = 0;
}
pb.truncated_blocks = 0;
- retval = ext2fs_block_iterate2(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE,
+ retval = ext2fs_block_iterate3(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE,
block_buf, release_inode_block, &pb);
if (retval) {
com_err("release_inode_blocks", retval,
@@ -198,7 +198,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
ext2fs_iblk_sub_blocks(fs, inode, pb.truncated_blocks);
if (ext2fs_file_acl_block(inode)) {
- retval = ext2fs_adjust_ea_refcount(fs, ext2fs_file_acl_block(inode),
+ retval = ext2fs_adjust_ea_refcount2(fs, ext2fs_file_acl_block(inode),
block_buf, -1, &count);
if (retval == EXT2_ET_BAD_EA_BLOCK_NUM) {
retval = 0;
@@ -206,7 +206,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
}
if (retval) {
com_err("release_inode_blocks", retval,
- _("while calling ext2fs_adjust_ea_refcount for inode %d"),
+ _("while calling ext2fs_adjust_ea_refcount2 for inode %d"),
ino);
return 1;
}
@@ -313,7 +313,7 @@ void check_resize_inode(e2fsck_t ctx)
struct problem_context pctx;
int i, gdt_off, ind_off;
dgrp_t j;
- blk_t blk, pblk, expect;
+ blk64_t blk, pblk, expect;
__u32 *dind_buf = 0, *ind_buf;
errcode_t retval;
@@ -456,20 +456,20 @@ static void e2fsck_fix_dirhash_hint(e2fsck_t ctx)
void check_super_block(e2fsck_t ctx)
{
ext2_filsys fs = ctx->fs;
- blk_t first_block, last_block;
+ blk64_t first_block, last_block;
struct ext2_super_block *sb = fs->super;
problem_t problem;
- blk_t blocks_per_group = fs->super->s_blocks_per_group;
- blk_t bpg_max;
+ blk64_t blocks_per_group = fs->super->s_blocks_per_group;
+ __u32 bpg_max;
int inodes_per_block;
int ipg_max;
int inode_size;
int accept_time_fudge;
int broken_system_clock;
dgrp_t i;
- blk_t should_be;
+ blk64_t should_be;
struct problem_context pctx;
- blk_t free_blocks = 0;
+ blk64_t free_blocks = 0;
ino_t free_inodes = 0;
int csum_flag, clear_test_fs_flag;
@@ -906,7 +906,7 @@ int check_backup_super_block(e2fsck_t ctx)
ext2_filsys fs = ctx->fs;
errcode_t retval;
dgrp_t g;
- blk_t sb;
+ blk64_t sb;
int ret = 0;
char buf[SUPERBLOCK_SIZE];
struct ext2_super_block *backup_sb;
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 07a8349a..bae3b38c 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -101,9 +101,9 @@ static void show_stats(e2fsck_t ctx)
{
ext2_filsys fs = ctx->fs;
ext2_ino_t inodes, inodes_used;
- blk_t blocks, blocks_used;
- int dir_links;
- int num_files, num_links;
+ blk64_t blocks, blocks_used;
+ unsigned int dir_links;
+ unsigned int num_files, num_links;
int frag_percent_file, frag_percent_dir, frag_percent_total;
int i, j;
@@ -129,7 +129,7 @@ static void show_stats(e2fsck_t ctx)
frag_percent_total = (frag_percent_total + 5) / 10;
if (!verbose) {
- printf(_("%s: %u/%u files (%0d.%d%% non-contiguous), %u/%u blocks\n"),
+ printf(_("%s: %u/%u files (%0d.%d%% non-contiguous), %llu/%llu blocks\n"),
ctx->device_name, inodes_used, inodes,
frag_percent_total / 10, frag_percent_total % 10,
blocks_used, blocks);
@@ -163,7 +163,8 @@ static void show_stats(e2fsck_t ctx)
fputc('\n', stdout);
}
- printf (P_("%8u block used (%2.2f%%)\n", "%8u blocks used (%2.2f%%)\n",
+ printf (P_("%8llu block used (%2.2f%%)\n",
+ "%8llu blocks used (%2.2f%%)\n",
blocks_used), blocks_used, 100.0 * blocks_used / blocks);
printf (P_("%8u bad block\n", "%8u bad blocks\n",
ctx->fs_badblocks_count), ctx->fs_badblocks_count);
@@ -737,7 +738,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
/* What we do by default, anyway! */
break;
case 'b':
- res = sscanf(optarg, "%u", &ctx->use_superblock);
+ res = sscanf(optarg, "%llu", &ctx->use_superblock);
if (res != 1)
goto sscanf_err;
ctx->flags |= E2F_FLAG_SB_SPECIFIED;