# 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;
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);
#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
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),
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) :