Module Name:    src
Committed By:   dholland
Date:           Sun Jan 29 06:51:43 UTC 2012

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

Log Message:
Move toplevel proplib iteration of QUOTACTL_CLEAR to fs-independent code.

Note: this change requires a kernel version bump.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/kern/vfs_quotactl.c
cvs rdiff -u -r1.13 -r1.14 src/sys/sys/quotactl.h
cvs rdiff -u -r1.87 -r1.88 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.15 src/sys/kern/vfs_quotactl.c:1.16
--- src/sys/kern/vfs_quotactl.c:1.15	Sun Jan 29 06:49:43 2012
+++ src/sys/kern/vfs_quotactl.c	Sun Jan 29 06:51:42 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_quotactl.c,v 1.15 2012/01/29 06:49:43 dholland Exp $	*/
+/*	$NetBSD: vfs_quotactl.c,v 1.16 2012/01/29 06:51:42 dholland Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993, 1994
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.15 2012/01/29 06:49:43 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.16 2012/01/29 06:51:42 dholland Exp $");
 
 #include <sys/mount.h>
 #include <sys/quota.h>
@@ -456,13 +456,63 @@ vfs_quotactl_clear(struct mount *mp,
 			prop_dictionary_t cmddict, int q2type,
 			prop_array_t datas)
 {
+	prop_array_t replies;
+	prop_object_iterator_t iter;
+	prop_dictionary_t data;
+	uint32_t id;
+	int defaultq;
+	const char *idstr;
 	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_CLEAR, &args);
+	KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
+	KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
+
+	replies = prop_array_create();
+	if (replies == NULL)
+		return ENOMEM;
+
+	iter = prop_array_iterator(datas);
+	if (iter == NULL) {
+		prop_object_release(replies);
+		return ENOMEM;
+	}
+
+	while ((data = prop_object_iterator_next(iter)) != NULL) {
+		if (!prop_dictionary_get_uint32(data, "id", &id)) {
+			if (!prop_dictionary_get_cstring_nocopy(data, "id",
+			    &idstr))
+				continue;
+			if (strcmp(idstr, "default"))
+				continue;
+			id = 0;
+			defaultq = 1;
+		} else {
+			defaultq = 0;
+		}
+
+		args.qc_type = QCT_CLEAR;
+		args.u.clear.qc_idtype = q2type;
+		args.u.clear.qc_id = id;
+		args.u.clear.qc_defaultq = defaultq;
+		args.u.clear.qc_data = data;
+		error = VFS_QUOTACTL(mp, QUOTACTL_CLEAR, &args);
+		if (error) {
+			goto err;
+		}
+	}
+
+	prop_object_iterator_release(iter);
+	if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) {
+		error = ENOMEM;
+	} else {
+		error = 0;
+	}
+	return error;
+err:
+	prop_object_iterator_release(iter);
+	prop_object_release(replies);
+	return error;
 }
 
 static int

Index: src/sys/sys/quotactl.h
diff -u src/sys/sys/quotactl.h:1.13 src/sys/sys/quotactl.h:1.14
--- src/sys/sys/quotactl.h:1.13	Sun Jan 29 06:49:43 2012
+++ src/sys/sys/quotactl.h	Sun Jan 29 06:51:43 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quotactl.h,v 1.13 2012/01/29 06:49:43 dholland Exp $	*/
+/*	$NetBSD: quotactl.h,v 1.14 2012/01/29 06:51:43 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -52,6 +52,7 @@ enum vfs_quotactl_argtypes {
 	QCT_GETVERSION,	/* getversion */
 	QCT_GET,	/* get */
 	QCT_PUT,	/* put */
+	QCT_CLEAR,	/* clear */
 };
 struct vfs_quotactl_args {
 	enum vfs_quotactl_argtypes qc_type;
@@ -72,6 +73,12 @@ struct vfs_quotactl_args {
 			const struct quotakey *qc_key;
 			const struct quotaval *qc_val;
 		} put;
+		struct {
+			int qc_idtype;
+			id_t qc_id;
+			int qc_defaultq;
+			prop_dictionary_t qc_data;
+		} clear;
 	} u;
 };
 

Index: src/sys/ufs/ufs/ufs_quota.c
diff -u src/sys/ufs/ufs/ufs_quota.c:1.87 src/sys/ufs/ufs/ufs_quota.c:1.88
--- src/sys/ufs/ufs/ufs_quota.c:1.87	Sun Jan 29 06:50:53 2012
+++ src/sys/ufs/ufs/ufs_quota.c	Sun Jan 29 06:51:43 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota.c,v 1.87 2012/01/29 06:50:53 dholland Exp $	*/
+/*	$NetBSD: ufs_quota.c,v 1.88 2012/01/29 06:51:43 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.87 2012/01/29 06:50:53 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.88 2012/01/29 06:51:43 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -315,56 +315,33 @@ static int 
 quota_handle_cmd_clear(struct mount *mp, struct lwp *l, 
     struct vfs_quotactl_args *args)
 {
-	prop_array_t replies;
-	prop_object_iterator_t iter;
-	prop_dictionary_t data;
-	uint32_t id;
 	struct ufsmount *ump = VFSTOUFS(mp);
-	int error, defaultq = 0;
-	const char *idstr;
-	prop_dictionary_t cmddict;
-	int q2type;
-	prop_array_t datas;
+	int idtype;
+	id_t id;
+	int defaultq;
+	prop_dictionary_t data;
+	int error;
 
-	KASSERT(args->qc_type == QCT_PROPLIB);
-	cmddict = args->u.proplib.qc_cmddict;
-	q2type = args->u.proplib.qc_q2type;
-	datas = args->u.proplib.qc_datas;
+	KASSERT(args->qc_type == QCT_CLEAR);
+	idtype = args->u.clear.qc_idtype;
+	id = args->u.clear.qc_id;
+	defaultq = args->u.clear.qc_defaultq;
+	data = args->u.clear.qc_data;
 
-	KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
-	KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
+	KASSERT(prop_object_type(data) == PROP_TYPE_DICTIONARY);
 
 	if ((ump->um_flags & UFS_QUOTA2) == 0)
 		return EOPNOTSUPP;
-	
-	replies = prop_array_create();
-	if (replies == NULL)
-		return ENOMEM;
 
-	iter = prop_array_iterator(datas);
-	if (iter == NULL) {
-		prop_object_release(replies);
-		return ENOMEM;
-	}
-	while ((data = prop_object_iterator_next(iter)) != NULL) {
-		if (!prop_dictionary_get_uint32(data, "id", &id)) {
-			if (!prop_dictionary_get_cstring_nocopy(data, "id",
-			    &idstr))
-				continue;
-			if (strcmp(idstr, "default"))
-				continue;
-			id = 0;
-			defaultq = 1;
-		} else {
-			defaultq = 0;
-		}
+	/* avoid whitespace changes */
+	{
 		error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA,
 		    KAUTH_REQ_SYSTEM_FS_QUOTA_MANAGE, mp, KAUTH_ARG(id), NULL);
 		if (error != 0)
 			goto err;
 #ifdef QUOTA2
 		if (ump->um_flags & UFS_QUOTA2) {
-			error = quota2_handle_cmd_clear(ump, q2type, id, defaultq,
+			error = quota2_handle_cmd_clear(ump, idtype, id, defaultq,
 			    data);
 		} else
 #endif
@@ -373,16 +350,9 @@ quota_handle_cmd_clear(struct mount *mp,
 		if (error && error != ENOENT)
 			goto err;
 	}
-	prop_object_iterator_release(iter);
-	if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) {
-		error = ENOMEM;
-	} else {
-		error = 0;
-	}
-	return error;
-err:
-	prop_object_iterator_release(iter);
-	prop_object_release(replies);
+
+	return 0;
+ err:
 	return error;
 }
 

Reply via email to