Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Change dqblk_to_quotaval() from quota1_subr.c to dqblk_to_qu...



details:   https://anonhg.NetBSD.org/src/rev/a4af37644762
branches:  trunk
changeset: 773160:a4af37644762
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Jan 29 06:23:20 2012 +0000

description:
Change dqblk_to_quotaval() from quota1_subr.c to dqblk_to_quotavals(),
and pass in two single quotaval structs (for blocks and inodes)
instead of an array of (implicitly) QUOTA_NLIMITS quotaval structs
indexed by constants from quotaprop.h.

Note: because this code is used by COMPAT_50 as well as ufs, this
change requires a kernel version bump. (The code is also used by
edquota, but via .PATH so it's not ABI-sensitive there.)

diffstat:

 sys/compat/common/vfs_syscalls_50.c |  11 +++++--
 sys/ufs/ufs/quota1.h                |   9 +++--
 sys/ufs/ufs/quota1_subr.c           |  51 +++++++++++++++---------------------
 sys/ufs/ufs/ufs_quota1.c            |   7 ++--
 usr.sbin/edquota/edquota.c          |  12 +++++--
 5 files changed, 46 insertions(+), 44 deletions(-)

diffs (216 lines):

diff -r bc4583c401f6 -r a4af37644762 sys/compat/common/vfs_syscalls_50.c
--- a/sys/compat/common/vfs_syscalls_50.c       Sun Jan 29 06:22:01 2012 +0000
+++ b/sys/compat/common/vfs_syscalls_50.c       Sun Jan 29 06:23:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls_50.c,v 1.10 2011/11/25 16:55:05 dholland Exp $    */
+/*     $NetBSD: vfs_syscalls_50.c,v 1.11 2012/01/29 06:23:20 dholland Exp $    */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_50.c,v 1.10 2011/11/25 16:55:05 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_50.c,v 1.11 2012/01/29 06:23:20 dholland Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -452,7 +452,9 @@
                    ufs_quota_limit_names, QUOTA_NLIMITS);
                if (error)
                        goto out_dict;
-               quotaval_to_dqblk(qv, &dqblk);
+               quotavals_to_dqblk(&qv[QUOTA_LIMIT_BLOCK],
+                                  &qv[QUOTA_LIMIT_FILE],
+                                  &dqblk);
                error = copyout(&dqblk, SCARG(uap, arg), sizeof(dqblk));
                goto out_dict;
                
@@ -460,7 +462,8 @@
                error = copyin(SCARG(uap, arg), &dqblk, sizeof(dqblk));
                if (error)
                        goto out_datas;
-               dqblk_to_quotaval(&dqblk, qv);
+               dqblk_to_quotavals(&dqblk, &qv[QUOTA_LIMIT_BLOCK],
+                                  &qv[QUOTA_LIMIT_FILE]);
 
                error = ENOMEM;
                data = quota64toprop(SCARG(uap, uid), 0, values,
diff -r bc4583c401f6 -r a4af37644762 sys/ufs/ufs/quota1.h
--- a/sys/ufs/ufs/quota1.h      Sun Jan 29 06:22:01 2012 +0000
+++ b/sys/ufs/ufs/quota1.h      Sun Jan 29 06:23:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: quota1.h,v 1.5 2011/11/25 16:55:05 dholland Exp $      */
+/*     $NetBSD: quota1.h,v 1.6 2012/01/29 06:23:20 dholland Exp $      */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -104,8 +104,9 @@
 };
 
 /* quota1_subr.c */
-struct quota2_entry;
-void dqblk_to_quotaval(const struct dqblk *, struct quotaval *);
-void quotaval_to_dqblk(const struct quotaval *, struct dqblk *);
+void dqblk_to_quotavals(const struct dqblk *,
+                       struct quotaval *, struct quotaval *);
+void quotavals_to_dqblk(const struct quotaval *, const struct quotaval *,
+                       struct dqblk *);
 
 #endif /* !_UFS_UFS_QUOTA1_H_ */
diff -r bc4583c401f6 -r a4af37644762 sys/ufs/ufs/quota1_subr.c
--- a/sys/ufs/ufs/quota1_subr.c Sun Jan 29 06:22:01 2012 +0000
+++ b/sys/ufs/ufs/quota1_subr.c Sun Jan 29 06:23:20 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: quota1_subr.c,v 1.6 2011/11/25 16:55:05 dholland Exp $ */
+/* $NetBSD: quota1_subr.c,v 1.7 2012/01/29 06:23:20 dholland Exp $ */
 /*-
   * Copyright (c) 2010 Manuel Bouyer
   * All rights reserved.
@@ -26,13 +26,12 @@
   */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: quota1_subr.c,v 1.6 2011/11/25 16:55:05 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: quota1_subr.c,v 1.7 2012/01/29 06:23:20 dholland Exp $");
 
 #include <sys/types.h>
 #include <machine/limits.h>
 
 #include <sys/quota.h>
-#include <quota/quotaprop.h>
 #include <ufs/ufs/quota1.h>
 
 static uint64_t
@@ -54,42 +53,36 @@
 }
 
 void
-dqblk_to_quotaval(const struct dqblk *dqblk, struct quotaval *qv)
+dqblk_to_quotavals(const struct dqblk *dqblk,
+                  struct quotaval *blocks, struct quotaval *files)
 {
        /* XXX is qv_grace getting handled correctly? */
 
-       qv[QUOTA_LIMIT_BLOCK].qv_hardlimit =
-           dqblk2q2e_limit(dqblk->dqb_bhardlimit);
-       qv[QUOTA_LIMIT_BLOCK].qv_softlimit =
-           dqblk2q2e_limit(dqblk->dqb_bsoftlimit);
-       qv[QUOTA_LIMIT_BLOCK].qv_usage       = dqblk->dqb_curblocks;
-       qv[QUOTA_LIMIT_BLOCK].qv_expiretime      = dqblk->dqb_btime;
+       blocks->qv_hardlimit  = dqblk2q2e_limit(dqblk->dqb_bhardlimit);
+       blocks->qv_softlimit  = dqblk2q2e_limit(dqblk->dqb_bsoftlimit);
+       blocks->qv_usage      = dqblk->dqb_curblocks;
+       blocks->qv_expiretime = dqblk->dqb_btime;
 
-       qv[QUOTA_LIMIT_FILE].qv_hardlimit =
-           dqblk2q2e_limit(dqblk->dqb_ihardlimit);
-       qv[QUOTA_LIMIT_FILE].qv_softlimit =
-           dqblk2q2e_limit(dqblk->dqb_isoftlimit);
-       qv[QUOTA_LIMIT_FILE].qv_usage       = dqblk->dqb_curinodes;
-       qv[QUOTA_LIMIT_FILE].qv_expiretime      = dqblk->dqb_itime;
+       files->qv_hardlimit  = dqblk2q2e_limit(dqblk->dqb_ihardlimit);
+       files->qv_softlimit  = dqblk2q2e_limit(dqblk->dqb_isoftlimit);
+       files->qv_usage      = dqblk->dqb_curinodes;
+       files->qv_expiretime = dqblk->dqb_itime;
 }
 
 void
-quotaval_to_dqblk(const struct quotaval *qv, struct dqblk *dqblk)
+quotavals_to_dqblk(const struct quotaval *blocks, const struct quotaval *files,
+                  struct dqblk *dqblk)
 {
        /* XXX is qv_grace getting handled correctly? */
 
-       dqblk->dqb_bhardlimit =
-           q2e2dqblk_limit(qv[QUOTA_LIMIT_BLOCK].qv_hardlimit);
-       dqblk->dqb_bsoftlimit =
-           q2e2dqblk_limit(qv[QUOTA_LIMIT_BLOCK].qv_softlimit);
-       dqblk->dqb_curblocks  = qv[QUOTA_LIMIT_BLOCK].qv_usage;
-       dqblk->dqb_btime      = qv[QUOTA_LIMIT_BLOCK].qv_expiretime;
+       dqblk->dqb_bhardlimit = q2e2dqblk_limit(blocks->qv_hardlimit);
+       dqblk->dqb_bsoftlimit = q2e2dqblk_limit(blocks->qv_softlimit);
+       dqblk->dqb_curblocks  = blocks->qv_usage;
+       dqblk->dqb_btime      = blocks->qv_expiretime;
 
-       dqblk->dqb_ihardlimit =
-           q2e2dqblk_limit(qv[QUOTA_LIMIT_FILE].qv_hardlimit);
-       dqblk->dqb_isoftlimit =
-           q2e2dqblk_limit(qv[QUOTA_LIMIT_FILE].qv_softlimit);
-       dqblk->dqb_curinodes  = qv[QUOTA_LIMIT_FILE].qv_usage;
-       dqblk->dqb_itime      = qv[QUOTA_LIMIT_FILE].qv_expiretime;
+       dqblk->dqb_ihardlimit = q2e2dqblk_limit(files->qv_hardlimit);
+       dqblk->dqb_isoftlimit = q2e2dqblk_limit(files->qv_softlimit);
+       dqblk->dqb_curinodes  = files->qv_usage;
+       dqblk->dqb_itime      = files->qv_expiretime;
 }
 
diff -r bc4583c401f6 -r a4af37644762 sys/ufs/ufs/ufs_quota1.c
--- a/sys/ufs/ufs/ufs_quota1.c  Sun Jan 29 06:22:01 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota1.c  Sun Jan 29 06:23:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_quota1.c,v 1.6 2011/11/25 16:55:05 dholland Exp $  */
+/*     $NetBSD: ufs_quota1.c,v 1.7 2012/01/29 06:23:20 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.6 2011/11/25 16:55:05 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.7 2012/01/29 06:23:20 dholland Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -516,7 +516,8 @@
                if ((error = dqget(NULLVP, id, ump, type, &dq)) != 0)
                        return error;
        }
-       dqblk_to_quotaval(&dq->dq_un.dq1_dqb, qv);
+       dqblk_to_quotavals(&dq->dq_un.dq1_dqb,
+                          &qv[QUOTA_LIMIT_BLOCK], &qv[QUOTA_LIMIT_FILE]);
        dqrele(NULLVP, dq);
        if (defaultq) {
                if (qv[QUOTA_LIMIT_BLOCK].qv_expiretime > 0)
diff -r bc4583c401f6 -r a4af37644762 usr.sbin/edquota/edquota.c
--- a/usr.sbin/edquota/edquota.c        Sun Jan 29 06:22:01 2012 +0000
+++ b/usr.sbin/edquota/edquota.c        Sun Jan 29 06:23:20 2012 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: edquota.c,v 1.41 2012/01/09 15:44:42 dholland Exp $ */
+/*      $NetBSD: edquota.c,v 1.42 2012/01/29 06:23:20 dholland Exp $ */
 /*
  * Copyright (c) 1980, 1990, 1993
  *     The Regents of the University of California.  All rights reserved.
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "from: @(#)edquota.c    8.3 (Berkeley) 4/27/95";
 #else
-__RCSID("$NetBSD: edquota.c,v 1.41 2012/01/09 15:44:42 dholland Exp $");
+__RCSID("$NetBSD: edquota.c,v 1.42 2012/01/29 06:23:20 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -249,7 +249,9 @@
        struct dqblk dqblk;
        int fd;
 
-       quotaval_to_dqblk(qup->qv, &dqblk);
+       quotavals_to_dqblk(&qup->qv[QUOTA_LIMIT_BLOCK],
+                          &qup->qv[QUOTA_LIMIT_FILE],
+                          &dqblk);
        assert((qup->flags & DEFAULT) == 0);
 
        if ((fd = open(qup->qfname, O_WRONLY)) < 0) {
@@ -327,7 +329,9 @@
        close(fd);
        qup->qfname = qfpathname;
        endfsent();
-       dqblk_to_quotaval(&dqblk, qup->qv);
+       dqblk_to_quotavals(&dqblk,
+                          &qup->qv[QUOTA_LIMIT_BLOCK],
+                          &qup->qv[QUOTA_LIMIT_FILE]);
        return qup;
 }
 



Home | Main Index | Thread Index | Old Index