Whamcloud - gitweb
ChangeLog, unix.c:
authorTheodore Ts'o <tytso@mit.edu>
Wed, 26 Aug 1998 15:23:31 +0000 (15:23 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 26 Aug 1998 15:23:31 +0000 (15:23 +0000)
  unix.c (check_if_skip): Move the "not cleanly mounted" check ahead of
   the maximal mount and too long since checked tests.
  (reserve_stdio_fds): Make sure 0,1,2 file descriptors are open, so
   that we don't open the filesystem using the same file
   descriptor as stdout or stderr.

e2fsck/ChangeLog
e2fsck/unix.c

index 17f883b..59db2cc 100644 (file)
@@ -1,3 +1,11 @@
+1998-08-17  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+       * unix.c (check_if_skip): Move the "not cleanly mounted" check
+               ahead of the maximal mount and too long since checked tests.
+               (reserve_stdio_fds): Make sure 0,1,2 file descriptors are
+               open, so that we don't open the filesystem using the same
+               file descriptor as stdout or stderr.
+
 1998-08-01  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
        * pass2.c (e2fsck_pass2): Fix the progress accounting so that we
index b4710a2..d9d86dc 100644 (file)
@@ -198,6 +198,8 @@ static void check_if_skip(e2fsck_t ctx)
        
        if (fs->super->s_state & EXT2_ERROR_FS)
                reason = "contains a file system with errors";
+       else if ((fs->super->s_state & EXT2_VALID_FS) == 0)
+               reason = "was not cleanly unmounted";
        else if (fs->super->s_mnt_count >=
                 (unsigned) fs->super->s_max_mnt_count)
                reason = "has reached maximal mount count";
@@ -205,8 +207,6 @@ static void check_if_skip(e2fsck_t ctx)
                 time(0) >= (fs->super->s_lastcheck +
                             fs->super->s_checkinterval))
                reason = "has gone too long without being checked";
-       else if ((fs->super->s_state & EXT2_VALID_FS) == 0)
-               reason = "was not cleanly unmounted";
        if (reason) {
                printf("%s %s, check forced.\n", ctx->device_name, reason);
                return;
@@ -246,6 +246,18 @@ static int e2fsck_update_progress(e2fsck_t ctx, int pass,
 
 #define PATH_SET "PATH=/sbin"
 
+static void reserve_stdio_fds(NOARGS)
+{
+       int     fd;
+
+       while (1) {
+               fd = open("/dev/null", O_RDWR);
+               if (fd > 2)
+                       break;
+       }
+       close(fd);
+}
+
 static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
 {
        int             flush = 0;
@@ -456,7 +468,8 @@ int main (int argc, char *argv[])
                        "while trying to initialize program");
                exit(1);
        }
-
+       reserve_stdio_fds();
+       
 #ifdef RESOURCE_TRACK
        init_resource_track(&ctx->global_rtrack);
 #endif