From 1d2eef4227f165789a8a39d904542a1865a88283 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 15 Mar 2003 13:30:07 -0500 Subject: [PATCH] rehash.c (e2fsck_rehash_dir): If user specified the -n option, skip trying to write out directory. (e2fsck_rehash_directories): Fix the percentage calculation in the progress bar. --- e2fsck/ChangeLog | 7 +++++++ e2fsck/rehash.c | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index 9bf7594..c02827e 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,3 +1,10 @@ +2003-03-15 Theodore Ts'o + + * rehash.c (e2fsck_rehash_dir): If user specified the -n option, + skip trying to write out directory. + (e2fsck_rehash_directories): Fix the percentage + calculation in the progress bar. + 2003-03-14 Theodore Ts'o * problem.c, problem.h (PR_2_REPORT_DUP_DIRENT): Add new problem code. diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c index d048003..fbb206f 100644 --- a/e2fsck/rehash.c +++ b/e2fsck/rehash.c @@ -228,8 +228,10 @@ static errcode_t alloc_size_dir(ext2_filsys fs, struct out_dir *outdir, static void free_out_dir(struct out_dir *outdir) { - free(outdir->buf); - free(outdir->hashes); + if (outdir->buf) + free(outdir->buf); + if (outdir->hashes) + free(outdir->hashes); outdir->max = 0; outdir->num =0; } @@ -659,6 +661,9 @@ errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino) struct fill_dir_struct fd; struct out_dir outdir; + outdir.max = outdir.num = 0; + outdir.buf = 0; + outdir.hashes = 0; e2fsck_read_inode(ctx, ino, &inode, "rehash_dir"); retval = ENOMEM; @@ -712,6 +717,11 @@ resort: if (duplicate_search_and_fix(ctx, fs, ino, &fd)) goto resort; + if (ctx->options & E2F_OPT_NO) { + retval = 0; + goto errout; + } + /* * Copy the directory entries. In a htree directory these * will become the leaf nodes. @@ -809,7 +819,7 @@ void e2fsck_rehash_directories(e2fsck_t ctx) } if (ctx->progress && !ctx->progress_fd) e2fsck_simple_progress(ctx, "Rebuilding directory", - (float) (++cur) / (float) max, ino); + 100.0 * (float) (++cur) / (float) max, ino); } end_problem_latch(ctx, PR_LATCH_OPTIMIZE_DIR); if (!all_dirs) -- 1.8.3.1