diff options
author | Theodore Ts'o <tytso@mit.edu> | 1997-10-03 17:48:10 +0000 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 1997-10-03 17:48:10 +0000 |
commit | 1b6bf1759af884957234b7dce768b785f792abd0 (patch) | |
tree | 275137be213c5a3d049080df8febbeac4b857684 /e2fsck/pass3.c | |
parent | d163b0948731e6d84bd3efe75075a2d0a8009272 (diff) | |
download | e2fsprogs-1b6bf1759af884957234b7dce768b785f792abd0.tar.gz |
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
Diffstat (limited to 'e2fsck/pass3.c')
-rw-r--r-- | e2fsck/pass3.c | 306 |
1 files changed, 164 insertions, 142 deletions
diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c index 2f97aa4c..7d7c6495 100644 --- a/e2fsck/pass3.c +++ b/e2fsck/pass3.c @@ -37,18 +37,17 @@ #ifdef HAVE_ERRNO_H #include <errno.h> #endif -#include "et/com_err.h" #include "e2fsck.h" #include "problem.h" -static void check_root(ext2_filsys fs); -static void check_directory(ext2_filsys fs, struct dir_info *dir, +static void check_root(e2fsck_t ctx); +static void check_directory(e2fsck_t ctx, struct dir_info *dir, struct problem_context *pctx); -static ino_t get_lost_and_found(ext2_filsys fs); -static void fix_dotdot(ext2_filsys fs, struct dir_info *dir, ino_t parent); -static errcode_t adjust_inode_count(ext2_filsys fs, ino_t ino, int adj); -static errcode_t expand_directory(ext2_filsys fs, ino_t dir); +static ino_t get_lost_and_found(e2fsck_t ctx); +static void fix_dotdot(e2fsck_t ctx, struct dir_info *dir, ino_t parent); +static errcode_t adjust_inode_count(e2fsck_t ctx, ino_t ino, int adj); +static errcode_t expand_directory(e2fsck_t ctx, ino_t dir); static ino_t lost_and_found = 0; static int bad_lost_and_found = 0; @@ -56,120 +55,120 @@ static int bad_lost_and_found = 0; static ext2fs_inode_bitmap inode_loop_detect; static ext2fs_inode_bitmap inode_done_map; -void pass3(ext2_filsys fs) +void pass3(e2fsck_t ctx) { + ext2_filsys fs = ctx->fs; int i; - errcode_t retval; struct resource_track rtrack; struct problem_context pctx; struct dir_info *dir; init_resource_track(&rtrack); + clear_problem_context(&pctx); + #ifdef MTRACE mtrace_print("Pass 3"); #endif - if (!preen) - printf("Pass 3: Checking directory connectivity\n"); + if (!(ctx->options & E2F_OPT_PREEN)) + fix_problem(ctx, PR_3_PASS_HEADER, &pctx); /* * Allocate some bitmaps to do loop detection. */ - retval = ext2fs_allocate_inode_bitmap(fs, - "inode loop detection bitmap", - &inode_loop_detect); - if (retval) { - com_err("ext2fs_allocate_inode_bitmap", retval, - "while allocating inode_loop_detect"); + pctx.errcode = ext2fs_allocate_inode_bitmap(fs, + "inode loop detection bitmap", &inode_loop_detect); + if (pctx.errcode) { + pctx.num = 1; + fix_problem(ctx, PR_3_ALLOCATE_IBITMAP_ERROR, &pctx); fatal_error(0); } - retval = ext2fs_allocate_inode_bitmap(fs, "inode done bitmap", - &inode_done_map); - if (retval) { - com_err("ext2fs_allocate_inode_bitmap", retval, - "while allocating inode_done_map"); + pctx.errcode = ext2fs_allocate_inode_bitmap(fs, "inode done bitmap", + &inode_done_map); + if (pctx.errcode) { + pctx.num = 2; + fix_problem(ctx, PR_3_ALLOCATE_IBITMAP_ERROR, &pctx); fatal_error(0); } - if (tflag) { - printf("Peak memory: "); - print_resource_track(&global_rtrack); - } + if (ctx->options & E2F_OPT_TIME) + print_resource_track("Peak memory", &ctx->global_rtrack); - check_root(fs); + check_root(ctx); ext2fs_mark_inode_bitmap(inode_done_map, EXT2_ROOT_INO); - clear_problem_context(&pctx); for (i=0; (dir = dir_info_iter(&i)) != 0;) { - if (ext2fs_test_inode_bitmap(inode_dir_map, dir->ino)) - check_directory(fs, dir, &pctx); + if (ext2fs_test_inode_bitmap(ctx->inode_dir_map, dir->ino)) + check_directory(ctx, dir, &pctx); } free_dir_info(fs); ext2fs_free_inode_bitmap(inode_loop_detect); ext2fs_free_inode_bitmap(inode_done_map); - if (tflag > 1) { - printf("Pass 3: "); - print_resource_track(&rtrack); - } + if (ctx->options & E2F_OPT_TIME2) + print_resource_track("Pass 3", &rtrack); } /* * This makes sure the root inode is present; if not, we ask if the * user wants us to create it. Not creating it is a fatal error. */ -static void check_root(ext2_filsys fs) +static void check_root(e2fsck_t ctx) { + ext2_filsys fs = ctx->fs; blk_t blk; - errcode_t retval; struct ext2_inode inode; char * block; + struct problem_context pctx; - if (ext2fs_test_inode_bitmap(inode_used_map, EXT2_ROOT_INO)) { + clear_problem_context(&pctx); + + if (ext2fs_test_inode_bitmap(ctx->inode_used_map, EXT2_ROOT_INO)) { /* * If the root inode is a directory, die here. The * user must have answered 'no' in pass1 when we * offered to clear it. */ - if (!(ext2fs_test_inode_bitmap(inode_dir_map, EXT2_ROOT_INO))) + if (!(ext2fs_test_inode_bitmap(ctx->inode_dir_map, + EXT2_ROOT_INO))) fatal_error("Root inode not directory"); return; } - if (!fix_problem(fs, PR_3_NO_ROOT_INODE, 0)) + if (!fix_problem(ctx, PR_3_NO_ROOT_INODE, &pctx)) fatal_error("Cannot proceed without a root inode."); - read_bitmaps(fs); + read_bitmaps(ctx); /* * First, find a free block */ - retval = ext2fs_new_block(fs, 0, block_found_map, &blk); - if (retval) { - com_err("ext2fs_new_block", retval, - "while trying to create root directory"); + pctx.errcode = ext2fs_new_block(fs, 0, ctx->block_found_map, &blk); + if (pctx.errcode) { + pctx.str = "ext2fs_new_block"; + fix_problem(ctx, PR_3_CREATE_ROOT_ERROR, &pctx); fatal_error(0); } - ext2fs_mark_block_bitmap(block_found_map, blk); + ext2fs_mark_block_bitmap(ctx->block_found_map, blk); ext2fs_mark_block_bitmap(fs->block_map, blk); ext2fs_mark_bb_dirty(fs); /* * Now let's create the actual data block for the inode */ - retval = ext2fs_new_dir_block(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, - &block); - if (retval) { - com_err("ext2fs_new_dir_block", retval, - "while creating new root directory"); + pctx.errcode = ext2fs_new_dir_block(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, + &block); + if (pctx.errcode) { + pctx.str = "ext2fs_new_dir_block"; + fix_problem(ctx, PR_3_CREATE_ROOT_ERROR, &pctx); fatal_error(0); } - retval = ext2fs_write_dir_block(fs, blk, block); - if (retval) { - com_err("ext2fs_write_dir_block", retval, - "while writing the root directory block"); + pctx.errcode = ext2fs_write_dir_block(fs, blk, block); + if (pctx.errcode) { + pctx.str = "ext2fs_write_dir_block"; + fix_problem(ctx, PR_3_CREATE_ROOT_ERROR, &pctx); fatal_error(0); } free(block); @@ -188,10 +187,10 @@ static void check_root(ext2_filsys fs) /* * Write out the inode. */ - retval = ext2fs_write_inode(fs, EXT2_ROOT_INO, &inode); - if (retval) { - com_err("ext2fs_write_inode", retval, - "While trying to create /lost+found"); + pctx.errcode = ext2fs_write_inode(fs, EXT2_ROOT_INO, &inode); + if (pctx.errcode) { + pctx.str = "ext2fs_write_inode"; + fix_problem(ctx, PR_3_CREATE_ROOT_ERROR, &pctx); fatal_error(0); } @@ -199,11 +198,11 @@ static void check_root(ext2_filsys fs) * Miscellaneous bookkeeping... */ add_dir_info(fs, EXT2_ROOT_INO, EXT2_ROOT_INO); - ext2fs_icount_store(inode_count, EXT2_ROOT_INO, 2); - ext2fs_icount_store(inode_link_info, EXT2_ROOT_INO, 2); + ext2fs_icount_store(ctx->inode_count, EXT2_ROOT_INO, 2); + ext2fs_icount_store(ctx->inode_link_info, EXT2_ROOT_INO, 2); - ext2fs_mark_inode_bitmap(inode_used_map, EXT2_ROOT_INO); - ext2fs_mark_inode_bitmap(inode_dir_map, EXT2_ROOT_INO); + ext2fs_mark_inode_bitmap(ctx->inode_used_map, EXT2_ROOT_INO); + ext2fs_mark_inode_bitmap(ctx->inode_dir_map, EXT2_ROOT_INO); ext2fs_mark_inode_bitmap(fs->inode_map, EXT2_ROOT_INO); ext2fs_mark_ib_dirty(fs); } @@ -216,9 +215,10 @@ static void check_root(ext2_filsys fs) * a loop, we treat that as a disconnected directory and offer to * reparent it to lost+found. */ -static void check_directory(ext2_filsys fs, struct dir_info *dir, +static void check_directory(e2fsck_t ctx, struct dir_info *dir, struct problem_context *pctx) { + ext2_filsys fs = ctx->fs; struct dir_info *p = dir; ext2fs_clear_inode_bitmap(inode_loop_detect); @@ -258,12 +258,12 @@ static void check_directory(ext2_filsys fs, struct dir_info *dir, * inode; offer to reconnect it to lost+found. */ pctx->ino = p->ino; - if (fix_problem(fs, PR_3_UNCONNECTED_DIR, pctx)) { - if (reconnect_file(fs, p->ino)) + if (fix_problem(ctx, PR_3_UNCONNECTED_DIR, pctx)) { + if (reconnect_file(ctx, p->ino)) ext2fs_unmark_valid(fs); else { p->parent = lost_and_found; - fix_dotdot(fs, p, lost_and_found); + fix_dotdot(ctx, p, lost_and_found); } } @@ -276,8 +276,8 @@ check_dot_dot: pctx->ino = dir->ino; pctx->ino2 = dir->dotdot; pctx->dir = dir->parent; - if (fix_problem(fs, PR_3_BAD_DOT_DOT, pctx)) - fix_dotdot(fs, dir, dir->parent); + if (fix_problem(ctx, PR_3_BAD_DOT_DOT, pctx)) + fix_dotdot(ctx, dir, dir->parent); } } @@ -285,56 +285,61 @@ check_dot_dot: * This routine gets the lost_and_found inode, making it a directory * if necessary */ -ino_t get_lost_and_found(ext2_filsys fs) +ino_t get_lost_and_found(e2fsck_t ctx) { + ext2_filsys fs = ctx->fs; ino_t ino; blk_t blk; errcode_t retval; struct ext2_inode inode; char * block; const char name[] = "lost+found"; + struct problem_context pctx; + clear_problem_context(&pctx); + retval = ext2fs_lookup(fs, EXT2_ROOT_INO, name, sizeof(name)-1, 0, &ino); if (!retval) return ino; - if (retval != ENOENT) - printf("Error while trying to find /lost+found: %s", - error_message(retval)); - if (!fix_problem(fs, PR_3_NO_LF_DIR, 0)) + if (retval != ENOENT) { + pctx.errcode = retval; + fix_problem(ctx, PR_3_ERR_FIND_LPF, &pctx); + } + if (!fix_problem(ctx, PR_3_NO_LF_DIR, 0)) return 0; /* * Read the inode and block bitmaps in; we'll be messing with * them. */ - read_bitmaps(fs); + read_bitmaps(ctx); /* * First, find a free block */ - retval = ext2fs_new_block(fs, 0, block_found_map, &blk); + retval = ext2fs_new_block(fs, 0, ctx->block_found_map, &blk); if (retval) { - com_err("ext2fs_new_block", retval, - "while trying to create /lost+found directory"); + pctx.errcode = retval; + fix_problem(ctx, PR_3_ERR_LPF_NEW_BLOCK, &pctx); return 0; } - ext2fs_mark_block_bitmap(block_found_map, blk); + ext2fs_mark_block_bitmap(ctx->block_found_map, blk); ext2fs_mark_block_bitmap(fs->block_map, blk); ext2fs_mark_bb_dirty(fs); /* * Next find a free inode. */ - retval = ext2fs_new_inode(fs, EXT2_ROOT_INO, 040755, inode_used_map, - &ino); + retval = ext2fs_new_inode(fs, EXT2_ROOT_INO, 040755, + ctx->inode_used_map, &ino); if (retval) { - com_err("ext2fs_new_inode", retval, - "while trying to create /lost+found directory"); + pctx.errcode = retval; + fix_problem(ctx, PR_3_ERR_LPF_NEW_INODE, &pctx); return 0; } - ext2fs_mark_inode_bitmap(inode_used_map, ino); - ext2fs_mark_inode_bitmap(inode_dir_map, ino); + ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino); + ext2fs_mark_inode_bitmap(ctx->inode_dir_map, ino); ext2fs_mark_inode_bitmap(fs->inode_map, ino); ext2fs_mark_ib_dirty(fs); @@ -343,16 +348,16 @@ ino_t get_lost_and_found(ext2_filsys fs) */ retval = ext2fs_new_dir_block(fs, ino, EXT2_ROOT_INO, &block); if (retval) { - com_err("ext2fs_new_dir_block", retval, - "while creating new directory block"); + pctx.errcode = retval; + fix_problem(ctx, PR_3_ERR_LPF_NEW_DIR_BLOCK, &pctx); return 0; } retval = ext2fs_write_dir_block(fs, blk, block); free(block); if (retval) { - com_err("ext2fs_write_dir_block", retval, - "while writing the directory block for /lost+found"); + pctx.errcode = retval; + fix_problem(ctx, PR_3_ERR_LPF_WRITE_BLOCK, &pctx); return 0; } @@ -370,18 +375,19 @@ ino_t get_lost_and_found(ext2_filsys fs) /* * Next, write out the inode. */ - retval = ext2fs_write_inode(fs, ino, &inode); - if (retval) { - com_err("ext2fs_write_inode", retval, - "While trying to create /lost+found"); + pctx.errcode = ext2fs_write_inode(fs, ino, &inode); + if (pctx.errcode) { + pctx.str = "ext2fs_write_inode"; + fix_problem(ctx, PR_3_CREATE_LPF_ERROR, &pctx); return 0; } /* * Finally, create the directory link */ - retval = ext2fs_link(fs, EXT2_ROOT_INO, name, ino, 0); - if (retval) { - com_err("ext2fs_link", retval, "While creating /lost+found"); + pctx.errcode = ext2fs_link(fs, EXT2_ROOT_INO, name, ino, 0); + if (pctx.errcode) { + pctx.str = "ext2fs_link"; + fix_problem(ctx, PR_3_CREATE_LPF_ERROR, &pctx); return 0; } @@ -389,9 +395,9 @@ ino_t get_lost_and_found(ext2_filsys fs) * Miscellaneous bookkeeping that needs to be kept straight. */ add_dir_info(fs, ino, EXT2_ROOT_INO); - adjust_inode_count(fs, EXT2_ROOT_INO, +1); - ext2fs_icount_store(inode_count, ino, 2); - ext2fs_icount_store(inode_link_info, ino, 2); + adjust_inode_count(ctx, EXT2_ROOT_INO, +1); + ext2fs_icount_store(ctx->inode_count, ino, 2); + ext2fs_icount_store(ctx->inode_link_info, ino, 2); #if 0 printf("/lost+found created; inode #%lu\n", ino); #endif @@ -401,44 +407,45 @@ ino_t get_lost_and_found(ext2_filsys fs) /* * This routine will connect a file to lost+found */ -int reconnect_file(ext2_filsys fs, ino_t inode) +int reconnect_file(e2fsck_t ctx, ino_t inode) { + ext2_filsys fs = ctx->fs; errcode_t retval; char name[80]; - + struct problem_context pctx; + + clear_problem_context(&pctx); + pctx.ino = inode; + + if (!bad_lost_and_found && !lost_and_found) { + lost_and_found = get_lost_and_found(ctx); + if (!lost_and_found) + bad_lost_and_found++; + } if (bad_lost_and_found) { - printf("Bad or nonexistent /lost+found. Cannot reconnect.\n"); + fix_problem(ctx, PR_3_NO_LPF, &pctx); return 1; } - if (!lost_and_found) { - lost_and_found = get_lost_and_found(fs); - if (!lost_and_found) { - printf("Bad or nonexistent /lost+found. Cannot reconnect.\n"); - bad_lost_and_found++; - return 1; - } - } - + sprintf(name, "#%lu", inode); retval = ext2fs_link(fs, lost_and_found, name, inode, 0); if (retval == EXT2_ET_DIR_NO_SPACE) { - if (!fix_problem(fs, PR_3_EXPAND_LF_DIR, 0)) + if (!fix_problem(ctx, PR_3_EXPAND_LF_DIR, &pctx)) return 1; - retval = expand_directory(fs, lost_and_found); + retval = expand_directory(ctx, lost_and_found); if (retval) { - printf("Could not expand /lost+found: %s\n", - error_message(retval)); + pctx.errcode = retval; + fix_problem(ctx, PR_3_CANT_EXPAND_LPF, &pctx); return 1; } retval = ext2fs_link(fs, lost_and_found, name, inode, 0); } if (retval) { - printf("Could not reconnect %lu: %s\n", inode, - error_message(retval)); + pctx.errcode = retval; + fix_problem(ctx, PR_3_CANT_RECONNECT, &pctx); return 1; } - - adjust_inode_count(fs, inode, +1); + adjust_inode_count(ctx, inode, +1); return 0; } @@ -446,8 +453,9 @@ int reconnect_file(ext2_filsys fs, ino_t inode) /* * Utility routine to adjust the inode counts on an inode. */ -static errcode_t adjust_inode_count(ext2_filsys fs, ino_t ino, int adj) +static errcode_t adjust_inode_count(e2fsck_t ctx, ino_t ino, int adj) { + ext2_filsys fs = ctx->fs; errcode_t retval; struct ext2_inode inode; @@ -465,11 +473,11 @@ static errcode_t adjust_inode_count(ext2_filsys fs, ino_t ino, int adj) inode.i_links_count += adj; if (adj == 1) { - ext2fs_icount_increment(inode_count, ino, 0); - ext2fs_icount_increment(inode_link_info, ino, 0); + ext2fs_icount_increment(ctx->inode_count, ino, 0); + ext2fs_icount_increment(ctx->inode_link_info, ino, 0); } else { - ext2fs_icount_decrement(inode_count, ino, 0); - ext2fs_icount_decrement(inode_link_info, ino, 0); + ext2fs_icount_decrement(ctx->inode_count, ino, 0); + ext2fs_icount_decrement(ctx->inode_link_info, ino, 0); } @@ -487,6 +495,7 @@ struct fix_dotdot_struct { ext2_filsys fs; ino_t parent; int done; + e2fsck_t ctx; }; static int fix_dotdot_proc(struct ext2_dir_entry *dirent, @@ -497,35 +506,42 @@ static int fix_dotdot_proc(struct ext2_dir_entry *dirent, { struct fix_dotdot_struct *fp = (struct fix_dotdot_struct *) private; errcode_t retval; + struct problem_context pctx; if (dirent->name_len != 2) return 0; if (strncmp(dirent->name, "..", 2)) return 0; - - retval = adjust_inode_count(fp->fs, dirent->inode, -1); - if (retval) - printf("Error while adjusting inode count on inode %u\n", - dirent->inode); - retval = adjust_inode_count(fp->fs, fp->parent, 1); - if (retval) - printf("Error while adjusting inode count on inode %lu\n", - fp->parent); + clear_problem_context(&pctx); + + retval = adjust_inode_count(fp->ctx, dirent->inode, -1); + if (retval) { + pctx.errcode = retval; + fix_problem(fp->ctx, PR_3_ADJUST_INODE, &pctx); + } + retval = adjust_inode_count(fp->ctx, fp->parent, 1); + if (retval) { + pctx.errcode = retval; + fix_problem(fp->ctx, PR_3_ADJUST_INODE, &pctx); + } dirent->inode = fp->parent; fp->done++; return DIRENT_ABORT | DIRENT_CHANGED; } -static void fix_dotdot(ext2_filsys fs, struct dir_info *dir, ino_t parent) +static void fix_dotdot(e2fsck_t ctx, struct dir_info *dir, ino_t parent) { + ext2_filsys fs = ctx->fs; errcode_t retval; struct fix_dotdot_struct fp; + struct problem_context pctx; fp.fs = fs; fp.parent = parent; fp.done = 0; + fp.ctx = ctx; #if 0 printf("Fixing '..' of inode %lu to be %lu...\n", dir->ino, parent); @@ -534,9 +550,11 @@ static void fix_dotdot(ext2_filsys fs, struct dir_info *dir, ino_t parent) retval = ext2fs_dir_iterate(fs, dir->ino, DIRENT_FLAG_INCLUDE_EMPTY, 0, fix_dotdot_proc, &fp); if (retval || !fp.done) { - printf("Couldn't fix parent of inode %lu: %s\n\n", - dir->ino, retval ? error_message(retval) : - "Couldn't find parent direntory entry"); + clear_problem_context(&pctx); + pctx.ino = dir->ino; + pctx.errcode = retval; + fix_problem(ctx, retval ? PR_3_FIX_PARENT_ERR : + PR_3_FIX_PARENT_NOFIND, &pctx); ext2fs_unmark_valid(fs); } dir->dotdot = parent; @@ -552,6 +570,7 @@ static void fix_dotdot(ext2_filsys fs, struct dir_info *dir, ino_t parent) struct expand_dir_struct { int done; errcode_t err; + e2fsck_t ctx; }; static int expand_dir_proc(ext2_filsys fs, @@ -564,12 +583,16 @@ static int expand_dir_proc(ext2_filsys fs, static blk_t last_blk = 0; char *block; errcode_t retval; + e2fsck_t ctx; + + ctx = es->ctx; if (*blocknr) { last_blk = *blocknr; return 0; } - retval = ext2fs_new_block(fs, last_blk, block_found_map, &new_blk); + retval = ext2fs_new_block(fs, last_blk, ctx->block_found_map, + &new_blk); if (retval) { es->err = retval; return BLOCK_ABORT; @@ -596,7 +619,7 @@ static int expand_dir_proc(ext2_filsys fs, } free(block); *blocknr = new_blk; - ext2fs_mark_block_bitmap(block_found_map, new_blk); + ext2fs_mark_block_bitmap(ctx->block_found_map, new_blk); ext2fs_mark_block_bitmap(fs->block_map, new_blk); ext2fs_mark_bb_dirty(fs); if (es->done) @@ -605,8 +628,9 @@ static int expand_dir_proc(ext2_filsys fs, return BLOCK_CHANGED; } -static errcode_t expand_directory(ext2_filsys fs, ino_t dir) +static errcode_t expand_directory(e2fsck_t ctx, ino_t dir) { + ext2_filsys fs = ctx->fs; errcode_t retval; struct expand_dir_struct es; struct ext2_inode inode; @@ -620,6 +644,7 @@ static errcode_t expand_directory(ext2_filsys fs, ino_t dir) es.done = 0; es.err = 0; + es.ctx = ctx; retval = ext2fs_block_iterate(fs, dir, BLOCK_FLAG_APPEND, 0, expand_dir_proc, &es); @@ -643,6 +668,3 @@ static errcode_t expand_directory(ext2_filsys fs, ino_t dir) return 0; } - - - |