Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Move toplevel proplib iteration of QUOTACTL_CLEAR to fs-...
details: https://anonhg.NetBSD.org/src/rev/b4bb107fa788
branches: trunk
changeset: 773184:b4bb107fa788
user: dholland <dholland%NetBSD.org@localhost>
date: Sun Jan 29 06:51:42 2012 +0000
description:
Move toplevel proplib iteration of QUOTACTL_CLEAR to fs-independent code.
Note: this change requires a kernel version bump.
diffstat:
sys/kern/vfs_quotactl.c | 64 +++++++++++++++++++++++++++++++++++++++++-----
sys/sys/quotactl.h | 9 +++++-
sys/ufs/ufs/ufs_quota.c | 68 +++++++++++++-----------------------------------
3 files changed, 84 insertions(+), 57 deletions(-)
diffs (226 lines):
diff -r 852f464cbf14 -r b4bb107fa788 sys/kern/vfs_quotactl.c
--- a/sys/kern/vfs_quotactl.c Sun Jan 29 06:50:53 2012 +0000
+++ b/sys/kern/vfs_quotactl.c Sun Jan 29 06:51:42 2012 +0000
@@ -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 @@
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;
+
+ 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;
+ }
- 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);
+ 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
diff -r 852f464cbf14 -r b4bb107fa788 sys/sys/quotactl.h
--- a/sys/sys/quotactl.h Sun Jan 29 06:50:53 2012 +0000
+++ b/sys/sys/quotactl.h Sun Jan 29 06:51:42 2012 +0000
@@ -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 @@
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 @@
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;
};
diff -r 852f464cbf14 -r b4bb107fa788 sys/ufs/ufs/ufs_quota.c
--- a/sys/ufs/ufs/ufs_quota.c Sun Jan 29 06:50:53 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota.c Sun Jan 29 06:51:42 2012 +0000
@@ -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 @@
quota_handle_cmd_clear(struct mount *mp, struct lwp *l,
struct vfs_quotactl_args *args)
{
- prop_array_t replies;
- prop_object_iterator_t iter;
+ struct ufsmount *ump = VFSTOUFS(mp);
+ int idtype;
+ id_t id;
+ int defaultq;
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 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 @@
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;
}
Home |
Main Index |
Thread Index |
Old Index