Sun Jan 29 07:11:55 2012 UTC ()
Move proplib bits for QUOTACTL_QUOTAOFF out of the ufs code.

This change requires a kernel version bump.


(dholland)
diff -r1.31 -r1.32 src/sys/kern/vfs_quotactl.c
diff -r1.27 -r1.28 src/sys/sys/quotactl.h
diff -r1.99 -r1.100 src/sys/ufs/ufs/ufs_quota.c

cvs diff -r1.31 -r1.32 src/sys/kern/vfs_quotactl.c (expand / switch to unified diff)

--- src/sys/kern/vfs_quotactl.c 2012/01/29 07:11:12 1.31
+++ src/sys/kern/vfs_quotactl.c 2012/01/29 07:11:55 1.32
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: vfs_quotactl.c,v 1.31 2012/01/29 07:11:12 dholland Exp $ */ 1/* $NetBSD: vfs_quotactl.c,v 1.32 2012/01/29 07:11:55 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1991, 1993, 1994 4 * Copyright (c) 1991, 1993, 1994
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc. 6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed 7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph 8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc. 10 * the permission of UNIX System Laboratories, Inc.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -70,27 +70,27 @@ @@ -70,27 +70,27 @@
70 * 70 *
71 * @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95 71 * @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95
72 * From NetBSD: ufs_quota.c,v 1.70 2011/03/24 17:05:46 bouyer Exp 72 * From NetBSD: ufs_quota.c,v 1.70 2011/03/24 17:05:46 bouyer Exp
73 */ 73 */
74 74
75/* 75/*
76 * Note that both of the copyrights above are moderately spurious; 76 * Note that both of the copyrights above are moderately spurious;
77 * this code should almost certainly have the Copyright 2010 Manuel 77 * this code should almost certainly have the Copyright 2010 Manuel
78 * Bouyer notice and license found in e.g. sys/ufs/ufs/quota2_subr.c. 78 * Bouyer notice and license found in e.g. sys/ufs/ufs/quota2_subr.c.
79 * However, they're what was on the files this code was sliced out of. 79 * However, they're what was on the files this code was sliced out of.
80 */ 80 */
81 81
82#include <sys/cdefs.h> 82#include <sys/cdefs.h>
83__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.31 2012/01/29 07:11:12 dholland Exp $"); 83__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.32 2012/01/29 07:11:55 dholland Exp $");
84 84
85#include <sys/malloc.h> /* XXX: temporary */ 85#include <sys/malloc.h> /* XXX: temporary */
86#include <sys/mount.h> 86#include <sys/mount.h>
87#include <sys/quota.h> 87#include <sys/quota.h>
88#include <sys/quotactl.h> 88#include <sys/quotactl.h>
89#include <quota/quotaprop.h> 89#include <quota/quotaprop.h>
90 90
91static int 91static int
92vfs_quotactl_getversion(struct mount *mp, 92vfs_quotactl_getversion(struct mount *mp,
93 prop_dictionary_t cmddict, int q2type, 93 prop_dictionary_t cmddict, int q2type,
94 prop_array_t datas) 94 prop_array_t datas)
95{ 95{
96 prop_array_t replies; 96 prop_array_t replies;
@@ -164,30 +164,34 @@ vfs_quotactl_quotaon(struct mount *mp, @@ -164,30 +164,34 @@ vfs_quotactl_quotaon(struct mount *mp,
164 args.qc_type = QCT_QUOTAON; 164 args.qc_type = QCT_QUOTAON;
165 args.u.quotaon.qc_idtype = q2type; 165 args.u.quotaon.qc_idtype = q2type;
166 args.u.quotaon.qc_quotafile = qfile; 166 args.u.quotaon.qc_quotafile = qfile;
167 return VFS_QUOTACTL(mp, QUOTACTL_QUOTAON, &args); 167 return VFS_QUOTACTL(mp, QUOTACTL_QUOTAON, &args);
168} 168}
169 169
170static int 170static int
171vfs_quotactl_quotaoff(struct mount *mp, 171vfs_quotactl_quotaoff(struct mount *mp,
172 prop_dictionary_t cmddict, int q2type, 172 prop_dictionary_t cmddict, int q2type,
173 prop_array_t datas) 173 prop_array_t datas)
174{ 174{
175 struct vfs_quotactl_args args; 175 struct vfs_quotactl_args args;
176 176
177 args.qc_type = QCT_PROPLIB; 177 KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
178 args.u.proplib.qc_cmddict = cmddict; 178 KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
179 args.u.proplib.qc_q2type = q2type; 179
180 args.u.proplib.qc_datas = datas; 180 if (prop_array_count(datas) != 0)
 181 return EINVAL;
 182
 183 args.qc_type = QCT_QUOTAOFF;
 184 args.u.quotaoff.qc_idtype = q2type;
181 return VFS_QUOTACTL(mp, QUOTACTL_QUOTAOFF, &args); 185 return VFS_QUOTACTL(mp, QUOTACTL_QUOTAOFF, &args);
182} 186}
183 187
184static int 188static int
185vfs_quotactl_get_addreply(const struct quotakey *qk, 189vfs_quotactl_get_addreply(const struct quotakey *qk,
186 const struct quotaval *blocks, 190 const struct quotaval *blocks,
187 const struct quotaval *files, 191 const struct quotaval *files,
188 prop_array_t replies) 192 prop_array_t replies)
189{ 193{
190 prop_dictionary_t dict; 194 prop_dictionary_t dict;
191 id_t id; 195 id_t id;
192 int defaultq; 196 int defaultq;
193 uint64_t *valuesp[QUOTA_NLIMITS]; 197 uint64_t *valuesp[QUOTA_NLIMITS];

cvs diff -r1.27 -r1.28 src/sys/sys/quotactl.h (expand / switch to unified diff)

--- src/sys/sys/quotactl.h 2012/01/29 07:11:12 1.27
+++ src/sys/sys/quotactl.h 2012/01/29 07:11:55 1.28
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: quotactl.h,v 1.27 2012/01/29 07:11:12 dholland Exp $ */ 1/* $NetBSD: quotactl.h,v 1.28 2012/01/29 07:11:55 dholland Exp $ */
2/*- 2/*-
3 * Copyright (c) 2011 The NetBSD Foundation, Inc. 3 * Copyright (c) 2011 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by David A. Holland. 7 * by David A. Holland.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -57,38 +57,39 @@ struct quotakcursor { @@ -57,38 +57,39 @@ struct quotakcursor {
57#define QUOTACTL_QUOTAOFF 2 57#define QUOTACTL_QUOTAOFF 2
58#define QUOTACTL_GET 3 58#define QUOTACTL_GET 3
59#define QUOTACTL_PUT 4 59#define QUOTACTL_PUT 4
60#define QUOTACTL_CURSORGET 5 60#define QUOTACTL_CURSORGET 5
61#define QUOTACTL_DELETE 6 61#define QUOTACTL_DELETE 6
62#define QUOTACTL_CURSOROPEN 7 62#define QUOTACTL_CURSOROPEN 7
63#define QUOTACTL_CURSORCLOSE 8 63#define QUOTACTL_CURSORCLOSE 8
64#define QUOTACTL_CURSORSKIPIDTYPE 9 64#define QUOTACTL_CURSORSKIPIDTYPE 9
65#define QUOTACTL_CURSORATEND 10 65#define QUOTACTL_CURSORATEND 10
66#define QUOTACTL_CURSORREWIND 11 66#define QUOTACTL_CURSORREWIND 11
67 67
68/* Argument encoding. */ 68/* Argument encoding. */
69enum vfs_quotactl_argtypes { 69enum vfs_quotactl_argtypes {
70 QCT_PROPLIB, /* quotaoff */ 70 QCT_PROPLIB, /* unused */
71 QCT_GETVERSION, /* getversion */ 71 QCT_GETVERSION, /* getversion */
72 QCT_GET, /* get */ 72 QCT_GET, /* get */
73 QCT_PUT, /* put */ 73 QCT_PUT, /* put */
74 QCT_DELETE, /* delete */ 74 QCT_DELETE, /* delete */
75 QCT_CURSOROPEN, /* open cursor */ 75 QCT_CURSOROPEN, /* open cursor */
76 QCT_CURSORCLOSE,/* close cursor */ 76 QCT_CURSORCLOSE,/* close cursor */
77 QCT_CURSORGET, /* get from cursor */ 77 QCT_CURSORGET, /* get from cursor */
78 QCT_CURSORSKIPIDTYPE, /* iteration hint */ 78 QCT_CURSORSKIPIDTYPE, /* iteration hint */
79 QCT_CURSORATEND,/* test cursor */ 79 QCT_CURSORATEND,/* test cursor */
80 QCT_CURSORREWIND,/* reset cursor */ 80 QCT_CURSORREWIND,/* reset cursor */
81 QCT_QUOTAON, /* quotaon */ 81 QCT_QUOTAON, /* quotaon */
 82 QCT_QUOTAOFF, /* quotaoff */
82}; 83};
83struct vfs_quotactl_args { 84struct vfs_quotactl_args {
84 enum vfs_quotactl_argtypes qc_type; 85 enum vfs_quotactl_argtypes qc_type;
85 union { 86 union {
86 struct { 87 struct {
87 prop_dictionary_t qc_cmddict; 88 prop_dictionary_t qc_cmddict;
88 int qc_q2type; 89 int qc_q2type;
89 prop_array_t qc_datas; 90 prop_array_t qc_datas;
90 } proplib; 91 } proplib;
91 struct { 92 struct {
92 int *qc_version_ret; 93 int *qc_version_ret;
93 } getversion; 94 } getversion;
94 struct { 95 struct {
@@ -120,17 +121,20 @@ struct vfs_quotactl_args { @@ -120,17 +121,20 @@ struct vfs_quotactl_args {
120 unsigned *qc_ret; 121 unsigned *qc_ret;
121 } cursorget; 122 } cursorget;
122 struct { 123 struct {
123 struct quotakcursor *qc_cursor; 124 struct quotakcursor *qc_cursor;
124 int *qc_ret; /* really boolean */ 125 int *qc_ret; /* really boolean */
125 } cursoratend; 126 } cursoratend;
126 struct { 127 struct {
127 struct quotakcursor *qc_cursor; 128 struct quotakcursor *qc_cursor;
128 } cursorrewind; 129 } cursorrewind;
129 struct { 130 struct {
130 int qc_idtype; 131 int qc_idtype;
131 const char *qc_quotafile; 132 const char *qc_quotafile;
132 } quotaon; 133 } quotaon;
 134 struct {
 135 int qc_idtype;
 136 } quotaoff;
133 } u; 137 } u;
134}; 138};
135 139
136#endif /* _SYS_QUOTACTL_H_ */ 140#endif /* _SYS_QUOTACTL_H_ */

cvs diff -r1.99 -r1.100 src/sys/ufs/ufs/ufs_quota.c (expand / switch to unified diff)

--- src/sys/ufs/ufs/ufs_quota.c 2012/01/29 07:11:12 1.99
+++ src/sys/ufs/ufs/ufs_quota.c 2012/01/29 07:11:55 1.100
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ufs_quota.c,v 1.99 2012/01/29 07:11:12 dholland Exp $ */ 1/* $NetBSD: ufs_quota.c,v 1.100 2012/01/29 07:11:55 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1986, 1990, 1993, 1995 4 * Copyright (c) 1982, 1986, 1990, 1993, 1995
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Robert Elz at The University of Melbourne. 8 * Robert Elz at The University of Melbourne.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 * 33 *
34 * @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95 34 * @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95
35 */ 35 */
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.99 2012/01/29 07:11:12 dholland Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.100 2012/01/29 07:11:55 dholland Exp $");
39 39
40#if defined(_KERNEL_OPT) 40#if defined(_KERNEL_OPT)
41#include "opt_quota.h" 41#include "opt_quota.h"
42#endif  42#endif
43#include <sys/param.h> 43#include <sys/param.h>
44#include <sys/kernel.h> 44#include <sys/kernel.h>
45#include <sys/systm.h> 45#include <sys/systm.h>
46#include <sys/namei.h> 46#include <sys/namei.h>
47#include <sys/file.h> 47#include <sys/file.h>
48#include <sys/proc.h> 48#include <sys/proc.h>
49#include <sys/vnode.h> 49#include <sys/vnode.h>
50#include <sys/mount.h> 50#include <sys/mount.h>
51#include <sys/kauth.h> 51#include <sys/kauth.h>
@@ -561,52 +561,42 @@ quota_handle_cmd_quotaon(struct mount *m @@ -561,52 +561,42 @@ quota_handle_cmd_quotaon(struct mount *m
561 error = quota1_handle_cmd_quotaon(l, ump, idtype, qfile); 561 error = quota1_handle_cmd_quotaon(l, ump, idtype, qfile);
562#else 562#else
563 error = EOPNOTSUPP; 563 error = EOPNOTSUPP;
564#endif 564#endif
565  565
566 return error; 566 return error;
567} 567}
568 568
569static int  569static int
570quota_handle_cmd_quotaoff(struct mount *mp, struct lwp *l,  570quota_handle_cmd_quotaoff(struct mount *mp, struct lwp *l,
571 struct vfs_quotactl_args *args) 571 struct vfs_quotactl_args *args)
572{ 572{
573 struct ufsmount *ump = VFSTOUFS(mp); 573 struct ufsmount *ump = VFSTOUFS(mp);
 574 int idtype;
574 int error; 575 int error;
575 prop_dictionary_t cmddict; 
576 int q2type; 
577 prop_array_t datas; 
578 
579 KASSERT(args->qc_type == QCT_PROPLIB); 
580 cmddict = args->u.proplib.qc_cmddict; 
581 q2type = args->u.proplib.qc_q2type; 
582 datas = args->u.proplib.qc_datas; 
583 576
584 KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY); 577 KASSERT(args->qc_type == QCT_QUOTAOFF);
585 KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY); 578 idtype = args->u.quotaoff.qc_idtype;
586 579
587 if ((ump->um_flags & UFS_QUOTA2) != 0) 580 if ((ump->um_flags & UFS_QUOTA2) != 0)
588 return EOPNOTSUPP; 581 return EOPNOTSUPP;
589  582
590 if (prop_array_count(datas) != 0) 
591 return EINVAL; 
592 
593 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA, 583 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA,
594 KAUTH_REQ_SYSTEM_FS_QUOTA_ONOFF, mp, NULL, NULL); 584 KAUTH_REQ_SYSTEM_FS_QUOTA_ONOFF, mp, NULL, NULL);
595 if (error != 0) { 585 if (error != 0) {
596 return error; 586 return error;
597 } 587 }
598#ifdef QUOTA 588#ifdef QUOTA
599 error = quota1_handle_cmd_quotaoff(l, ump, q2type); 589 error = quota1_handle_cmd_quotaoff(l, ump, idtype);
600#else 590#else
601 error = EOPNOTSUPP; 591 error = EOPNOTSUPP;
602#endif 592#endif
603  593
604 return error; 594 return error;
605} 595}
606 596
607/* 597/*
608 * Initialize the quota system. 598 * Initialize the quota system.
609 */ 599 */
610void 600void
611dqinit(void) 601dqinit(void)
612{ 602{