changeset 16677:a07ab0c638d2

quota: Improved init() failure error logging.
author Timo Sirainen <tss@iki.fi>
date Wed, 07 Aug 2013 16:09:29 +0300
parents cecaa7b85f65
children 17e43eda8f22
files src/plugins/quota/quota-dict.c src/plugins/quota/quota-fs.c src/plugins/quota/quota-maildir.c src/plugins/quota/quota-private.h src/plugins/quota/quota.c
diffstat 5 files changed, 15 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/quota/quota-dict.c	Tue Aug 06 18:44:37 2013 +0000
+++ b/src/plugins/quota/quota-dict.c	Wed Aug 07 16:09:29 2013 +0300
@@ -28,14 +28,15 @@
 	return &root->root;
 }
 
-static int dict_quota_init(struct quota_root *_root, const char *args)
+static int dict_quota_init(struct quota_root *_root, const char *args,
+			   const char **error_r)
 {
 	struct dict_quota_root *root = (struct dict_quota_root *)_root;
 	const char *username, *p, *error;
 
 	p = args == NULL ? NULL : strchr(args, ':');
 	if (p == NULL) {
-		i_error("dict quota: URI missing from parameters");
+		*error_r = "URI missing from parameters";
 		return -1;
 	}
 
@@ -80,7 +81,7 @@
 	if (dict_init(args, DICT_DATA_TYPE_STRING, username,
 		      _root->quota->user->set->base_dir, &root->dict,
 		      &error) < 0) {
-		i_error("dict quota: dict_init(%s) failed: %s", args, error);
+		*error_r = t_strdup_printf("dict_init(%s) failed: %s", args, error);
 		return -1;
 	}
 	return 0;
--- a/src/plugins/quota/quota-fs.c	Tue Aug 06 18:44:37 2013 +0000
+++ b/src/plugins/quota/quota-fs.c	Wed Aug 07 16:09:29 2013 +0300
@@ -95,7 +95,8 @@
 	return &root->root;
 }
 
-static int fs_quota_init(struct quota_root *_root, const char *args)
+static int fs_quota_init(struct quota_root *_root, const char *args,
+			 const char **error_r)
 {
 	struct fs_quota_root *root = (struct fs_quota_root *)_root;
 	const char *const *tmp;
@@ -116,7 +117,7 @@
 			i_free(root->storage_mount_path);
 			root->storage_mount_path = i_strdup(*tmp + 6);
 		} else {
-			i_error("fs quota: Invalid parameter: %s", *tmp);
+			*error_r = t_strdup_printf("Invalid parameter: %s", *tmp);
 			return -1;
 		}
 	}
--- a/src/plugins/quota/quota-maildir.c	Tue Aug 06 18:44:37 2013 +0000
+++ b/src/plugins/quota/quota-maildir.c	Wed Aug 07 16:09:29 2013 +0300
@@ -753,7 +753,8 @@
 	return &root->root;
 }
 
-static int maildir_quota_init(struct quota_root *_root, const char *args)
+static int maildir_quota_init(struct quota_root *_root, const char *args,
+			      const char **error_r)
 {
 	const char *const *tmp;
 
@@ -768,7 +769,7 @@
 		else if (strncmp(*tmp, "ns=", 3) == 0)
 			_root->ns_prefix = p_strdup(_root->pool, *tmp + 3);
 		else {
-			i_error("maildir quota: Invalid parameter: %s", *tmp);
+			*error_r = t_strdup_printf("Invalid parameter: %s", *tmp);
 			return -1;
 		}
 	}
--- a/src/plugins/quota/quota-private.h	Tue Aug 06 18:44:37 2013 +0000
+++ b/src/plugins/quota/quota-private.h	Wed Aug 07 16:09:29 2013 +0300
@@ -48,7 +48,8 @@
 
 struct quota_backend_vfuncs {
 	struct quota_root *(*alloc)(void);
-	int (*init)(struct quota_root *root, const char *args);
+	int (*init)(struct quota_root *root, const char *args,
+		    const char **error_r);
 	void (*deinit)(struct quota_root *root);
 
 	bool (*parse_rule)(struct quota_root_settings *root_set,
--- a/src/plugins/quota/quota.c	Tue Aug 06 18:44:37 2013 +0000
+++ b/src/plugins/quota/quota.c	Wed Aug 07 16:09:29 2013 +0300
@@ -270,8 +270,9 @@
 		     sizeof(void *), 10);
 
 	if (root->backend.v.init != NULL) {
-		if (root->backend.v.init(root, root_set->args) < 0) {
-			*error_r = "init() failed";
+		if (root->backend.v.init(root, root_set->args, error_r) < 0) {
+			*error_r = t_strdup_printf("%s quota init failed: %s",
+					root->backend.name, *error_r);
 			return -1;
 		}
 	} else if (root_set->args != NULL) {