Module Name:    src
Committed By:   dholland
Date:           Mon Jan 30 16:44:09 UTC 2012

Modified Files:
        src/include: quota.h
        src/lib/libquota: quota_proplib.c quota_schema.c quotapvt.h

Log Message:
Add quota_getrestrictions() to report the semantic restrictions
associated with a particular quotahandle.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/include/quota.h
cvs rdiff -u -r1.8 -r1.9 src/lib/libquota/quota_proplib.c
cvs rdiff -u -r1.4 -r1.5 src/lib/libquota/quota_schema.c
cvs rdiff -u -r1.10 -r1.11 src/lib/libquota/quotapvt.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/include/quota.h
diff -u src/include/quota.h:1.3 src/include/quota.h:1.4
--- src/include/quota.h:1.3	Sun Jan 29 06:40:57 2012
+++ src/include/quota.h	Mon Jan 30 16:44:08 2012
@@ -46,6 +46,7 @@ const char *quota_getmountpoint(struct q
 const char *quota_getmountdevice(struct quotahandle *);
 
 const char *quota_getimplname(struct quotahandle *);
+unsigned quota_getrestrictions(struct quotahandle *);
 
 unsigned quota_getnumidtypes(struct quotahandle *);
 const char *quota_idtype_getname(struct quotahandle *, int /*idtype*/);

Index: src/lib/libquota/quota_proplib.c
diff -u src/lib/libquota/quota_proplib.c:1.8 src/lib/libquota/quota_proplib.c:1.9
--- src/lib/libquota/quota_proplib.c:1.8	Mon Jan 30 06:00:49 2012
+++ src/lib/libquota/quota_proplib.c	Mon Jan 30 16:44:08 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_proplib.c,v 1.8 2012/01/30 06:00:49 dholland Exp $	*/
+/*	$NetBSD: quota_proplib.c,v 1.9 2012/01/30 16:44:08 dholland Exp $	*/
 /*-
   * Copyright (c) 2011 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: quota_proplib.c,v 1.8 2012/01/30 06:00:49 dholland Exp $");
+__RCSID("$NetBSD: quota_proplib.c,v 1.9 2012/01/30 16:44:08 dholland Exp $");
 
 #include <stdlib.h>
 #include <string.h>
@@ -181,6 +181,24 @@ __quota_proplib_getimplname(struct quota
 }
 
 unsigned
+__quota_proplib_getrestrictions(struct quotahandle *qh)
+{
+	int8_t version;
+
+	if (__quota_proplib_getversion(qh, &version) < 0) {
+		/* XXX no decent way to report an error here */
+		return 0;
+	}
+	switch (version) {
+		case 1: return QUOTA_RESTRICT_NEEDSQUOTACHECK |
+				QUOTA_RESTRICT_UNIFORMGRACE |
+				QUOTA_RESTRICT_32BIT;
+		default: break;
+	}
+	return 0;
+}
+
+unsigned
 __quota_proplib_getnumidtypes(void)
 {
 	return QUOTA_NCLASS;

Index: src/lib/libquota/quota_schema.c
diff -u src/lib/libquota/quota_schema.c:1.4 src/lib/libquota/quota_schema.c:1.5
--- src/lib/libquota/quota_schema.c:1.4	Wed Jan 25 17:43:37 2012
+++ src/lib/libquota/quota_schema.c	Mon Jan 30 16:44:09 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_schema.c,v 1.4 2012/01/25 17:43:37 dholland Exp $	*/
+/*	$NetBSD: quota_schema.c,v 1.5 2012/01/30 16:44:09 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: quota_schema.c,v 1.4 2012/01/25 17:43:37 dholland Exp $");
+__RCSID("$NetBSD: quota_schema.c,v 1.5 2012/01/30 16:44:09 dholland Exp $");
 
 #include <sys/types.h>
 #include <sys/statvfs.h>
@@ -65,7 +65,28 @@ quota_getimplname(struct quotahandle *qh
 	return NULL;
 }
 
-/* ARGSUSED */
+unsigned
+quota_getrestrictions(struct quotahandle *qh)
+{
+	switch (qh->qh_mode) {
+	    case QUOTA_MODE_NFS:
+		/* XXX this should maybe report the rquotad protocol version */
+		return QUOTA_RESTRICT_32BIT | QUOTA_RESTRICT_READONLY;
+
+	    case QUOTA_MODE_PROPLIB:
+		return __quota_proplib_getrestrictions(qh);
+
+	    case QUOTA_MODE_OLDFILES:
+		return QUOTA_RESTRICT_NEEDSQUOTACHECK |
+			QUOTA_RESTRICT_UNIFORMGRACE |
+			QUOTA_RESTRICT_32BIT;
+	    default:
+		break;
+	}
+	errno = EINVAL;
+	return 0;
+}
+
 unsigned
 quota_getnumidtypes(struct quotahandle *qh)
 {
@@ -84,7 +105,6 @@ quota_getnumidtypes(struct quotahandle *
 	return 2;
 }
 
-/* ARGSUSED */
 const char *
 quota_idtype_getname(struct quotahandle *qh, int idtype)
 {
@@ -111,7 +131,6 @@ quota_idtype_getname(struct quotahandle 
 	return "???";
 }
 
-/* ARGSUSED */
 unsigned
 quota_getnumobjtypes(struct quotahandle *qh)
 {
@@ -127,7 +146,6 @@ quota_getnumobjtypes(struct quotahandle 
 	return 2;
 }
 
-/* ARGSUSED */
 const char *
 quota_objtype_getname(struct quotahandle *qh, int objtype)
 {
@@ -152,7 +170,6 @@ quota_objtype_getname(struct quotahandle
 	return "???"; /* ? */
 }
 
-/* ARGSUSED */
 int
 quota_objtype_isbytes(struct quotahandle *qh, int objtype)
 {

Index: src/lib/libquota/quotapvt.h
diff -u src/lib/libquota/quotapvt.h:1.10 src/lib/libquota/quotapvt.h:1.11
--- src/lib/libquota/quotapvt.h:1.10	Wed Jan 25 17:43:37 2012
+++ src/lib/libquota/quotapvt.h	Mon Jan 30 16:44:09 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quotapvt.h,v 1.10 2012/01/25 17:43:37 dholland Exp $	*/
+/*	$NetBSD: quotapvt.h,v 1.11 2012/01/30 16:44:09 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -58,6 +58,7 @@ struct quotacursor {
 /* proplib kernel interface */
 int __quota_proplib_getversion(struct quotahandle *qh, int8_t *version_ret);
 const char *__quota_proplib_getimplname(struct quotahandle *);
+unsigned __quota_proplib_getrestrictions(struct quotahandle *);
 unsigned __quota_proplib_getnumidtypes(void);
 const char *__quota_proplib_idtype_getname(int idtype);
 unsigned __quota_proplib_getnumobjtypes(void);

Reply via email to