ChangeLog, e2fsck.h, message.c, pass1.c, pass2.c, problem.c, problem.h:
  message.c: Add compression for the word "Illegal"
  problem.c: Added entries for PR_2_BAD_CHAR_DEV and PR_2_BAD_BLOCK_DEV
  pass1.c (pass1, check_device_inode), pass2.c (process_bad_inode): Use
  	a more stringent test for a valid device.
ChangeLog, Makefile.in:
  Makefile.in (install): Fix rm command to use $(DESTDIR) appropriately.

diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
index e8b3e0a..9fceacd 100644
--- a/e2fsck/ChangeLog
+++ b/e2fsck/ChangeLog
@@ -1,3 +1,16 @@
+Thu Aug 14 10:55:21 1997  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+	* message.c: Add compression for the word "Illegal"
+
+	* problem.c: Added entries for PR_2_BAD_CHAR_DEV and
+	 	PR_2_BAD_BLOCK_DEV
+
+Wed Aug 13 09:55:57 1997  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+	* pass1.c (pass1, check_device_inode), pass2.c
+ 		(process_bad_inode): Use a more stringent test for a valid
+ 		device.
+
 Sun Aug 10 18:58:02 1997  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
 	* e2fsck.c (check_mount): Add stronger warning message about the
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index 9efefa3..c6dbd57 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -160,6 +160,7 @@
 				  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(ext2_filsys fs, const char *bad_blocks_file,
diff --git a/e2fsck/message.c b/e2fsck/message.c
index c5f2593..b9f9dea 100644
--- a/e2fsck/message.c
+++ b/e2fsck/message.c
@@ -44,6 +44,7 @@
  * 	@B	bitmap
  * 	@C	conflicts with some other fs block
  * 	@i	inode
+ * 	@I	illegal
  * 	@D	deleted
  * 	@d	directory
  * 	@e	entry
@@ -84,6 +85,7 @@
 	"Bbitmap",
 	"Cconflicts with some other fs @b",
 	"iinode",
+	"Iillegal",
 	"Ddeleted",
 	"ddirectory",
 	"eentry",
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 1e83759..2f1d67e 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -166,6 +166,20 @@
 	fs_fragmented = 0;
 }
 
+/*
+ * Check to make sure a device inode is real.  Returns 1 if the device
+ * checks out, 0 if not.
+ */
+int e2fsck_pass1_check_device_inode(struct ext2_inode *inode)
+{
+	int	i;
+
+	for (i=4; i < EXT2_N_BLOCKS; i++) 
+		if (inode->i_block[i])
+			return 0;
+	return 1;
+}
+
 void pass1(ext2_filsys fs)
 {
 	ino_t	ino;
@@ -402,9 +416,11 @@
 			fs_directory_count++;
 		} else if (LINUX_S_ISREG (inode.i_mode))
 			fs_regular_count++;
-		else if (LINUX_S_ISCHR (inode.i_mode))
+		else if (LINUX_S_ISCHR (inode.i_mode) &&
+			 e2fsck_pass1_check_device_inode(&inode))
 			fs_chardev_count++;
-		else if (LINUX_S_ISBLK (inode.i_mode))
+		else if (LINUX_S_ISBLK (inode.i_mode) &&
+			 e2fsck_pass1_check_device_inode(&inode))
 			fs_blockdev_count++;
 		else if (LINUX_S_ISLNK (inode.i_mode)) {
 			fs_symlinks_count++;
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index 4c987f3..2c52944 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -556,6 +556,24 @@
 			return 1;
 		}
 	}
+
+	if (LINUX_S_ISCHR(inode.i_mode)
+	    && !e2fsck_pass1_check_device_inode(&inode)) {
+		if (fix_problem(fs, PR_2_BAD_CHAR_DEV, &pctx)) {
+			deallocate_inode(fs, ino, 0);
+			return 1;
+		}
+	}
+		
+	if (LINUX_S_ISBLK(inode.i_mode)
+	    && !e2fsck_pass1_check_device_inode(&inode)) {
+		if (fix_problem(fs, PR_2_BAD_BLOCK_DEV, &pctx)) {
+			deallocate_inode(fs, ino, 0);
+			return 1;
+		}
+	}
+
+		
 	if (inode.i_faddr &&
 	    fix_problem(fs, PR_2_FADDR_ZERO, &pctx)) {
 		inode.i_faddr = 0;
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index 573b840..512e2c6 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -150,7 +150,7 @@
 
 	/* Illegal block number in inode */
 	{ PR_1_ILLEGAL_BLOCK_NUM,
-	  "Illegal @b #%B (%b) in @i %i.  ",
+	  "@I @b #%B (%b) in @i %i.  ",
 	  PROMPT_CLEAR, PR_LATCH_BLOCK },
 
 	/* Block number overlaps fs metadata */
@@ -170,7 +170,7 @@
 
 	/* Illegal block number in bad block inode */
 	{ PR_1_BB_ILLEGAL_BLOCK_NUM,
-	  "Illegal @b #%B (%b) in bad @b @i.  ",
+	  "@I @b #%B (%b) in bad @b @i.  ",
 	  PROMPT_CLEAR, PR_LATCH_BBLOCK },
 
 	/* Bad block inode has illegal blocks (latch question) */
@@ -313,6 +313,16 @@
 	  "'..' directory entry in @d @i %i is not NULL terminated\n",
 	  PROMPT_FIX, 0 },
 
+	/* Illegal character device inode */
+	{ PR_2_BAD_CHAR_DEV,
+	  "@i %i (%Q) is an @I character device.\n",
+	  PROMPT_CLEAR, 0 },
+
+	/* Illegal block device inode */
+	{ PR_2_BAD_BLOCK_DEV,
+	  "@i %i (%Q) is an @I @b device.\n",
+	  PROMPT_CLEAR, 0 },
+
 	  /* Pass 3 errors */
 
 	/* Root inode not allocated */
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
index e41cee1..5e1fd9b 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -201,6 +201,12 @@
 /* '..' is not NULL terminated */
 #define PR_2_DOT_DOT_NULL_TERM	0x020017
 
+/* Illegal character device in inode */
+#define PR_2_BAD_CHAR_DEV	0x020018
+
+/* Illegal block device in inode */
+#define PR_2_BAD_BLOCK_DEV	0x020019
+
 /*
  * Pass 3 errors
  */
diff --git a/lib/ss/ChangeLog b/lib/ss/ChangeLog
index 52820ca..1448246 100644
--- a/lib/ss/ChangeLog
+++ b/lib/ss/ChangeLog
@@ -1,3 +1,8 @@
+Thu Aug 14 08:17:22 1997  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+	* Makefile.in (install): Fix rm command to use $(DESTDIR)
+		appropriately.
+
 Tue Jun 17 01:33:20 1997  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
 	* Release of E2fsprogs 1.11
diff --git a/lib/ss/Makefile.in b/lib/ss/Makefile.in
index fb81372..e3c3571 100644
--- a/lib/ss/Makefile.in
+++ b/lib/ss/Makefile.in
@@ -137,7 +137,7 @@
 	$(CHMOD) 644 $(DESTDIR)$(ulibdir)/libss.a
 	-$(RANLIB) $(DESTDIR)$(ulibdir)/libss.a
 	$(CHMOD) $(LIBMODE) $(DESTDIR)$(ulibdir)/libss.a
-	$(RM) -f $(includedir)/ss/*
+	$(RM) -f $(DESTDIR)$(includedir)/ss/*
 	for i in $(INSTALL_HFILES) copyright.h; do \
 		$(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(includedir)/ss/$$i; \
 	done