fixes for quota support on NetBSD
Thomas Klausner
tk at giga.or.at
Mon Oct 20 10:16:14 UTC 2014
This patch still applies cleanly against 2.2.14, and is still needed.
Thomas
On Fri, Oct 10, 2014 at 05:07:38PM +0200, Thomas Klausner wrote:
> Hi!
>
> dovecot-2.2.13 already has quota support for NetBSD, but it's buggy.
> The attached patches by Manuel Bouyer <bouyer at NetBSD.org> fix the
> issues.
>
> There is one thing that's not nice in them: one include is now for
> "/usr/include/quota.h" since dovecot comes with its own file "quota.h"
> which is earlier in the search path. Perhaps dovecot's copy can be
> renamed to dovecot-quota.h or to some other non-conflicting name?
>
> Cheers,
> Thomas
> $NetBSD: patch-src_plugins_quota_quota-fs.c,v 1.4 2013/08/05 23:12:42 bouyer Exp $
>
> fix support for NetBSD's libquota
>
> --- src/plugins/quota/quota-fs.c.orig 2013-02-26 09:42:04.000000000 +0100
> +++ src/plugins/quota/quota-fs.c 2013-08-06 01:00:32.000000000 +0200
> @@ -672,34 +672,38 @@
> {
> struct quotakey qk;
> struct quotaval qv;
> + struct quotahandle *qh;
> + int ret;
>
> - if (root->qh == NULL) {
> - if ((root->qh = quota_open(root->mount->mount_path)) == NULL) {
> - i_error("cannot open quota for %s: %m",
> - root->mount->mount_path);
> - fs_quota_root_disable(root, group);
> - return 0;
> - }
> - }
> + if ((qh = quota_open(root->mount->mount_path)) == NULL) {
> + i_error("cannot open quota for %s: %m",
> + root->mount->mount_path);
> + fs_quota_root_disable(root, group);
> + return 0;
> + }
>
> qk.qk_idtype = group ? QUOTA_IDTYPE_GROUP : QUOTA_IDTYPE_USER;
> qk.qk_id = group ? root->gid : root->uid;
> qk.qk_objtype = bytes ? QUOTA_OBJTYPE_BLOCKS : QUOTA_OBJTYPE_FILES;
>
> - if (quota_get(root->qh, &qk, &qv) != 0) {
> + if (quota_get(qh, &qk, &qv) != 0) {
> if (errno == ESRCH) {
> fs_quota_root_disable(root, group);
> return 0;
> }
> i_error("quotactl(Q_GETQUOTA, %s) failed: %m",
> root->mount->mount_path);
> - return -1;
> + ret = -1;
> + goto end;
> }
>
> *value_r = qv.qv_usage * DEV_BSIZE;
> *limit_r = qv.qv_softlimit * DEV_BSIZE;
>
> - return 1;
> + ret = 1;
> +end:
> + quota_close(qh);
> + return ret;
> }
> #endif
>
> $NetBSD: patch-src_plugins_quota_quota-fs.h,v 1.4 2013/08/05 23:12:42 bouyer Exp $
>
> fix support for NetBSD's libquota
>
> --- src/plugins/quota/quota-fs.h.orig 2013-08-06 00:53:34.000000000 +0200
> +++ src/plugins/quota/quota-fs.h 2013-08-06 00:54:29.000000000 +0200
> @@ -7,7 +7,8 @@
> #endif
>
> #ifdef HAVE_QUOTA_OPEN
> -# include <quota.h> /* NetBSD with libquota */
> +/* absolute path to avoid confusion with ./quota.h */
> +# include "/usr/include/quota.h" /* NetBSD with libquota */
> #endif
>
> #ifdef HAVE_SYS_QUOTA_H
More information about the dovecot
mailing list