Module Name:    src
Committed By:   dholland
Date:           Sun Jan 29 07:12:41 UTC 2012

Modified Files:
        src/sys/kern: vfs_quotactl.c
        src/sys/sys: quotactl.h
        src/sys/ufs/ufs: ufs_quota.c

Log Message:
Change QUOTACTL_GETVERSION to QUOTACTL_STAT. Add struct quotastat.

This change requires a kernel version bump.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/kern/vfs_quotactl.c
cvs rdiff -u -r1.28 -r1.29 src/sys/sys/quotactl.h
cvs rdiff -u -r1.100 -r1.101 src/sys/ufs/ufs/ufs_quota.c

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

Modified files:

Index: src/sys/kern/vfs_quotactl.c
diff -u src/sys/kern/vfs_quotactl.c:1.32 src/sys/kern/vfs_quotactl.c:1.33
--- src/sys/kern/vfs_quotactl.c:1.32	Sun Jan 29 07:11:55 2012
+++ src/sys/kern/vfs_quotactl.c	Sun Jan 29 07:12:40 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_quotactl.c,v 1.32 2012/01/29 07:11:55 dholland Exp $	*/
+/*	$NetBSD: vfs_quotactl.c,v 1.33 2012/01/29 07:12:40 dholland Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993, 1994
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.32 2012/01/29 07:11:55 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.33 2012/01/29 07:12:40 dholland Exp $");
 
 #include <sys/malloc.h> /* XXX: temporary */
 #include <sys/mount.h>
@@ -95,6 +95,7 @@ vfs_quotactl_getversion(struct mount *mp
 {
 	prop_array_t replies;
 	prop_dictionary_t data;
+	struct quotastat stat;
 	int q2version;
 	struct vfs_quotactl_args args;
 	int error;
@@ -102,13 +103,24 @@ vfs_quotactl_getversion(struct mount *mp
 	KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
 	KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
 
-	args.qc_type = QCT_GETVERSION;
-	args.u.getversion.qc_version_ret = &q2version;
-	error = VFS_QUOTACTL(mp, QUOTACTL_GETVERSION, &args);
+	args.qc_type = QCT_STAT;
+	args.u.stat.qc_ret = &stat;
+	error = VFS_QUOTACTL(mp, QUOTACTL_STAT, &args);
 	if (error) {
 		return error;
 	}
 
+	/*
+	 * Set q2version based on the stat results. Currently there
+	 * are two valid values for q2version, 1 and 2, which we pick
+	 * based on whether quotacheck is required.
+	 */
+	if (stat.qs_restrictions & QUOTA_RESTRICT_NEEDSQUOTACHECK) {
+		q2version = 1;
+	} else {
+		q2version = 2;
+	}
+
 	data = prop_dictionary_create();
 	if (data == NULL) {
 		return ENOMEM;

Index: src/sys/sys/quotactl.h
diff -u src/sys/sys/quotactl.h:1.28 src/sys/sys/quotactl.h:1.29
--- src/sys/sys/quotactl.h:1.28	Sun Jan 29 07:11:55 2012
+++ src/sys/sys/quotactl.h	Sun Jan 29 07:12:41 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quotactl.h,v 1.28 2012/01/29 07:11:55 dholland Exp $	*/
+/*	$NetBSD: quotactl.h,v 1.29 2012/01/29 07:12:41 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -37,6 +37,26 @@
  * use the <quota.h> API instead.
  */
 
+/* Size of random quota strings */
+#define QUOTA_NAMELEN   32
+
+/*
+ * Restrictions for qs_restrictions.
+ */
+#define QUOTA_RESTRICT_NEEDSQUOTACHECK	0x1	/* quotacheck(8) required */
+#define QUOTA_RESTRICT_UNIFORMGRACE	0x2	/* grace time is global */
+#define QUOTA_RESTRICT_32BIT		0x4	/* values limited to 2^32 */
+        
+/*              
+ * Structure for QUOTACTL_STAT.
+ */             
+struct quotastat {
+	char qs_implname[QUOTA_NAMELEN];
+	unsigned qs_numidtypes;
+	unsigned qs_numobjtypes;
+	unsigned qs_restrictions;
+};
+                        
 /*
  * Semi-opaque structure for cursors. This holds the cursor state in
  * userland; the size is exposed only to libquota, not to client code,
@@ -52,7 +72,7 @@ struct quotakcursor {
 };
 
 /* Command codes. */
-#define QUOTACTL_GETVERSION	0
+#define QUOTACTL_STAT		0
 #define QUOTACTL_QUOTAON	1
 #define QUOTACTL_QUOTAOFF	2
 #define QUOTACTL_GET		3
@@ -68,7 +88,7 @@ struct quotakcursor {
 /* Argument encoding. */
 enum vfs_quotactl_argtypes {
 	QCT_PROPLIB,	/* unused */
-	QCT_GETVERSION,	/* getversion */
+	QCT_STAT,	/* stat */
 	QCT_GET,	/* get */
 	QCT_PUT,	/* put */
 	QCT_DELETE,	/* delete */
@@ -90,8 +110,8 @@ struct vfs_quotactl_args {
 			prop_array_t qc_datas;
 		} proplib;
 		struct {
-			int *qc_version_ret;
-		} getversion;
+			struct quotastat *qc_ret;
+		} stat;
 		struct {
 			const struct quotakey *qc_key;
 			struct quotaval *qc_ret;

Index: src/sys/ufs/ufs/ufs_quota.c
diff -u src/sys/ufs/ufs/ufs_quota.c:1.100 src/sys/ufs/ufs/ufs_quota.c:1.101
--- src/sys/ufs/ufs/ufs_quota.c:1.100	Sun Jan 29 07:11:55 2012
+++ src/sys/ufs/ufs/ufs_quota.c	Sun Jan 29 07:12:41 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota.c,v 1.100 2012/01/29 07:11:55 dholland Exp $	*/
+/*	$NetBSD: ufs_quota.c,v 1.101 2012/01/29 07:12:41 dholland Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.100 2012/01/29 07:11:55 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.101 2012/01/29 07:12:41 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -71,7 +71,7 @@ static u_long dqhash;
 static pool_cache_t dquot_cache;
 
 
-static int quota_handle_cmd_get_version(struct mount *, struct lwp *,
+static int quota_handle_cmd_stat(struct mount *, struct lwp *,
     struct vfs_quotactl_args *args);
 static int quota_handle_cmd_get(struct mount *, struct lwp *,
     struct vfs_quotactl_args *args);
@@ -170,8 +170,8 @@ quota_handle_cmd(struct mount *mp, struc
 	int error = 0;
 
 	switch (op) {
-	    case QUOTACTL_GETVERSION:
-		error = quota_handle_cmd_get_version(mp, l, args);
+	    case QUOTACTL_STAT:
+		error = quota_handle_cmd_stat(mp, l, args);
 		break;
 	    case QUOTACTL_QUOTAON:
 		error = quota_handle_cmd_quotaon(mp, l, args);
@@ -214,26 +214,36 @@ quota_handle_cmd(struct mount *mp, struc
 }
 
 static int 
-quota_handle_cmd_get_version(struct mount *mp, struct lwp *l, 
+quota_handle_cmd_stat(struct mount *mp, struct lwp *l, 
     struct vfs_quotactl_args *args)
 {
 	struct ufsmount *ump = VFSTOUFS(mp);
-	int *version_ret;
+	struct quotastat *ret;
 
-	KASSERT(args->qc_type == QCT_GETVERSION);
-	version_ret = args->u.getversion.qc_version_ret;
+	KASSERT(args->qc_type == QCT_STAT);
+	ret = args->u.stat.qc_ret;
 
 	if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0)
 		return EOPNOTSUPP;
 
 #ifdef QUOTA
 	if (ump->um_flags & UFS_QUOTA) {
-		*version_ret = 1;
+		strcpy(ret->qs_implname, "ufs/ffs quota v1");
+		ret->qs_numidtypes = MAXQUOTAS;
+		/* XXX no define for this */
+		ret->qs_numobjtypes = 2;
+		ret->qs_restrictions = 0;
+		ret->qs_restrictions |= QUOTA_RESTRICT_NEEDSQUOTACHECK;
+		ret->qs_restrictions |= QUOTA_RESTRICT_UNIFORMGRACE;
+		ret->qs_restrictions |= QUOTA_RESTRICT_32BIT;
 	} else
 #endif
 #ifdef QUOTA2
 	if (ump->um_flags & UFS_QUOTA2) {
-		*version_ret = 2;
+		strcpy(ret->qs_implname, "ufs/ffs quota v2");
+		ret->qs_numidtypes = MAXQUOTAS;
+		ret->qs_numobjtypes = N_QL;
+		ret->qs_restrictions = 0;
 	} else
 #endif
 		return EOPNOTSUPP;

Reply via email to