#endif
#ifndef DEV_BSIZE
-# define DEV_BSIZE 512
+# ifdef DQBSIZE
+# define DEV_BSIZE DQBSIZE /* AIX */
+# else
+# define DEV_BSIZE 512
+# endif
#endif
#ifdef HAVE_STRUCT_DQBLK_CURSPACE
#endif
}
+static bool fs_quota_match_box(struct quota_root *_root, struct mailbox *box)
+{
+ struct fs_quota_root *root = (struct fs_quota_root *)_root;
+ struct stat mst, rst;
+ const char *mailbox_path;
+ bool is_file, match;
+
+ mailbox_path = mail_storage_get_mailbox_path(box->storage, box->name,
+ &is_file);
+ if (stat(mailbox_path, &mst) < 0) {
+ if (errno != ENOENT)
+ i_error("stat(%s) failed: %m", mailbox_path);
+ return FALSE;
+ }
+ if (stat(root->storage_mount_path, &rst) < 0) {
+ if (getenv("DEBUG") != NULL) {
+ i_error("stat(%s) failed: %m",
+ root->storage_mount_path);
+ }
+ return FALSE;
+ }
+ match = CMP_DEV_T(mst.st_dev, rst.st_dev);
+ if (getenv("DEBUG") != NULL) {
+ i_info("box=%s mount=%s match=%s", mailbox_path,
+ root->storage_mount_path, match ? "yes" : "no");
+ }
+ return match;
+}
+
static int
fs_quota_get_resource(struct quota_root *_root, const char *name,
uint64_t *value_r)
fs_quota_root_get_resources,
fs_quota_get_resource,
- fs_quota_update
+ fs_quota_update,
+
+ fs_quota_match_box
}
};
return iter;
}
+static bool
+quota_root_is_visible(struct quota_root *root, struct mailbox *box,
+ bool enforce)
+{
+ if (root->no_enforcing && enforce) {
+ /* we don't want to include this root in quota enforcing */
+ return FALSE;
+ }
+ if (array_count(&root->quota->roots) == 1) {
+ /* a single quota root: don't bother checking further */
+ return TRUE;
+ }
+ return root->backend.v.match_box == NULL ? TRUE :
+ root->backend.v.match_box(root, box);
+}
+
struct quota_root *quota_root_iter_next(struct quota_root_iter *iter)
{
struct quota_root *const *roots, *root = NULL;
return NULL;
for (; iter->i < count; iter->i++) {
+ if (!quota_root_is_visible(roots[iter->i], iter->box, FALSE))
+ continue;
+
ret = quota_get_resource(roots[iter->i], "",
QUOTA_NAME_STORAGE_KILOBYTES,
&value, &limit);
/* find the lowest quota limits from all roots and use them */
roots = array_get(&ctx->quota->roots, &count);
for (i = 0; i < count; i++) {
- if (roots[i]->no_enforcing) {
- /* we don't care what the current quota is */
+ if (!quota_root_is_visible(roots[i], ctx->box, TRUE))
continue;
- }
ret = quota_get_resource(roots[i], mailbox_name,
QUOTA_NAME_STORAGE_BYTES,
mailbox_name = mailbox_get_name(ctx->box);
roots = array_get(&ctx->quota->roots, &count);
for (i = 0; i < count; i++) {
+ if (!quota_root_is_visible(roots[i], ctx->box, TRUE))
+ continue;
+
rule = quota_root_rule_find(roots[i], mailbox_name);
if (rule != NULL && rule->ignore) {
/* mailbox not included in quota */
for (i = 0; i < count; i++) {
uint64_t bytes_limit, count_limit;
+ if (!quota_root_is_visible(roots[i], ctx->box, TRUE))
+ continue;
+
if (!quota_root_get_rule_limits(roots[i],
mailbox_get_name(ctx->box),
&bytes_limit, &count_limit))