aboutsummaryrefslogtreecommitdiff
path: root/e2fsprogs
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-04-06 22:49:04 +0000
committerRob Landley <rob@landley.net>2006-04-06 22:49:04 +0000
commit3e72c5931c1f981b894bf3f1aed4852338904ffc (patch)
tree7129f07d05d6d7769882e7824b1206e8fbc6afe1 /e2fsprogs
parentbc142140180c517dcb1c8bb59bdf9110f0a1422e (diff)
downloadbusybox-w32-3e72c5931c1f981b894bf3f1aed4852338904ffc.tar.gz
busybox-w32-3e72c5931c1f981b894bf3f1aed4852338904ffc.tar.bz2
busybox-w32-3e72c5931c1f981b894bf3f1aed4852338904ffc.zip
Another size reduction patch from Garrett.
Diffstat (limited to 'e2fsprogs')
-rw-r--r--e2fsprogs/e2fsck.c486
-rw-r--r--e2fsprogs/e2fsck.h20
2 files changed, 18 insertions, 488 deletions
diff --git a/e2fsprogs/e2fsck.c b/e2fsprogs/e2fsck.c
index 52069fe60..788da4df4 100644
--- a/e2fsprogs/e2fsck.c
+++ b/e2fsprogs/e2fsck.c
@@ -76,18 +76,10 @@ static void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size,
76static int ask(e2fsck_t ctx, const char * string, int def); 76static int ask(e2fsck_t ctx, const char * string, int def);
77static void e2fsck_read_bitmaps(e2fsck_t ctx); 77static void e2fsck_read_bitmaps(e2fsck_t ctx);
78static void preenhalt(e2fsck_t ctx); 78static void preenhalt(e2fsck_t ctx);
79#ifdef RESOURCE_TRACK
80static void print_resource_track(const char *desc,
81 struct resource_track *track);
82static void init_resource_track(struct resource_track *track);
83#endif
84static void e2fsck_read_inode(e2fsck_t ctx, unsigned long ino, 79static void e2fsck_read_inode(e2fsck_t ctx, unsigned long ino,
85 struct ext2_inode * inode, const char * proc); 80 struct ext2_inode * inode, const char * proc);
86static void e2fsck_write_inode(e2fsck_t ctx, unsigned long ino, 81static void e2fsck_write_inode(e2fsck_t ctx, unsigned long ino,
87 struct ext2_inode * inode, const char * proc); 82 struct ext2_inode * inode, const char * proc);
88#ifdef MTRACE
89static void mtrace_print(char *mesg);
90#endif
91static blk_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, 83static blk_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs,
92 const char *name, io_manager manager); 84 const char *name, io_manager manager);
93 85
@@ -1631,9 +1623,6 @@ static void e2fsck_add_dir_info(e2fsck_t ctx, ext2_ino_t ino, ext2_ino_t parent)
1631 errcode_t retval; 1623 errcode_t retval;
1632 unsigned long old_size; 1624 unsigned long old_size;
1633 1625
1634#if 0
1635 printf("add_dir_info for inode %lu...\n", ino);
1636#endif
1637 if (!ctx->dir_info) { 1626 if (!ctx->dir_info) {
1638 ctx->dir_info_count = 0; 1627 ctx->dir_info_count = 0;
1639 retval = ext2fs_get_num_dirs(ctx->fs, &num_dirs); 1628 retval = ext2fs_get_num_dirs(ctx->fs, &num_dirs);
@@ -1763,9 +1752,6 @@ static void e2fsck_add_dx_dir(e2fsck_t ctx, ext2_ino_t ino, int num_blocks)
1763 errcode_t retval; 1752 errcode_t retval;
1764 unsigned long old_size; 1753 unsigned long old_size;
1765 1754
1766#if 0
1767 printf("add_dx_dir_info for inode %lu...\n", ino);
1768#endif
1769 if (!ctx->dx_dir_info) { 1755 if (!ctx->dx_dir_info) {
1770 ctx->dx_dir_info_count = 0; 1756 ctx->dx_dir_info_count = 0;
1771 ctx->dx_dir_info_size = 100; /* Guess */ 1757 ctx->dx_dir_info_size = 100; /* Guess */
@@ -2168,9 +2154,6 @@ retry:
2168 printf("Non-cursor get_refcount_el: %u\n", blk); 2154 printf("Non-cursor get_refcount_el: %u\n", blk);
2169#endif 2155#endif
2170 while (low <= high) { 2156 while (low <= high) {
2171#if 0
2172 mid = (low+high)/2;
2173#else
2174 if (low == high) 2157 if (low == high)
2175 mid = low; 2158 mid = low;
2176 else { 2159 else {
@@ -2187,7 +2170,7 @@ retry:
2187 (highval - lowval); 2170 (highval - lowval);
2188 mid = low + ((int) (range * (high-low))); 2171 mid = low + ((int) (range * (high-low)));
2189 } 2172 }
2190#endif 2173
2191 if (blk == refcount->list[mid].ea_blk) { 2174 if (blk == refcount->list[mid].ea_blk) {
2192 refcount->cursor = mid+1; 2175 refcount->cursor = mid+1;
2193 return &refcount->list[mid]; 2176 return &refcount->list[mid];
@@ -4164,9 +4147,6 @@ fix:
4164 * it seems like a corruption. it's very unlikely we could repair 4147 * it seems like a corruption. it's very unlikely we could repair
4165 * EA(s) in automatic fashion -bzzz 4148 * EA(s) in automatic fashion -bzzz
4166 */ 4149 */
4167#if 0
4168 problem = PR_1_ATTR_HASH;
4169#endif
4170 if (problem == 0 || !fix_problem(ctx, problem, pctx)) 4150 if (problem == 0 || !fix_problem(ctx, problem, pctx))
4171 return; 4151 return;
4172 4152
@@ -4189,10 +4169,6 @@ static void check_inode_extra_space(e2fsck_t ctx, struct problem_context *pctx)
4189 return; 4169 return;
4190 } 4170 }
4191 4171
4192#if 0
4193 printf("inode #%u, i_extra_size %d\n", pctx->ino,
4194 inode->i_extra_isize);
4195#endif
4196 /* i_extra_isize must cover i_extra_isize + i_pad1 at least */ 4172 /* i_extra_isize must cover i_extra_isize + i_pad1 at least */
4197 min = sizeof(inode->i_extra_isize) + sizeof(inode->i_pad1); 4173 min = sizeof(inode->i_extra_isize) + sizeof(inode->i_pad1);
4198 max = EXT2_INODE_SIZE(sb) - EXT2_GOOD_OLD_INODE_SIZE; 4174 max = EXT2_INODE_SIZE(sb) - EXT2_GOOD_OLD_INODE_SIZE;
@@ -4227,9 +4203,6 @@ static void e2fsck_pass1(e2fsck_t ctx)
4227 struct ext2_inode *inode; 4203 struct ext2_inode *inode;
4228 ext2_inode_scan scan; 4204 ext2_inode_scan scan;
4229 char *block_buf; 4205 char *block_buf;
4230#ifdef RESOURCE_TRACK
4231 struct resource_track rtrack;
4232#endif
4233 unsigned char frag, fsize; 4206 unsigned char frag, fsize;
4234 struct problem_context pctx; 4207 struct problem_context pctx;
4235 struct scan_callback_struct scan_struct; 4208 struct scan_callback_struct scan_struct;
@@ -4238,9 +4211,6 @@ static void e2fsck_pass1(e2fsck_t ctx)
4238 int busted_fs_time = 0; 4211 int busted_fs_time = 0;
4239 int inode_size; 4212 int inode_size;
4240 4213
4241#ifdef RESOURCE_TRACK
4242 init_resource_track(&rtrack);
4243#endif
4244 clear_problem_context(&pctx); 4214 clear_problem_context(&pctx);
4245 4215
4246 if (!(ctx->options & E2F_OPT_PREEN)) 4216 if (!(ctx->options & E2F_OPT_PREEN))
@@ -4252,9 +4222,7 @@ static void e2fsck_pass1(e2fsck_t ctx)
4252 ctx->dirs_to_hash = 0; 4222 ctx->dirs_to_hash = 0;
4253 } 4223 }
4254 4224
4255#ifdef MTRACE 4225 /* Pass 1 */
4256 mtrace_print("Pass 1");
4257#endif
4258 4226
4259#define EXT2_BPP(bits) (1ULL << ((bits) - 2)) 4227#define EXT2_BPP(bits) (1ULL << ((bits) - 2))
4260 4228
@@ -4753,12 +4721,6 @@ endit:
4753 ext2fs_free_mem(&block_buf); 4721 ext2fs_free_mem(&block_buf);
4754 ext2fs_free_mem(&inode); 4722 ext2fs_free_mem(&inode);
4755 4723
4756#ifdef RESOURCE_TRACK
4757 if (ctx->options & E2F_OPT_TIME2) {
4758 e2fsck_clear_progbar(ctx);
4759 print_resource_track(_("Pass 1"), &rtrack);
4760 }
4761#endif
4762} 4724}
4763 4725
4764/* 4726/*
@@ -4797,9 +4759,7 @@ static void process_inodes(e2fsck_t ctx, char *block_buf)
4797 char buf[80]; 4759 char buf[80];
4798 struct problem_context pctx; 4760 struct problem_context pctx;
4799 4761
4800#if 0 4762 /* begin process_inodes */
4801 printf("begin process_inodes: ");
4802#endif
4803 if (process_inode_count == 0) 4763 if (process_inode_count == 0)
4804 return; 4764 return;
4805 old_operation = ehandler_operation(0); 4765 old_operation = ehandler_operation(0);
@@ -4811,10 +4771,6 @@ static void process_inodes(e2fsck_t ctx, char *block_buf)
4811 for (i=0; i < process_inode_count; i++) { 4771 for (i=0; i < process_inode_count; i++) {
4812 pctx.inode = ctx->stashed_inode = &inodes_to_process[i].inode; 4772 pctx.inode = ctx->stashed_inode = &inodes_to_process[i].inode;
4813 pctx.ino = ctx->stashed_ino = inodes_to_process[i].ino; 4773 pctx.ino = ctx->stashed_ino = inodes_to_process[i].ino;
4814
4815#if 0
4816 printf("%u ", pctx.ino);
4817#endif
4818 sprintf(buf, _("reading indirect blocks of inode %u"), 4774 sprintf(buf, _("reading indirect blocks of inode %u"),
4819 pctx.ino); 4775 pctx.ino);
4820 ehandler_operation(buf); 4776 ehandler_operation(buf);
@@ -4825,9 +4781,8 @@ static void process_inodes(e2fsck_t ctx, char *block_buf)
4825 ctx->stashed_inode = old_stashed_inode; 4781 ctx->stashed_inode = old_stashed_inode;
4826 ctx->stashed_ino = old_stashed_ino; 4782 ctx->stashed_ino = old_stashed_ino;
4827 process_inode_count = 0; 4783 process_inode_count = 0;
4828#if 0 4784 /* end process inodes */
4829 printf("end process inodes\n"); 4785
4830#endif
4831 ehandler_operation(old_operation); 4786 ehandler_operation(old_operation);
4832} 4787}
4833 4788
@@ -5046,11 +5001,6 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx,
5046 } 5001 }
5047 } 5002 }
5048 5003
5049#if 0
5050 /* Debugging text */
5051 printf("Inode %u has EA block %u\n", ino, blk);
5052#endif
5053
5054 /* Have we seen this EA block before? */ 5004 /* Have we seen this EA block before? */
5055 if (ext2fs_fast_test_block_bitmap(ctx->block_ea_map, blk)) { 5005 if (ext2fs_fast_test_block_bitmap(ctx->block_ea_map, blk)) {
5056 if (ea_refcount_decrement(ctx->refcount, blk, 0) == 0) 5006 if (ea_refcount_decrement(ctx->refcount, blk, 0) == 0)
@@ -5313,11 +5263,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
5313 } 5263 }
5314 5264
5315 pb.num_blocks *= (fs->blocksize / 512); 5265 pb.num_blocks *= (fs->blocksize / 512);
5316#if 0 5266
5317 printf("inode %u, i_size = %lu, last_block = %lld, i_blocks=%lu, num_blocks = %lu\n",
5318 ino, inode->i_size, pb.last_block, inode->i_blocks,
5319 pb.num_blocks);
5320#endif
5321 if (pb.is_dir) { 5267 if (pb.is_dir) {
5322 int nblock = inode->i_size >> EXT2_BLOCK_SIZE_BITS(fs->super); 5268 int nblock = inode->i_size >> EXT2_BLOCK_SIZE_BITS(fs->super);
5323 if (nblock > (pb.last_block + 1)) 5269 if (nblock > (pb.last_block + 1))
@@ -5362,57 +5308,6 @@ out:
5362 e2fsck_write_inode(ctx, ino, inode, "check_blocks"); 5308 e2fsck_write_inode(ctx, ino, inode, "check_blocks");
5363} 5309}
5364 5310
5365#if 0
5366/*
5367 * Helper function called by process block when an illegal block is
5368 * found. It returns a description about why the block is illegal
5369 */
5370static char *describe_illegal_block(ext2_filsys fs, blk_t block)
5371{
5372 blk_t super;
5373 int i;
5374 static char problem[80];
5375
5376 super = fs->super->s_first_data_block;
5377 strcpy(problem, "PROGRAMMING ERROR: Unknown reason for illegal block");
5378 if (block < super) {
5379 sprintf(problem, "< FIRSTBLOCK (%u)", super);
5380 return(problem);
5381 } else if (block >= fs->super->s_blocks_count) {
5382 sprintf(problem, "> BLOCKS (%u)", fs->super->s_blocks_count);
5383 return(problem);
5384 }
5385 for (i = 0; i < fs->group_desc_count; i++) {
5386 if (block == super) {
5387 sprintf(problem, "is the superblock in group %d", i);
5388 break;
5389 }
5390 if (block > super &&
5391 block <= (super + fs->desc_blocks)) {
5392 sprintf(problem, "is in the group descriptors "
5393 "of group %d", i);
5394 break;
5395 }
5396 if (block == fs->group_desc[i].bg_block_bitmap) {
5397 sprintf(problem, "is the block bitmap of group %d", i);
5398 break;
5399 }
5400 if (block == fs->group_desc[i].bg_inode_bitmap) {
5401 sprintf(problem, "is the inode bitmap of group %d", i);
5402 break;
5403 }
5404 if (block >= fs->group_desc[i].bg_inode_table &&
5405 (block < fs->group_desc[i].bg_inode_table
5406 + fs->inode_blocks_per_group)) {
5407 sprintf(problem, "is in the inode table of group %d",
5408 i);
5409 break;
5410 }
5411 super += fs->super->s_blocks_per_group;
5412 }
5413 return(problem);
5414}
5415#endif
5416 5311
5417/* 5312/*
5418 * This is a helper function for check_blocks(). 5313 * This is a helper function for check_blocks().
@@ -5473,20 +5368,11 @@ static int process_block(ext2_filsys fs,
5473 if (blockcnt < 0) 5368 if (blockcnt < 0)
5474 return 0; 5369 return 0;
5475 if (blockcnt * fs->blocksize < p->inode->i_size) { 5370 if (blockcnt * fs->blocksize < p->inode->i_size) {
5476#if 0
5477 printf("Missing block (#%d) in directory inode %lu!\n",
5478 blockcnt, p->ino);
5479#endif
5480 goto mark_dir; 5371 goto mark_dir;
5481 } 5372 }
5482 return 0; 5373 return 0;
5483 } 5374 }
5484 5375
5485#if 0
5486 printf("Process_block, inode %lu, block %u, #%d\n", p->ino, blk,
5487 blockcnt);
5488#endif
5489
5490 /* 5376 /*
5491 * Simplistic fragmentation check. We merely require that the 5377 * Simplistic fragmentation check. We merely require that the
5492 * file be contiguous. (Which can never be true for really 5378 * file be contiguous. (Which can never be true for really
@@ -5623,9 +5509,7 @@ static int process_bad_block(ext2_filsys fs,
5623 mark_block_used(ctx, blk); 5509 mark_block_used(ctx, blk);
5624 return 0; 5510 return 0;
5625 } 5511 }
5626#if 0 5512
5627 printf ("DEBUG: Marking %u as bad.\n", blk);
5628#endif
5629 ctx->fs_badblocks_count++; 5513 ctx->fs_badblocks_count++;
5630 /* 5514 /*
5631 * If the block is not used, then mark it as used and return. 5515 * If the block is not used, then mark it as used and return.
@@ -6609,10 +6493,7 @@ static int clone_file_block(ext2_filsys fs,
6609 return BLOCK_ABORT; 6493 return BLOCK_ABORT;
6610 } 6494 }
6611 } 6495 }
6612#if 0 6496
6613 printf("Cloning block %u to %u\n", *block_nr,
6614 new_block);
6615#endif
6616 retval = io_channel_read_blk(fs->io, *block_nr, 1, 6497 retval = io_channel_read_blk(fs->io, *block_nr, 1,
6617 cs->buf); 6498 cs->buf);
6618 if (retval) { 6499 if (retval) {
@@ -6785,8 +6666,6 @@ static int check_if_fs_block(e2fsck_t ctx, blk_t test_block)
6785 * - The inode_reg_map bitmap 6666 * - The inode_reg_map bitmap
6786 */ 6667 */
6787 6668
6788/* #define DX_DEBUG */
6789
6790/* 6669/*
6791 * Keeps track of how many times an inode is referenced. 6670 * Keeps track of how many times an inode is referenced.
6792 */ 6671 */
@@ -6820,9 +6699,6 @@ static void e2fsck_pass2(e2fsck_t ctx)
6820 struct problem_context pctx; 6699 struct problem_context pctx;
6821 ext2_filsys fs = ctx->fs; 6700 ext2_filsys fs = ctx->fs;
6822 char *buf; 6701 char *buf;
6823#ifdef RESOURCE_TRACK
6824 struct resource_track rtrack;
6825#endif
6826 struct dir_info *dir; 6702 struct dir_info *dir;
6827 struct check_dir_struct cd; 6703 struct check_dir_struct cd;
6828 struct dx_dir_info *dx_dir; 6704 struct dx_dir_info *dx_dir;
@@ -6832,15 +6708,9 @@ static void e2fsck_pass2(e2fsck_t ctx)
6832 problem_t code; 6708 problem_t code;
6833 int bad_dir; 6709 int bad_dir;
6834 6710
6835#ifdef RESOURCE_TRACK
6836 init_resource_track(&rtrack);
6837#endif
6838
6839 clear_problem_context(&cd.pctx); 6711 clear_problem_context(&cd.pctx);
6840 6712
6841#ifdef MTRACE 6713 /* Pass 2 */
6842 mtrace_print("Pass 2");
6843#endif
6844 6714
6845 if (!(ctx->options & E2F_OPT_PREEN)) 6715 if (!(ctx->options & E2F_OPT_PREEN))
6846 fix_problem(ctx, PR_2_PASS_HEADER, &cd.pctx); 6716 fix_problem(ctx, PR_2_PASS_HEADER, &cd.pctx);
@@ -7007,12 +6877,6 @@ static void e2fsck_pass2(e2fsck_t ctx)
7007 } 6877 }
7008 } 6878 }
7009 6879
7010#ifdef RESOURCE_TRACK
7011 if (ctx->options & E2F_OPT_TIME2) {
7012 e2fsck_clear_progbar(ctx);
7013 print_resource_track(_("Pass 2"), &rtrack);
7014 }
7015#endif
7016} 6880}
7017 6881
7018#define MAX_DEPTH 32000 6882#define MAX_DEPTH 32000
@@ -7294,29 +7158,12 @@ static void parse_int_node(ext2_filsys fs,
7294 7158
7295 if (db->blockcnt == 0) { 7159 if (db->blockcnt == 0) {
7296 root = (struct ext2_dx_root_info *) (block_buf + 24); 7160 root = (struct ext2_dx_root_info *) (block_buf + 24);
7297
7298#ifdef DX_DEBUG
7299 printf("Root node dump:\n");
7300 printf("\t Reserved zero: %d\n", root->reserved_zero);
7301 printf("\t Hash Version: %d\n", root->hash_version);
7302 printf("\t Info length: %d\n", root->info_length);
7303 printf("\t Indirect levels: %d\n", root->indirect_levels);
7304 printf("\t Flags: %d\n", root->unused_flags);
7305#endif
7306
7307 ent = (struct ext2_dx_entry *) (block_buf + 24 + root->info_length); 7161 ent = (struct ext2_dx_entry *) (block_buf + 24 + root->info_length);
7308 } else { 7162 } else {
7309 ent = (struct ext2_dx_entry *) (block_buf+8); 7163 ent = (struct ext2_dx_entry *) (block_buf+8);
7310 } 7164 }
7311 limit = (struct ext2_dx_countlimit *) ent; 7165 limit = (struct ext2_dx_countlimit *) ent;
7312 7166
7313#ifdef DX_DEBUG
7314 printf("Number of entries (count): %d\n",
7315 ext2fs_le16_to_cpu(limit->count));
7316 printf("Number of entries (limit): %d\n",
7317 ext2fs_le16_to_cpu(limit->limit));
7318#endif
7319
7320 count = ext2fs_le16_to_cpu(limit->count); 7167 count = ext2fs_le16_to_cpu(limit->count);
7321 expect_limit = (fs->blocksize - ((char *) ent - block_buf)) / 7168 expect_limit = (fs->blocksize - ((char *) ent - block_buf)) /
7322 sizeof(struct ext2_dx_entry); 7169 sizeof(struct ext2_dx_entry);
@@ -7335,10 +7182,6 @@ static void parse_int_node(ext2_filsys fs,
7335 for (i=0; i < count; i++) { 7182 for (i=0; i < count; i++) {
7336 prev_hash = hash; 7183 prev_hash = hash;
7337 hash = i ? (ext2fs_le32_to_cpu(ent[i].hash) & ~1) : 0; 7184 hash = i ? (ext2fs_le32_to_cpu(ent[i].hash) & ~1) : 0;
7338#ifdef DX_DEBUG
7339 printf("Entry #%d: Hash 0x%08x, block %d\n", i,
7340 hash, ext2fs_le32_to_cpu(ent[i].block));
7341#endif
7342 blk = ext2fs_le32_to_cpu(ent[i].block) & 0x0ffffff; 7185 blk = ext2fs_le32_to_cpu(ent[i].block) & 0x0ffffff;
7343 /* Check to make sure the block is valid */ 7186 /* Check to make sure the block is valid */
7344 if (blk > (blk_t) dx_dir->numblocks) { 7187 if (blk > (blk_t) dx_dir->numblocks) {
@@ -7372,10 +7215,6 @@ static void parse_int_node(ext2_filsys fs,
7372 if (i == 0) 7215 if (i == 0)
7373 dx_db->flags |= DX_FLAG_FIRST; 7216 dx_db->flags |= DX_FLAG_FIRST;
7374 } 7217 }
7375#ifdef DX_DEBUG
7376 printf("Blockcnt = %d, min hash 0x%08x, max hash 0x%08x\n",
7377 db->blockcnt, min_hash, max_hash);
7378#endif
7379 dx_db = &dx_dir->dx_block[db->blockcnt]; 7218 dx_db = &dx_dir->dx_block[db->blockcnt];
7380 dx_db->min_hash = min_hash; 7219 dx_db->min_hash = min_hash;
7381 dx_db->max_hash = max_hash; 7220 dx_db->max_hash = max_hash;
@@ -7513,11 +7352,6 @@ static int check_dir_block(ext2_filsys fs,
7513 ext2fs_u32_list_test(ctx->dirs_to_hash, ino)) 7352 ext2fs_u32_list_test(ctx->dirs_to_hash, ino))
7514 dups_found++; 7353 dups_found++;
7515 7354
7516#if 0
7517 printf("In process_dir_block block %lu, #%d, inode %lu\n", block_nr,
7518 db->blockcnt, ino);
7519#endif
7520
7521 cd->pctx.errcode = ext2fs_read_dir_block(fs, block_nr, buf); 7355 cd->pctx.errcode = ext2fs_read_dir_block(fs, block_nr, buf);
7522 if (cd->pctx.errcode == EXT2_ET_DIR_CORRUPTED) 7356 if (cd->pctx.errcode == EXT2_ET_DIR_CORRUPTED)
7523 cd->pctx.errcode = 0; /* We'll handle this ourselves */ 7357 cd->pctx.errcode = 0; /* We'll handle this ourselves */
@@ -7775,16 +7609,8 @@ static int check_dir_block(ext2_filsys fs,
7775 offset += dirent->rec_len; 7609 offset += dirent->rec_len;
7776 dot_state++; 7610 dot_state++;
7777 } while (offset < fs->blocksize); 7611 } while (offset < fs->blocksize);
7778#if 0
7779 printf("\n");
7780#endif
7781#ifdef ENABLE_HTREE 7612#ifdef ENABLE_HTREE
7782 if (dx_db) { 7613 if (dx_db) {
7783#ifdef DX_DEBUG
7784 printf("db_block %d, type %d, min_hash 0x%0x, max_hash 0x%0x\n",
7785 db->blockcnt, dx_db->type,
7786 dx_db->min_hash, dx_db->max_hash);
7787#endif
7788 cd->pctx.dir = cd->pctx.ino; 7614 cd->pctx.dir = cd->pctx.ino;
7789 if ((dx_db->type == DX_DIRBLOCK_ROOT) || 7615 if ((dx_db->type == DX_DIRBLOCK_ROOT) ||
7790 (dx_db->type == DX_DIRBLOCK_NODE)) 7616 (dx_db->type == DX_DIRBLOCK_NODE))
@@ -8205,22 +8031,13 @@ static void e2fsck_pass3(e2fsck_t ctx)
8205{ 8031{
8206 ext2_filsys fs = ctx->fs; 8032 ext2_filsys fs = ctx->fs;
8207 int i; 8033 int i;
8208#ifdef RESOURCE_TRACK
8209 struct resource_track rtrack;
8210#endif
8211 struct problem_context pctx; 8034 struct problem_context pctx;
8212 struct dir_info *dir; 8035 struct dir_info *dir;
8213 unsigned long maxdirs, count; 8036 unsigned long maxdirs, count;
8214 8037
8215#ifdef RESOURCE_TRACK
8216 init_resource_track(&rtrack);
8217#endif
8218
8219 clear_problem_context(&pctx); 8038 clear_problem_context(&pctx);
8220 8039
8221#ifdef MTRACE 8040 /* Pass 3 */
8222 mtrace_print("Pass 3");
8223#endif
8224 8041
8225 if (!(ctx->options & E2F_OPT_PREEN)) 8042 if (!(ctx->options & E2F_OPT_PREEN))
8226 fix_problem(ctx, PR_3_PASS_HEADER, &pctx); 8043 fix_problem(ctx, PR_3_PASS_HEADER, &pctx);
@@ -8236,13 +8053,6 @@ static void e2fsck_pass3(e2fsck_t ctx)
8236 ctx->flags |= E2F_FLAG_ABORT; 8053 ctx->flags |= E2F_FLAG_ABORT;
8237 goto abort_exit; 8054 goto abort_exit;
8238 } 8055 }
8239#ifdef RESOURCE_TRACK
8240 if (ctx->options & E2F_OPT_TIME) {
8241 e2fsck_clear_progbar(ctx);
8242 print_resource_track(_("Peak memory"), &ctx->global_rtrack);
8243 }
8244#endif
8245
8246 check_root(ctx); 8056 check_root(ctx);
8247 if (ctx->flags & E2F_FLAG_SIGNAL_MASK) 8057 if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
8248 goto abort_exit; 8058 goto abort_exit;
@@ -8284,13 +8094,6 @@ abort_exit:
8284 inode_loop_detect = 0; 8094 inode_loop_detect = 0;
8285 ext2fs_free_inode_bitmap(inode_done_map); 8095 ext2fs_free_inode_bitmap(inode_done_map);
8286 inode_done_map = 0; 8096 inode_done_map = 0;
8287
8288#ifdef RESOURCE_TRACK
8289 if (ctx->options & E2F_OPT_TIME2) {
8290 e2fsck_clear_progbar(ctx);
8291 print_resource_track(_("Pass 3"), &rtrack);
8292 }
8293#endif
8294} 8097}
8295 8098
8296/* 8099/*
@@ -8650,9 +8453,6 @@ ext2_ino_t e2fsck_get_lost_and_found(e2fsck_t ctx, int fix)
8650 ext2fs_icount_store(ctx->inode_count, ino, 2); 8453 ext2fs_icount_store(ctx->inode_count, ino, 2);
8651 ext2fs_icount_store(ctx->inode_link_info, ino, 2); 8454 ext2fs_icount_store(ctx->inode_link_info, ino, 2);
8652 ctx->lost_and_found = ino; 8455 ctx->lost_and_found = ino;
8653#if 0
8654 printf("/lost+found created; inode #%lu\n", ino);
8655#endif
8656 return ino; 8456 return ino;
8657} 8457}
8658 8458
@@ -8723,11 +8523,6 @@ errcode_t e2fsck_adjust_inode_count(e2fsck_t ctx, ext2_ino_t ino, int adj)
8723 if (retval) 8523 if (retval)
8724 return retval; 8524 return retval;
8725 8525
8726#if 0
8727 printf("Adjusting link count for inode %lu by %d (from %d)\n", ino, adj,
8728 inode.i_links_count);
8729#endif
8730
8731 if (adj == 1) { 8526 if (adj == 1) {
8732 ext2fs_icount_increment(ctx->inode_count, ino, 0); 8527 ext2fs_icount_increment(ctx->inode_count, ino, 0);
8733 if (inode.i_links_count == (__u16) ~0) 8528 if (inode.i_links_count == (__u16) ~0)
@@ -8804,10 +8599,6 @@ static void fix_dotdot(e2fsck_t ctx, struct dir_info *dir, ext2_ino_t parent)
8804 fp.done = 0; 8599 fp.done = 0;
8805 fp.ctx = ctx; 8600 fp.ctx = ctx;
8806 8601
8807#if 0
8808 printf("Fixing '..' of inode %lu to be %lu...\n", dir->ino, parent);
8809#endif
8810
8811 retval = ext2fs_dir_iterate(fs, dir->ino, DIRENT_FLAG_INCLUDE_EMPTY, 8602 retval = ext2fs_dir_iterate(fs, dir->ino, DIRENT_FLAG_INCLUDE_EMPTY,
8812 0, fix_dotdot_proc, &fp); 8603 0, fix_dotdot_proc, &fp);
8813 if (retval || !fp.done) { 8604 if (retval || !fp.done) {
@@ -9026,21 +8817,12 @@ static void e2fsck_pass4(e2fsck_t ctx)
9026 ext2_filsys fs = ctx->fs; 8817 ext2_filsys fs = ctx->fs;
9027 ext2_ino_t i; 8818 ext2_ino_t i;
9028 struct ext2_inode inode; 8819 struct ext2_inode inode;
9029#ifdef RESOURCE_TRACK
9030 struct resource_track rtrack;
9031#endif
9032 struct problem_context pctx; 8820 struct problem_context pctx;
9033 __u16 link_count, link_counted; 8821 __u16 link_count, link_counted;
9034 char *buf = 0; 8822 char *buf = 0;
9035 int group, maxgroup; 8823 int group, maxgroup;
9036 8824
9037#ifdef RESOURCE_TRACK 8825 /* Pass 4 */
9038 init_resource_track(&rtrack);
9039#endif
9040
9041#ifdef MTRACE
9042 mtrace_print("Pass 4");
9043#endif
9044 8826
9045 clear_problem_context(&pctx); 8827 clear_problem_context(&pctx);
9046 8828
@@ -9109,12 +8891,6 @@ static void e2fsck_pass4(e2fsck_t ctx)
9109 ext2fs_free_inode_bitmap(ctx->inode_imagic_map); 8891 ext2fs_free_inode_bitmap(ctx->inode_imagic_map);
9110 ctx->inode_imagic_map = 0; 8892 ctx->inode_imagic_map = 0;
9111 ext2fs_free_mem(&buf); 8893 ext2fs_free_mem(&buf);
9112#ifdef RESOURCE_TRACK
9113 if (ctx->options & E2F_OPT_TIME2) {
9114 e2fsck_clear_progbar(ctx);
9115 print_resource_track(_("Pass 4"), &rtrack);
9116 }
9117#endif
9118} 8894}
9119 8895
9120/* 8896/*
@@ -9594,18 +9370,9 @@ static void check_block_end(e2fsck_t ctx)
9594 9370
9595static void e2fsck_pass5(e2fsck_t ctx) 9371static void e2fsck_pass5(e2fsck_t ctx)
9596{ 9372{
9597#ifdef RESOURCE_TRACK
9598 struct resource_track rtrack;
9599#endif
9600 struct problem_context pctx; 9373 struct problem_context pctx;
9601 9374
9602#ifdef MTRACE 9375 /* Pass 5 */
9603 mtrace_print("Pass 5");
9604#endif
9605
9606#ifdef RESOURCE_TRACK
9607 init_resource_track(&rtrack);
9608#endif
9609 9376
9610 clear_problem_context(&pctx); 9377 clear_problem_context(&pctx);
9611 9378
@@ -9637,13 +9404,6 @@ static void e2fsck_pass5(e2fsck_t ctx)
9637 ctx->inode_dir_map = 0; 9404 ctx->inode_dir_map = 0;
9638 ext2fs_free_block_bitmap(ctx->block_found_map); 9405 ext2fs_free_block_bitmap(ctx->block_found_map);
9639 ctx->block_found_map = 0; 9406 ctx->block_found_map = 0;
9640
9641#ifdef RESOURCE_TRACK
9642 if (ctx->options & E2F_OPT_TIME2) {
9643 e2fsck_clear_progbar(ctx);
9644 print_resource_track(_("Pass 5"), &rtrack);
9645 }
9646#endif
9647} 9407}
9648 9408
9649/* 9409/*
@@ -12408,11 +12168,6 @@ static errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino)
12408 goto errout; 12168 goto errout;
12409 } 12169 }
12410 12170
12411#if 0
12412 printf("%d entries (%d bytes) found in inode %d\n",
12413 fd.num_array, fd.dir_size, ino);
12414#endif
12415
12416 /* Sort the list */ 12171 /* Sort the list */
12417resort: 12172resort:
12418 if (fd.compress) 12173 if (fd.compress)
@@ -12463,19 +12218,12 @@ errout:
12463void e2fsck_rehash_directories(e2fsck_t ctx) 12218void e2fsck_rehash_directories(e2fsck_t ctx)
12464{ 12219{
12465 struct problem_context pctx; 12220 struct problem_context pctx;
12466#ifdef RESOURCE_TRACK
12467 struct resource_track rtrack;
12468#endif
12469 struct dir_info *dir; 12221 struct dir_info *dir;
12470 ext2_u32_iterate iter; 12222 ext2_u32_iterate iter;
12471 ext2_ino_t ino; 12223 ext2_ino_t ino;
12472 errcode_t retval; 12224 errcode_t retval;
12473 int i, cur, max, all_dirs, dir_index, first = 1; 12225 int i, cur, max, all_dirs, dir_index, first = 1;
12474 12226
12475#ifdef RESOURCE_TRACK
12476 init_resource_track(&rtrack);
12477#endif
12478
12479 all_dirs = ctx->options & E2F_OPT_COMPRESS_DIRS; 12227 all_dirs = ctx->options & E2F_OPT_COMPRESS_DIRS;
12480 12228
12481 if (!ctx->dirs_to_hash && !all_dirs) 12229 if (!ctx->dirs_to_hash && !all_dirs)
@@ -12516,9 +12264,6 @@ void e2fsck_rehash_directories(e2fsck_t ctx)
12516 fix_problem(ctx, PR_3A_PASS_HEADER, &pctx); 12264 fix_problem(ctx, PR_3A_PASS_HEADER, &pctx);
12517 first = 0; 12265 first = 0;
12518 } 12266 }
12519#if 0
12520 fix_problem(ctx, PR_3A_OPTIMIZE_DIR, &pctx);
12521#endif
12522 pctx.errcode = e2fsck_rehash_dir(ctx, ino); 12267 pctx.errcode = e2fsck_rehash_dir(ctx, ino);
12523 if (pctx.errcode) { 12268 if (pctx.errcode) {
12524 end_problem_latch(ctx, PR_LATCH_OPTIMIZE_DIR); 12269 end_problem_latch(ctx, PR_LATCH_OPTIMIZE_DIR);
@@ -12534,13 +12279,6 @@ void e2fsck_rehash_directories(e2fsck_t ctx)
12534 12279
12535 ext2fs_u32_list_free(ctx->dirs_to_hash); 12280 ext2fs_u32_list_free(ctx->dirs_to_hash);
12536 ctx->dirs_to_hash = 0; 12281 ctx->dirs_to_hash = 0;
12537
12538#ifdef RESOURCE_TRACK
12539 if (ctx->options & E2F_OPT_TIME2) {
12540 e2fsck_clear_progbar(ctx);
12541 print_resource_track("Pass 3A", &rtrack);
12542 }
12543#endif
12544} 12282}
12545 12283
12546/* 12284/*
@@ -13463,7 +13201,6 @@ static void check_super_block(e2fsck_t ctx)
13463 13201
13464 clear_problem_context(&pctx); 13202 clear_problem_context(&pctx);
13465 13203
13466#ifndef EXT2_SKIP_UUID
13467 /* 13204 /*
13468 * If the UUID field isn't assigned, assign it. 13205 * If the UUID field isn't assigned, assign it.
13469 */ 13206 */
@@ -13474,9 +13211,8 @@ static void check_super_block(e2fsck_t ctx)
13474 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; 13211 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
13475 } 13212 }
13476 } 13213 }
13477#endif
13478 13214
13479 /* 13215 /* FIXME - HURD support?
13480 * For the Hurd, check to see if the filetype option is set, 13216 * For the Hurd, check to see if the filetype option is set,
13481 * since it doesn't support it. 13217 * since it doesn't support it.
13482 */ 13218 */
@@ -13727,18 +13463,10 @@ static void ext2fs_swap_bitmap(ext2fs_generic_bitmap bmap)
13727static void swap_filesys(e2fsck_t ctx) 13463static void swap_filesys(e2fsck_t ctx)
13728{ 13464{
13729 ext2_filsys fs = ctx->fs; 13465 ext2_filsys fs = ctx->fs;
13730#ifdef RESOURCE_TRACK
13731 struct resource_track rtrack;
13732
13733 init_resource_track(&rtrack);
13734#endif
13735
13736 if (!(ctx->options & E2F_OPT_PREEN)) 13466 if (!(ctx->options & E2F_OPT_PREEN))
13737 printf(_("Pass 0: Doing byte-swap of filesystem\n")); 13467 printf(_("Pass 0: Doing byte-swap of filesystem\n"));
13738 13468
13739#ifdef MTRACE 13469 /* Byte swap */
13740 mtrace_print("Byte swap");
13741#endif
13742 13470
13743 if (fs->super->s_mnt_count) { 13471 if (fs->super->s_mnt_count) {
13744 fprintf(stderr, _("%s: the filesystem must be freshly " 13472 fprintf(stderr, _("%s: the filesystem must be freshly "
@@ -13773,11 +13501,6 @@ static void swap_filesys(e2fsck_t ctx)
13773 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; 13501 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
13774 ext2fs_flush(fs); 13502 ext2fs_flush(fs);
13775 fs->flags |= EXT2_FLAG_MASTER_SB_ONLY; 13503 fs->flags |= EXT2_FLAG_MASTER_SB_ONLY;
13776
13777#ifdef RESOURCE_TRACK
13778 if (ctx->options & E2F_OPT_TIME2)
13779 print_resource_track(_("Byte swap"), &rtrack);
13780#endif
13781} 13504}
13782#endif /* ENABLE_SWAPFS */ 13505#endif /* ENABLE_SWAPFS */
13783 13506
@@ -13788,33 +13511,12 @@ static void swap_filesys(e2fsck_t ctx)
13788 */ 13511 */
13789 13512
13790 13513
13791#if 0
13792void fatal_error(e2fsck_t ctx, const char *msg)
13793{
13794 if (msg)
13795 fprintf (stderr, "e2fsck: %s\n", msg);
13796 if (ctx->fs && ctx->fs->io) {
13797 if (ctx->fs->io->magic == EXT2_ET_MAGIC_IO_CHANNEL)
13798 io_channel_flush(ctx->fs->io);
13799 else
13800 fprintf(stderr, "e2fsck: io manager magic bad!\n");
13801 }
13802 ctx->flags |= E2F_FLAG_ABORT;
13803 if (ctx->flags & E2F_FLAG_SETJMP_OK)
13804 longjmp(ctx->abort_loc, 1);
13805 exit(EXIT_ERROR);
13806}
13807#endif
13808
13809void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size, 13514void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size,
13810 const char *description) 13515 const char *description)
13811{ 13516{
13812 void *ret; 13517 void *ret;
13813 char buf[256]; 13518 char buf[256];
13814 13519
13815#ifdef DEBUG_ALLOCATE_MEMORY
13816 printf("Allocating %d bytes for %s...\n", size, description);
13817#endif
13818 ret = malloc(size); 13520 ret = malloc(size);
13819 if (!ret) { 13521 if (!ret) {
13820 sprintf(buf, "Can't allocate %s\n", description); 13522 sprintf(buf, "Can't allocate %s\n", description);
@@ -14011,75 +13713,6 @@ void preenhalt(e2fsck_t ctx)
14011 exit(EXIT_UNCORRECTED); 13713 exit(EXIT_UNCORRECTED);
14012} 13714}
14013 13715
14014#ifdef RESOURCE_TRACK
14015void init_resource_track(struct resource_track *track)
14016{
14017#ifdef HAVE_GETRUSAGE
14018 struct rusage r;
14019#endif
14020
14021 track->brk_start = sbrk(0);
14022 gettimeofday(&track->time_start, 0);
14023#ifdef HAVE_GETRUSAGE
14024#ifdef sun
14025 memset(&r, 0, sizeof(struct rusage));
14026#endif
14027 getrusage(RUSAGE_SELF, &r);
14028 track->user_start = r.ru_utime;
14029 track->system_start = r.ru_stime;
14030#else
14031 track->user_start.tv_sec = track->user_start.tv_usec = 0;
14032 track->system_start.tv_sec = track->system_start.tv_usec = 0;
14033#endif
14034}
14035
14036static _INLINE_ float timeval_subtract(struct timeval *tv1,
14037 struct timeval *tv2)
14038{
14039 return ((tv1->tv_sec - tv2->tv_sec) +
14040 ((float) (tv1->tv_usec - tv2->tv_usec)) / 1000000);
14041}
14042
14043void print_resource_track(const char *desc, struct resource_track *track)
14044{
14045#ifdef HAVE_GETRUSAGE
14046 struct rusage r;
14047#endif
14048#ifdef HAVE_MALLINFO
14049 struct mallinfo malloc_info;
14050#endif
14051 struct timeval time_end;
14052
14053 gettimeofday(&time_end, 0);
14054
14055 if (desc)
14056 printf("%s: ", desc);
14057
14058#ifdef HAVE_MALLINFO
14059#define kbytes(x) (((x) + 1023) / 1024)
14060
14061 malloc_info = mallinfo();
14062 printf(_("Memory used: %dk/%dk (%dk/%dk), "),
14063 kbytes(malloc_info.arena), kbytes(malloc_info.hblkhd),
14064 kbytes(malloc_info.uordblks), kbytes(malloc_info.fordblks));
14065#else
14066 printf(_("Memory used: %d, "),
14067 (int) (((char *) sbrk(0)) - ((char *) track->brk_start)));
14068#endif
14069#ifdef HAVE_GETRUSAGE
14070 getrusage(RUSAGE_SELF, &r);
14071
14072 printf(_("time: %5.2f/%5.2f/%5.2f\n"),
14073 timeval_subtract(&time_end, &track->time_start),
14074 timeval_subtract(&r.ru_utime, &track->user_start),
14075 timeval_subtract(&r.ru_stime, &track->system_start));
14076#else
14077 printf(_("elapsed time: %6.3f\n"),
14078 timeval_subtract(&time_end, &track->time_start));
14079#endif
14080}
14081#endif /* RESOURCE_TRACK */
14082
14083void e2fsck_read_inode(e2fsck_t ctx, unsigned long ino, 13716void e2fsck_read_inode(e2fsck_t ctx, unsigned long ino,
14084 struct ext2_inode * inode, const char *proc) 13717 struct ext2_inode * inode, const char *proc)
14085{ 13718{
@@ -14120,17 +13753,6 @@ extern void e2fsck_write_inode(e2fsck_t ctx, unsigned long ino,
14120 } 13753 }
14121} 13754}
14122 13755
14123#ifdef MTRACE
14124void mtrace_print(char *mesg)
14125{
14126 FILE *malloc_get_mallstream();
14127 FILE *f = malloc_get_mallstream();
14128
14129 if (f)
14130 fprintf(f, "============= %s\n", mesg);
14131}
14132#endif
14133
14134blk_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name, 13756blk_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name,
14135 io_manager manager) 13757 io_manager manager)
14136{ 13758{
@@ -14259,39 +13881,6 @@ static int replace_bad_blocks;
14259static int keep_bad_blocks; 13881static int keep_bad_blocks;
14260static char *bad_blocks_file; 13882static char *bad_blocks_file;
14261 13883
14262#ifdef __CONFIG_JBD_DEBUG__E2FS /* Enabled by configure --enable-jfs-debug */
14263int journal_enable_debug = -1;
14264#endif
14265
14266#if 0
14267static void usage(e2fsck_t ctx)
14268{
14269 fprintf(stderr,
14270 _("Usage: %s [-panyrcdfvstDFSV] [-b superblock] [-B blocksize]\n"
14271 "\t\t[-I inode_buffer_blocks] [-P process_inode_size]\n"
14272 "\t\t[-l|-L bad_blocks_file] [-C fd] [-j external_journal]\n"
14273 "\t\t[-E extended-options] device\n"),
14274 ctx->program_name);
14275
14276 fprintf(stderr, _("\nEmergency help:\n"
14277 " -p Automatic repair (no questions)\n"
14278 " -n Make no changes to the filesystem\n"
14279 " -y Assume \"yes\" to all questions\n"
14280 " -c Check for bad blocks and add them to the badblock list\n"
14281 " -f Force checking even if filesystem is marked clean\n"));
14282 fprintf(stderr, _(""
14283 " -v Be verbose\n"
14284 " -b superblock Use alternative superblock\n"
14285 " -B blocksize Force blocksize when looking for superblock\n"
14286 " -j external_journal Set location of the external journal\n"
14287 " -l bad_blocks_file Add to badblocks list\n"
14288 " -L bad_blocks_file Set badblocks list\n"
14289 ));
14290
14291 exit(EXIT_USAGE);
14292}
14293#endif
14294
14295#define P_E2(singular, plural, n) n, ((n) == 1 ? singular : plural) 13884#define P_E2(singular, plural, n) n, ((n) == 1 ? singular : plural)
14296 13885
14297static void show_stats(e2fsck_t ctx) 13886static void show_stats(e2fsck_t ctx)
@@ -14729,9 +14318,6 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
14729{ 14318{
14730 int flush = 0; 14319 int flush = 0;
14731 int c, fd; 14320 int c, fd;
14732#ifdef MTRACE
14733 extern void *mallwatch;
14734#endif
14735 e2fsck_t ctx; 14321 e2fsck_t ctx;
14736 errcode_t retval; 14322 errcode_t retval;
14737 struct sigaction sa; 14323 struct sigaction sa;
@@ -14804,15 +14390,9 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
14804 ctx->options |= E2F_OPT_YES; 14390 ctx->options |= E2F_OPT_YES;
14805 break; 14391 break;
14806 case 't': 14392 case 't':
14807#ifdef RESOURCE_TRACK 14393 /* FIXME - This needs to go away in a future path - will change binary */
14808 if (ctx->options & E2F_OPT_TIME)
14809 ctx->options |= E2F_OPT_TIME2;
14810 else
14811 ctx->options |= E2F_OPT_TIME;
14812#else
14813 fprintf(stderr, _("The -t option is not " 14394 fprintf(stderr, _("The -t option is not "
14814 "supported on this version of e2fsck.\n")); 14395 "supported on this version of e2fsck.\n"));
14815#endif
14816 break; 14396 break;
14817 case 'c': 14397 case 'c':
14818 if (cflag++) 14398 if (cflag++)
@@ -14858,11 +14438,6 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
14858 case 'V': 14438 case 'V':
14859 show_version_only = 1; 14439 show_version_only = 1;
14860 break; 14440 break;
14861#ifdef MTRACE
14862 case 'M':
14863 mallwatch = (void *) strtol(optarg, NULL, 0);
14864 break;
14865#endif
14866 case 'N': 14441 case 'N':
14867 ctx->device_name = optarg; 14442 ctx->device_name = optarg;
14868 break; 14443 break;
@@ -14954,10 +14529,6 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
14954 /* Update our PATH to include /sbin if we need to run badblocks */ 14529 /* Update our PATH to include /sbin if we need to run badblocks */
14955 if (cflag) 14530 if (cflag)
14956 e2fs_set_sbin_path(); 14531 e2fs_set_sbin_path();
14957#ifdef __CONFIG_JBD_DEBUG__E2FS
14958 if (getenv("E2FSCK_JBD_DEBUG"))
14959 journal_enable_debug = atoi(getenv("E2FSCK_JBD_DEBUG"));
14960#endif
14961 return 0; 14532 return 0;
14962} 14533}
14963 14534
@@ -14978,18 +14549,7 @@ int e2fsck_main (int argc, char *argv[])
14978 int flags, run_result; 14549 int flags, run_result;
14979 14550
14980 clear_problem_context(&pctx); 14551 clear_problem_context(&pctx);
14981#ifdef MTRACE 14552
14982 mtrace();
14983#endif
14984#ifdef MCHECK
14985 mcheck(0);
14986#endif
14987#ifdef ENABLE_NLS
14988 setlocale(LC_MESSAGES, "");
14989 setlocale(LC_CTYPE, "");
14990 bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
14991 textdomain(NLS_CAT_NAME);
14992#endif
14993 my_ver = ext2fs_parse_version_string(my_ver_string); 14553 my_ver = ext2fs_parse_version_string(my_ver_string);
14994 lib_ver = ext2fs_get_library_version(0, &lib_ver_date); 14554 lib_ver = ext2fs_get_library_version(0, &lib_ver_date);
14995 if (my_ver > lib_ver) { 14555 if (my_ver > lib_ver) {
@@ -15006,10 +14566,6 @@ int e2fsck_main (int argc, char *argv[])
15006 } 14566 }
15007 reserve_stdio_fds(); 14567 reserve_stdio_fds();
15008 14568
15009#ifdef RESOURCE_TRACK
15010 init_resource_track(&ctx->global_rtrack);
15011#endif
15012
15013 if (!(ctx->options & E2F_OPT_PREEN) || show_version_only) 14569 if (!(ctx->options & E2F_OPT_PREEN) || show_version_only)
15014 fprintf(stderr, "e2fsck %s (%s)\n", my_ver_string, 14570 fprintf(stderr, "e2fsck %s (%s)\n", my_ver_string,
15015 my_ver_date); 14571 my_ver_date);
@@ -15187,6 +14743,7 @@ restart:
15187 goto get_newer; 14743 goto get_newer;
15188 } 14744 }
15189#ifdef ENABLE_COMPRESSION 14745#ifdef ENABLE_COMPRESSION
14746 /* FIXME - do we support this at all? */
15190 if (sb->s_feature_incompat & EXT2_FEATURE_INCOMPAT_COMPRESSION) 14747 if (sb->s_feature_incompat & EXT2_FEATURE_INCOMPAT_COMPRESSION)
15191 com_err(ctx->program_name, 0, 14748 com_err(ctx->program_name, 0,
15192 _("Warning: compression support is experimental.\n")); 14749 _("Warning: compression support is experimental.\n"));
@@ -15292,9 +14849,7 @@ restart:
15292 if (run_result & E2F_FLAG_ABORT) 14849 if (run_result & E2F_FLAG_ABORT)
15293 fatal_error(ctx, _("aborted")); 14850 fatal_error(ctx, _("aborted"));
15294 14851
15295#ifdef MTRACE 14852 /* Cleanup */
15296 mtrace_print("Cleanup");
15297#endif
15298 if (ext2fs_test_changed(fs)) { 14853 if (ext2fs_test_changed(fs)) {
15299 exit_value |= EXIT_NONDESTRUCT; 14854 exit_value |= EXIT_NONDESTRUCT;
15300 if (!(ctx->options & E2F_OPT_PREEN)) 14855 if (!(ctx->options & E2F_OPT_PREEN))
@@ -15337,10 +14892,5 @@ restart:
15337 free(ctx->journal_name); 14892 free(ctx->journal_name);
15338 e2fsck_free_context(ctx); 14893 e2fsck_free_context(ctx);
15339 14894
15340#ifdef RESOURCE_TRACK
15341 if (ctx->options & E2F_OPT_TIME)
15342 print_resource_track(NULL, &ctx->global_rtrack);
15343#endif
15344
15345 return exit_value; 14895 return exit_value;
15346} 14896}
diff --git a/e2fsprogs/e2fsck.h b/e2fsprogs/e2fsck.h
index 18d424449..9bf47b603 100644
--- a/e2fsprogs/e2fsck.h
+++ b/e2fsprogs/e2fsck.h
@@ -95,19 +95,6 @@ The following defines are used in the 'flags' field of a dx_dirblock_info
95#define DX_FLAG_FIRST 4 95#define DX_FLAG_FIRST 4
96#define DX_FLAG_LAST 8 96#define DX_FLAG_LAST 8
97 97
98#ifdef RESOURCE_TRACK
99/*
100 * This structure is used for keeping track of how much resources have
101 * been used for a particular pass of e2fsck.
102 */
103struct resource_track {
104 struct timeval time_start;
105 struct timeval user_start;
106 struct timeval system_start;
107 void *brk_start;
108};
109#endif
110
111/* 98/*
112 * E2fsck options 99 * E2fsck options
113 */ 100 */
@@ -289,13 +276,6 @@ struct e2fsck_struct {
289 io_channel journal_io; 276 io_channel journal_io;
290 char *journal_name; 277 char *journal_name;
291 278
292#ifdef RESOURCE_TRACK
293 /*
294 * For timing purposes
295 */
296 struct resource_track global_rtrack;
297#endif
298
299 /* 279 /*
300 * How we display the progress update (for unix) 280 * How we display the progress update (for unix)
301 */ 281 */