Source-Changes-HG archive

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

[src/trunk]: src/sys Provide quota info to QUOTACTL_SET as two struct quotava...



details:   https://anonhg.NetBSD.org/src/rev/3dd4a8730640
branches:  trunk
changeset: 773176:3dd4a8730640
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Jan 29 06:45:25 2012 +0000

description:
Provide quota info to QUOTACTL_SET as two struct quotaval points
as well as via proplib.

Note: this change requires a kernel version bump.

diffstat:

 sys/kern/vfs_quotactl.c  |  64 ++++++++++++++++++++++++++++++++++++++++++++++-
 sys/sys/quotactl.h       |   4 ++-
 sys/ufs/ufs/ufs_quota1.c |   5 ++-
 3 files changed, 68 insertions(+), 5 deletions(-)

diffs (147 lines):

diff -r 199a8bb12f10 -r 3dd4a8730640 sys/kern/vfs_quotactl.c
--- a/sys/kern/vfs_quotactl.c   Sun Jan 29 06:44:33 2012 +0000
+++ b/sys/kern/vfs_quotactl.c   Sun Jan 29 06:45:25 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_quotactl.c,v 1.11 2012/01/29 06:44:33 dholland Exp $       */
+/*     $NetBSD: vfs_quotactl.c,v 1.12 2012/01/29 06:45:25 dholland Exp $       */
 
 /*
  * Copyright (c) 1991, 1993, 1994
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.11 2012/01/29 06:44:33 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.12 2012/01/29 06:45:25 dholland Exp $");
 
 #include <sys/mount.h>
 #include <sys/quota.h>
@@ -299,6 +299,58 @@
 }
 
 static int
+vfs_quotactl_set_extractinfo(prop_dictionary_t data,
+                       struct quotaval *blocks, struct quotaval *files)
+{
+       /*
+        * So, the way proptoquota64 works is that you pass it an
+        * array of pointers to uint64. Each of these pointers is
+        * supposed to point to 5 (UFS_QUOTA_NENTRIES) uint64s. This
+        * array of pointers is the second argument. The third and
+        * forth argument are the names of the five values to extract,
+        * and UFS_QUOTA_NENTRIES. The last two arguments are the
+        * names assocated with the pointers (QUOTATYPE_LDICT_BLOCK,
+        * QUOTADICT_LTYPE_FILE) and the number of pointers. Most of
+        * the existing code was unsafely casting struct quotaval
+        * (formerly struct ufs_quota_entry) to (uint64_t *) and using
+        * that as the block of 5 uint64s. Or worse, pointing to
+        * subregions of that and reducing the number of uint64s to
+        * pull "adjacent" values. Demons fly out of your nose!
+        */
+
+       uint64_t bvals[UFS_QUOTA_NENTRIES];
+       uint64_t fvals[UFS_QUOTA_NENTRIES];
+       uint64_t *valptrs[QUOTA_NLIMITS];
+       int error;
+
+       valptrs[QUOTA_LIMIT_BLOCK] = bvals;
+       valptrs[QUOTA_LIMIT_FILE] = fvals;
+       error = proptoquota64(data, valptrs,
+                             ufs_quota_entry_names, UFS_QUOTA_NENTRIES,
+                             ufs_quota_limit_names, QUOTA_NLIMITS);
+       if (error) {
+               return error;
+       }
+
+       /*
+        * There are no symbolic constants for these indexes!
+        */
+
+       blocks->qv_hardlimit = bvals[0];
+       blocks->qv_softlimit = bvals[1];
+       blocks->qv_usage = bvals[2];
+       blocks->qv_expiretime = bvals[3];
+       blocks->qv_grace = bvals[4];
+       files->qv_hardlimit = fvals[0];
+       files->qv_softlimit = fvals[1];
+       files->qv_usage = fvals[2];
+       files->qv_expiretime = fvals[3];
+       files->qv_grace = fvals[4];
+
+       return 0;
+}
+
+static int
 vfs_quotactl_set(struct mount *mp,
                        prop_dictionary_t cmddict, int q2type,
                        prop_array_t datas)
@@ -309,6 +361,7 @@
        int defaultq;
        uint32_t id;
        const char *idstr;
+       struct quotaval blocks, files;
        struct vfs_quotactl_args args;
        int error;
 
@@ -338,10 +391,17 @@
                        defaultq = 0;
                }
 
+               error = vfs_quotactl_set_extractinfo(data, &blocks, &files);
+               if (error) {
+                       goto err;
+               }
+
                args.qc_type = QCT_SET;
                args.u.set.qc_id = id;
                args.u.set.qc_defaultq = defaultq;
                args.u.set.qc_q2type = q2type;
+               args.u.set.qc_blocks = &blocks;
+               args.u.set.qc_files = &files;
                args.u.set.qc_data = data;
                error = VFS_QUOTACTL(mp, QUOTACTL_SET, &args);
                if (error) {
diff -r 199a8bb12f10 -r 3dd4a8730640 sys/sys/quotactl.h
--- a/sys/sys/quotactl.h        Sun Jan 29 06:44:33 2012 +0000
+++ b/sys/sys/quotactl.h        Sun Jan 29 06:45:25 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: quotactl.h,v 1.9 2012/01/29 06:44:33 dholland Exp $    */
+/*     $NetBSD: quotactl.h,v 1.10 2012/01/29 06:45:26 dholland Exp $   */
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -72,6 +72,8 @@
                        id_t qc_id;
                        int qc_defaultq;
                        int qc_q2type;
+                       const struct quotaval *qc_blocks;
+                       const struct quotaval *qc_files;
                        prop_dictionary_t qc_data;
                } set;
        } u;
diff -r 199a8bb12f10 -r 3dd4a8730640 sys/ufs/ufs/ufs_quota1.c
--- a/sys/ufs/ufs/ufs_quota1.c  Sun Jan 29 06:44:33 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota1.c  Sun Jan 29 06:45:25 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_quota1.c,v 1.10 2012/01/29 06:41:42 dholland Exp $ */
+/*     $NetBSD: ufs_quota1.c,v 1.11 2012/01/29 06:45:26 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.10 2012/01/29 06:41:42 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.11 2012/01/29 06:45:26 dholland Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -568,6 +568,7 @@
 
        if (defaultq) {
                /* just update grace times */
+               KASSERT(id == 0);
                error = proptoquota64(data, valuesp, val_limitsonly_grace, 1,
                    ufs_quota_limit_names, QUOTA_NLIMITS);
                if (error)



Home | Main Index | Thread Index | Old Index