diff src/plugins/quota/quota-fs.c @ 7294:9e4c26471b19 HEAD

Relative (%) limits in quota rules and warnings work now if the backend specifies or changes the limits (e.g. Maildir++ maildirsize file)
author Timo Sirainen <tss@iki.fi>
date Tue, 26 Feb 2008 16:21:05 +0200
parents e6693a0ec8e1
children 1a58b18652a6
line wrap: on
line diff
--- a/src/plugins/quota/quota-fs.c	Tue Feb 26 15:11:34 2008 +0200
+++ b/src/plugins/quota/quota-fs.c	Tue Feb 26 16:21:05 2008 +0200
@@ -549,14 +549,14 @@
 
 static int
 fs_quota_get_resource(struct quota_root *_root, const char *name,
-		      uint64_t *value_r, uint64_t *limit_r)
+		      uint64_t *value_r)
 {
 	struct fs_quota_root *root = (struct fs_quota_root *)_root;
+	uint64_t limit = 0;
 	bool bytes;
 	int ret;
 
 	*value_r = 0;
-	*limit_r = 0;
 
 	if (root->mount == NULL ||
 	    (strcasecmp(name, QUOTA_NAME_STORAGE_BYTES) != 0 &&
@@ -566,22 +566,29 @@
 
 #ifdef HAVE_RQUOTA
 	if (strcmp(root->mount->type, "nfs") == 0) {
-		int ret;
-
 		T_BEGIN {
-			ret = do_rquota(root, bytes, value_r, limit_r);
+			ret = do_rquota(root, bytes, value_r, &limit);
 		} T_END;
-		return ret;
-	}
+	} else
 #endif
-
-	ret = fs_quota_get_one_resource(root, FALSE, bytes,
-					value_r, limit_r);
-	if (ret != 0)
+	{
+		ret = fs_quota_get_one_resource(root, FALSE, bytes,
+						value_r, &limit);
+		if (ret == 0) {
+			/* fallback to group quota */
+			ret = fs_quota_get_one_resource(root, TRUE, bytes,
+							value_r, &limit);
+		}
+	}
+	if (ret <= 0)
 		return ret;
 
-	/* fallback to group quota */
-	return fs_quota_get_one_resource(root, TRUE, bytes, value_r, limit_r);
+	/* update limit */
+	if (bytes)
+		_root->default_rule.bytes_limit = limit;
+	else
+		_root->default_rule.count_limit = limit;
+	return 1;
 }
 
 static int