Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Use struct quotakey with QUOTACTL_GET. Tidy up accordingly.
details: https://anonhg.NetBSD.org/src/rev/68645eaf55a2
branches: trunk
changeset: 773172:68645eaf55a2
user: dholland <dholland%NetBSD.org@localhost>
date: Sun Jan 29 06:41:41 2012 +0000
description:
Use struct quotakey with QUOTACTL_GET. Tidy up accordingly.
Step 5 of 5 for QUOTACTL_GET.
Note: this change requires a kernel version bump.
diffstat:
sys/kern/vfs_quotactl.c | 47 +++++++++++++++++++++++++++--------------------
sys/sys/quotactl.h | 7 ++-----
sys/ufs/ufs/ufs_quota.c | 22 +++++++---------------
sys/ufs/ufs/ufs_quota.h | 6 +++---
sys/ufs/ufs/ufs_quota1.c | 19 ++++++++++++-------
sys/ufs/ufs/ufs_quota2.c | 33 +++++++++++++++++----------------
6 files changed, 68 insertions(+), 66 deletions(-)
diffs (truncated from 396 to 300 lines):
diff -r 62b5f0dd4727 -r 68645eaf55a2 sys/kern/vfs_quotactl.c
--- a/sys/kern/vfs_quotactl.c Sun Jan 29 06:40:57 2012 +0000
+++ b/sys/kern/vfs_quotactl.c Sun Jan 29 06:41:41 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_quotactl.c,v 1.9 2012/01/29 06:40:57 dholland Exp $ */
+/* $NetBSD: vfs_quotactl.c,v 1.10 2012/01/29 06:41:41 dholland Exp $ */
/*
* Copyright (c) 1991, 1993, 1994
@@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.9 2012/01/29 06:40:57 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.10 2012/01/29 06:41:41 dholland Exp $");
#include <sys/mount.h>
#include <sys/quota.h>
@@ -167,19 +167,28 @@
}
static int
-vfs_quotactl_get_addreply(id_t id,
- int defaultq,
+vfs_quotactl_get_addreply(const struct quotakey *qk,
const struct quotaval *blocks,
const struct quotaval *files,
prop_array_t replies)
{
prop_dictionary_t dict;
+ id_t id;
+ int defaultq;
+ uint64_t *valuesp[QUOTA_NLIMITS];
/* XXX illegal casts */
- uint64_t *valuesp[QUOTA_NLIMITS];
valuesp[QUOTA_LIMIT_BLOCK] = (void *)(intptr_t)&blocks->qv_hardlimit;
valuesp[QUOTA_LIMIT_FILE] = (void *)(intptr_t)&files->qv_hardlimit;
+ if (qk->qk_id == QUOTA_DEFAULTID) {
+ id = 0;
+ defaultq = 1;
+ } else {
+ id = qk->qk_id;
+ defaultq = 0;
+ }
+
dict = quota64toprop(id, defaultq, valuesp,
ufs_quota_entry_names, UFS_QUOTA_NENTRIES,
ufs_quota_limit_names, QUOTA_NLIMITS);
@@ -195,16 +204,16 @@
static int
vfs_quotactl_get(struct mount *mp,
- prop_dictionary_t cmddict, int q2type,
+ prop_dictionary_t cmddict, int idtype,
prop_array_t datas)
{
prop_object_iterator_t iter;
prop_dictionary_t data;
prop_array_t replies;
uint32_t id;
- int defaultq;
const char *idstr;
struct vfs_quotactl_args args;
+ struct quotakey qk;
struct quotaval blocks, files;
int error;
@@ -223,6 +232,8 @@
}
while ((data = prop_object_iterator_next(iter)) != NULL) {
+ qk.qk_idtype = idtype;
+
if (!prop_dictionary_get_uint32(data, "id", &id)) {
if (!prop_dictionary_get_cstring_nocopy(data, "id",
&idstr))
@@ -231,17 +242,15 @@
error = EINVAL;
goto fail;
}
- id = 0;
- defaultq = 1;
+ qk.qk_id = QUOTA_DEFAULTID;
} else {
- defaultq = 0;
+ qk.qk_id = id;
}
+ qk.qk_objtype = QUOTA_OBJTYPE_BLOCKS;
+
args.qc_type = QCT_GET;
- args.u.get.qc_q2type = q2type;
- args.u.get.qc_id = id;
- args.u.get.qc_defaultq = defaultq;
- args.u.get.qc_objtype = QUOTA_OBJTYPE_BLOCKS;
+ args.u.get.qc_key = &qk;
args.u.get.qc_ret = &blocks;
error = VFS_QUOTACTL(mp, QUOTACTL_GET, &args);
if (error == EPERM) {
@@ -254,11 +263,10 @@
goto fail;
}
+ qk.qk_objtype = QUOTA_OBJTYPE_FILES;
+
args.qc_type = QCT_GET;
- args.u.get.qc_q2type = q2type;
- args.u.get.qc_id = id;
- args.u.get.qc_defaultq = defaultq;
- args.u.get.qc_objtype = QUOTA_OBJTYPE_FILES;
+ args.u.get.qc_key = &qk;
args.u.get.qc_ret = &files;
error = VFS_QUOTACTL(mp, QUOTACTL_GET, &args);
if (error == EPERM) {
@@ -271,8 +279,7 @@
goto fail;
}
- error = vfs_quotactl_get_addreply(id, defaultq,
- &blocks, &files,
+ error = vfs_quotactl_get_addreply(&qk, &blocks, &files,
replies);
}
diff -r 62b5f0dd4727 -r 68645eaf55a2 sys/sys/quotactl.h
--- a/sys/sys/quotactl.h Sun Jan 29 06:40:57 2012 +0000
+++ b/sys/sys/quotactl.h Sun Jan 29 06:41:41 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: quotactl.h,v 1.7 2012/01/29 06:40:57 dholland Exp $ */
+/* $NetBSD: quotactl.h,v 1.8 2012/01/29 06:41:41 dholland Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -64,10 +64,7 @@
int *qc_version_ret;
} getversion;
struct {
- int qc_q2type;
- id_t qc_id;
- int qc_defaultq;
- int qc_objtype;
+ const struct quotakey *qc_key;
struct quotaval *qc_ret;
} get;
} u;
diff -r 62b5f0dd4727 -r 68645eaf55a2 sys/ufs/ufs/ufs_quota.c
--- a/sys/ufs/ufs/ufs_quota.c Sun Jan 29 06:40:57 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota.c Sun Jan 29 06:41:41 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota.c,v 1.77 2012/01/29 06:40:57 dholland Exp $ */
+/* $NetBSD: ufs_quota.c,v 1.78 2012/01/29 06:41: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.77 2012/01/29 06:40:57 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.78 2012/01/29 06:41:41 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@@ -232,36 +232,28 @@
{
struct ufsmount *ump = VFSTOUFS(mp);
int error;
- id_t id;
- int q2type;
- int defaultq;
- int objtype;
+ const struct quotakey *qk;
struct quotaval *ret;
KASSERT(args->qc_type == QCT_GET);
- id = args->u.get.qc_id;
- q2type = args->u.get.qc_q2type;
- defaultq = args->u.get.qc_defaultq;
- objtype = args->u.get.qc_objtype;
+ qk = args->u.get.qc_key;
ret = args->u.get.qc_ret;
if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0)
return EOPNOTSUPP;
/* avoid whitespace diffs */ {
- error = quota_get_auth(mp, l, id);
+ error = quota_get_auth(mp, l, qk->qk_id);
if (error != 0)
return error;
#ifdef QUOTA
if (ump->um_flags & UFS_QUOTA) {
- error = quota1_handle_cmd_get(ump, q2type, id, defaultq,
- objtype, ret);
+ error = quota1_handle_cmd_get(ump, qk, ret);
} else
#endif
#ifdef QUOTA2
if (ump->um_flags & UFS_QUOTA2) {
- error = quota2_handle_cmd_get(ump, q2type, id, defaultq,
- objtype, ret);
+ error = quota2_handle_cmd_get(ump, qk, ret);
} else
#endif
panic("quota_handle_cmd_get: no support ?");
diff -r 62b5f0dd4727 -r 68645eaf55a2 sys/ufs/ufs/ufs_quota.h
--- a/sys/ufs/ufs/ufs_quota.h Sun Jan 29 06:40:57 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota.h Sun Jan 29 06:41:41 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota.h,v 1.4 2012/01/29 06:40:57 dholland Exp $ */
+/* $NetBSD: ufs_quota.h,v 1.5 2012/01/29 06:41:41 dholland Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -113,7 +113,7 @@
int q1sync(struct mount *);
int dq1get(struct vnode *, u_long, struct ufsmount *, int, struct dquot *);
int dq1sync(struct vnode *, struct dquot *);
-int quota1_handle_cmd_get(struct ufsmount *, int, int, int, int,
+int quota1_handle_cmd_get(struct ufsmount *, const struct quotakey *,
struct quotaval *);
int quota1_handle_cmd_set(struct ufsmount *, int, int, int, prop_dictionary_t);
int quota1_handle_cmd_quotaon(struct lwp *, struct ufsmount *, int,
@@ -122,7 +122,7 @@
int chkdq2(struct inode *, int64_t, kauth_cred_t, int);
int chkiq2(struct inode *, int32_t, kauth_cred_t, int);
-int quota2_handle_cmd_get(struct ufsmount *, int, int, int, int,
+int quota2_handle_cmd_get(struct ufsmount *, const struct quotakey *,
struct quotaval *);
int quota2_handle_cmd_set(struct ufsmount *, int, int, int, prop_dictionary_t);
int quota2_handle_cmd_clear(struct ufsmount *, int, int, int, prop_dictionary_t);
diff -r 62b5f0dd4727 -r 68645eaf55a2 sys/ufs/ufs/ufs_quota1.c
--- a/sys/ufs/ufs/ufs_quota1.c Sun Jan 29 06:40:57 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota1.c Sun Jan 29 06:41:41 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota1.c,v 1.9 2012/01/29 06:40:57 dholland Exp $ */
+/* $NetBSD: ufs_quota1.c,v 1.10 2012/01/29 06:41:42 dholland Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.9 2012/01/29 06:40:57 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.10 2012/01/29 06:41:42 dholland Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -493,17 +493,22 @@
}
int
-quota1_handle_cmd_get(struct ufsmount *ump, int idtype, int id,
- int defaultq, int objtype, struct quotaval *ret)
+quota1_handle_cmd_get(struct ufsmount *ump, const struct quotakey *qk,
+ struct quotaval *ret)
{
struct dquot *dq;
int error;
struct quotaval blocks, files;
+ int idtype;
+ id_t id;
+
+ idtype = qk->qk_idtype;
+ id = qk->qk_id;
if (ump->um_quotas[idtype] == NULLVP)
return ENODEV;
- if (defaultq) { /* we want the grace period of id 0 */
+ if (id == QUOTA_DEFAULTID) { /* we want the grace period of id 0 */
if ((error = dqget(NULLVP, 0, ump, idtype, &dq)) != 0)
return error;
@@ -513,7 +518,7 @@
}
dqblk_to_quotavals(&dq->dq_un.dq1_dqb, &blocks, &files);
dqrele(NULLVP, dq);
- if (defaultq) {
+ if (id == QUOTA_DEFAULTID) {
if (blocks.qv_expiretime > 0)
blocks.qv_grace = blocks.qv_expiretime;
else
@@ -524,7 +529,7 @@
files.qv_grace = MAX_DQ_TIME;
}
- switch (objtype) {
+ switch (qk->qk_objtype) {
case QUOTA_OBJTYPE_BLOCKS:
*ret = blocks;
break;
diff -r 62b5f0dd4727 -r 68645eaf55a2 sys/ufs/ufs/ufs_quota2.c
--- a/sys/ufs/ufs/ufs_quota2.c Sun Jan 29 06:40:57 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota2.c Sun Jan 29 06:41:41 2012 +0000
@@ -1,4 +1,4 @@
Home |
Main Index |
Thread Index |
Old Index