Module Name: src Committed By: dholland Date: Sun Jan 29 06:36:51 UTC 2012
Modified Files: src/sys/kern: vfs_quotactl.c src/sys/sys: quotactl.h src/sys/ufs/ufs: ufs_quota.c Log Message: Move proplib frobbing for QUOTACTL_GETVERSION to FS-independent code. Note: this change requires a kernel version bump. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/kern/vfs_quotactl.c cvs rdiff -u -r1.3 -r1.4 src/sys/sys/quotactl.h cvs rdiff -u -r1.72 -r1.73 src/sys/ufs/ufs/ufs_quota.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/vfs_quotactl.c diff -u src/sys/kern/vfs_quotactl.c:1.5 src/sys/kern/vfs_quotactl.c:1.6 --- src/sys/kern/vfs_quotactl.c:1.5 Sun Jan 29 06:36:06 2012 +++ src/sys/kern/vfs_quotactl.c Sun Jan 29 06:36:50 2012 @@ -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 @@ vfs_quotactl_getversion(struct mount *mp 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; - 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); + 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; + } + + 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 Index: src/sys/sys/quotactl.h diff -u src/sys/sys/quotactl.h:1.3 src/sys/sys/quotactl.h:1.4 --- src/sys/sys/quotactl.h:1.3 Sun Jan 29 06:36:06 2012 +++ src/sys/sys/quotactl.h Sun Jan 29 06:36:50 2012 @@ -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 @@ struct vfs_quotactl_args { int qc_q2type; prop_array_t qc_datas; } proplib; + struct { + int *qc_version_ret; + } getversion; } u; }; Index: src/sys/ufs/ufs/ufs_quota.c diff -u src/sys/ufs/ufs/ufs_quota.c:1.72 src/sys/ufs/ufs/ufs_quota.c:1.73 --- src/sys/ufs/ufs/ufs_quota.c:1.72 Sun Jan 29 06:36:07 2012 +++ src/sys/ufs/ufs/ufs_quota.c Sun Jan 29 06:36:51 2012 @@ -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 @@ quota_handle_cmd_get_version(struct moun 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 ? */