+2000-11-16 Theodore Ts'o <tytso@valinux.com>
+
+ * pass1b.c: Change routines to use PR_1B_BLOCK_ITERATE when
+ reporting problems rather than using com_err directly.
+
+ * problem.c, problem.h (PR_1B_BLOCK_ITERATE): Add new problem code.
+
+ * message.c (expand_percent_expression): Add safety check. If
+ ctx->str is NULL, print "NULL" instead of dereferencing
+ the null pointer.
+
+ * pass1b.c, pass2.c, pass3.c: Change calls to ext2fs_block_iterate
+ to ext2fs_block_iterate2, to support 64-bit filesizes and
+ to speed things up slightly by avoiding the use of the
+ ext2fs_block_iterate's compatibility shim layer.
+
2000-10-30 <tytso@snap.thunk.org>
* util.c (get_backup_sb): Calculate backup superblock correctly
};
static int process_pass1b_block(ext2_filsys fs, blk_t *blocknr,
- int blockcnt, void *priv_data);
+ e2_blkcnt_t blockcnt, blk_t ref_blk,
+ int ref_offset, void *priv_data);
static void delete_file(e2fsck_t ctx, struct dup_inode *dp,
char *block_buf);
static int clone_file(e2fsck_t ctx, struct dup_inode *dp, char* block_buf);
ctx->stashed_inode = &inode;
pb.ctx = ctx;
pb.pctx = &pctx;
+ pctx.str = "pass1b";
while (ino) {
pctx.ino = ctx->stashed_ino = ino;
if ((ino != EXT2_BAD_INO) &&
pb.ino = ino;
pb.dup_blocks = 0;
- retval = ext2fs_block_iterate(fs, ino, 0, block_buf,
+ pctx.errcode = ext2fs_block_iterate2(fs, ino, 0, block_buf,
process_pass1b_block, &pb);
if (pb.dup_blocks) {
end_problem_latch(ctx, PR_LATCH_DBLOCK);
if (ino != EXT2_BAD_INO)
dup_inode_count++;
}
- if (retval)
- com_err(ctx->program_name, retval,
- _("while calling ext2fs_block_iterate in pass1b"));
-
+ if (pctx.errcode)
+ fix_problem(ctx, PR_1B_BLOCK_ITERATE, &pctx);
next:
pctx.errcode = ext2fs_get_next_inode(scan, &ino, &inode);
if (pctx.errcode == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE)
int process_pass1b_block(ext2_filsys fs,
blk_t *block_nr,
- int blockcnt,
+ e2_blkcnt_t blockcnt,
+ blk_t ref_blk,
+ int ref_offset,
void *priv_data)
{
struct process_block_struct *p;
static int delete_file_block(ext2_filsys fs,
blk_t *block_nr,
- int blockcnt,
+ e2_blkcnt_t blockcnt,
+ blk_t ref_block,
+ int ref_offset,
void *priv_data)
{
struct process_block_struct *pb;
errcode_t retval;
struct process_block_struct pb;
struct ext2_inode inode;
+ struct problem_context pctx;
- pb.ino = dp->ino;
+ clear_problem_context(&pctx);
+ pctx.ino = pb.ino = dp->ino;
pb.dup_blocks = dp->num_dupblocks;
pb.ctx = ctx;
-
- retval = ext2fs_block_iterate(fs, dp->ino, 0, block_buf,
- delete_file_block, &pb);
- if (retval)
- com_err("delete_file", retval,
- _("while calling ext2fs_block_iterate for inode %d"),
- dp->ino);
+ pctx.str = "delete_file";
+
+ pctx.errcode = ext2fs_block_iterate2(fs, dp->ino, 0, block_buf,
+ delete_file_block, &pb);
+ if (pctx.errcode)
+ fix_problem(ctx, PR_1B_BLOCK_ITERATE, &pctx);
ext2fs_unmark_inode_bitmap(ctx->inode_used_map, dp->ino);
ext2fs_unmark_inode_bitmap(ctx->inode_dir_map, dp->ino);
if (ctx->inode_bad_map)
static int clone_file_block(ext2_filsys fs,
blk_t *block_nr,
- int blockcnt,
+ e2_blkcnt_t blockcnt,
+ blk_t ref_block,
+ int ref_offset,
void *priv_data)
{
struct dup_block *p;
ext2_filsys fs = ctx->fs;
errcode_t retval;
struct clone_struct cs;
+ struct problem_context pctx;
+ clear_problem_context(&pctx);
cs.errcode = 0;
cs.dir = 0;
cs.ctx = ctx;
if (ext2fs_test_inode_bitmap(ctx->inode_dir_map, dp->ino))
cs.dir = dp->ino;
-
- retval = ext2fs_block_iterate(fs, dp->ino, 0, block_buf,
+
+ pctx.ino = dp->ino;
+ pctx.str = "clone_file";
+ pctx.errcode = ext2fs_block_iterate2(fs, dp->ino, 0, block_buf,
clone_file_block, &cs);
ext2fs_mark_bb_dirty(fs);
ext2fs_free_mem((void **) &cs.buf);
- if (retval) {
- com_err("clone_file", retval,
- _("while calling ext2fs_block_iterate for inode %d"),
- dp->ino);
- return retval;
+ if (pctx.errcode) {
+ fix_problem(ctx, PR_1B_BLOCK_ITERATE, &pctx);
+ return pctx.errcode;
}
if (cs.errcode) {
com_err("clone_file", cs.errcode,
_("returned from clone_file_block"));
- return retval;
+ return cs.errcode;
}
return 0;
}
char *buf, struct problem_context *pctx);
static int update_dir_block(ext2_filsys fs,
blk_t *block_nr,
- int blockcnt,
+ e2_blkcnt_t blockcnt,
+ blk_t ref_block,
+ int ref_offset,
void *priv_data);
struct check_dir_struct {
* functioned called by deallocate inode via ext2fs_iterate_block().
*/
static int deallocate_inode_block(ext2_filsys fs,
- blk_t *block_nr,
- int blockcnt,
- void *priv_data)
+ blk_t *block_nr,
+ e2_blkcnt_t blockcnt,
+ blk_t ref_block,
+ int ref_offset,
+ void *priv_data)
{
e2fsck_t ctx = (e2fsck_t) priv_data;
return;
ext2fs_mark_bb_dirty(fs);
- pctx.errcode = ext2fs_block_iterate(fs, ino, 0, block_buf,
+ pctx.errcode = ext2fs_block_iterate2(fs, ino, 0, block_buf,
deallocate_inode_block, ctx);
if (pctx.errcode) {
fix_problem(ctx, PR_2_DEALLOC_INODE, &pctx);
* Finally, update the block pointers for the inode
*/
db->blk = blk;
- pctx->errcode = ext2fs_block_iterate(fs, db->ino, BLOCK_FLAG_HOLE,
+ pctx->errcode = ext2fs_block_iterate2(fs, db->ino, BLOCK_FLAG_HOLE,
0, update_dir_block, db);
if (pctx->errcode) {
pctx->str = "ext2fs_block_iterate";
*/
static int update_dir_block(ext2_filsys fs,
blk_t *block_nr,
- int blockcnt,
+ e2_blkcnt_t blockcnt,
+ blk_t ref_block,
+ int ref_offset,
void *priv_data)
{
struct ext2_db_entry *db;
db = (struct ext2_db_entry *) priv_data;
- if (db->blockcnt == blockcnt) {
+ if (db->blockcnt == (int) blockcnt) {
*block_nr = db->blk;
return BLOCK_CHANGED;
}