Mercurial > dovecot > original-hg > dovecot-1.2
changeset 8096:f35a8a3dc06d HEAD
Fixed FS quota compiling and Maildir++ quota with multiple users.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 13 Aug 2008 18:08:45 -0400 |
parents | 1f948670f274 |
children | 4d6cc7bb3426 |
files | src/plugins/quota/quota-fs.c src/plugins/quota/quota-maildir.c src/plugins/quota/quota-private.h src/plugins/quota/quota.c |
diffstat | 4 files changed, 27 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/quota/quota-fs.c Wed Aug 13 16:43:29 2008 -0400 +++ b/src/plugins/quota/quota-fs.c Wed Aug 13 18:08:45 2008 -0400 @@ -661,9 +661,9 @@ /* update limit */ if (bytes) - _root->default_rule.bytes_limit = limit; + _root->bytes_limit = limit; else - _root->default_rule.count_limit = limit; + _root->count_limit = limit; return 1; }
--- a/src/plugins/quota/quota-maildir.c Wed Aug 13 16:43:29 2008 -0400 +++ b/src/plugins/quota/quota-maildir.c Wed Aug 13 18:08:45 2008 -0400 @@ -217,7 +217,7 @@ static int maildirsize_write(struct maildir_quota_root *root, const char *path) { - const struct quota_rule *rule = &root->root.set->default_rule; + struct quota_root *_root = &root->root; struct mail_storage *const *storages; unsigned int i, count; struct dotlock *dotlock; @@ -257,15 +257,15 @@ } str = t_str_new(128); - if (rule->bytes_limit != 0) { + if (_root->bytes_limit != 0) { str_printfa(str, "%lluS", - (unsigned long long)rule->bytes_limit); + (unsigned long long)_root->bytes_limit); } - if (rule->count_limit != 0) { + if (_root->count_limit != 0) { if (str_len(str) > 0) str_append_c(str, ','); str_printfa(str, "%lluC", - (unsigned long long)rule->count_limit); + (unsigned long long)_root->count_limit); } str_printfa(str, "\n%llu %llu\n", (unsigned long long)root->total_bytes, @@ -410,7 +410,7 @@ static int maildirsize_parse(struct maildir_quota_root *root, int fd, const char *const *lines) { - struct quota_rule *rule = &root->root.set->default_rule; + struct quota_root *_root = &root->root; uint64_t message_bytes_limit, message_count_limit; long long bytes_diff, total_bytes; int count_diff, total_count; @@ -429,8 +429,8 @@ if (message_count_limit >= (1ULL << 63)) message_count_limit = (1ULL << 63) - 1; - if (rule->bytes_limit == (int64_t)message_bytes_limit && - rule->count_limit == (int64_t)message_count_limit) { + if (root->root.bytes_limit == (int64_t)message_bytes_limit && + root->root.count_limit == (int64_t)message_count_limit) { /* limits haven't changed */ } else if (root->root.set->force_default_rule) { /* we know the limits and they've changed. @@ -438,8 +438,8 @@ return 0; } else { /* we're using limits from the file. */ - rule->bytes_limit = message_bytes_limit; - rule->count_limit = message_count_limit; + root->root.bytes_limit = message_bytes_limit; + root->root.count_limit = message_count_limit; quota_root_recalculate_relative_rules(root->root.set); } @@ -463,8 +463,8 @@ return -1; } - if ((total_bytes > rule->bytes_limit && rule->bytes_limit != 0) || - (total_count > rule->count_limit && rule->count_limit != 0)) { + if ((total_bytes > _root->bytes_limit && _root->bytes_limit != 0) || + (total_count > _root->count_limit && _root->count_limit != 0)) { /* we're over quota. don't trust these values if the file contains more than the initial summary line, or if the file is older than 15 minutes. */
--- a/src/plugins/quota/quota-private.h Wed Aug 13 16:43:29 2008 -0400 +++ b/src/plugins/quota/quota-private.h Wed Aug 13 18:08:45 2008 -0400 @@ -96,6 +96,11 @@ struct quota *quota; struct quota_backend backend; + /* initially the same as set->default_rule.*_limit, but some backends + may change these by reading the limits elsewhere (e.g. Maildir++, + FS quota) */ + int64_t bytes_limit, count_limit; + /* Module-specific contexts. See quota_module_id. */ ARRAY_DEFINE(quota_module_contexts, void);
--- a/src/plugins/quota/quota.c Wed Aug 13 16:43:29 2008 -0400 +++ b/src/plugins/quota/quota.c Wed Aug 13 18:08:45 2008 -0400 @@ -143,6 +143,8 @@ root->set = root_set; root->quota = quota; root->backend = *root_set->backend; + root->bytes_limit = root_set->default_rule.bytes_limit; + root->count_limit = root_set->default_rule.count_limit; array_create(&root->quota_module_contexts, root->pool, sizeof(void *), 10); @@ -424,7 +426,7 @@ return ret; } -static bool quota_root_get_rule_limits(struct quota_root_settings *root_set, +static bool quota_root_get_rule_limits(struct quota_root *root, const char *mailbox_name, uint64_t *bytes_limit_r, uint64_t *count_limit_r) @@ -433,14 +435,14 @@ int64_t bytes_limit, count_limit; bool found; - bytes_limit = root_set->default_rule.bytes_limit; - count_limit = root_set->default_rule.count_limit; + bytes_limit = root->bytes_limit; + count_limit = root->count_limit; /* if default rule limits are 0, this rule applies only to specific mailboxes */ found = bytes_limit != 0 || count_limit != 0; - rule = quota_root_rule_find(root_set, mailbox_name); + rule = quota_root_rule_find(root->set, mailbox_name); if (rule != NULL) { if (!rule->ignore) { bytes_limit += rule->bytes_limit; @@ -685,7 +687,7 @@ if (ret <= 0) return ret; - (void)quota_root_get_rule_limits(root->set, mailbox_name, + (void)quota_root_get_rule_limits(root, mailbox_name, &bytes_limit, &count_limit); if (strcmp(name, QUOTA_NAME_STORAGE_BYTES) == 0) *limit_r = bytes_limit; @@ -914,7 +916,7 @@ if (!quota_root_is_visible(roots[i], ctx->box, TRUE)) continue; - if (!quota_root_get_rule_limits(roots[i]->set, + if (!quota_root_get_rule_limits(roots[i], mailbox_get_name(ctx->box), &bytes_limit, &count_limit)) continue;