Source-Changes-HG archive

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

[src/trunk]: src/sys Move proplib frobbing for QUOTACTL_GETVERSION to FS-inde...



details:   https://anonhg.NetBSD.org/src/rev/3d823e134ab7
branches:  trunk
changeset: 773167:3d823e134ab7
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Jan 29 06:36:50 2012 +0000

description:
Move proplib frobbing for QUOTACTL_GETVERSION to FS-independent code.

Note: this change requires a kernel version bump.

diffstat:

 sys/kern/vfs_quotactl.c |  51 ++++++++++++++++++++++++++++++++++++++++++------
 sys/sys/quotactl.h      |   8 +++++-
 sys/ufs/ufs/ufs_quota.c |  48 +++++++++------------------------------------
 3 files changed, 60 insertions(+), 47 deletions(-)

diffs (185 lines):

diff -r fe73a76c06b0 -r 3d823e134ab7 sys/kern/vfs_quotactl.c
--- a/sys/kern/vfs_quotactl.c   Sun Jan 29 06:36:06 2012 +0000
+++ b/sys/kern/vfs_quotactl.c   Sun Jan 29 06:36:50 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_quotactl.c,v 1.5 2012/01/29 06:36:06 dholland Exp $        */
+/*     $NetBSD: vfs_quotactl.c,v 1.6 2012/01/29 06:36:50 dholland Exp $        */
 
 /*
  * Copyright (c) 1991, 1993, 1994
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.5 2012/01/29 06:36:06 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.6 2012/01/29 06:36:50 dholland Exp $");
 
 #include <sys/mount.h>
 #include <sys/quotactl.h>
@@ -91,13 +91,50 @@
                        prop_dictionary_t cmddict, int q2type,
                        prop_array_t datas)
 {
+       prop_array_t replies;
+       prop_dictionary_t data;
+       int q2version;
        struct vfs_quotactl_args args;
+       int error;
+
+       KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
+       KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
+
+       args.qc_type = QCT_GETVERSION;
+       args.u.getversion.qc_version_ret = &q2version;
+       error = VFS_QUOTACTL(mp, QUOTACTL_GETVERSION, &args);
+       if (error) {
+               return error;
+       }
+
+       data = prop_dictionary_create();
+       if (data == NULL) {
+               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_GETVERSION, &args);
+       if (!prop_dictionary_set_int8(data, "version", q2version)) {
+               prop_object_release(data);
+               return ENOMEM;
+       }
+
+       replies = prop_array_create();
+       if (replies == NULL) {
+               prop_object_release(data);
+               return ENOMEM;
+       }
+
+       if (!prop_array_add_and_rel(replies, data)) {
+               prop_object_release(data);
+               prop_object_release(replies);
+               return ENOMEM;
+       }
+
+       if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) {
+               prop_object_release(replies);
+               return ENOMEM;
+       }
+
+       return error;
 }
 
 static int
diff -r fe73a76c06b0 -r 3d823e134ab7 sys/sys/quotactl.h
--- a/sys/sys/quotactl.h        Sun Jan 29 06:36:06 2012 +0000
+++ b/sys/sys/quotactl.h        Sun Jan 29 06:36:50 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: quotactl.h,v 1.3 2012/01/29 06:36:06 dholland Exp $    */
+/*     $NetBSD: quotactl.h,v 1.4 2012/01/29 06:36:50 dholland Exp $    */
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -48,7 +48,8 @@
 
 /* Argument encoding. */
 enum vfs_quotactl_argtypes {
-       QCT_PROPLIB,    /* getversion, quotaon/off, get, set, getall, clear */
+       QCT_PROPLIB,    /* quotaon/off, get, set, getall, clear */
+       QCT_GETVERSION, /* getversion */
 };
 struct vfs_quotactl_args {
        enum vfs_quotactl_argtypes qc_type;
@@ -58,6 +59,9 @@
                        int qc_q2type;
                        prop_array_t qc_datas;
                } proplib;
+               struct {
+                       int *qc_version_ret;
+               } getversion;
        } u;
 };
 
diff -r fe73a76c06b0 -r 3d823e134ab7 sys/ufs/ufs/ufs_quota.c
--- a/sys/ufs/ufs/ufs_quota.c   Sun Jan 29 06:36:06 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota.c   Sun Jan 29 06:36:50 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_quota.c,v 1.72 2012/01/29 06:36:07 dholland Exp $  */
+/*     $NetBSD: ufs_quota.c,v 1.73 2012/01/29 06:36:51 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.72 2012/01/29 06:36:07 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.73 2012/01/29 06:36:51 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -193,55 +193,27 @@
     struct vfs_quotactl_args *args)
 {
        struct ufsmount *ump = VFSTOUFS(mp);
-       prop_array_t replies;
-       prop_dictionary_t data;
-       int error = 0;
-       prop_dictionary_t cmddict;
-       prop_array_t datas;
+       int *version_ret;
 
-       KASSERT(args->qc_type == QCT_PROPLIB);
-       cmddict = args->u.proplib.qc_cmddict;
-       /* qc_q2type not used */
-       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_GETVERSION);
+       version_ret = args->u.getversion.qc_version_ret;
 
        if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0)
                return EOPNOTSUPP;
 
-       replies = prop_array_create();
-       if (replies == NULL)
-               return ENOMEM;
-
-       data = prop_dictionary_create();
-       if (data == NULL) {
-               prop_object_release(replies);
-               return ENOMEM;
-       }
-
 #ifdef QUOTA
        if (ump->um_flags & UFS_QUOTA) {
-               if (!prop_dictionary_set_int8(data, "version", 1))
-                       error = ENOMEM;
+               *version_ret = 1;
        } else
 #endif
 #ifdef QUOTA2
        if (ump->um_flags & UFS_QUOTA2) {
-               if (!prop_dictionary_set_int8(data, "version", 2))
-                       error = ENOMEM;
+               *version_ret = 2;
        } else
 #endif
-               error = 0;
-       if (error)
-               prop_object_release(data);
-       else if (!prop_array_add_and_rel(replies, data))
-               error = ENOMEM;
-       if (error)
-               prop_object_release(replies);
-       else if (!prop_dictionary_set_and_rel(cmddict, "data", replies))
-               error = ENOMEM;
-       return error;
+               return EOPNOTSUPP;
+
+       return 0;
 }
 
 /* XXX shouldn't all this be in kauth ? */



Home | Main Index | Thread Index | Old Index