Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Tidy up the VFS_QUOTACTL interface. Renumber the command...
details: https://anonhg.NetBSD.org/src/rev/63071137ed40
branches: trunk
changeset: 773205:63071137ed40
user: dholland <dholland%NetBSD.org@localhost>
date: Sun Jan 29 07:13:42 2012 +0000
description:
Tidy up the VFS_QUOTACTL interface. Renumber the command codes in a
logical order (as opposed to the previous order, which accumulated
arbitrarily), remove the separate codes for argument encoding as
there's now a 1-1 mapping between ops and argument substructures,
and assert in VFS_QUOTACTL() itself that the op in the args structure
matches the op passed directly.
This change requires a kernel version bump.
diffstat:
sys/kern/vfs_quotactl.c | 36 ++++++++++++++++++------------------
sys/kern/vfs_subr.c | 7 +++++--
sys/sys/quotactl.h | 46 +++++++++++++---------------------------------
sys/ufs/ufs/ufs_quota.c | 28 ++++++++++++++--------------
4 files changed, 50 insertions(+), 67 deletions(-)
diffs (truncated from 387 to 300 lines):
diff -r b0f99484258a -r 63071137ed40 sys/kern/vfs_quotactl.c
--- a/sys/kern/vfs_quotactl.c Sun Jan 29 07:12:40 2012 +0000
+++ b/sys/kern/vfs_quotactl.c Sun Jan 29 07:13:42 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_quotactl.c,v 1.33 2012/01/29 07:12:40 dholland Exp $ */
+/* $NetBSD: vfs_quotactl.c,v 1.34 2012/01/29 07:13: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.33 2012/01/29 07:12:40 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.34 2012/01/29 07:13:42 dholland Exp $");
#include <sys/malloc.h> /* XXX: temporary */
#include <sys/mount.h>
@@ -103,7 +103,7 @@
KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
- args.qc_type = QCT_STAT;
+ args.qc_op = QUOTACTL_STAT;
args.u.stat.qc_ret = &stat;
error = VFS_QUOTACTL(mp, QUOTACTL_STAT, &args);
if (error) {
@@ -173,7 +173,7 @@
&qfile))
return EINVAL;
- args.qc_type = QCT_QUOTAON;
+ args.qc_op = QUOTACTL_QUOTAON;
args.u.quotaon.qc_idtype = q2type;
args.u.quotaon.qc_quotafile = qfile;
return VFS_QUOTACTL(mp, QUOTACTL_QUOTAON, &args);
@@ -192,7 +192,7 @@
if (prop_array_count(datas) != 0)
return EINVAL;
- args.qc_type = QCT_QUOTAOFF;
+ args.qc_op = QUOTACTL_QUOTAOFF;
args.u.quotaoff.qc_idtype = q2type;
return VFS_QUOTACTL(mp, QUOTACTL_QUOTAOFF, &args);
}
@@ -280,7 +280,7 @@
qk.qk_objtype = QUOTA_OBJTYPE_BLOCKS;
- args.qc_type = QCT_GET;
+ args.qc_op = QUOTACTL_GET;
args.u.get.qc_key = &qk;
args.u.get.qc_ret = &blocks;
error = VFS_QUOTACTL(mp, QUOTACTL_GET, &args);
@@ -296,7 +296,7 @@
qk.qk_objtype = QUOTA_OBJTYPE_FILES;
- args.qc_type = QCT_GET;
+ args.qc_op = QUOTACTL_GET;
args.u.get.qc_key = &qk;
args.u.get.qc_ret = &files;
error = VFS_QUOTACTL(mp, QUOTACTL_GET, &args);
@@ -435,7 +435,7 @@
qk.qk_id = defaultq ? QUOTA_DEFAULTID : id;
qk.qk_objtype = QUOTA_OBJTYPE_BLOCKS;
- args.qc_type = QCT_PUT;
+ args.qc_op = QUOTACTL_PUT;
args.u.put.qc_key = &qk;
args.u.put.qc_val = &blocks;
error = VFS_QUOTACTL(mp, QUOTACTL_PUT, &args);
@@ -447,7 +447,7 @@
qk.qk_id = defaultq ? QUOTA_DEFAULTID : id;
qk.qk_objtype = QUOTA_OBJTYPE_FILES;
- args.qc_type = QCT_PUT;
+ args.qc_op = QUOTACTL_PUT;
args.u.put.qc_key = &qk;
args.u.put.qc_val = &files;
error = VFS_QUOTACTL(mp, QUOTACTL_PUT, &args);
@@ -572,7 +572,7 @@
KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
- args.qc_type = QCT_CURSOROPEN;
+ args.qc_op = QUOTACTL_CURSOROPEN;
args.u.cursoropen.qc_cursor = &cursor;
error = VFS_QUOTACTL(mp, QUOTACTL_CURSOROPEN, &args);
if (error) {
@@ -584,7 +584,7 @@
skipidtype = (q2type == QUOTA_IDTYPE_USER ?
QUOTA_IDTYPE_GROUP : QUOTA_IDTYPE_USER);
- args.qc_type = QCT_CURSORSKIPIDTYPE;
+ args.qc_op = QUOTACTL_CURSORSKIPIDTYPE;
args.u.cursorskipidtype.qc_cursor = &cursor;
args.u.cursorskipidtype.qc_idtype = skipidtype;
error = VFS_QUOTACTL(mp, QUOTACTL_CURSORSKIPIDTYPE, &args);
@@ -602,7 +602,7 @@
atzero = 0;
while (1) {
- args.qc_type = QCT_CURSORATEND;
+ args.qc_op = QUOTACTL_CURSORATEND;
args.u.cursoratend.qc_cursor = &cursor;
args.u.cursoratend.qc_ret = &atend;
error = VFS_QUOTACTL(mp, QUOTACTL_CURSORATEND, &args);
@@ -613,7 +613,7 @@
break;
}
- args.qc_type = QCT_CURSORGET;
+ args.qc_op = QUOTACTL_CURSORGET;
args.u.cursorget.qc_cursor = &cursor;
args.u.cursorget.qc_keys = keys;
args.u.cursorget.qc_vals = vals;
@@ -626,14 +626,14 @@
* transaction abort, start over
*/
- args.qc_type = QCT_CURSORREWIND;
+ args.qc_op = QUOTACTL_CURSORREWIND;
args.u.cursorrewind.qc_cursor = &cursor;
error = VFS_QUOTACTL(mp, QUOTACTL_CURSORREWIND, &args);
if (error) {
goto err;
}
- args.qc_type = QCT_CURSORSKIPIDTYPE;
+ args.qc_op = QUOTACTL_CURSORSKIPIDTYPE;
args.u.cursorskipidtype.qc_cursor = &cursor;
args.u.cursorskipidtype.qc_idtype = skipidtype;
error = VFS_QUOTACTL(mp, QUOTACTL_CURSORSKIPIDTYPE,
@@ -729,7 +729,7 @@
prop_object_release(replies);
}
- args.qc_type = QCT_CURSORCLOSE;
+ args.qc_op = QUOTACTL_CURSORCLOSE;
args.u.cursorclose.qc_cursor = &cursor;
error2 = VFS_QUOTACTL(mp, QUOTACTL_CURSORCLOSE, &args);
@@ -785,7 +785,7 @@
qk.qk_id = defaultq ? QUOTA_DEFAULTID : id;
qk.qk_objtype = QUOTA_OBJTYPE_BLOCKS;
- args.qc_type = QCT_DELETE;
+ args.qc_op = QUOTACTL_DELETE;
args.u.delete.qc_key = &qk;
error = VFS_QUOTACTL(mp, QUOTACTL_DELETE, &args);
if (error) {
@@ -796,7 +796,7 @@
qk.qk_id = defaultq ? QUOTA_DEFAULTID : id;
qk.qk_objtype = QUOTA_OBJTYPE_FILES;
- args.qc_type = QCT_DELETE;
+ args.qc_op = QUOTACTL_DELETE;
args.u.delete.qc_key = &qk;
error = VFS_QUOTACTL(mp, QUOTACTL_DELETE, &args);
if (error) {
diff -r b0f99484258a -r 63071137ed40 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c Sun Jan 29 07:12:40 2012 +0000
+++ b/sys/kern/vfs_subr.c Sun Jan 29 07:13:42 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_subr.c,v 1.429 2012/01/29 06:36:06 dholland Exp $ */
+/* $NetBSD: vfs_subr.c,v 1.430 2012/01/29 07:13:42 dholland Exp $ */
/*-
* Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.429 2012/01/29 06:36:06 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.430 2012/01/29 07:13:42 dholland Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@@ -90,6 +90,7 @@
#include <sys/syscallargs.h>
#include <sys/kauth.h>
#include <sys/module.h>
+#include <sys/quotactl.h> /* XXX temporary */
#include <miscfs/genfs/genfs.h>
#include <miscfs/syncfs/syncfs.h>
@@ -1010,6 +1011,8 @@
{
int error;
+ KASSERT(op == args->qc_op);
+
if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) {
KERNEL_LOCK(1, NULL);
}
diff -r b0f99484258a -r 63071137ed40 sys/sys/quotactl.h
--- a/sys/sys/quotactl.h Sun Jan 29 07:12:40 2012 +0000
+++ b/sys/sys/quotactl.h Sun Jan 29 07:13:42 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: quotactl.h,v 1.29 2012/01/29 07:12:41 dholland Exp $ */
+/* $NetBSD: quotactl.h,v 1.30 2012/01/29 07:13:43 dholland Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -73,43 +73,23 @@
/* Command codes. */
#define QUOTACTL_STAT 0
-#define QUOTACTL_QUOTAON 1
-#define QUOTACTL_QUOTAOFF 2
-#define QUOTACTL_GET 3
-#define QUOTACTL_PUT 4
-#define QUOTACTL_CURSORGET 5
-#define QUOTACTL_DELETE 6
-#define QUOTACTL_CURSOROPEN 7
-#define QUOTACTL_CURSORCLOSE 8
-#define QUOTACTL_CURSORSKIPIDTYPE 9
-#define QUOTACTL_CURSORATEND 10
-#define QUOTACTL_CURSORREWIND 11
+#define QUOTACTL_GET 1
+#define QUOTACTL_PUT 2
+#define QUOTACTL_DELETE 3
+#define QUOTACTL_CURSOROPEN 4
+#define QUOTACTL_CURSORCLOSE 5
+#define QUOTACTL_CURSORSKIPIDTYPE 6
+#define QUOTACTL_CURSORGET 7
+#define QUOTACTL_CURSORATEND 8
+#define QUOTACTL_CURSORREWIND 9
+#define QUOTACTL_QUOTAON 10
+#define QUOTACTL_QUOTAOFF 11
/* Argument encoding. */
-enum vfs_quotactl_argtypes {
- QCT_PROPLIB, /* unused */
- QCT_STAT, /* stat */
- QCT_GET, /* get */
- QCT_PUT, /* put */
- QCT_DELETE, /* delete */
- QCT_CURSOROPEN, /* open cursor */
- QCT_CURSORCLOSE,/* close cursor */
- QCT_CURSORGET, /* get from cursor */
- QCT_CURSORSKIPIDTYPE, /* iteration hint */
- QCT_CURSORATEND,/* test cursor */
- QCT_CURSORREWIND,/* reset cursor */
- QCT_QUOTAON, /* quotaon */
- QCT_QUOTAOFF, /* quotaoff */
-};
struct vfs_quotactl_args {
- enum vfs_quotactl_argtypes qc_type;
+ unsigned qc_op;
union {
struct {
- prop_dictionary_t qc_cmddict;
- int qc_q2type;
- prop_array_t qc_datas;
- } proplib;
- struct {
struct quotastat *qc_ret;
} stat;
struct {
diff -r b0f99484258a -r 63071137ed40 sys/ufs/ufs/ufs_quota.c
--- a/sys/ufs/ufs/ufs_quota.c Sun Jan 29 07:12:40 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota.c Sun Jan 29 07:13:42 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota.c,v 1.101 2012/01/29 07:12:41 dholland Exp $ */
+/* $NetBSD: ufs_quota.c,v 1.102 2012/01/29 07:13: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.101 2012/01/29 07:12:41 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.102 2012/01/29 07:13:43 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@@ -220,7 +220,7 @@
struct ufsmount *ump = VFSTOUFS(mp);
struct quotastat *ret;
- KASSERT(args->qc_type == QCT_STAT);
+ KASSERT(args->qc_op == QUOTACTL_STAT);
ret = args->u.stat.qc_ret;
if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0)
@@ -270,7 +270,7 @@
const struct quotakey *qk;
struct quotaval *ret;
- KASSERT(args->qc_type == QCT_GET);
+ KASSERT(args->qc_op == QUOTACTL_GET);
qk = args->u.get.qc_key;
ret = args->u.get.qc_ret;
@@ -308,7 +308,7 @@
id_t kauth_id;
int error;
Home |
Main Index |
Thread Index |
Old Index