ChangeLog, mke2fs.c, tune2fs.8.in:
  tune2fs.8.in: Fix minor display bug in the nroff.
  mke2fs.c (show_stats, write_inode_tables): Use the log10 function to
  	calculate the display of block numbers so that things look nice on an
  	80 character display.
  mke2fs.c (usage): Add the sparse-super-flag to the usage message.
ChangeLog, e2fsck.c, pass1.c, pass2.c, problem.c, problem.h, unix.c:
  unix.c (main): Move ext2fs_close() after e2fsck_free_context() since
  	e2fsck_free_context may reference data in ctx->fs.
  e2fsck.c (e2fsck_reset_context): Make sure ctx->fs is non-NULL before
  	checking ctx->fs->dblist.
  pass1.c (e2fsck_pass1): Use the device check subroutine on FIFO's and
  	Socket's, so that we catch bogus immutable inodes.
  pass2.c (process_bad_inode): Process bad socket and fifo's.
  problem.h, problem.c: Define new problem codes PR_2_BAD_FIFO and
  	PR_2_BAD_SOCKET.

diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
index 7ef240e..0e651f5 100644
--- a/e2fsck/ChangeLog
+++ b/e2fsck/ChangeLog
@@ -1,3 +1,21 @@
+1998-10-28  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+	* unix.c (main): Move ext2fs_close() after e2fsck_free_context()
+		since e2fsck_free_context may reference data in ctx->fs.
+
+	* e2fsck.c (e2fsck_reset_context): Make sure ctx->fs is non-NULL
+		before checking ctx->fs->dblist.
+
+1998-10-09  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+	* pass1.c (e2fsck_pass1): Use the device check subroutine on
+		FIFO's and Socket's, so that we catch bogus immutable inodes.
+
+	* pass2.c (process_bad_inode): Process bad socket and fifo's.
+
+	* problem.h, problem.c: Define new problem codes PR_2_BAD_FIFO and
+		PR_2_BAD_SOCKET.
+
 1998-09-02  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
 	* problem.c: Add PR_3_NO_DIRINFO error code.
diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c
index 77e0e2e..3cfca69 100644
--- a/e2fsck/e2fsck.c
+++ b/e2fsck/e2fsck.c
@@ -58,7 +58,7 @@
 		ext2fs_free_icount(ctx->inode_link_info);
 		ctx->inode_link_info = 0;
 	}
-	if (ctx->fs->dblist) {
+	if (ctx->fs && ctx->fs->dblist) {
 		ext2fs_free_dblist(ctx->fs->dblist);
 		ctx->fs->dblist = 0;
 	}
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index c834a11..6766f41 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -110,6 +110,10 @@
 /*
  * Check to make sure a device inode is real.  Returns 1 if the device
  * checks out, 0 if not.
+ *
+ * Note: this routine is now also used to check FIFO's and Sockets,
+ * since they have the same requirement; the i_block fields should be
+ * zero. 
  */
 int e2fsck_pass1_check_device_inode(struct ext2_inode *inode)
 {
@@ -424,9 +428,11 @@
 				goto next;
 			}
 		}
-		else if (LINUX_S_ISFIFO (inode.i_mode))
+		else if (LINUX_S_ISFIFO (inode.i_mode) &&
+			  e2fsck_pass1_check_device_inode(&inode))
 			ctx->fs_fifo_count++;
-		else if (LINUX_S_ISSOCK (inode.i_mode))
+		else if ((LINUX_S_ISSOCK (inode.i_mode)) &&
+			 e2fsck_pass1_check_device_inode(&inode))
 		        ctx->fs_sockets_count++;
 		else {
 			if (!ctx->inode_bad_map)
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index 1767d00..5453c61 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -615,6 +615,14 @@
 	    && !e2fsck_pass1_check_device_inode(&inode))
 		problem = PR_2_BAD_BLOCK_DEV;
 
+	if (LINUX_S_ISFIFO(inode.i_mode)
+	    && !e2fsck_pass1_check_device_inode(&inode))
+		problem = PR_2_BAD_FIFO;
+		
+	if (LINUX_S_ISSOCK(inode.i_mode)
+	    && !e2fsck_pass1_check_device_inode(&inode))
+		problem = PR_2_BAD_SOCKET;
+
 	if (problem) {
 		if (fix_problem(ctx, problem, &pctx)) {
 			deallocate_inode(ctx, ino, 0);
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index d6f6774..e9ef1cf 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -675,6 +675,16 @@
 	  "@d @e for '.' is big.  ",
 	  PROMPT_SPLIT, PR_NO_OK },
 
+	/* Illegal FIFO inode */
+	{ PR_2_BAD_FIFO,
+	  "@i %i (%Q) is an @I FIFO.\n",
+	  PROMPT_CLEAR, 0 },
+
+	/* Illegal socket inode */
+	{ PR_2_BAD_SOCKET,
+	  "@i %i (%Q) is an @I socket.\n",
+	  PROMPT_CLEAR, 0 },
+
 	/* Pass 3 errors */
 
 	/* Pass 3: Checking directory connectivity */
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
index 0f16ba6..d5f5ed0 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -402,6 +402,12 @@
 /* Directory entry for '.' is big.  Split? */
 #define PR_2_SPLIT_DOT		0x0200024
 
+/* Illegal FIFO */
+#define PR_2_BAD_FIFO		0x020025
+
+/* Illegal socket */
+#define PR_2_BAD_SOCKET		0x020026
+
 /*
  * Pass 3 errors
  */
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index d9d86dc..e17d5a3 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -693,7 +693,6 @@
 	show_stats(ctx);
 
 	e2fsck_write_bitmaps(ctx);
-	ext2fs_close(fs);
 	
 #ifdef RESOURCE_TRACK
 	if (ctx->options & E2F_OPT_TIME)
@@ -701,6 +700,7 @@
 #endif
 
 	e2fsck_free_context(ctx);
+	ext2fs_close(fs);
 	
 	return exit_value;
 }