From: Timo Sirainen Date: Fri, 24 Oct 2014 23:52:50 +0000 (+0300) Subject: quota: Fixed NetBSD quota X-Git-Tag: 2.2.15~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5f83be0c55c71e15b62cbc275f8dd4b3e80e18b6;p=thirdparty%2Fdovecot%2Fcore.git quota: Fixed NetBSD quota I guess it's because quota is refreshed only at quota_open() time. Based on patch by Manuel Bouyer --- diff --git a/src/plugins/quota/quota-fs.c b/src/plugins/quota/quota-fs.c index f61d9b5c1e..8b00070963 100644 --- a/src/plugins/quota/quota-fs.c +++ b/src/plugins/quota/quota-fs.c @@ -673,34 +673,35 @@ fs_quota_get_netbsd(struct fs_quota_root *root, bool group, bool bytes, { 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