Sun Jan 29 06:36:51 2012 UTC ()
Move proplib frobbing for QUOTACTL_GETVERSION to FS-independent code.

Note: this change requires a kernel version bump.


(dholland)
diff -r1.5 -r1.6 src/sys/kern/vfs_quotactl.c
diff -r1.3 -r1.4 src/sys/sys/quotactl.h
diff -r1.72 -r1.73 src/sys/ufs/ufs/ufs_quota.c

cvs diff -r1.5 -r1.6 src/sys/kern/vfs_quotactl.c (expand / switch to context diff)
--- src/sys/kern/vfs_quotactl.c 2012/01/29 06:36:06 1.5
+++ src/sys/kern/vfs_quotactl.c 2012/01/29 06:36:50 1.6
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_quotactl.c,v 1.5 2012/01/29 06:36:06 dholland Exp $	*/
+/*	$NetBSD: vfs_quotactl.c,v 1.6 2012/01/29 06:36:50 dholland Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993, 1994
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.5 2012/01/29 06:36:06 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.6 2012/01/29 06:36:50 dholland Exp $");
 
 #include <sys/mount.h>
 #include <sys/quotactl.h>
@@ -91,13 +91,50 @@
 			prop_dictionary_t cmddict, int q2type,
 			prop_array_t datas)
 {
+	prop_array_t replies;
+	prop_dictionary_t data;
+	int q2version;
 	struct vfs_quotactl_args args;
+	int error;
 
-	args.qc_type = QCT_PROPLIB;
-	args.u.proplib.qc_cmddict = cmddict;
-	args.u.proplib.qc_q2type = q2type;
-	args.u.proplib.qc_datas = datas;
-	return VFS_QUOTACTL(mp, QUOTACTL_GETVERSION, &args);
+	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);
+	if (error) {
+		return error;
+	}
+
+	data = prop_dictionary_create();
+	if (data == NULL) {
+		return ENOMEM;
+	}
+
+	if (!prop_dictionary_set_int8(data, "version", q2version)) {
+		prop_object_release(data);
+		return ENOMEM;
+	}
+
+	replies = prop_array_create();
+	if (replies == NULL) {
+		prop_object_release(data);
+		return ENOMEM;
+	}
+
+	if (!prop_array_add_and_rel(replies, data)) {
+		prop_object_release(data);
+		prop_object_release(replies);
+		return ENOMEM;
+	}
+
+	if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) {
+		prop_object_release(replies);
+		return ENOMEM;
+	}
+
+	return error;
 }
 
 static int

cvs diff -r1.3 -r1.4 src/sys/sys/quotactl.h (expand / switch to context diff)
--- src/sys/sys/quotactl.h 2012/01/29 06:36:06 1.3
+++ src/sys/sys/quotactl.h 2012/01/29 06:36:50 1.4
@@ -1,4 +1,4 @@
-/*	$NetBSD: quotactl.h,v 1.3 2012/01/29 06:36:06 dholland Exp $	*/
+/*	$NetBSD: quotactl.h,v 1.4 2012/01/29 06:36:50 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -48,7 +48,8 @@
 
 /* Argument encoding. */
 enum vfs_quotactl_argtypes {
-	QCT_PROPLIB,	/* getversion, quotaon/off, get, set, getall, clear */
+	QCT_PROPLIB,	/* quotaon/off, get, set, getall, clear */
+	QCT_GETVERSION,	/* getversion */
 };
 struct vfs_quotactl_args {
 	enum vfs_quotactl_argtypes qc_type;
@@ -58,6 +59,9 @@
 			int qc_q2type;
 			prop_array_t qc_datas;
 		} proplib;
+		struct {
+			int *qc_version_ret;
+		} getversion;
 	} u;
 };
 

cvs diff -r1.72 -r1.73 src/sys/ufs/ufs/ufs_quota.c (expand / switch to context diff)
--- src/sys/ufs/ufs/ufs_quota.c 2012/01/29 06:36:07 1.72
+++ src/sys/ufs/ufs/ufs_quota.c 2012/01/29 06:36:51 1.73
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota.c,v 1.72 2012/01/29 06:36:07 dholland Exp $	*/
+/*	$NetBSD: ufs_quota.c,v 1.73 2012/01/29 06:36:51 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.72 2012/01/29 06:36:07 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.73 2012/01/29 06:36:51 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -193,55 +193,27 @@
     struct vfs_quotactl_args *args)
 {
 	struct ufsmount *ump = VFSTOUFS(mp);
-	prop_array_t replies;
-	prop_dictionary_t data;
-	int error = 0;
-	prop_dictionary_t cmddict;
-	prop_array_t datas;
+	int *version_ret;
 
-	KASSERT(args->qc_type == QCT_PROPLIB);
-	cmddict = args->u.proplib.qc_cmddict;
-	/* qc_q2type not used */
-	datas = args->u.proplib.qc_datas;
+	KASSERT(args->qc_type == QCT_GETVERSION);
+	version_ret = args->u.getversion.qc_version_ret;
 
-	KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
-	KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
-
 	if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0)
 		return EOPNOTSUPP;
 
-	replies = prop_array_create();
-	if (replies == NULL)
-		return ENOMEM;
-
-	data = prop_dictionary_create();
-	if (data == NULL) {
-		prop_object_release(replies);
-		return ENOMEM;
-	}
-
 #ifdef QUOTA
 	if (ump->um_flags & UFS_QUOTA) {
-		if (!prop_dictionary_set_int8(data, "version", 1))
-			error = ENOMEM;
+		*version_ret = 1;
 	} else
 #endif
 #ifdef QUOTA2
 	if (ump->um_flags & UFS_QUOTA2) {
-		if (!prop_dictionary_set_int8(data, "version", 2))
-			error = ENOMEM;
+		*version_ret = 2;
 	} else
 #endif
-		error = 0;
-	if (error)
-		prop_object_release(data);
-	else if (!prop_array_add_and_rel(replies, data))
-		error = ENOMEM;
-	if (error)
-		prop_object_release(replies);
-	else if (!prop_dictionary_set_and_rel(cmddict, "data", replies))
-		error = ENOMEM;
-	return error;
+		return EOPNOTSUPP;
+
+	return 0;
 }
 
 /* XXX shouldn't all this be in kauth ? */