Many files:
  pass4.c (e2fsck_pass4): If an inode is set in the inode_imagic_map
  	bitmap, don't check to see if it is disconnected from the inode tree
  	(because it almost certainly will be).  Free inode_imagic_map at the
  	end of pass 4.
  pass2.c (check_dir_block, check_filetype): If the FILETYPE feature is
  	set, check the directory entry's filetype information field, and
  	fix/set it if necessary.  (e2fsck_pass2): Free the inode_reg_map
  	bitmap at the end of pass 2.
  pass1.c (e2fsck_pass1, alloc_imagic_map): Allocate and fill in
  	information for inode_reg_map and inode_imagic_map, which indicates
  	which inodes are regular files and AFS inodes, respectively.
  	Since only the master superblock is written during a restart, force
  	that superblock to be used after a restart; otherwise changes to the
  	block group descriptors end up getting ignored.
  problem.c, problemP.h: If e2fsck is run -n, make def_yn variable be 0
  	for "no".  Add support for a new flag, PR_NO_NOMSG, which supresses
  	the problem message if e2fsck is run with the -n option.
  problem.c, problem.h (PR_2_SET_FILETYPE, PR_2_BAD_FILETYPE): Add new
  	problem codes.
  message.c (expand_dirent_expression): Add support for %dt which prints
  	the dirent type information.
  e2fsck.c (e2fsck_reset_context): Free new bitmaps (inode_reg_map and
  	inode_imagic_map).
  e2fsck.h (e2fsck_t): Add new inode_reg_map and inode_magic_map to the
  	context structure.
ChangeLog, nt_io.c:
  nt_io.c: New file which supports I/O under Windows NT.
ChangeLog, gen_uuid_nt.c:
  gen_uuid_nt.c: New file which creates a UUID under Windows NT.
Many files:
  Add support for non-Unix compiles

diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index 37114e3..2eec914 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -38,11 +38,18 @@
  *
  * Pass 2 frees the following data structures
  * 	- The inode_bad_map bitmap
+ * 	- The inode_reg_map bitmap
  */
 
 #include "e2fsck.h"
 #include "problem.h"
 
+#ifdef NO_INLINE_FUNCS
+#define _INLINE_
+#else
+#define _INLINE_ inline
+#endif
+
 /*
  * Keeps track of how many times an inode is referenced.
  */
@@ -134,6 +141,10 @@
 		ext2fs_free_inode_bitmap(ctx->inode_bad_map);
 		ctx->inode_bad_map = 0;
 	}
+	if (ctx->inode_reg_map) {
+		ext2fs_free_inode_bitmap(ctx->inode_reg_map);
+		ctx->inode_reg_map = 0;
+	}
 #ifdef RESOURCE_TRACK
 	if (ctx->options & E2F_OPT_TIME2) {
 		e2fsck_clear_progbar(ctx);
@@ -268,6 +279,57 @@
 	return ret;
 }
 
+/*
+ * Check the directory filetype (if present)
+ */
+static _INLINE_ int check_filetype(e2fsck_t ctx,
+		      struct ext2_dir_entry *dirent,
+		      ino_t dir_ino, struct problem_context *pctx)
+{
+	int	filetype = dirent->name_len >> 8;
+	int	should_be = EXT2_FT_UNKNOWN;
+	struct ext2_inode	inode;
+
+	if (!(ctx->fs->super->s_feature_incompat &
+	      EXT2_FEATURE_INCOMPAT_FILETYPE))
+		return 0;
+
+	if (ext2fs_test_inode_bitmap(ctx->inode_dir_map, dirent->inode)) {
+		should_be = EXT2_FT_DIR;
+	} else if (ext2fs_test_inode_bitmap(ctx->inode_reg_map,
+					    dirent->inode)) {
+		should_be = EXT2_FT_REG_FILE;
+	} else if (ctx->inode_bad_map &&
+		   ext2fs_test_inode_bitmap(ctx->inode_bad_map,
+					    dirent->inode))
+		should_be = 0;
+	else {
+		e2fsck_read_inode(ctx, dirent->inode, &inode,
+				  "check_filetype");
+		if (LINUX_S_ISCHR (inode.i_mode))
+			should_be = EXT2_FT_CHRDEV;
+		else if (LINUX_S_ISBLK (inode.i_mode))
+			should_be = EXT2_FT_BLKDEV;
+		else if (LINUX_S_ISLNK (inode.i_mode))
+			should_be = EXT2_FT_SYMLINK;
+		else if (LINUX_S_ISFIFO (inode.i_mode))
+			should_be = EXT2_FT_FIFO;
+		else if (LINUX_S_ISSOCK (inode.i_mode))
+			should_be = EXT2_FT_SOCK;
+	}
+	if (filetype == should_be)
+		return 0;
+	pctx->num = should_be;
+
+	if (fix_problem(ctx, filetype ? PR_2_BAD_FILETYPE : PR_2_SET_FILETYPE,
+			pctx) == 0)
+		return 0;
+			
+	dirent->name_len = (dirent->name_len & 0xFF) | should_be << 8;
+	return 1;
+}
+
+
 static int check_dir_block(ext2_filsys fs,
 			   struct ext2_db_entry *db,
 			   void *priv_data)
@@ -465,6 +527,9 @@
 		if (check_name(ctx, dirent, ino, &cd->pctx))
 			dir_modified++;
 
+		if (check_filetype(ctx, dirent, ino, &cd->pctx))
+			dir_modified++;
+
 		/*
 		 * If this is a directory, then mark its parent in its
 		 * dir_info structure.  If the parent field is already