[dovecot-cvs] dovecot/src/plugins/quota quota-fs.c, 1.19, 1.20 quota-maildir.c, 1.13, 1.14 quota-private.h, 1.11, 1.12 quota.c, 1.12, 1.13 quota.h, 1.6, 1.7

cras at dovecot.org cras at dovecot.org
Sun Jul 30 21:32:10 EEST 2006


Update of /var/lib/cvs/dovecot/src/plugins/quota
In directory talvi:/tmp/cvs-serv8242/quota

Modified Files:
	quota-fs.c quota-maildir.c quota-private.h quota.c quota.h 
Log Message:
Changes to make trash plugin working again.



Index: quota-fs.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota-fs.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- quota-fs.c	30 Jul 2006 17:58:43 -0000	1.19
+++ quota-fs.c	30 Jul 2006 18:32:07 -0000	1.20
@@ -110,7 +110,7 @@
 
 	roots = array_get(&quota->roots, &count);
 	for (i = 0; i < count; i++) {
-		if (roots[i]->backend == &quota_backend_fs) {
+		if (roots[i]->backend.name == quota_backend_fs.name) {
 			struct fs_quota_root *root =
 				(struct fs_quota_root *)roots[i];
 

Index: quota-maildir.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota-maildir.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- quota-maildir.c	30 Jul 2006 17:58:43 -0000	1.13
+++ quota-maildir.c	30 Jul 2006 18:32:07 -0000	1.14
@@ -577,7 +577,7 @@
 
 	roots = array_get_modifiable(&quota->roots, &count);
 	for (i = 0; i < count; i++) {
-		if (roots[i]->backend == &quota_backend_maildir)
+		if (roots[i]->backend.name == quota_backend_maildir.name)
 			maildir_quota_root_storage_added(roots[i], _storage);
 	}
 

Index: quota-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota-private.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- quota-private.h	30 Jul 2006 17:58:43 -0000	1.11
+++ quota-private.h	30 Jul 2006 18:32:07 -0000	1.12
@@ -11,6 +11,9 @@
 struct quota {
 	ARRAY_DEFINE(roots, struct quota_root *);
 	ARRAY_DEFINE(storages, struct mail_storage *);
+
+	int (*test_alloc)(struct quota_transaction_context *ctx,
+			  uoff_t size, bool *too_large_r);
 };
 
 struct quota_backend_vfuncs {
@@ -33,6 +36,7 @@
 };
 
 struct quota_backend {
+	/* quota backends equal if backend1.name == backend2.name */
 	const char *name;
 	struct quota_backend_vfuncs v;
 };
@@ -52,7 +56,7 @@
 	/* pointer to the quota that owns this root */
 	struct quota *quota;
 
-	struct quota_backend *backend;
+	struct quota_backend backend;
 	struct quota_rule default_rule;
 	ARRAY_DEFINE(rules, struct quota_rule);
 

Index: quota.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- quota.c	30 Jul 2006 17:58:43 -0000	1.12
+++ quota.c	30 Jul 2006 18:32:07 -0000	1.13
@@ -23,7 +23,7 @@
 extern struct quota_backend quota_backend_fs;
 extern struct quota_backend quota_backend_maildir;
 
-static struct quota_backend *quota_backends[] = {
+static const struct quota_backend *quota_backends[] = {
 #ifdef HAVE_FS_QUOTA
 	&quota_backend_fs,
 #endif
@@ -33,13 +33,15 @@
 };
 #define QUOTA_CLASS_COUNT (sizeof(quota_backends)/sizeof(quota_backends[0]))
 
-void (*hook_quota_root_created)(struct quota_root *root);
+static int quota_default_test_alloc(struct quota_transaction_context *ctx,
+				    uoff_t size, bool *too_large_r);
 
 struct quota *quota_init(void)
 {
 	struct quota *quota;
 
 	quota = i_new(struct quota, 1);
+	quota->test_alloc = quota_default_test_alloc;
 	ARRAY_CREATE(&quota->roots, default_pool, struct quota_root *, 4);
 	ARRAY_CREATE(&quota->storages, default_pool, struct mail_storage *, 8);
 
@@ -60,7 +62,7 @@
 	i_free(quota);
 }
 
-static struct quota_backend *quota_backend_find(const char *name)
+static const struct quota_backend *quota_backend_find(const char *name)
 {
 	unsigned int i;
 
@@ -75,7 +77,7 @@
 struct quota_root *quota_root_init(struct quota *quota, const char *root_def)
 {
 	struct quota_root *root;
-	struct quota_backend *backend;
+	const struct quota_backend *backend;
 	const char *p, *args, *backend_name;
 
 	t_push();
@@ -98,7 +100,7 @@
 
 	root = backend->v.alloc();
 	root->quota = quota;
-	root->backend = backend;
+	root->backend = *backend;
 	root->pool = pool_alloconly_create("quota root", 512);
 
 	if (args != NULL) {
@@ -126,9 +128,6 @@
 			return NULL;
 		}
 	}
-
-	if (hook_quota_root_created != NULL)
-		hook_quota_root_created(root);
 	return root;
 }
 
@@ -147,7 +146,7 @@
 	array_free(&root->rules);
 	array_free(&root->quota_module_contexts);
 
-	root->backend->v.deinit(root);
+	root->backend.v.deinit(root);
 	pool_unref(pool);
 }
 
@@ -248,11 +247,11 @@
 	backends = t_new(struct quota_backend *, count + 1);
 	for (i = 0; i < count; i++) {
 		for (j = 0; backends[j] != NULL; j++) {
-			if (backends[j] == roots[i]->backend)
+			if (backends[j]->name == roots[i]->backend.name)
 				break;
 		}
 		if (backends[j] == NULL)
-			backends[j] = roots[i]->backend;
+			backends[j] = &roots[i]->backend;
 	}
 
 	for (i = 0; backends[i] != NULL; i++) {
@@ -341,7 +340,7 @@
 
 const char *const *quota_root_get_resources(struct quota_root *root)
 {
-	return root->backend->v.get_resources(root);
+	return root->backend.v.get_resources(root);
 }
 
 int quota_get_resource(struct quota_root *root, const char *mailbox_name,
@@ -359,7 +358,7 @@
 	else
 		*limit_r = 0;
 
-	ret = root->backend->v.get_resource(root, name, value_r, limit_r);
+	ret = root->backend.v.get_resource(root, name, value_r, limit_r);
 	return ret <= 0 ? ret :
 		(*limit_r == 0 ? 0 : 1);
 }
@@ -432,7 +431,7 @@
 	else {
 		roots = array_get(&ctx->quota->roots, &count);
 		for (i = 0; i < count; i++) {
-			if (roots[i]->backend->v.update(roots[i], ctx) < 0)
+			if (roots[i]->backend.v.update(roots[i], ctx) < 0)
 				ret = -1;
 		}
 	}
@@ -462,6 +461,12 @@
 int quota_test_alloc(struct quota_transaction_context *ctx,
 		     uoff_t size, bool *too_large_r)
 {
+	return ctx->quota->test_alloc(ctx, size, too_large_r);
+}
+
+static int quota_default_test_alloc(struct quota_transaction_context *ctx,
+				    uoff_t size, bool *too_large_r)
+{
 	struct quota_root *const *roots;
 	unsigned int i, count;
 

Index: quota.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- quota.h	30 Jul 2006 17:58:43 -0000	1.6
+++ quota.h	30 Jul 2006 18:32:07 -0000	1.7
@@ -14,8 +14,6 @@
 struct quota_root_iter;
 struct quota_transaction_context;
 
-extern void (*hook_quota_root_created)(struct quota_root *root);
-
 struct quota *quota_init(void);
 void quota_deinit(struct quota *quota);
 



More information about the dovecot-cvs mailing list