ChangeLog, pass1.c, problem.c, problem.h:
  pass1.c (pass1, check_size): Apply patch from Chris Wedgewood
  	(cw@foof.org) which checks to see if special devices have a non-zero
  	size, and deals with it.
  problem.c, problem.h (PR1_SET_NONZSIZE): Add new problem code.

diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
index f90eab8..048b17c 100644
--- a/e2fsck/ChangeLog
+++ b/e2fsck/ChangeLog
@@ -1,3 +1,11 @@
+2000-05-27  Theodore Ts'o  <tytso@valinux.com>
+
+	* pass1.c (pass1, check_size): Apply patch from Chris Wedgewood
+		(cw@foof.org) which checks to see if special devices have
+		a non-zero size, and deals with it.
+
+	* problem.c, problem.h (PR1_SET_NONZSIZE): Add new problem code.
+
 2000-05-18  Theodore Ts'o  <tytso@valinux.com>
 
 	* Makefile.in (install): Create a symbolic link for fsck.ext3 as
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 3829509..e4775d8 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -158,6 +158,28 @@
 	e2fsck_write_inode(ctx, pctx->ino, pctx->inode, "pass1");
 }
 
+/*
+ * If device, fifo or socket, check size is zero -- if not offer to
+ * clear it
+ */
+static void check_size(e2fsck_t ctx, struct problem_context *pctx)
+{
+	struct ext2_inode *inode = pctx->inode;
+	
+	if ((LINUX_S_ISBLK(inode->i_mode) ||
+	     LINUX_S_ISCHR(inode->i_mode) ||
+	     LINUX_S_ISFIFO(inode->i_mode) ||
+	     LINUX_S_ISSOCK(inode->i_mode)) && 
+	    !inode->i_size)
+		return;
+	
+	if(!fix_problem(ctx, PR_1_SET_NONZSIZE, pctx))
+		return;
+	
+	inode->i_size = 0;
+	e2fsck_write_inode(ctx, pctx->ino, pctx->inode, "pass1");
+}
+	
 
 void e2fsck_pass1(e2fsck_t ctx)
 {
@@ -455,10 +477,12 @@
 		} else if (LINUX_S_ISCHR (inode.i_mode) &&
 			   e2fsck_pass1_check_device_inode(&inode)) {
 			check_immutable(ctx, &pctx);
+			check_size(ctx, &pctx);
 			ctx->fs_chardev_count++;
 		} else if (LINUX_S_ISBLK (inode.i_mode) &&
 			   e2fsck_pass1_check_device_inode(&inode)) {
 			check_immutable(ctx, &pctx);
+			check_size(ctx, &pctx);
 			ctx->fs_blockdev_count++;
 		} else if (LINUX_S_ISLNK (inode.i_mode)) {
 			ctx->fs_symlinks_count++;
@@ -470,11 +494,13 @@
 		else if (LINUX_S_ISFIFO (inode.i_mode) &&
 			 e2fsck_pass1_check_device_inode(&inode)) {
 			check_immutable(ctx, &pctx);
+			check_size(ctx, &pctx);
 			ctx->fs_fifo_count++;
 		} else if ((LINUX_S_ISSOCK (inode.i_mode)) &&
 			   e2fsck_pass1_check_device_inode(&inode)) {
 			check_immutable(ctx, &pctx);
-		        ctx->fs_sockets_count++;
+			check_size(ctx, &pctx);
+			ctx->fs_sockets_count++;
 		} else {
 			if (!ctx->inode_bad_map)
 				alloc_bad_map(ctx);
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index ebbef2d..6766e01 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -433,6 +433,11 @@
 	  N_("@i %i has @cion flag set on @f without @cion support.  "),
 	  PROMPT_CLEAR, 0 },
 
+	/* Non-zero size for device, fifo or socket inode */
+	{ PR_1_SET_NONZSIZE,
+	  "Special (device/socket/fifo) @i %i has non-zero size.  ",
+	  PROMPT_FIX, PR_PREEN_OK },
+	  
 	/* Pass 1b errors */
 
 	/* Pass 1B: Rescan for duplicate/bad blocks */
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
index 3c9586d..a0d067f 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -248,6 +248,9 @@
 /* Compression flag set on a non-compressed filesystem */
 #define PR_1_COMPR_SET			0x010031
 
+/* Non-zero size on on device, fifo or socket inode */
+#define PR_1_SET_NONZSIZE		0x010032
+
 /*
  * Pass 1b errors
  */