ChangeLog, pass3.c, problem.c, problem.h, util.c:
util.c (print_resource_track): Use mallinfo if present to get more
accurate malloc statistics.
pass3.c (get_lost_and_found): Check to see if lost+found is a plain
fail; if so, offer to unlink it.
problem.c, problem.h (PR_3_LPF_NOTDIR): Add new problem code.
problem.c: Fix problem message for PR_1_BAD_GROUP_DESCRIPTORS so that
the block group number is printed. Add new prompt, PROMPT_UNLINK.
diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
index 56cbcad..04efa41 100644
--- a/e2fsck/ChangeLog
+++ b/e2fsck/ChangeLog
@@ -1,3 +1,23 @@
+1999-03-14 Theodore Ts'o <tytso@rsts-11.mit.edu>
+
+ * util.c (print_resource_track): Use mallinfo if present to get
+ more accurate malloc statistics.
+
+ * pass3.c (get_lost_and_found): Check to see if lost+found is a
+ plain fail; if so, offer to unlink it.
+
+ * problem.c, problem.h (PR_3_LPF_NOTDIR): Add new problem code.
+
+1999-03-09 Theodore Ts'o <tytso@rsts-11.mit.edu>
+
+ * problem.c: Fix problem message for PR_1_BAD_GROUP_DESCRIPTORS so
+ that the block group number is printed. Add new prompt,
+ PROMPT_UNLINK.
+
+1999-01-09 Theodore Ts'o <tytso@rsts-11.mit.edu>
+
+ * Release of E2fsprogs 1.14
+
1999-01-09 Theodore Ts'o <tytso@rsts-11.mit.edu>
* message.c (safe_print): New function which prints strings,
diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c
index 560f291..7ca7484 100644
--- a/e2fsck/pass3.c
+++ b/e2fsck/pass3.c
@@ -340,14 +340,32 @@
char * block;
const char name[] = "lost+found";
struct problem_context pctx;
+ struct dir_info *dirinfo;
clear_problem_context(&pctx);
retval = ext2fs_lookup(fs, EXT2_ROOT_INO, name,
sizeof(name)-1, 0, &ino);
- if (!retval)
- return ino;
- if (retval != EXT2_ET_FILE_NOT_FOUND) {
+ if (!retval) {
+ if (ext2fs_test_inode_bitmap(ctx->inode_dir_map, ino))
+ return ino;
+ /* Lost+found isn't a directory! */
+ pctx.ino = ino;
+ if (!fix_problem(ctx, PR_3_LPF_NOTDIR, &pctx))
+ return 0;
+
+ /* OK, unlink the old /lost+found directory. */
+ pctx.errcode = ext2fs_unlink(fs, EXT2_ROOT_INO, name, ino, 0);
+ if (pctx.errcode) {
+ pctx.str = "ext2fs_unlink";
+ fix_problem(ctx, PR_3_CREATE_LPF_ERROR, &pctx);
+ return 0;
+ }
+ dirinfo = e2fsck_get_dir_info(ctx, ino);
+ if (dirinfo)
+ dirinfo->parent = 0;
+ adjust_inode_count(ctx, ino, -1);
+ } else if (retval != EXT2_ET_FILE_NOT_FOUND) {
pctx.errcode = retval;
fix_problem(ctx, PR_3_ERR_FIND_LPF, &pctx);
}
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index 5113d4a..6811826 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -37,6 +37,7 @@
#define PROMPT_CLONE 14
#define PROMPT_DELETE 15
#define PROMPT_SUPPRESS 16
+#define PROMPT_UNLINK 17
/*
* These are the prompts which are used to ask the user if they want
@@ -60,6 +61,7 @@
"Clone duplicate/bad blocks", /* 14 */
"Delete file", /* 15 */
"Suppress messages", /* 16 */
+ "Unlink", /* 17 */
};
/*
@@ -84,6 +86,7 @@
"DUPLICATE/BAD BLOCKS CLONED", /* 14 */
"FILE DELETED", /* 15 */
"SUPPRESSED", /* 16 */
+ "UNLINKED", /* 17 */
};
static const struct e2fsck_problem problem_table[] = {
@@ -311,7 +314,7 @@
/* Bad block group descriptors in group */
{ PR_1_BAD_GROUP_DESCRIPTORS,
- "Warning: Group %d's copy of the @g descriptors has a bad "
+ "Warning: Group %g's copy of the @g descriptors has a bad "
"@b (%b).\n",
PROMPT_NONE, PR_PREEN_OK | PR_PREEN_NOMSG },
@@ -802,6 +805,11 @@
"Internal error: couldn't find dir_info for %i.\n",
PROMPT_NONE, PR_FATAL },
+ /* Lost+found not a directory */
+ { PR_3_LPF_NOTDIR,
+ "/@l is not a @d (ino=%i)\n",
+ PROMPT_UNLINK, 0 },
+
/* Pass 4 errors */
/* Pass 4: Checking reference counts */
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
index d5f5ed0..240bd7a 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -479,7 +479,10 @@
#define PR_3_NO_ROOT_INODE_ABORT 0x030015
/* Internal error: couldn't find dir_info */
-#define PR_3_NO_DIRINFO 0x020016
+#define PR_3_NO_DIRINFO 0x030016
+
+/* Lost+found is not a directory */
+#define PR_3_LPF_NOTDIR 0x030017
/*
* Pass 4 errors
diff --git a/e2fsck/util.c b/e2fsck/util.c
index 6634cec..d48c769 100644
--- a/e2fsck/util.c
+++ b/e2fsck/util.c
@@ -14,6 +14,9 @@
#include <string.h>
#include <ctype.h>
#include <termios.h>
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
#include "e2fsck.h"
@@ -219,24 +222,32 @@
#ifdef HAVE_GETRUSAGE
struct rusage r;
#endif
+#ifdef HAVE_MALLINFO
+ struct mallinfo malloc_info;
+#endif
struct timeval time_end;
gettimeofday(&time_end, 0);
if (desc)
printf("%s: ", desc);
-
+
+#ifdef HAVE_MALLINFO
+ malloc_info = mallinfo();
+ printf("Memory used: %d/%d, ", malloc_info.arena, malloc_info.hblkhd);
+#else
+ printf("Memory used: %d, ",
+ (int) (((char *) sbrk(0)) - ((char *) track->brk_start)));
+#endif
#ifdef HAVE_GETRUSAGE
getrusage(RUSAGE_SELF, &r);
- printf("Memory used: %d, elapsed time: %6.3f/%6.3f/%6.3f\n",
- (int) (((char *) sbrk(0)) - ((char *) track->brk_start)),
+ printf("elapsed time: %6.3f/%6.3f/%6.3f\n",
timeval_subtract(&time_end, &track->time_start),
timeval_subtract(&r.ru_utime, &track->user_start),
timeval_subtract(&r.ru_stime, &track->system_start));
#else
- printf("Memory used: %d, elapsed time: %6.3f\n",
- (int) (((char *) sbrk(0)) - ((char *) track->brk_start)),
+ printf("elapsed time: %6.3f\n",
timeval_subtract(&time_end, &track->time_start));
#endif
}