Module Name: src Committed By: dholland Date: Sun Jan 29 06:44:33 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 the top level iteration for QUOTACTL_SET from ufs to vfs_quotactl. Note: this change requires a kernel version bump. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/kern/vfs_quotactl.c cvs rdiff -u -r1.8 -r1.9 src/sys/sys/quotactl.h cvs rdiff -u -r1.79 -r1.80 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.10 src/sys/kern/vfs_quotactl.c:1.11 --- src/sys/kern/vfs_quotactl.c:1.10 Sun Jan 29 06:41:41 2012 +++ src/sys/kern/vfs_quotactl.c Sun Jan 29 06:44:33 2012 @@ -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 @@ vfs_quotactl_set(struct mount *mp, 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; - 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); + 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; + } + + 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 Index: src/sys/sys/quotactl.h diff -u src/sys/sys/quotactl.h:1.8 src/sys/sys/quotactl.h:1.9 --- src/sys/sys/quotactl.h:1.8 Sun Jan 29 06:41:41 2012 +++ src/sys/sys/quotactl.h Sun Jan 29 06:44:33 2012 @@ -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 @@ enum vfs_quotactl_argtypes { 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 @@ struct vfs_quotactl_args { 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; }; Index: src/sys/ufs/ufs/ufs_quota.c diff -u src/sys/ufs/ufs/ufs_quota.c:1.79 src/sys/ufs/ufs/ufs_quota.c:1.80 --- src/sys/ufs/ufs/ufs_quota.c:1.79 Sun Jan 29 06:42:14 2012 +++ src/sys/ufs/ufs/ufs_quota.c Sun Jan 29 06:44:33 2012 @@ -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 @@ static int 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 @@ quota_handle_cmd_set(struct mount *mp, s 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; }