dovecot: Removed special autofs check. Instead check ignore moun...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jul 19 00:29:39 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/cc8b6e73e830
changeset: 6085:cc8b6e73e830
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jul 19 00:29:35 2007 +0300
description:
Removed special autofs check. Instead check ignore mount option and swap
correctly. Use getextmntent() to find the wanted device instead of stat()ing
everything.

diffstat:

1 file changed, 18 insertions(+), 16 deletions(-)
src/lib/mountpoint.c |   34 ++++++++++++++++++----------------

diffs (70 lines):

diff -r 00495c124ea0 -r cc8b6e73e830 src/lib/mountpoint.c
--- a/src/lib/mountpoint.c	Wed Jul 18 09:42:21 2007 +0300
+++ b/src/lib/mountpoint.c	Thu Jul 19 00:29:35 2007 +0300
@@ -19,6 +19,7 @@
 #elif defined(HAVE_SYS_MNTTAB_H)
 #  include <stdio.h>
 #  include <sys/mnttab.h> /* Solaris */
+#  include <sys/mntent.h>
 #else
 #  define MOUNTPOINT_UNKNOWN
 #endif
@@ -37,11 +38,6 @@
 #  define MNTTYPE_IGNORE "ignore"
 #endif
 
-/* autofs mounts will show two entries. First for autofs and second for the
-   actual filesystem type. We want the second one. */
-#ifndef MNTTYPE_AUTOFS
-#  define MNTTYPE_AUTOFS "autofs"
-#endif
 
 int mountpoint_get(const char *path, pool_t pool, struct mountpoint *point_r)
 {
@@ -74,11 +70,15 @@ int mountpoint_get(const char *path, poo
 #else
 	/* Linux, Solaris: /etc/mtab reading */
 #ifdef HAVE_SYS_MNTTAB_H
-	struct mnttab ent;
+	union {
+		struct mnttab ent;
+		struct extmnttab ext;
+	} ent;
 #else
 	struct mntent *ent;
+	struct stat st2;
 #endif
-	struct stat st, st2;
+	struct stat st;
 	const char *device_path = NULL, *mount_path = NULL, *type = NULL;
 	unsigned int block_size;
 	FILE *f;
@@ -100,17 +100,19 @@ int mountpoint_get(const char *path, poo
 		i_error("fopen(%s) failed: %m", MTAB_PATH);
 		return -1;
 	}
-	while ((getmntent(f, &ent)) == 0) {
-		if (strcmp(ent.mnt_fstype, MNTTYPE_SWAP) == 0 ||
-		    strcmp(ent.mnt_fstype, MNTTYPE_AUTOFS) == 0 ||
-		    strcmp(ent.mnt_fstype, MNTTYPE_IGNORE) == 0)
+	while ((getextmntent(f, &ent.ext, sizeof(ent.ext))) == 0) {
+		if (hasmntopt(&ent.ent, MNTOPT_IGNORE) != NULL)
 			continue;
 
-		if (stat(ent.mnt_mountp, &st2) == 0 &&
-		    CMP_DEV_T(st.st_dev, st2.st_dev)) {
-			device_path = ent.mnt_special;
-			mount_path = ent.mnt_mountp;
-			type = ent.mnt_fstype;
+		/* mnt_type contains tmpfs with swap */
+		if (strcmp(ent.ent.mnt_special, MNTTYPE_SWAP) == 0)
+			continue;
+
+		if (major(st.st_dev) == ent.ext.mnt_major &&
+		    minor(st.st_dev) == ent.ext.mnt_minor) {
+			device_path = ent.ent.mnt_special;
+			mount_path = ent.ent.mnt_mountp;
+			type = ent.ent.mnt_fstype;
 			break;
 		}
 	}


More information about the dovecot-cvs mailing list