Module Name: src Committed By: dholland Date: Sun Jan 29 06:41:42 UTC 2012
Modified Files: src/sys/kern: vfs_quotactl.c src/sys/sys: quotactl.h src/sys/ufs/ufs: ufs_quota.c ufs_quota.h ufs_quota1.c ufs_quota2.c Log Message: Use struct quotakey with QUOTACTL_GET. Tidy up accordingly. Step 5 of 5 for QUOTACTL_GET. Note: this change requires a kernel version bump. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/kern/vfs_quotactl.c cvs rdiff -u -r1.7 -r1.8 src/sys/sys/quotactl.h cvs rdiff -u -r1.77 -r1.78 src/sys/ufs/ufs/ufs_quota.c cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/ufs/ufs_quota.h cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/ufs/ufs_quota1.c cvs rdiff -u -r1.6 -r1.7 src/sys/ufs/ufs/ufs_quota2.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.9 src/sys/kern/vfs_quotactl.c:1.10 --- src/sys/kern/vfs_quotactl.c:1.9 Sun Jan 29 06:40:57 2012 +++ src/sys/kern/vfs_quotactl.c Sun Jan 29 06:41:41 2012 @@ -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 @@ vfs_quotactl_quotaoff(struct mount *mp, } 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 @@ vfs_quotactl_get_addreply(id_t id, 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 @@ vfs_quotactl_get(struct mount *mp, } 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 @@ vfs_quotactl_get(struct mount *mp, 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 @@ vfs_quotactl_get(struct mount *mp, 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 @@ vfs_quotactl_get(struct mount *mp, goto fail; } - error = vfs_quotactl_get_addreply(id, defaultq, - &blocks, &files, + error = vfs_quotactl_get_addreply(&qk, &blocks, &files, replies); } Index: src/sys/sys/quotactl.h diff -u src/sys/sys/quotactl.h:1.7 src/sys/sys/quotactl.h:1.8 --- src/sys/sys/quotactl.h:1.7 Sun Jan 29 06:40:57 2012 +++ src/sys/sys/quotactl.h Sun Jan 29 06:41:41 2012 @@ -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 @@ struct vfs_quotactl_args { 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; Index: src/sys/ufs/ufs/ufs_quota.c diff -u src/sys/ufs/ufs/ufs_quota.c:1.77 src/sys/ufs/ufs/ufs_quota.c:1.78 --- src/sys/ufs/ufs/ufs_quota.c:1.77 Sun Jan 29 06:40:57 2012 +++ src/sys/ufs/ufs/ufs_quota.c Sun Jan 29 06:41:41 2012 @@ -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 @@ quota_handle_cmd_get(struct mount *mp, s { 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 ?"); Index: src/sys/ufs/ufs/ufs_quota.h diff -u src/sys/ufs/ufs/ufs_quota.h:1.4 src/sys/ufs/ufs/ufs_quota.h:1.5 --- src/sys/ufs/ufs/ufs_quota.h:1.4 Sun Jan 29 06:40:57 2012 +++ src/sys/ufs/ufs/ufs_quota.h Sun Jan 29 06:41:41 2012 @@ -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 chkiq1(struct inode *, int32_t, kaut 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 quota1_handle_cmd_quotaoff(struct lw 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); Index: src/sys/ufs/ufs/ufs_quota1.c diff -u src/sys/ufs/ufs/ufs_quota1.c:1.9 src/sys/ufs/ufs/ufs_quota1.c:1.10 --- src/sys/ufs/ufs/ufs_quota1.c:1.9 Sun Jan 29 06:40:57 2012 +++ src/sys/ufs/ufs/ufs_quota1.c Sun Jan 29 06:41:42 2012 @@ -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 @@ again: } 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 @@ quota1_handle_cmd_get(struct ufsmount *u } 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 @@ quota1_handle_cmd_get(struct ufsmount *u files.qv_grace = MAX_DQ_TIME; } - switch (objtype) { + switch (qk->qk_objtype) { case QUOTA_OBJTYPE_BLOCKS: *ret = blocks; break; Index: src/sys/ufs/ufs/ufs_quota2.c diff -u src/sys/ufs/ufs/ufs_quota2.c:1.6 src/sys/ufs/ufs/ufs_quota2.c:1.7 --- src/sys/ufs/ufs/ufs_quota2.c:1.6 Sun Jan 29 06:40:58 2012 +++ src/sys/ufs/ufs/ufs_quota2.c Sun Jan 29 06:41:42 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_quota2.c,v 1.6 2012/01/29 06:40:58 dholland Exp $ */ +/* $NetBSD: ufs_quota2.c,v 1.7 2012/01/29 06:41:42 dholland Exp $ */ /*- * Copyright (c) 2010 Manuel Bouyer * All rights reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.6 2012/01/29 06:40:58 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.7 2012/01/29 06:41:42 dholland Exp $"); #include <sys/buf.h> #include <sys/param.h> @@ -853,8 +853,8 @@ quota2_array_add_q2e(struct ufsmount *um } static int -quota2_fetch_q2e(struct ufsmount *ump, int type, - int id, int objtype, struct quotaval *ret) +quota2_fetch_q2e(struct ufsmount *ump, const struct quotakey *qk, + struct quotaval *ret) { struct dquot *dq; int error; @@ -863,7 +863,7 @@ quota2_fetch_q2e(struct ufsmount *ump, i const int needswap = UFS_MPNEEDSWAP(ump); id_t id2; - error = dqget(NULLVP, id, ump, type, &dq); + error = dqget(NULLVP, qk->qk_id, ump, qk->qk_idtype, &dq); if (error) return error; @@ -873,7 +873,7 @@ quota2_fetch_q2e(struct ufsmount *ump, i dqrele(NULLVP, dq); return ENOENT; } - error = getq2e(ump, type, dq->dq2_lblkno, dq->dq2_blkoff, + error = getq2e(ump, qk->qk_idtype, dq->dq2_lblkno, dq->dq2_blkoff, &bp, &q2ep, 0); if (error) { mutex_exit(&dq->dq_interlock); @@ -885,14 +885,14 @@ quota2_fetch_q2e(struct ufsmount *ump, i mutex_exit(&dq->dq_interlock); dqrele(NULLVP, dq); - q2e_to_quotaval(&q2e, 0, &id2, objtype, ret); - KASSERT(id2 == id); + q2e_to_quotaval(&q2e, 0, &id2, qk->qk_objtype, ret); + KASSERT(id2 == qk->qk_id); return 0; } int -quota2_handle_cmd_get(struct ufsmount *ump, int type, int id, - int defaultq, int objtype, struct quotaval *ret) +quota2_handle_cmd_get(struct ufsmount *ump, const struct quotakey *qk, + struct quotaval *ret) { int error; struct quota2_header *q2h; @@ -910,15 +910,15 @@ quota2_handle_cmd_get(struct ufsmount *u CTASSERT(QL_FILE == QUOTA_OBJTYPE_FILES); CTASSERT(N_QL == 2); - if (objtype < 0 || objtype >= N_QL) { + if (qk->qk_objtype < 0 || qk->qk_objtype >= N_QL) { return EINVAL; } - if (ump->um_quotas[type] == NULLVP) + if (ump->um_quotas[qk->qk_idtype] == NULLVP) return ENODEV; - if (defaultq) { + if (qk->qk_id == QUOTA_DEFAULTID) { mutex_enter(&dqlock); - error = getq2h(ump, type, &bp, &q2h, 0); + error = getq2h(ump, qk->qk_idtype, &bp, &q2h, 0); if (error) { mutex_exit(&dqlock); return error; @@ -926,10 +926,11 @@ quota2_handle_cmd_get(struct ufsmount *u quota2_ufs_rwq2e(&q2h->q2h_defentry, &q2e, needswap); mutex_exit(&dqlock); brelse(bp, 0); - q2e_to_quotaval(&q2e, defaultq, &id2, objtype, ret); + q2e_to_quotaval(&q2e, qk->qk_id == QUOTA_DEFAULTID, &id2, + qk->qk_objtype, ret); (void)id2; } else - error = quota2_fetch_q2e(ump, type, id, objtype, ret); + error = quota2_fetch_q2e(ump, qk, ret); return error; }