Whamcloud - gitweb
tune2fs.c (main): If the environment variable
authorTheodore Ts'o <tytso@mit.edu>
Wed, 7 Apr 2004 13:27:36 +0000 (09:27 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 7 Apr 2004 13:27:36 +0000 (09:27 -0400)
TUNE2FS_SKIP_MOUNT_CHECK is set, do not try
to check if the filesystem is mounted.
(update_feature_set): If the compatibility bitmasks were
not modified, don't set the superblock dirty bit.

misc/ChangeLog
misc/tune2fs.8.in
misc/tune2fs.c

index c50c9cd..40a6877 100644 (file)
@@ -1,3 +1,11 @@
+2004-04-07  Theodore Ts'o  <tytso@mit.edu>
+
+       * tune2fs.c (main): If the environment variable
+               TUNE2FS_SKIP_MOUNT_CHECK is set, do not try to check if
+               the filesystem is mounted.
+               (update_feature_set): If the compatibility bitmasks were
+               not modified, don't set the superblock dirty bit.
+
 2004-04-03  Theodore Ts'o  <tytso@mit.edu>
 
        * Makefile.in: Update the modtime even if subst doesn't need to
index f0ce7ff..a5d6dca 100644 (file)
@@ -459,6 +459,20 @@ Time-dependent checking was added by Uwe Ohse <uwe@tirka.gun.de>.
 .B tune2fs
 is part of the e2fsprogs package and is available from 
 http://e2fsprogs.sourceforge.net.
+.SH ENVIRONMENT VARIABLES
+The
+.B tune2fs
+program's behavior is affected by the following environment variables:
+.TP
+.B TUNE2FS_SKIP_MOUNT_CHECK
+If this environment variable is set, 
+.B tune2fs
+will not try to check to see if the filesystem is mounted.  This may be 
+necessary in limited initrd environments when 
+.I /etc/mtab
+or
+.I /proc
+may not be available.
 .SH SEE ALSO
 .BR dumpe2fs (8),
 .BR e2fsck (8),
index 1e66204..6f51561 100644 (file)
@@ -282,6 +282,11 @@ static void update_feature_set(ext2_filsys fs, char *features)
        int sparse, old_sparse, filetype, old_filetype;
        int journal, old_journal, dxdir, old_dxdir;
        struct ext2_super_block *sb= fs->super;
+       __u32   old_compat, old_incompat, old_ro_compat;
+
+       old_compat = sb->s_feature_compat;
+       old_ro_compat = sb->s_feature_ro_compat;
+       old_incompat = sb->s_feature_incompat;
 
        old_sparse = sb->s_feature_ro_compat &
                EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
@@ -355,7 +360,10 @@ static void update_feature_set(ext2_filsys fs, char *features)
                sb->s_state &= ~EXT2_VALID_FS;
                printf("\n%s\n", _(please_fsck));
        }
-       ext2fs_mark_super_dirty(fs);
+       if ((old_compat != sb->s_feature_compat) ||
+           (old_ro_compat != sb->s_feature_ro_compat) ||
+           (old_incompat != sb->s_feature_incompat))
+               ext2fs_mark_super_dirty(fs);
 }
 
 /*
@@ -769,13 +777,18 @@ int main (int argc, char ** argv)
                       sb->s_volume_name);
                exit(0);
        }
-       retval = ext2fs_check_if_mounted(device_name, &mount_flags);
-       if (retval) {
-               com_err("ext2fs_check_if_mount", retval,
-                       _("while determining whether %s is mounted."),
-                       device_name);
-               exit(1);
+       if (getenv("TUNE2FS_SKIP_MOUNT_CHECK")) {
+               mount_flags = 0;
+       } else {
+               retval = ext2fs_check_if_mounted(device_name, &mount_flags);
+               if (retval) {
+                       com_err("ext2fs_check_if_mount", retval,
+                               _("while determining whether %s is mounted."),
+                               device_name);
+                       exit(1);
+               }
        }
+
        /* Normally we only need to write out the superblock */
        fs->flags |= EXT2_FLAG_SUPER_ONLY;