Source-Changes-HG archive

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

[src/trunk]: src/sys Move first-layer proplib frobbing for QUOTACTL_GET to FS...



details:   https://anonhg.NetBSD.org/src/rev/7140b7fda492
branches:  trunk
changeset: 773168:7140b7fda492
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Jan 29 06:37:30 2012 +0000

description:
Move first-layer proplib frobbing for QUOTACTL_GET to FS-independent code.
(step 1 of several)

Note: this change requires a kernel version bump.

diffstat:

 sys/kern/vfs_quotactl.c |  75 ++++++++++++++++++++++++++++++++++++++++++++----
 sys/sys/quotactl.h      |   9 +++++-
 sys/ufs/ufs/ufs_quota.c |  71 +++++++++------------------------------------
 3 files changed, 91 insertions(+), 64 deletions(-)

diffs (238 lines):

diff -r 3d823e134ab7 -r 7140b7fda492 sys/kern/vfs_quotactl.c
--- a/sys/kern/vfs_quotactl.c   Sun Jan 29 06:36:50 2012 +0000
+++ b/sys/kern/vfs_quotactl.c   Sun Jan 29 06:37:30 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_quotactl.c,v 1.6 2012/01/29 06:36:50 dholland Exp $        */
+/*     $NetBSD: vfs_quotactl.c,v 1.7 2012/01/29 06:37:30 dholland Exp $        */
 
 /*
  * Copyright (c) 1991, 1993, 1994
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.6 2012/01/29 06:36:50 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.7 2012/01/29 06:37:30 dholland Exp $");
 
 #include <sys/mount.h>
 #include <sys/quotactl.h>
@@ -170,13 +170,74 @@
                        prop_dictionary_t cmddict, int q2type,
                        prop_array_t datas)
 {
+       prop_object_iterator_t iter;
+       prop_dictionary_t data;
+       uint32_t id;
+       int defaultq;
+       const char *idstr;
+       prop_array_t replies;
        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_GET, &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")) {
+                               error = EINVAL;
+                               goto fail;
+                       }
+                       id = 0;
+                       defaultq = 1;
+               } else {
+                       defaultq = 0;
+               }
+
+               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_replies = replies;
+               error = VFS_QUOTACTL(mp, QUOTACTL_GET, &args);
+               if (error == EPERM) {
+                       /* XXX does this make sense? */
+                       continue;
+               } else if (error == ENOENT) {
+                       /* XXX does *this* make sense? */
+                       continue;
+               } else if (error) {
+                       goto fail;
+               }
+       }
+
+       prop_object_iterator_release(iter);
+       if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) {
+               error = ENOMEM;
+       } else {
+               error = 0;
+       }
+
+       return error;
+
+ fail:
+       prop_object_iterator_release(iter);
+       prop_object_release(replies);
+       return error;
 }
 
 static int
diff -r 3d823e134ab7 -r 7140b7fda492 sys/sys/quotactl.h
--- a/sys/sys/quotactl.h        Sun Jan 29 06:36:50 2012 +0000
+++ b/sys/sys/quotactl.h        Sun Jan 29 06:37:30 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: quotactl.h,v 1.4 2012/01/29 06:36:50 dholland Exp $    */
+/*     $NetBSD: quotactl.h,v 1.5 2012/01/29 06:37:30 dholland Exp $    */
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -50,6 +50,7 @@
 enum vfs_quotactl_argtypes {
        QCT_PROPLIB,    /* quotaon/off, get, set, getall, clear */
        QCT_GETVERSION, /* getversion */
+       QCT_GET,        /* get */
 };
 struct vfs_quotactl_args {
        enum vfs_quotactl_argtypes qc_type;
@@ -62,6 +63,12 @@
                struct {
                        int *qc_version_ret;
                } getversion;
+               struct {
+                       int qc_q2type;
+                       id_t qc_id;
+                       int qc_defaultq;
+                       prop_array_t qc_replies;
+               } get;
        } u;
 };
 
diff -r 3d823e134ab7 -r 7140b7fda492 sys/ufs/ufs/ufs_quota.c
--- a/sys/ufs/ufs/ufs_quota.c   Sun Jan 29 06:36:50 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota.c   Sun Jan 29 06:37:30 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_quota.c,v 1.73 2012/01/29 06:36:51 dholland Exp $  */
+/*     $NetBSD: ufs_quota.c,v 1.74 2012/01/29 06:37:30 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.73 2012/01/29 06:36:51 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.74 2012/01/29 06:37:30 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -230,56 +230,26 @@
 quota_handle_cmd_get(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;
+       int error;
+       id_t id;
        int q2type;
-       prop_array_t datas;
+       int defaultq;
+       prop_array_t replies;
 
-       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(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
-       KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
+       KASSERT(args->qc_type == QCT_GET);
+       id = args->u.get.qc_id;
+       q2type = args->u.get.qc_q2type;
+       defaultq = args->u.get.qc_defaultq;
+       replies = args->u.get.qc_replies;
 
        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")) {
-                               error = EINVAL;
-                               goto err;
-                       }
-                       id = 0;
-                       defaultq = 1;
-               } else {
-                       defaultq = 0;
-               }
+       /* avoid whitespace diffs */ {
                error = quota_get_auth(mp, l, id);
-               if (error == EPERM)
-                       continue;
                if (error != 0) 
-                       goto err;
+                       return error;
 #ifdef QUOTA
                if (ump->um_flags & UFS_QUOTA)
                        error = quota1_handle_cmd_get(ump, q2type, id, defaultq,
@@ -294,21 +264,10 @@
 #endif
                        panic("quota_handle_cmd_get: no support ?");
                
-               if (error == ENOENT)
-                       continue;
                if (error != 0)
-                       goto err;
+                       return error;
        }
-       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;
 }
 



Home | Main Index | Thread Index | Old Index