# HG changeset patch # User Timo Sirainen # Date 1154558390 -10800 # Node ID f598896bb40aabd89f6ced380e2a1db313811de7 # Parent 0ffb6fa117448474dccc90f3fa904e55e80be6fd 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. diff -r 0ffb6fa11744 -r f598896bb40a configure.in --- 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 - #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 - #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([ diff -r 0ffb6fa11744 -r f598896bb40a src/plugins/quota/quota-fs.c --- 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 #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) diff -r 0ffb6fa11744 -r f598896bb40a src/plugins/quota/quota-fs.h --- 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 /* Linux */