Module Name: src Committed By: dholland Date: Sun Jan 29 07:11:12 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 proplib bits for QUOTACTL_QUOTAON out of the ufs code. This change requires a kernel version bump. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/kern/vfs_quotactl.c cvs rdiff -u -r1.26 -r1.27 src/sys/sys/quotactl.h cvs rdiff -u -r1.98 -r1.99 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.30 src/sys/kern/vfs_quotactl.c:1.31 --- src/sys/kern/vfs_quotactl.c:1.30 Sun Jan 29 07:10:24 2012 +++ src/sys/kern/vfs_quotactl.c Sun Jan 29 07:11:12 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_quotactl.c,v 1.30 2012/01/29 07:10:24 dholland Exp $ */ +/* $NetBSD: vfs_quotactl.c,v 1.31 2012/01/29 07:11:12 dholland Exp $ */ /* * Copyright (c) 1991, 1993, 1994 @@ -80,7 +80,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.30 2012/01/29 07:10:24 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.31 2012/01/29 07:11:12 dholland Exp $"); #include <sys/malloc.h> /* XXX: temporary */ #include <sys/mount.h> @@ -144,12 +144,26 @@ vfs_quotactl_quotaon(struct mount *mp, prop_dictionary_t cmddict, int q2type, prop_array_t datas) { + prop_dictionary_t data; + const char *qfile; struct vfs_quotactl_args args; - args.qc_type = QCT_PROPLIB; - args.u.proplib.qc_cmddict = cmddict; - args.u.proplib.qc_q2type = q2type; - args.u.proplib.qc_datas = datas; + KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY); + KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY); + + if (prop_array_count(datas) != 1) + return EINVAL; + + data = prop_array_get(datas, 0); + if (data == NULL) + return ENOMEM; + if (!prop_dictionary_get_cstring_nocopy(data, "quotafile", + &qfile)) + return EINVAL; + + args.qc_type = QCT_QUOTAON; + args.u.quotaon.qc_idtype = q2type; + args.u.quotaon.qc_quotafile = qfile; return VFS_QUOTACTL(mp, QUOTACTL_QUOTAON, &args); } Index: src/sys/sys/quotactl.h diff -u src/sys/sys/quotactl.h:1.26 src/sys/sys/quotactl.h:1.27 --- src/sys/sys/quotactl.h:1.26 Sun Jan 29 07:09:52 2012 +++ src/sys/sys/quotactl.h Sun Jan 29 07:11:12 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: quotactl.h,v 1.26 2012/01/29 07:09:52 dholland Exp $ */ +/* $NetBSD: quotactl.h,v 1.27 2012/01/29 07:11:12 dholland Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -67,7 +67,7 @@ struct quotakcursor { /* Argument encoding. */ enum vfs_quotactl_argtypes { - QCT_PROPLIB, /* quotaon/off */ + QCT_PROPLIB, /* quotaoff */ QCT_GETVERSION, /* getversion */ QCT_GET, /* get */ QCT_PUT, /* put */ @@ -78,6 +78,7 @@ enum vfs_quotactl_argtypes { QCT_CURSORSKIPIDTYPE, /* iteration hint */ QCT_CURSORATEND,/* test cursor */ QCT_CURSORREWIND,/* reset cursor */ + QCT_QUOTAON, /* quotaon */ }; struct vfs_quotactl_args { enum vfs_quotactl_argtypes qc_type; @@ -125,6 +126,10 @@ struct vfs_quotactl_args { struct { struct quotakcursor *qc_cursor; } cursorrewind; + struct { + int qc_idtype; + const char *qc_quotafile; + } quotaon; } u; }; Index: src/sys/ufs/ufs/ufs_quota.c diff -u src/sys/ufs/ufs/ufs_quota.c:1.98 src/sys/ufs/ufs/ufs_quota.c:1.99 --- src/sys/ufs/ufs/ufs_quota.c:1.98 Sun Jan 29 07:09:52 2012 +++ src/sys/ufs/ufs/ufs_quota.c Sun Jan 29 07:11:12 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_quota.c,v 1.98 2012/01/29 07:09:52 dholland Exp $ */ +/* $NetBSD: ufs_quota.c,v 1.99 2012/01/29 07:11:12 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.98 2012/01/29 07:09:52 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.99 2012/01/29 07:11:12 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -540,42 +540,25 @@ static int quota_handle_cmd_quotaon(struct mount *mp, struct lwp *l, struct vfs_quotactl_args *args) { - prop_dictionary_t data; struct ufsmount *ump = VFSTOUFS(mp); - int error; + int idtype; const char *qfile; - prop_dictionary_t cmddict; - int q2type; - prop_array_t datas; - - KASSERT(args->qc_type == QCT_PROPLIB); - cmddict = args->u.proplib.qc_cmddict; - q2type = args->u.proplib.qc_q2type; - datas = args->u.proplib.qc_datas; + int error; - KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY); - KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY); + KASSERT(args->qc_type == QCT_QUOTAON); + idtype = args->u.quotaon.qc_idtype; + qfile = args->u.quotaon.qc_quotafile; if ((ump->um_flags & UFS_QUOTA2) != 0) return EBUSY; - if (prop_array_count(datas) != 1) - return EINVAL; - - data = prop_array_get(datas, 0); - if (data == NULL) - return ENOMEM; - if (!prop_dictionary_get_cstring_nocopy(data, "quotafile", - &qfile)) - return EINVAL; - error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA, KAUTH_REQ_SYSTEM_FS_QUOTA_ONOFF, mp, NULL, NULL); if (error != 0) { return error; } #ifdef QUOTA - error = quota1_handle_cmd_quotaon(l, ump, q2type, qfile); + error = quota1_handle_cmd_quotaon(l, ump, idtype, qfile); #else error = EOPNOTSUPP; #endif