dovecot-2.0: quota-fs: Added support for NFSv4 rquota.

dovecot at dovecot.org dovecot at dovecot.org
Mon Jul 5 15:01:14 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/4f4096096364
changeset: 11729:4f4096096364
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jul 05 13:01:10 2010 +0100
description:
quota-fs: Added support for NFSv4 rquota.
Based on patch by Martin Schanzenbach, which also borrowed comment from
linuxquota.

diffstat:

 src/plugins/quota/quota-fs.c |  18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diffs (56 lines):

diff -r c187993c96f2 -r 4f4096096364 src/plugins/quota/quota-fs.c
--- a/src/plugins/quota/quota-fs.c	Mon Jul 05 12:56:28 2010 +0100
+++ b/src/plugins/quota/quota-fs.c	Mon Jul 05 13:01:10 2010 +0100
@@ -48,6 +48,10 @@
 #  define _LINUX_QUOTA_VERSION 1
 #endif
 
+#define mount_type_is_nfs(mount) \
+	(strcmp((mount)->type, "nfs") == 0 || \
+	 strcmp((mount)->type, "nfs4") == 0)
+
 struct fs_quota_mountpoint {
 	int refcount;
 
@@ -179,7 +183,7 @@
 	mount->fd = -1;
 #endif
 
-	if (strcmp(mount->type, "nfs") == 0) {
+	if (mount_type_is_nfs(mount)) {
 		if (strchr(mount->device_path, ':') == NULL) {
 			i_error("quota-fs: %s is not a valid NFS device path",
 				mount->device_path);
@@ -225,7 +229,7 @@
 
 #ifdef FS_QUOTA_SOLARIS
 #ifdef HAVE_RQUOTA
-	if (strcmp(mount->type, "nfs") == 0) {
+	if (mount_type_is_nfs(mount)) {
 		/* using rquota for this mount */
 	} else
 #endif
@@ -335,6 +339,14 @@
 	host = t_strdup_until(mount->device_path, path);
 	path++;
 
+	/* For NFSv4, we send the filesystem path without initial /. Server
+	   prepends proper NFS pseudoroot automatically and uses this for
+	   detection of NFSv4 mounts. */
+	if (strcmp(root->mount->type, "nfs4") == 0) {
+		while (*path == '/')
+			path++;
+	}
+
 	if (root->root.quota->set->debug) {
 		i_debug("quota-fs: host=%s, path=%s, uid=%s, %s",
 			host, path, dec2str(root->uid),
@@ -773,7 +785,7 @@
 	bytes = strcasecmp(name, QUOTA_NAME_STORAGE_BYTES) == 0;
 
 #ifdef HAVE_RQUOTA
-	if (strcmp(root->mount->type, "nfs") == 0) {
+	if (mount_type_is_nfs(root->mount)) {
 		T_BEGIN {
 			ret = !root->user_disabled ?
 				do_rquota_user(root, bytes, value_r, &limit) :


More information about the dovecot-cvs mailing list