static int
count_quota_get_resource(struct quota_root *_root,
- const char *name, uint64_t *value_r)
+ const char *name, uint64_t *value_r,
+ const char **error_r)
{
struct count_quota_root *root = (struct count_quota_root *)_root;
uint64_t bytes, count;
- if (quota_count_cached(root, &bytes, &count) < 0)
+ if (quota_count_cached(root, &bytes, &count) < 0) {
+ *error_r = "quota-count failed";
return -1;
+ }
if (strcmp(name, QUOTA_NAME_STORAGE_BYTES) == 0)
*value_r = bytes;
static int
dict_quota_get_resource(struct quota_root *_root,
- const char *name, uint64_t *value_r)
+ const char *name, uint64_t *value_r,
+ const char **error_r)
{
struct dict_quota_root *root = (struct dict_quota_root *)_root;
bool want_bytes;
value_r);
}
}
+ if (ret < 0)
+ *error_r = "quota-dict failed";
return ret;
}
static int
dirsize_quota_get_resource(struct quota_root *_root, const char *name,
- uint64_t *value_r)
+ uint64_t *value_r, const char **error_r)
{
int ret;
ret = get_quota_root_usage(_root, value_r);
+ if (ret < 0)
+ *error_r = "quota-dirsize failed";
+
return ret < 0 ? -1 : 1;
}
static int
fs_quota_get_resource(struct quota_root *_root, const char *name,
- uint64_t *value_r)
+ uint64_t *value_r, const char **error_r)
{
struct fs_quota_root *root = (struct fs_quota_root *)_root;
uint64_t bytes_value, count_value;
&count_value, &count_limit);
}
}
+ if (ret < 0)
+ *error_r = "quota-fs failed";
if (ret <= 0)
return ret;
static int
imapc_quota_get_resource(struct quota_root *_root, const char *name,
- uint64_t *value_r)
+ uint64_t *value_r, const char **error_r)
{
struct imapc_quota_root *root = (struct imapc_quota_root *)_root;
- if (imapc_quota_refresh(root) < 0)
+ if (imapc_quota_refresh(root) < 0) {
+ *error_r = "quota-imapc failed";
return -1;
+ }
if (strcmp(name, QUOTA_NAME_STORAGE_BYTES) == 0)
*value_r = root->bytes_last;
static int
maildir_quota_get_resource(struct quota_root *_root, const char *name,
- uint64_t *value_r)
+ uint64_t *value_r, const char **error_r)
{
struct maildir_quota_root *root = (struct maildir_quota_root *)_root;
bool recalculated;
- if (maildirquota_refresh(root, &recalculated) < 0)
+ if (maildirquota_refresh(root, &recalculated) < 0) {
+ *error_r = "quota-maildir failed";
return -1;
+ }
if (strcmp(name, QUOTA_NAME_STORAGE_BYTES) == 0) {
*value_r = root->total_bytes;
/* Returns 1 if value was returned, 0 if resource name doesn't exist,
-1 if internal error. */
int (*get_resource)(struct quota_root *root,
- const char *name, uint64_t *value_r);
+ const char *name, uint64_t *value_r,
+ const char **error_r);
int (*update)(struct quota_root *root,
struct quota_transaction_context *ctx);
/* Get the value first. This call may also update quota limits if
they're defined externally. */
- ret = root->backend.v.get_resource(root, name, value_r);
+ const char *error;
+ ret = root->backend.v.get_resource(root, name, value_r, &error);
if (ret < 0) {
*error_r = t_strdup_printf(
- "Could not get %s from quota backend for mailbox %s",
- name, mailbox_name);
+ "Could not get %s from quota backend for mailbox %s: %s",
+ name, mailbox_name, error);
return QUOTA_GET_RESULT_INTERNAL_ERROR;
} else if (ret == 0) {
*error_r = t_strdup_printf(
return QUOTA_GET_RESULT_UNKNOWN_RESOURCE;
}
- const char *error;
if (quota_root_get_rule_limits(root, mailbox_name,
&bytes_limit, &count_limit,
&ignored, &error) < 0) {