changeset 4530:f598896bb40a HEAD

Added --with-linux-quota configure option to specify which Linux quota version to use. Don't bother looking into struct dqblk to see if curblocks or curspace field exists, we can figure it out from the quota version. If quotactl() returns EINVAL, it could have been because wrong quota version was used, so give a friendly message suggesting to look at --with-linux-quota.
author Timo Sirainen <tss@iki.fi>
date Thu, 03 Aug 2006 01:39:50 +0300
parents 0ffb6fa11744
children 9eefd9c4619a
files configure.in src/plugins/quota/quota-fs.c src/plugins/quota/quota-fs.h
diffstat 3 files changed, 23 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/configure.in	Wed Aug 02 23:14:19 2006 +0300
+++ b/configure.in	Thu Aug 03 01:39:50 2006 +0300
@@ -66,6 +66,12 @@
 	notify=$withval,
 	notify=)
 
+AC_ARG_WITH(linux-quota,
+[  --with-linux-quota=n    Linux quota version to use (default: system's)],
+	AC_DEFINE_UNQUOTED(_LINUX_QUOTA_VERSION, $withval,
+		[Linux quota version to use])
+)
+
 AC_ARG_WITH(passwd,
 [  --with-passwd           Build with /etc/passwd support (default)],
 	if test x$withval = xno; then
@@ -1135,36 +1141,6 @@
   AC_MSG_RESULT(no)
 ])
 
-dnl * Check if we have struct dqblk.dqb_curblocks
-AC_MSG_CHECKING([if struct dqblk.dqb_curblocks exists])
-AC_TRY_COMPILE([
-  #include <sys/types.h>
-  #include "$srcdir/src/plugins/quota/quota-fs.h"
-], [
-  struct dqblk dqblk;
-  unsigned int x = dqblk.dqb_curblocks;
-], [
-  AC_DEFINE(HAVE_STRUCT_DQBLK_CURBLOCKS,, Define if struct sqblk.dqb_curblocks exists)
-  AC_MSG_RESULT(yes)
-], [
-  AC_MSG_RESULT(no)
-])
-
-dnl * Check if we have struct dqblk.dqb_curspace
-AC_MSG_CHECKING([if struct dqblk.dqb_curspace exists])
-AC_TRY_COMPILE([
-  #include <sys/types.h>
-  #include "$srcdir/src/plugins/quota/quota-fs.h"
-], [
-  struct dqblk dqblk;
-  unsigned int x = dqblk.dqb_curspace;
-], [
-  AC_DEFINE(HAVE_STRUCT_DQBLK_CURSPACE,, Define if struct sqblk.dqb_curspace exists)
-  AC_MSG_RESULT(yes)
-], [
-  AC_MSG_RESULT(no)
-])
-
 dnl * Check if we have Q_QUOTACTL ioctl (Solaris)
 AC_MSG_CHECKING([if struct Q_QUOTACTL ioctl exists])
 AC_TRY_COMPILE([
--- a/src/plugins/quota/quota-fs.c	Wed Aug 02 23:14:19 2006 +0300
+++ b/src/plugins/quota/quota-fs.c	Thu Aug 03 01:39:50 2006 +0300
@@ -20,12 +20,14 @@
 #  include <linux/dqblk_xfs.h>
 #endif
 
-#ifdef HAVE_STRUCT_DQBLK_CURSPACE
-#  define dqb_curblocks dqb_curspace
+#ifndef DEV_BSIZE
+#  define DEV_BSIZE 512
 #endif
 
-#ifndef DEV_BSIZE
-#  define DEV_BSIZE 512
+/* This most likely should have been defined by above headers already, but
+   in case some OS has less than perfect emulation lets try to handle it. */
+#ifndef _LINUX_QUOTA_VERSION
+#  define _LINUX_QUOTA_VERSION 2
 #endif
 
 struct fs_quota_mountpoint {
@@ -222,10 +224,20 @@
 			     root->uid, (caddr_t)&dqblk) < 0) {
 			i_error("quotactl(Q_GETQUOTA, %s) failed: %m",
 				root->mount->device_path);
+			if (errno == EINVAL) {
+				i_error("Dovecot was compiled with Linux quota "
+					"v%d support, try changing it "
+					"(--with-linux-quota configure option)",
+					_LINUX_QUOTA_VERSION);
+			}
 			return -1;
 		}
 
+#if _LINUX_QUOTA_VERSION < 2
 		*value_r = dqblk.dqb_curblocks / 1024;
+#else
+		*value_r = dqblk.dqb_curspace / 1024;
+#endif
 		*limit_r = dqblk.dqb_bsoftlimit;
 	}
 #elif defined(HAVE_QUOTACTL)
--- a/src/plugins/quota/quota-fs.h	Wed Aug 02 23:14:19 2006 +0300
+++ b/src/plugins/quota/quota-fs.h	Thu Aug 03 01:39:50 2006 +0300
@@ -1,10 +1,7 @@
 #ifndef __QUOTA_FS_H
 #define __QUOTA_FS_H
 
-#if defined (HAVE_STRUCT_DQBLK_CURBLOCKS) || \
-	defined (HAVE_STRUCT_DQBLK_CURSPACE)
-#  define HAVE_FS_QUOTA
-#endif
+#define HAVE_FS_QUOTA
 
 #ifdef HAVE_SYS_QUOTA_H
 #  include <sys/quota.h> /* Linux */