Module Name: src Committed By: dholland Date: Sun Jan 29 06:39:37 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 what was second-layer proplib frobbing for QUOTACTL_GET to FS-independent code. (Step 3 of probably 5 for QUOTACTL_GET.) Note: this change requires a kernel version bump. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/kern/vfs_quotactl.c cvs rdiff -u -r1.5 -r1.6 src/sys/sys/quotactl.h cvs rdiff -u -r1.75 -r1.76 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.7 src/sys/kern/vfs_quotactl.c:1.8 --- src/sys/kern/vfs_quotactl.c:1.7 Sun Jan 29 06:37:30 2012 +++ src/sys/kern/vfs_quotactl.c Sun Jan 29 06:39:36 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_quotactl.c,v 1.7 2012/01/29 06:37:30 dholland Exp $ */ +/* $NetBSD: vfs_quotactl.c,v 1.8 2012/01/29 06:39:36 dholland Exp $ */ /* * Copyright (c) 1991, 1993, 1994 @@ -80,9 +80,10 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.7 2012/01/29 06:37:30 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.8 2012/01/29 06:39:36 dholland Exp $"); #include <sys/mount.h> +#include <sys/quota.h> #include <sys/quotactl.h> #include <quota/quotaprop.h> @@ -166,17 +167,45 @@ vfs_quotactl_quotaoff(struct mount *mp, } static int +vfs_quotactl_get_addreply(id_t id, + int defaultq, + const struct quotaval *blocks, + const struct quotaval *files, + prop_array_t replies) +{ + prop_dictionary_t dict; + + /* XXX illegal casts */ + uint64_t *valuesp[QUOTA_NLIMITS]; + valuesp[QUOTA_LIMIT_BLOCK] = (void *)(intptr_t)&blocks->qv_hardlimit; + valuesp[QUOTA_LIMIT_FILE] = (void *)(intptr_t)&files->qv_hardlimit; + + dict = quota64toprop(id, defaultq, valuesp, + ufs_quota_entry_names, UFS_QUOTA_NENTRIES, + ufs_quota_limit_names, QUOTA_NLIMITS); + if (dict == NULL) + return ENOMEM; + if (!prop_array_add_and_rel(replies, dict)) { + prop_object_release(dict); + return ENOMEM; + } + + return 0; +} + +static int vfs_quotactl_get(struct mount *mp, prop_dictionary_t cmddict, int q2type, prop_array_t datas) { prop_object_iterator_t iter; prop_dictionary_t data; + prop_array_t replies; uint32_t id; int defaultq; const char *idstr; - prop_array_t replies; struct vfs_quotactl_args args; + struct quotaval blocks, files; int error; KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY); @@ -212,7 +241,8 @@ vfs_quotactl_get(struct mount *mp, args.u.get.qc_q2type = q2type; args.u.get.qc_id = id; args.u.get.qc_defaultq = defaultq; - args.u.get.qc_replies = replies; + args.u.get.qc_blocks_ret = &blocks; + args.u.get.qc_files_ret = &files; error = VFS_QUOTACTL(mp, QUOTACTL_GET, &args); if (error == EPERM) { /* XXX does this make sense? */ @@ -223,6 +253,10 @@ vfs_quotactl_get(struct mount *mp, } else if (error) { goto fail; } + + error = vfs_quotactl_get_addreply(id, defaultq, + &blocks, &files, + replies); } prop_object_iterator_release(iter); Index: src/sys/sys/quotactl.h diff -u src/sys/sys/quotactl.h:1.5 src/sys/sys/quotactl.h:1.6 --- src/sys/sys/quotactl.h:1.5 Sun Jan 29 06:37:30 2012 +++ src/sys/sys/quotactl.h Sun Jan 29 06:39:36 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: quotactl.h,v 1.5 2012/01/29 06:37:30 dholland Exp $ */ +/* $NetBSD: quotactl.h,v 1.6 2012/01/29 06:39:36 dholland Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -67,7 +67,8 @@ struct vfs_quotactl_args { int qc_q2type; id_t qc_id; int qc_defaultq; - prop_array_t qc_replies; + struct quotaval *qc_blocks_ret; + struct quotaval *qc_files_ret; } get; } u; }; Index: src/sys/ufs/ufs/ufs_quota.c diff -u src/sys/ufs/ufs/ufs_quota.c:1.75 src/sys/ufs/ufs/ufs_quota.c:1.76 --- src/sys/ufs/ufs/ufs_quota.c:1.75 Sun Jan 29 06:38:24 2012 +++ src/sys/ufs/ufs/ufs_quota.c Sun Jan 29 06:39:37 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_quota.c,v 1.75 2012/01/29 06:38:24 dholland Exp $ */ +/* $NetBSD: ufs_quota.c,v 1.76 2012/01/29 06:39:37 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.75 2012/01/29 06:38:24 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.76 2012/01/29 06:39:37 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -226,33 +226,6 @@ quota_get_auth(struct mount *mp, struct KAUTH_REQ_SYSTEM_FS_QUOTA_GET, mp, KAUTH_ARG(id), NULL); } -static int -quota_fill_cmd_get_reply(id_t id, - int defaultq, - const struct quotaval *blocks, - const struct quotaval *files, - prop_array_t replies) -{ - prop_dictionary_t dict; - - /* XXX illegal casts */ - uint64_t *valuesp[QUOTA_NLIMITS]; - valuesp[QUOTA_LIMIT_BLOCK] = (void *)(intptr_t)&blocks->qv_hardlimit; - valuesp[QUOTA_LIMIT_FILE] = (void *)(intptr_t)&files->qv_hardlimit; - - dict = quota64toprop(id, defaultq, valuesp, - ufs_quota_entry_names, UFS_QUOTA_NENTRIES, - ufs_quota_limit_names, QUOTA_NLIMITS); - if (dict == NULL) - return ENOMEM; - if (!prop_array_add_and_rel(replies, dict)) { - prop_object_release(dict); - return ENOMEM; - } - - return 0; -} - static int quota_handle_cmd_get(struct mount *mp, struct lwp *l, struct vfs_quotactl_args *args) @@ -262,14 +235,14 @@ quota_handle_cmd_get(struct mount *mp, s id_t id; int q2type; int defaultq; - prop_array_t replies; - struct quotaval blocks, files; + struct quotaval *blocks, *files; 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; + blocks = args->u.get.qc_blocks_ret; + files = args->u.get.qc_files_ret; if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0) return EOPNOTSUPP; @@ -281,23 +254,19 @@ quota_handle_cmd_get(struct mount *mp, s #ifdef QUOTA if (ump->um_flags & UFS_QUOTA) { error = quota1_handle_cmd_get(ump, q2type, id, defaultq, - &blocks, &files); + blocks, files); } else #endif #ifdef QUOTA2 if (ump->um_flags & UFS_QUOTA2) { error = quota2_handle_cmd_get(ump, q2type, id, defaultq, - &blocks, &files); + blocks, files); } else #endif panic("quota_handle_cmd_get: no support ?"); if (error != 0) return error; - - error = quota_fill_cmd_get_reply(id, defaultq, - &blocks, &files, - replies); } return error;