Source-Changes-HG archive

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

[src/trunk]: src/sys Move the top level iteration for QUOTACTL_SET from ufs t...



details:   https://anonhg.NetBSD.org/src/rev/199a8bb12f10
branches:  trunk
changeset: 773175:199a8bb12f10
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Jan 29 06:44:33 2012 +0000

description:
Move the top level iteration for QUOTACTL_SET from ufs to vfs_quotactl.

Note: this change requires a kernel version bump.

diffstat:

 sys/kern/vfs_quotactl.c |  63 ++++++++++++++++++++++++++++++++++++++++++-----
 sys/sys/quotactl.h      |   9 ++++++-
 sys/ufs/ufs/ufs_quota.c |  64 +++++++++++++-----------------------------------
 3 files changed, 81 insertions(+), 55 deletions(-)

diffs (216 lines):

diff -r ea9b037cc6ed -r 199a8bb12f10 sys/kern/vfs_quotactl.c
--- a/sys/kern/vfs_quotactl.c   Sun Jan 29 06:43:34 2012 +0000
+++ b/sys/kern/vfs_quotactl.c   Sun Jan 29 06:44:33 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_quotactl.c,v 1.10 2012/01/29 06:41:41 dholland Exp $       */
+/*     $NetBSD: vfs_quotactl.c,v 1.11 2012/01/29 06:44:33 dholland Exp $       */
 
 /*
  * Copyright (c) 1991, 1993, 1994
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.10 2012/01/29 06:41:41 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.11 2012/01/29 06:44:33 dholland Exp $");
 
 #include <sys/mount.h>
 #include <sys/quota.h>
@@ -303,13 +303,62 @@
                        prop_dictionary_t cmddict, int q2type,
                        prop_array_t datas)
 {
+       prop_array_t replies;
+       prop_object_iterator_t iter;
+       prop_dictionary_t data;
+       int defaultq;
+       uint32_t id;
+       const char *idstr;
        struct vfs_quotactl_args args;
+       int error;
+
+       KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
+       KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
+
+       replies = prop_array_create();
+       if (replies == NULL)
+               return ENOMEM;
+
+       iter = prop_array_iterator(datas);
+       if (iter == NULL) {
+               prop_object_release(replies);
+               return ENOMEM;
+       }
 
-       args.qc_type = QCT_PROPLIB;
-       args.u.proplib.qc_cmddict = cmddict;
-       args.u.proplib.qc_q2type = q2type;
-       args.u.proplib.qc_datas = datas;
-       return VFS_QUOTACTL(mp, QUOTACTL_SET, &args);
+       while ((data = prop_object_iterator_next(iter)) != NULL) {
+               if (!prop_dictionary_get_uint32(data, "id", &id)) {
+                       if (!prop_dictionary_get_cstring_nocopy(data, "id",
+                           &idstr))
+                               continue;
+                       if (strcmp(idstr, "default"))
+                               continue;
+                       id = 0;
+                       defaultq = 1;
+               } else {
+                       defaultq = 0;
+               }
+
+               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_data = data;
+               error = VFS_QUOTACTL(mp, QUOTACTL_SET, &args);
+               if (error) {
+                       goto err;
+               }
+       }
+       prop_object_iterator_release(iter);
+       if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) {
+               error = ENOMEM;
+       } else {
+               error = 0;
+       }
+       return error;
+err:
+       prop_object_iterator_release(iter);
+       prop_object_release(replies);
+       return error;
 }
 
 static int
diff -r ea9b037cc6ed -r 199a8bb12f10 sys/sys/quotactl.h
--- a/sys/sys/quotactl.h        Sun Jan 29 06:43:34 2012 +0000
+++ b/sys/sys/quotactl.h        Sun Jan 29 06:44:33 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: quotactl.h,v 1.8 2012/01/29 06:41:41 dholland Exp $    */
+/*     $NetBSD: quotactl.h,v 1.9 2012/01/29 06:44:33 dholland Exp $    */
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -51,6 +51,7 @@
        QCT_PROPLIB,    /* quotaon/off, get, set, getall, clear */
        QCT_GETVERSION, /* getversion */
        QCT_GET,        /* get */
+       QCT_SET,        /* set */
 };
 struct vfs_quotactl_args {
        enum vfs_quotactl_argtypes qc_type;
@@ -67,6 +68,12 @@
                        const struct quotakey *qc_key;
                        struct quotaval *qc_ret;
                } get;
+               struct {
+                       id_t qc_id;
+                       int qc_defaultq;
+                       int qc_q2type;
+                       prop_dictionary_t qc_data;
+               } set;
        } u;
 };
 
diff -r ea9b037cc6ed -r 199a8bb12f10 sys/ufs/ufs/ufs_quota.c
--- a/sys/ufs/ufs/ufs_quota.c   Sun Jan 29 06:43:34 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota.c   Sun Jan 29 06:44:33 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_quota.c,v 1.79 2012/01/29 06:42:14 dholland Exp $  */
+/*     $NetBSD: ufs_quota.c,v 1.80 2012/01/29 06:44:33 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.79 2012/01/29 06:42:14 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.80 2012/01/29 06:44:33 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -267,49 +267,26 @@
 quota_handle_cmd_set(struct mount *mp, struct lwp *l, 
     struct vfs_quotactl_args *args)
 {
-       prop_array_t replies;
-       prop_object_iterator_t iter;
-       prop_dictionary_t data;
-       uint32_t id;
        struct ufsmount *ump = VFSTOUFS(mp);
-       int error, defaultq = 0;
-       const char *idstr;
-       prop_dictionary_t cmddict;
+       id_t id;
+       int defaultq;
        int q2type;
-       prop_array_t datas;
+       prop_dictionary_t data;
+       int error;
 
-       KASSERT(args->qc_type == QCT_PROPLIB);
-       cmddict = args->u.proplib.qc_cmddict;
-       q2type = args->u.proplib.qc_q2type;
-       datas = args->u.proplib.qc_datas;
+       KASSERT(args->qc_type == QCT_SET);
+       id = args->u.set.qc_id;
+       defaultq = args->u.set.qc_defaultq;
+       q2type = args->u.set.qc_q2type;
+       data = args->u.set.qc_data;
 
-       KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
-       KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
+       KASSERT(prop_object_type(data) == PROP_TYPE_DICTIONARY);
 
        if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0)
                return EOPNOTSUPP;
-       
-       replies = prop_array_create();
-       if (replies == NULL)
-               return ENOMEM;
 
-       iter = prop_array_iterator(datas);
-       if (iter == NULL) {
-               prop_object_release(replies);
-               return ENOMEM;
-       }
-       while ((data = prop_object_iterator_next(iter)) != NULL) {
-               if (!prop_dictionary_get_uint32(data, "id", &id)) {
-                       if (!prop_dictionary_get_cstring_nocopy(data, "id",
-                           &idstr))
-                               continue;
-                       if (strcmp(idstr, "default"))
-                               continue;
-                       id = 0;
-                       defaultq = 1;
-               } else {
-                       defaultq = 0;
-               }
+       /* avoid whitespace changes */
+       {
                error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA,
                    KAUTH_REQ_SYSTEM_FS_QUOTA_MANAGE, mp, KAUTH_ARG(id), NULL);
                if (error != 0)
@@ -331,16 +308,9 @@
                if (error && error != ENOENT)
                        goto err;
        }
-       prop_object_iterator_release(iter);
-       if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) {
-               error = ENOMEM;
-       } else {
-               error = 0;
-       }
-       return error;
-err:
-       prop_object_iterator_release(iter);
-       prop_object_release(replies);
+
+       return 0;
+ err:
        return error;
 }
 



Home | Main Index | Thread Index | Old Index