$NetBSD: patch-etc_afpd_quota_c,v 1.1 2011/12/16 05:21:37 dholland Exp $

Account for changes in prerelease NetBSD quota API.

--- etc/afpd/quota.c~	2011-08-18 12:23:44.000000000 +0000
+++ etc/afpd/quota.c
@@ -49,13 +49,25 @@ char *strchr (), *strrchr ();
 
 #ifdef HAVE_LIBQUOTA
 #include <quota/quota.h>
+#include <quota/quotaprop.h>
+
+/* Sleazy. */
+#if defined(__NetBSD__) && defined(_QUOTA_QUOTA_H)
+/* old names in -current only from ~March 2011 through ~Nov 2011 */
+#define quotaval ufs_quota_entry
+#define qv_hardlimit ufsqe_hardlimit
+#define qv_softlimit ufsqe_softlimit
+#define qv_usage ufsqe_cur
+#define qv_expiretime ufsqe_time
+#define qv_grace ufsqe_grace
+#endif
 
 static int
 getfreespace(struct vol *vol, VolSpace *bfree, VolSpace *btotal,
     uid_t uid, const char *classq)
 {
 	int retq;
-	struct ufs_quota_entry ufsq[QUOTA_NLIMITS];
+	struct quotaval ufsq[QUOTA_NLIMITS];
 	time_t now;
 
 	if (time(&now) == -1) {
@@ -77,19 +89,19 @@ getfreespace(struct vol *vol, VolSpace *
 	if (retq < 1)
 		return retq;
 
-	switch(QL_STATUS(quota_check_limit(ufsq[QUOTA_LIMIT_BLOCK].ufsqe_cur, 1,
-	    ufsq[QUOTA_LIMIT_BLOCK].ufsqe_softlimit,
-	    ufsq[QUOTA_LIMIT_BLOCK].ufsqe_hardlimit,
-	    ufsq[QUOTA_LIMIT_BLOCK].ufsqe_time, now))) {
+	switch(QL_STATUS(quota_check_limit(ufsq[QUOTA_LIMIT_BLOCK].qv_usage, 1,
+	    ufsq[QUOTA_LIMIT_BLOCK].qv_softlimit,
+	    ufsq[QUOTA_LIMIT_BLOCK].qv_hardlimit,
+	    ufsq[QUOTA_LIMIT_BLOCK].qv_expiretime, now))) {
 	case QL_S_DENY_HARD:
 	case QL_S_DENY_GRACE:
 		*bfree = 0;
-		*btotal = dbtob(ufsq[QUOTA_LIMIT_BLOCK].ufsqe_cur);
+		*btotal = dbtob(ufsq[QUOTA_LIMIT_BLOCK].qv_usage);
 		break;
 	default:
-		*bfree = dbtob(ufsq[QUOTA_LIMIT_BLOCK].ufsqe_hardlimit -
-		    ufsq[QUOTA_LIMIT_BLOCK].ufsqe_cur);
-		*btotal = dbtob(ufsq[QUOTA_LIMIT_BLOCK].ufsqe_hardlimit);
+		*bfree = dbtob(ufsq[QUOTA_LIMIT_BLOCK].qv_hardlimit -
+		    ufsq[QUOTA_LIMIT_BLOCK].qv_usage);
+		*btotal = dbtob(ufsq[QUOTA_LIMIT_BLOCK].qv_hardlimit);
 		break;
 	}
 	return 1;
