Many files:
Place #ifdef RESOURCE_TRACK around code which uses init_resource_track
and print_resource_track. (Not all systems have timeval)
diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
index d8de07f..880975f 100644
--- a/e2fsck/ChangeLog
+++ b/e2fsck/ChangeLog
@@ -1,5 +1,9 @@
Sun Oct 19 21:12:11 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
+ * pass*.c, super.c, unix.c, util.c, e2fsck.h: Place #ifdef
+ RESOURCE_TRACK around code which uses init_resource_track
+ and print_resource_track. (Not all systems have timeval)
+
* super.c: Remove excess #includes which are not necessary.
* e2fsck.h: Add #ifdef's for HAVE_SYS_TYPES_H and HAVE_SYS_TIME_H
diff --git a/e2fsck/Makefile.in b/e2fsck/Makefile.in
index afb130b..40595e6 100644
--- a/e2fsck/Makefile.in
+++ b/e2fsck/Makefile.in
@@ -14,6 +14,7 @@
PROGS= e2fsck @EXTRA_PROGS@
MANPAGES= e2fsck.8
+XTRA_CFLAGS= -DRESOURCE_TRACK
LIBS= $(LIBEXT2FS) $(LIBCOM_ERR) $(LIBUUID)
DEPLIBS= $(LIBEXT2FS) $(LIBCOM_ERR) $(LIBUUID)
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index b185d6b..83c5d61 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -59,6 +59,7 @@
ino_t parent; /* Parent according to treewalk */
};
+#ifdef RESOURCE_TRACK
/*
* This structure is used for keeping track of how much resources have
* been used for a particular pass of e2fsck.
@@ -69,6 +70,7 @@
struct timeval system_start;
void *brk_start;
};
+#endif
/*
* E2fsck options
@@ -130,10 +132,12 @@
int process_inode_size;
int inode_buffer_blocks;
+#ifdef RESOURCE_TRACK
/*
* For timing purposes
*/
struct resource_track global_rtrack;
+#endif
/* File counts */
int fs_directory_count;
@@ -215,9 +219,11 @@
extern void read_bitmaps(e2fsck_t ctx);
extern void write_bitmaps(e2fsck_t ctx);
extern void preenhalt(e2fsck_t ctx);
+#ifdef RESOURCE_TRACK
extern void print_resource_track(const char *desc,
struct resource_track *track);
extern void init_resource_track(struct resource_track *track);
+#endif
extern int inode_has_valid_blocks(struct ext2_inode *inode);
extern void e2fsck_read_inode(ext2_filsys fs, unsigned long ino,
struct ext2_inode * inode, const char * proc);
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index bd046d2..bda1a51 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -120,11 +120,15 @@
struct ext2_inode inode;
ext2_inode_scan scan;
char *block_buf;
+#ifdef RESOURCE_TRACK
struct resource_track rtrack;
+#endif
unsigned char frag, fsize;
struct problem_context pctx;
+#ifdef RESOURCE_TRACK
init_resource_track(&rtrack);
+#endif
clear_problem_context(&pctx);
if (!(ctx->options & E2F_OPT_PREEN))
@@ -435,8 +439,10 @@
ext2fs_free_block_bitmap(ctx->block_illegal_map);
ctx->block_illegal_map = 0;
+#ifdef RESOURCE_TRACK
if (ctx->options & E2F_OPT_TIME2)
print_resource_track("Pass 1", &rtrack);
+#endif
}
/*
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index bcd8aa2..edb2482 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -70,11 +70,15 @@
{
ext2_filsys fs = ctx->fs;
char *buf;
+#ifdef RESOURCE_TRACK
struct resource_track rtrack;
+#endif
struct dir_info *dir;
struct check_dir_struct cd;
+#ifdef RESOURCE_TRACK
init_resource_track(&rtrack);
+#endif
clear_problem_context(&cd.pctx);
@@ -120,8 +124,10 @@
ext2fs_free_inode_bitmap(ctx->inode_bad_map);
ctx->inode_bad_map = 0;
}
+#ifdef RESOURCE_TRACK
if (ctx->options & E2F_OPT_TIME2)
print_resource_track("Pass 2", &rtrack);
+#endif
}
/*
diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c
index 7d7c649..52c19c9 100644
--- a/e2fsck/pass3.c
+++ b/e2fsck/pass3.c
@@ -59,11 +59,15 @@
{
ext2_filsys fs = ctx->fs;
int i;
+#ifdef RESOURCE_TRACK
struct resource_track rtrack;
+#endif
struct problem_context pctx;
struct dir_info *dir;
+#ifdef RESOURCE_TRACK
init_resource_track(&rtrack);
+#endif
clear_problem_context(&pctx);
@@ -91,8 +95,10 @@
fix_problem(ctx, PR_3_ALLOCATE_IBITMAP_ERROR, &pctx);
fatal_error(0);
}
+#ifdef RESOURCE_TRACK
if (ctx->options & E2F_OPT_TIME)
print_resource_track("Peak memory", &ctx->global_rtrack);
+#endif
check_root(ctx);
ext2fs_mark_inode_bitmap(inode_done_map, EXT2_ROOT_INO);
@@ -106,8 +112,10 @@
free_dir_info(fs);
ext2fs_free_inode_bitmap(inode_loop_detect);
ext2fs_free_inode_bitmap(inode_done_map);
+#ifdef RESOURCE_TRACK
if (ctx->options & E2F_OPT_TIME2)
print_resource_track("Pass 3", &rtrack);
+#endif
}
/*
diff --git a/e2fsck/pass4.c b/e2fsck/pass4.c
index f5784cf..9b814b4 100644
--- a/e2fsck/pass4.c
+++ b/e2fsck/pass4.c
@@ -80,11 +80,15 @@
ext2_filsys fs = ctx->fs;
ino_t i;
struct ext2_inode inode;
+#ifdef RESOURCE_TRACK
struct resource_track rtrack;
+#endif
struct problem_context pctx;
__u16 link_count, link_counted;
+#ifdef RESOURCE_TRACK
init_resource_track(&rtrack);
+#endif
#ifdef MTRACE
mtrace_print("Pass 4");
@@ -133,7 +137,9 @@
ext2fs_free_icount(ctx->inode_count); ctx->inode_count = 0;
ext2fs_free_inode_bitmap(ctx->inode_bb_map);
ctx->inode_bb_map = 0;
+#ifdef RESOURCE_TRACK
if (ctx->options & E2F_OPT_TIME2)
print_resource_track("Pass 4", &rtrack);
+#endif
}
diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c
index 499c92c..be2edd9 100644
--- a/e2fsck/pass5.c
+++ b/e2fsck/pass5.c
@@ -20,14 +20,18 @@
void pass5(e2fsck_t ctx)
{
+#ifdef RESOURCE_TRACK
struct resource_track rtrack;
+#endif
struct problem_context pctx;
#ifdef MTRACE
mtrace_print("Pass 5");
#endif
+#ifdef RESOURCE_TRACK
init_resource_track(&rtrack);
+#endif
clear_problem_context(&pctx);
@@ -48,8 +52,10 @@
ext2fs_free_block_bitmap(ctx->block_found_map);
ctx->block_found_map = 0;
+#ifdef RESOURCE_TRACK
if (ctx->options & E2F_OPT_TIME2)
print_resource_track("Pass 5", &rtrack);
+#endif
}
static void check_block_bitmaps(e2fsck_t ctx)
diff --git a/e2fsck/swapfs.c b/e2fsck/swapfs.c
index 64d4775..f6d3d70 100644
--- a/e2fsck/swapfs.c
+++ b/e2fsck/swapfs.c
@@ -177,9 +177,11 @@
void swap_filesys(e2fsck_t ctx)
{
ext2_filsys fs = ctx->fs;
+#ifdef RESOURCE_TRACK
struct resource_track rtrack;
init_resource_track(&rtrack);
+#endif
if (!(ctx->options & E2F_OPT_PREEN))
printf("Pass 0: Doing byte-swap of filesystem\n");
@@ -210,8 +212,10 @@
EXT2_FLAG_SWAP_BYTES_WRITE);
ext2fs_flush(fs);
+#ifdef RESOURCE_TRACK
if (ctx->options & E2F_OPT_TIME2)
print_resource_track("Byte swap", &rtrack);
+#endif
}
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 7bc0963..1125670 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -288,10 +288,15 @@
ctx->options &= ~(E2F_OPT_PREEN|E2F_OPT_NO);
break;
case 't':
+#ifdef RESOURCE_TRACK
if (ctx->options & E2F_OPT_TIME)
ctx->options |= E2F_OPT_TIME2;
else
ctx->options |= E2F_OPT_TIME;
+#else
+ fprintf(stderr, "The -t option is not "
+ "supported on this version of e2fsck.\n");
+#endif
break;
case 'c':
cflag++;
@@ -433,7 +438,9 @@
exit(1);
}
+#ifdef RESOURCE_TRACK
init_resource_track(&ctx->global_rtrack);
+#endif
if (!(ctx->options & E2F_OPT_PREEN) || show_version_only)
fprintf (stderr, "e2fsck %s, %s for EXT2 FS %s, %s\n",
@@ -642,8 +649,10 @@
ext2fs_close(fs);
sync_disks();
+#ifdef RESOURCE_TRACK
if (ctx->options & E2F_OPT_TIME)
print_resource_track(NULL, &ctx->global_rtrack);
+#endif
e2fsck_free_context(ctx);
diff --git a/e2fsck/util.c b/e2fsck/util.c
index 879e7ba..f676b26 100644
--- a/e2fsck/util.c
+++ b/e2fsck/util.c
@@ -175,6 +175,7 @@
exit(FSCK_UNCORRECTED);
}
+#ifdef RESOURCE_TRACK
void init_resource_track(struct resource_track *track)
{
#ifdef HAVE_GETRUSAGE
@@ -235,6 +236,7 @@
timeval_subtract(&time_end, &track->time_start));
#endif
}
+#endif /* RESOURCE_TRACK */
void e2fsck_read_inode(ext2_filsys fs, unsigned long ino,
struct ext2_inode * inode, const char *proc)