ChangeLog, e2fsck.h, pass1.c, pass2.c, pass4.c, swapfs.c:
  e2fsck.h:
  pass1.c (pass1_get_blocks, pass1_read_inode, pass1_write_inode,
  	pass1_check_directory, e2fsck_use_inode_shortcuts): Make pass1_* be
  	private static functions, and create new function
  	e2fsck_use_inode_shortcuts which sets and clears the inode shortcut
  	functions in the fs structure.
  e2fsck.h:
  pass2.c (e2fsck_process_bad_inode): Make process_bad_inode() an
  	exported function.
  pass4.c (e2fsck_pass4): Call e2fsck_process_bad_inode to check if a
  	disconnected inode has any problems before connecting it to
  	/lost+found.  Bug and suggested fix by Pavel Machek <pavel@bug.ucw.cz>
ChangeLog, swapfs.c:
  swapfs.c (ext2fs_swap_inode): Add compatibility for Linux 2.3 kernels
  	that use i_generation instead of i_version.  Patch supplied by Jon
  	Bright <sircus@sircus.demon.co.uk>.
ChangeLog, mke2fs.8.in:
  mke2fs.8.in: Fix typo in man page which caused the badblocks command
  	to not show up in the "SEE ALSO" section.
ChangeLog, expect.1, expect.2, image.gz, name:
  f_recnect_bad: New test which checks the case where a disconnect inode
  	also bad inode fields; we need to make sure e2fsck offers to fix the
  	inode (or clear the inode, as necessary).

diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
index 5894054..82f8c34 100644
--- a/e2fsck/ChangeLog
+++ b/e2fsck/ChangeLog
@@ -1,4 +1,22 @@
-1999-06-21    <tytso@rsts-11.mit.edu>
+1999-06-25    <tytso@rsts-11.mit.edu>
+
+	* e2fsck.h:
+	* pass1.c (pass1_get_blocks, pass1_read_inode, pass1_write_inode, 
+		pass1_check_directory, e2fsck_use_inode_shortcuts): Make
+		pass1_* be private static functions, and create new
+		function e2fsck_use_inode_shortcuts which sets and clears
+		the inode shortcut functions in the fs structure.
+
+	* e2fsck.h:	
+	* pass2.c (e2fsck_process_bad_inode): Make process_bad_inode() an
+		exported function.
+
+	* pass4.c (e2fsck_pass4): Call e2fsck_process_bad_inode to check
+		if a disconnected inode has any problems before
+		connecting it to /lost+found.  Bug and suggested fix by 
+		Pavel Machek <pavel@bug.ucw.cz>
+
+1999-06-21    <tytso@valinux.com>
 
 	* unix.c (main): Add missing space in the disk write-protected
 		message. 
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index 12c5971..782edbc 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -241,15 +241,6 @@
 extern int e2fsck_run(e2fsck_t ctx);
 
 
-/* pass1.c */
-extern errcode_t pass1_check_directory(ext2_filsys fs, ino_t ino);
-extern errcode_t pass1_get_blocks(ext2_filsys fs, ino_t ino, blk_t *blocks);
-extern errcode_t pass1_read_inode(ext2_filsys fs, ino_t ino,
-				  struct ext2_inode *inode);
-extern errcode_t pass1_write_inode(ext2_filsys fs, ino_t ino,
-				   struct ext2_inode *inode);
-extern int e2fsck_pass1_check_device_inode(struct ext2_inode *inode);
-
 /* badblock.c */
 extern void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
 				 int replace_bad_blocks);
@@ -267,6 +258,16 @@
 extern const char *ehandler_operation(const char *op);
 extern void ehandler_init(io_channel channel);
 
+/* pass1.c */
+extern void e2fsck_use_inode_shortcuts(e2fsck_t ctx, int bool);
+extern int e2fsck_pass1_check_device_inode(struct ext2_inode *inode);
+
+/* pass2.c */
+extern int e2fsck_process_bad_inode(e2fsck_t ctx, ino_t dir, ino_t ino);
+
+/* pass3.c */
+extern int e2fsck_reconnect_file(e2fsck_t ctx, ino_t inode);
+
 /* super.c */
 void check_super_block(e2fsck_t ctx);
 errcode_t e2fsck_get_device_size(e2fsck_t ctx);
@@ -298,7 +299,3 @@
 #endif
 extern blk_t get_backup_sb(ext2_filsys fs);
 
-/*
- * pass3.c
- */
-extern int e2fsck_reconnect_file(e2fsck_t ctx, ino_t inode);
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 6766f41..5ebd6e0 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -239,10 +239,7 @@
 	mark_table_blocks(ctx);
 	block_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize * 3,
 						    "block interate buffer");
-	fs->get_blocks = pass1_get_blocks;
-	fs->check_directory = pass1_check_directory;
-	fs->read_inode = pass1_read_inode;
-	fs->write_inode = pass1_write_inode;
+	e2fsck_use_inode_shortcuts(ctx, 1);
 	ehandler_operation("doing inode scan");
 	pctx.errcode = ext2fs_open_inode_scan(fs, ctx->inode_buffer_blocks, 
 					      &scan);
@@ -501,10 +498,7 @@
 	}
 	ext2fs_free_mem((void **) &inodes_to_process);
 endit:
-	fs->get_blocks = 0;
-	fs->check_directory = 0;
-	fs->read_inode = 0;
-	fs->write_inode = 0;
+	e2fsck_use_inode_shortcuts(ctx, 0);
 	
 	ext2fs_free_mem((void **) &block_buf);
 	ext2fs_free_block_bitmap(ctx->block_illegal_map);
@@ -1313,12 +1307,12 @@
 }
 	
 /*
- * This subroutines short circuits ext2fs_get_blocks and
+ * Thes subroutines short circuits ext2fs_get_blocks and
  * ext2fs_check_directory; we use them since we already have the inode
  * structure, so there's no point in letting the ext2fs library read
  * the inode again.
  */
-errcode_t pass1_get_blocks(ext2_filsys fs, ino_t ino, blk_t *blocks)
+static errcode_t pass1_get_blocks(ext2_filsys fs, ino_t ino, blk_t *blocks)
 {
 	e2fsck_t ctx = (e2fsck_t) fs->priv_data;
 	int	i;
@@ -1331,7 +1325,8 @@
 	return 0;
 }
 
-errcode_t pass1_read_inode(ext2_filsys fs, ino_t ino, struct ext2_inode *inode)
+static errcode_t pass1_read_inode(ext2_filsys fs, ino_t ino,
+				  struct ext2_inode *inode)
 {
 	e2fsck_t ctx = (e2fsck_t) fs->priv_data;
 
@@ -1341,7 +1336,7 @@
 	return 0;
 }
 
-errcode_t pass1_write_inode(ext2_filsys fs, ino_t ino,
+static errcode_t pass1_write_inode(ext2_filsys fs, ino_t ino,
 			    struct ext2_inode *inode)
 {
 	e2fsck_t ctx = (e2fsck_t) fs->priv_data;
@@ -1351,7 +1346,7 @@
 	return EXT2_ET_CALLBACK_NOTHANDLED;
 }
 
-errcode_t pass1_check_directory(ext2_filsys fs, ino_t ino)
+static errcode_t pass1_check_directory(ext2_filsys fs, ino_t ino)
 {
 	e2fsck_t ctx = (e2fsck_t) fs->priv_data;
 
@@ -1362,3 +1357,23 @@
 		return EXT2_ET_NO_DIRECTORY;
 	return 0;
 }
+
+void e2fsck_use_inode_shortcuts(e2fsck_t ctx, int bool)
+{
+	ext2_filsys fs = ctx->fs;
+
+	if (bool) {
+		fs->get_blocks = pass1_get_blocks;
+		fs->check_directory = pass1_check_directory;
+		fs->read_inode = pass1_read_inode;
+		fs->write_inode = pass1_write_inode;
+		ctx->stashed_ino = 0;
+	} else {
+		fs->get_blocks = 0;
+		fs->check_directory = 0;
+		fs->read_inode = 0;
+		fs->write_inode = 0;
+	}
+}
+
+		
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index 5453c61..38c1eda 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -48,7 +48,6 @@
  */
 static void deallocate_inode(e2fsck_t ctx, ino_t ino,
 			     char* block_buf);
-static int process_bad_inode(e2fsck_t ctx, ino_t dir, ino_t ino);
 static int check_dir_block(ext2_filsys fs,
 			   struct ext2_db_entry *dir_blocks_info,
 			   void *priv_data);
@@ -451,7 +450,8 @@
 		if (ctx->inode_bad_map &&
 		    ext2fs_test_inode_bitmap(ctx->inode_bad_map,
 					     dirent->inode)) {
-			if (process_bad_inode(ctx, ino, dirent->inode)) {
+			if (e2fsck_process_bad_inode(ctx, ino,
+						     dirent->inode)) {
 				dirent->inode = 0;
 				dir_modified++;
 				goto next;
@@ -585,7 +585,7 @@
 	}
 }
 
-static int process_bad_inode(e2fsck_t ctx, ino_t dir, ino_t ino)
+extern int e2fsck_process_bad_inode(e2fsck_t ctx, ino_t dir, ino_t ino)
 {
 	ext2_filsys fs = ctx->fs;
 	struct ext2_inode	inode;
diff --git a/e2fsck/pass4.c b/e2fsck/pass4.c
index adde764..e059cc3 100644
--- a/e2fsck/pass4.c
+++ b/e2fsck/pass4.c
@@ -123,6 +123,8 @@
 		ext2fs_icount_fetch(ctx->inode_link_info, i, &link_count);
 		ext2fs_icount_fetch(ctx->inode_count, i, &link_counted);
 		if (link_counted == 0) {
+			if (e2fsck_process_bad_inode(ctx, 0, i))
+				continue;
 			if (disconnect_inode(ctx, i))
 				continue;
 			ext2fs_icount_fetch(ctx->inode_link_info, i,
diff --git a/e2fsck/swapfs.c b/e2fsck/swapfs.c
index 605b8e3..3a8a878 100644
--- a/e2fsck/swapfs.c
+++ b/e2fsck/swapfs.c
@@ -114,8 +114,7 @@
 	errcode_t		retval;
 	struct ext2_inode *	inode;
 
-	fs->read_inode = pass1_read_inode;
-	fs->get_blocks = pass1_get_blocks;
+	e2fsck_use_inode_shortcuts(ctx, 1);
 	
 	retval = ext2fs_get_mem(fs->blocksize * fs->inode_blocks_per_group,
 				(void **) &buf);
@@ -179,8 +178,7 @@
 	}
 	ext2fs_free_mem((void **) &buf);
 	ext2fs_free_mem((void **) &block_buf);
-	fs->read_inode = 0;
-	fs->get_blocks = 0;
+	e2fsck_use_inode_shortcuts(ctx, 0);
 }
 
 void swap_filesys(e2fsck_t ctx)