Blob Blame History Raw
autofs-5.0.5 - fix ext4 fsck at mount

From: Ian Kent <raven@themaw.net>

Autofs performs a "preen" fsck at max mount count for ext2 and ext3, but not
ext4.
---

 CHANGELOG            |    1 +
 Makefile.conf.in     |    3 ++
 configure            |   63 ++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.in         |    1 +
 include/config.h.in  |    6 +++++
 modules/Makefile     |   10 ++++++--
 modules/mount_ext2.c |   11 +++++----
 7 files changed, 88 insertions(+), 7 deletions(-)


diff --git a/CHANGELOG b/CHANGELOG
index 8b62370..e37dadb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@
 - more code analysis corrections (and fix a typo in an init script).
 - fix backwards #ifndef INET6.
 - fix stale initialization for file map instance.
+- add "preen" fsck for ext4 mounts.
 
 03/09/2009 autofs-5.0.5
 -----------------------
diff --git a/Makefile.conf.in b/Makefile.conf.in
index f0287c3..7670364 100644
--- a/Makefile.conf.in
+++ b/Makefile.conf.in
@@ -44,6 +44,9 @@ EXT2FS = @HAVE_E2FSCK@
 # Support for calling e3fsck when mounting ext3 filesystems
 EXT3FS = @HAVE_E3FSCK@
 
+# Support for calling e4fsck when mounting ext4 filesystems
+EXT4FS = @HAVE_E4FSCK@
+
 LEX = @PATH_LEX@
 YACC = @PATH_YACC@
 RPCGEN = @PATH_RPCGEN@
diff --git a/configure b/configure
index 159f25f..f5b7d07 100755
--- a/configure
+++ b/configure
@@ -668,6 +668,8 @@ PATH_LEX
 LEX
 HAVE_MODPROBE
 MODPROBE
+HAVE_E4FSCK
+E4FSCK
 HAVE_E3FSCK
 E3FSCK
 HAVE_E2FSCK
@@ -3407,6 +3409,67 @@ else
   HAVE_E3FSCK=0
 fi
 
+for ac_prog in fsck.ext4 e4fsck
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_E4FSCK+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  case $E4FSCK in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_E4FSCK="$E4FSCK" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $searchpath
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_E4FSCK="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+E4FSCK=$ac_cv_path_E4FSCK
+if test -n "$E4FSCK"; then
+  { $as_echo "$as_me:$LINENO: result: $E4FSCK" >&5
+$as_echo "$E4FSCK" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$E4FSCK" && break
+done
+
+if test -n "$E4FSCK"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_E4FSCK 1
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PATH_E4FSCK "$E4FSCK"
+_ACEOF
+
+  HAVE_E4FSCK=1
+else
+  HAVE_E4FSCK=0
+fi
+
 for ac_prog in modprobe
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
diff --git a/configure.in b/configure.in
index f649a58..78085bd 100644
--- a/configure.in
+++ b/configure.in
@@ -131,6 +131,7 @@ AF_PATH_INCLUDE(MOUNT, mount, /bin/mount, $searchpath)
 AF_PATH_INCLUDE(UMOUNT, umount, /bin/umount, $searchpath)
 AF_PATH_INCLUDE(E2FSCK, fsck.ext2 e2fsck, , $searchpath)
 AF_PATH_INCLUDE(E3FSCK, fsck.ext3 e3fsck, , $searchpath)
+AF_PATH_INCLUDE(E4FSCK, fsck.ext4 e4fsck, , $searchpath)
 AF_PATH_INCLUDE(MODPROBE, modprobe, , $searchpath)
 
 AF_CHECK_PROG(LEX, flex lex, , $searchpath)
diff --git a/include/config.h.in b/include/config.h.in
index 39cfa4b..dece33f 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -18,6 +18,9 @@
 /* define if you have E3FSCK */
 #undef HAVE_E3FSCK
 
+/* define if you have E4FSCK */
+#undef HAVE_E4FSCK
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
@@ -93,6 +96,9 @@
 /* define if you have E3FSCK */
 #undef PATH_E3FSCK
 
+/* define if you have E4FSCK */
+#undef PATH_E4FSCK
+
 /* define if you have LEX */
 #undef PATH_LEX
 
diff --git a/modules/Makefile b/modules/Makefile
index 13b3bd8..0bb9464 100644
--- a/modules/Makefile
+++ b/modules/Makefile
@@ -69,10 +69,16 @@ ifeq ($(EXT2FS), 1)
  ifeq ($(EXT3FS), 1)
 	ln -fs mount_ext2.so $(INSTALLROOT)$(autofslibdir)/mount_ext3.so
  endif
-else
- ifeq ($(EXT3FS), 1)
+ ifeq ($(EXT4FS), 1)
+	ln -fs mount_ext2.so $(INSTALLROOT)$(autofslibdir)/mount_ext4.so
+ endif
+else ifeq ($(EXT3FS), 1)
 	mv $(INSTALLROOT)$(autofslibdir)/mount_ext2.so $(INSTALLROOT)$(autofslibdir)/mount_ext3.so
+ ifeq ($(EXT4FS), 1)
+	ln -fs mount_ext3.so $(INSTALLROOT)$(autofslibdir)/mount_ext4.so
  endif
+else ifeq ($(EXT4FS), 1)
+	mv $(INSTALLROOT)$(autofslibdir)/mount_ext2.so $(INSTALLROOT)$(autofslibdir)/mount_ext4.so
 endif
 
 #
diff --git a/modules/mount_ext2.c b/modules/mount_ext2.c
index 724a5fa..26d59d1 100644
--- a/modules/mount_ext2.c
+++ b/modules/mount_ext2.c
@@ -83,13 +83,14 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
 			ro = 1;
 	}
 
+	fsck_prog = PATH_E2FSCK;
 #ifdef HAVE_E3FSCK
-	if (!strcmp(fstype,"ext3") || !strcmp(fstype,"auto"))
+	if (!strcmp(fstype,"ext3"))
 		fsck_prog = PATH_E3FSCK;
-	else
-		fsck_prog = PATH_E2FSCK;
-#else
-	fsck_prog = PATH_E2FSCK;
+#endif
+#ifdef HAVE_E4FSCK
+	if (!strcmp(fstype,"ext4"))
+		fsck_prog = PATH_E4FSCK;
 #endif
 	if (ro) {
 		debug(ap->logopt,