Whamcloud - gitweb
ChangeLog, pass1.c, problem.c, problem.h:
authorTheodore Ts'o <tytso@mit.edu>
Sat, 27 May 2000 14:40:09 +0000 (14:40 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 27 May 2000 14:40:09 +0000 (14:40 +0000)
  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.

e2fsck/ChangeLog
e2fsck/pass1.c
e2fsck/problem.c
e2fsck/problem.h

index f90eab8..048b17c 100644 (file)
@@ -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
index 3829509..e4775d8 100644 (file)
@@ -158,6 +158,28 @@ static void check_immutable(e2fsck_t ctx, struct problem_context *pctx)
        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 @@ void e2fsck_pass1(e2fsck_t ctx)
                } 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 @@ void e2fsck_pass1(e2fsck_t ctx)
                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);
index ebbef2d..6766e01 100644 (file)
@@ -433,6 +433,11 @@ static const struct e2fsck_problem problem_table[] = {
          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 */
index 3c9586d..a0d067f 100644 (file)
@@ -248,6 +248,9 @@ struct problem_context {
 /* 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
  */