dovecot-2.2: quota: Fixed NetBSD quota

dovecot at dovecot.org dovecot at dovecot.org
Fri Oct 24 23:54:52 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/221f3f59901f
changeset: 18006:221f3f59901f
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Oct 25 02:52:50 2014 +0300
description:
quota: Fixed NetBSD quota
I guess it's because quota is refreshed only at quota_open() time.
Based on patch by Manuel Bouyer

diffstat:

 src/plugins/quota/quota-fs.c |  31 ++++++++++++++++---------------
 1 files changed, 16 insertions(+), 15 deletions(-)

diffs (54 lines):

diff -r 3a8b417b0b80 -r 221f3f59901f src/plugins/quota/quota-fs.c
--- a/src/plugins/quota/quota-fs.c	Sat Oct 25 02:42:47 2014 +0300
+++ b/src/plugins/quota/quota-fs.c	Sat Oct 25 02:52:50 2014 +0300
@@ -673,34 +673,35 @@
 {
 	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;
+	} else {
+		*value_r = qv.qv_usage * DEV_BSIZE;
+		*limit_r = qv.qv_softlimit * DEV_BSIZE;
+		ret = 1;
 	}
-
-	*value_r = qv.qv_usage * DEV_BSIZE;
-	*limit_r = qv.qv_softlimit * DEV_BSIZE;
-
-	return 1;
+	quota_close(qh);
+	return ret;
 }
 #endif
 


More information about the dovecot-cvs mailing list