Sun Jan 29 06:52:39 2012 UTC ()
The handling of QUOTACTL_CLEAR does not use the proplib data
dictionary, so don't pass it.

Note: this change requires a kernel version bump.


(dholland)
diff -r1.16 -r1.17 src/sys/kern/vfs_quotactl.c
diff -r1.14 -r1.15 src/sys/sys/quotactl.h
diff -r1.88 -r1.89 src/sys/ufs/ufs/ufs_quota.c
diff -r1.10 -r1.11 src/sys/ufs/ufs/ufs_quota.h
diff -r1.11 -r1.12 src/sys/ufs/ufs/ufs_quota2.c

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

--- src/sys/kern/vfs_quotactl.c 2012/01/29 06:51:42 1.16
+++ src/sys/kern/vfs_quotactl.c 2012/01/29 06:52:38 1.17
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: vfs_quotactl.c,v 1.16 2012/01/29 06:51:42 dholland Exp $ */ 1/* $NetBSD: vfs_quotactl.c,v 1.17 2012/01/29 06:52:38 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.16 2012/01/29 06:51:42 dholland Exp $"); 83__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.17 2012/01/29 06:52:38 dholland Exp $");
84 84
85#include <sys/mount.h> 85#include <sys/mount.h>
86#include <sys/quota.h> 86#include <sys/quota.h>
87#include <sys/quotactl.h> 87#include <sys/quotactl.h>
88#include <quota/quotaprop.h> 88#include <quota/quotaprop.h>
89 89
90static int 90static int
91vfs_quotactl_getversion(struct mount *mp, 91vfs_quotactl_getversion(struct mount *mp,
92 prop_dictionary_t cmddict, int q2type, 92 prop_dictionary_t cmddict, int q2type,
93 prop_array_t datas) 93 prop_array_t datas)
94{ 94{
95 prop_array_t replies; 95 prop_array_t replies;
96 prop_dictionary_t data; 96 prop_dictionary_t data;
@@ -485,27 +485,26 @@ vfs_quotactl_clear(struct mount *mp, @@ -485,27 +485,26 @@ vfs_quotactl_clear(struct mount *mp,
485 continue; 485 continue;
486 if (strcmp(idstr, "default")) 486 if (strcmp(idstr, "default"))
487 continue; 487 continue;
488 id = 0; 488 id = 0;
489 defaultq = 1; 489 defaultq = 1;
490 } else { 490 } else {
491 defaultq = 0; 491 defaultq = 0;
492 } 492 }
493 493
494 args.qc_type = QCT_CLEAR; 494 args.qc_type = QCT_CLEAR;
495 args.u.clear.qc_idtype = q2type; 495 args.u.clear.qc_idtype = q2type;
496 args.u.clear.qc_id = id; 496 args.u.clear.qc_id = id;
497 args.u.clear.qc_defaultq = defaultq; 497 args.u.clear.qc_defaultq = defaultq;
498 args.u.clear.qc_data = data; 
499 error = VFS_QUOTACTL(mp, QUOTACTL_CLEAR, &args); 498 error = VFS_QUOTACTL(mp, QUOTACTL_CLEAR, &args);
500 if (error) { 499 if (error) {
501 goto err; 500 goto err;
502 } 501 }
503 } 502 }
504 503
505 prop_object_iterator_release(iter); 504 prop_object_iterator_release(iter);
506 if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) { 505 if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) {
507 error = ENOMEM; 506 error = ENOMEM;
508 } else { 507 } else {
509 error = 0; 508 error = 0;
510 } 509 }
511 return error; 510 return error;

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

--- src/sys/sys/quotactl.h 2012/01/29 06:51:43 1.14
+++ src/sys/sys/quotactl.h 2012/01/29 06:52:39 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: quotactl.h,v 1.14 2012/01/29 06:51:43 dholland Exp $ */ 1/* $NetBSD: quotactl.h,v 1.15 2012/01/29 06:52:39 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
@@ -67,19 +67,18 @@ struct vfs_quotactl_args { @@ -67,19 +67,18 @@ struct vfs_quotactl_args {
67 } getversion; 67 } getversion;
68 struct { 68 struct {
69 const struct quotakey *qc_key; 69 const struct quotakey *qc_key;
70 struct quotaval *qc_ret; 70 struct quotaval *qc_ret;
71 } get; 71 } get;
72 struct { 72 struct {
73 const struct quotakey *qc_key; 73 const struct quotakey *qc_key;
74 const struct quotaval *qc_val; 74 const struct quotaval *qc_val;
75 } put; 75 } put;
76 struct { 76 struct {
77 int qc_idtype; 77 int qc_idtype;
78 id_t qc_id; 78 id_t qc_id;
79 int qc_defaultq; 79 int qc_defaultq;
80 prop_dictionary_t qc_data; 
81 } clear; 80 } clear;
82 } u; 81 } u;
83}; 82};
84 83
85#endif /* _SYS_QUOTACTL_H_ */ 84#endif /* _SYS_QUOTACTL_H_ */

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

--- src/sys/ufs/ufs/ufs_quota.c 2012/01/29 06:51:43 1.88
+++ src/sys/ufs/ufs/ufs_quota.c 2012/01/29 06:52:39 1.89
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ufs_quota.c,v 1.88 2012/01/29 06:51:43 dholland Exp $ */ 1/* $NetBSD: ufs_quota.c,v 1.89 2012/01/29 06:52:39 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.88 2012/01/29 06:51:43 dholland Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.89 2012/01/29 06:52:39 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>
@@ -309,50 +309,46 @@ quota_handle_cmd_put(struct mount *mp, s @@ -309,50 +309,46 @@ quota_handle_cmd_put(struct mount *mp, s
309 } 309 }
310 310
311 return error; 311 return error;
312} 312}
313 313
314static int  314static int
315quota_handle_cmd_clear(struct mount *mp, struct lwp *l,  315quota_handle_cmd_clear(struct mount *mp, struct lwp *l,
316 struct vfs_quotactl_args *args) 316 struct vfs_quotactl_args *args)
317{ 317{
318 struct ufsmount *ump = VFSTOUFS(mp); 318 struct ufsmount *ump = VFSTOUFS(mp);
319 int idtype; 319 int idtype;
320 id_t id; 320 id_t id;
321 int defaultq; 321 int defaultq;
322 prop_dictionary_t data; 
323 int error; 322 int error;
324 323
325 KASSERT(args->qc_type == QCT_CLEAR); 324 KASSERT(args->qc_type == QCT_CLEAR);
326 idtype = args->u.clear.qc_idtype; 325 idtype = args->u.clear.qc_idtype;
327 id = args->u.clear.qc_id; 326 id = args->u.clear.qc_id;
328 defaultq = args->u.clear.qc_defaultq; 327 defaultq = args->u.clear.qc_defaultq;
329 data = args->u.clear.qc_data; 
330 
331 KASSERT(prop_object_type(data) == PROP_TYPE_DICTIONARY); 
332 328
333 if ((ump->um_flags & UFS_QUOTA2) == 0) 329 if ((ump->um_flags & UFS_QUOTA2) == 0)
334 return EOPNOTSUPP; 330 return EOPNOTSUPP;
335 331
336 /* avoid whitespace changes */ 332 /* avoid whitespace changes */
337 { 333 {
338 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA, 334 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA,
339 KAUTH_REQ_SYSTEM_FS_QUOTA_MANAGE, mp, KAUTH_ARG(id), NULL); 335 KAUTH_REQ_SYSTEM_FS_QUOTA_MANAGE, mp, KAUTH_ARG(id), NULL);
340 if (error != 0) 336 if (error != 0)
341 goto err; 337 goto err;
342#ifdef QUOTA2 338#ifdef QUOTA2
343 if (ump->um_flags & UFS_QUOTA2) { 339 if (ump->um_flags & UFS_QUOTA2) {
344 error = quota2_handle_cmd_clear(ump, idtype, id, defaultq, 340 error = quota2_handle_cmd_clear(ump, idtype, id,
345 data); 341 defaultq);
346 } else 342 } else
347#endif 343#endif
348 panic("quota_handle_cmd_get: no support ?"); 344 panic("quota_handle_cmd_get: no support ?");
349  345
350 if (error && error != ENOENT) 346 if (error && error != ENOENT)
351 goto err; 347 goto err;
352 } 348 }
353 349
354 return 0; 350 return 0;
355 err: 351 err:
356 return error; 352 return error;
357} 353}
358 354

cvs diff -r1.10 -r1.11 src/sys/ufs/ufs/ufs_quota.h (expand / switch to unified diff)

--- src/sys/ufs/ufs/ufs_quota.h 2012/01/29 06:49:44 1.10
+++ src/sys/ufs/ufs/ufs_quota.h 2012/01/29 06:52:39 1.11
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ufs_quota.h,v 1.10 2012/01/29 06:49:44 dholland Exp $ */ 1/* $NetBSD: ufs_quota.h,v 1.11 2012/01/29 06:52:39 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.
@@ -117,18 +117,18 @@ int quota1_handle_cmd_get(struct ufsmoun @@ -117,18 +117,18 @@ int quota1_handle_cmd_get(struct ufsmoun
117 struct quotaval *); 117 struct quotaval *);
118int quota1_handle_cmd_put(struct ufsmount *, const struct quotakey *, 118int quota1_handle_cmd_put(struct ufsmount *, const struct quotakey *,
119 const struct quotaval *); 119 const struct quotaval *);
120int quota1_handle_cmd_quotaon(struct lwp *, struct ufsmount *, int, 120int quota1_handle_cmd_quotaon(struct lwp *, struct ufsmount *, int,
121 const char *); 121 const char *);
122int quota1_handle_cmd_quotaoff(struct lwp *, struct ufsmount *, int); 122int quota1_handle_cmd_quotaoff(struct lwp *, struct ufsmount *, int);
123 123
124int chkdq2(struct inode *, int64_t, kauth_cred_t, int); 124int chkdq2(struct inode *, int64_t, kauth_cred_t, int);
125int chkiq2(struct inode *, int32_t, kauth_cred_t, int); 125int chkiq2(struct inode *, int32_t, kauth_cred_t, int);
126int quota2_handle_cmd_get(struct ufsmount *, const struct quotakey *, 126int quota2_handle_cmd_get(struct ufsmount *, const struct quotakey *,
127 struct quotaval *); 127 struct quotaval *);
128int quota2_handle_cmd_put(struct ufsmount *, const struct quotakey *, 128int quota2_handle_cmd_put(struct ufsmount *, const struct quotakey *,
129 const struct quotaval *); 129 const struct quotaval *);
130int quota2_handle_cmd_clear(struct ufsmount *, int, int, int, prop_dictionary_t); 130int quota2_handle_cmd_clear(struct ufsmount *, int, int, int);
131int quota2_handle_cmd_getall(struct ufsmount *, int, prop_array_t); 131int quota2_handle_cmd_getall(struct ufsmount *, int, prop_array_t);
132int q2sync(struct mount *); 132int q2sync(struct mount *);
133int dq2get(struct vnode *, u_long, struct ufsmount *, int, struct dquot *); 133int dq2get(struct vnode *, u_long, struct ufsmount *, int, struct dquot *);
134int dq2sync(struct vnode *, struct dquot *); 134int dq2sync(struct vnode *, struct dquot *);

cvs diff -r1.11 -r1.12 src/sys/ufs/ufs/ufs_quota2.c (expand / switch to unified diff)

--- src/sys/ufs/ufs/ufs_quota2.c 2012/01/29 06:49:44 1.11
+++ src/sys/ufs/ufs/ufs_quota2.c 2012/01/29 06:52:39 1.12
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ufs_quota2.c,v 1.11 2012/01/29 06:49:44 dholland Exp $ */ 1/* $NetBSD: ufs_quota2.c,v 1.12 2012/01/29 06:52:39 dholland Exp $ */
2/*- 2/*-
3 * Copyright (c) 2010 Manuel Bouyer 3 * Copyright (c) 2010 Manuel Bouyer
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -16,27 +16,27 @@ @@ -16,27 +16,27 @@
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE. 25 * POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.11 2012/01/29 06:49:44 dholland Exp $"); 29__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.12 2012/01/29 06:52:39 dholland Exp $");
30 30
31#include <sys/buf.h> 31#include <sys/buf.h>
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/kernel.h> 33#include <sys/kernel.h>
34#include <sys/systm.h> 34#include <sys/systm.h>
35#include <sys/malloc.h> 35#include <sys/malloc.h>
36#include <sys/namei.h> 36#include <sys/namei.h>
37#include <sys/file.h> 37#include <sys/file.h>
38#include <sys/proc.h> 38#include <sys/proc.h>
39#include <sys/vnode.h> 39#include <sys/vnode.h>
40#include <sys/mount.h> 40#include <sys/mount.h>
41#include <sys/fstrans.h> 41#include <sys/fstrans.h>
42#include <sys/kauth.h> 42#include <sys/kauth.h>
@@ -698,100 +698,100 @@ dq2clear_callback(struct ufsmount *ump,  @@ -698,100 +698,100 @@ dq2clear_callback(struct ufsmount *ump,
698 c->dq->dq2_lblkno = 0; 698 c->dq->dq2_lblkno = 0;
699 c->dq->dq2_blkoff = 0; 699 c->dq->dq2_blkoff = 0;
700 myoff = *offp; 700 myoff = *offp;
701 /* remove from hash list */ 701 /* remove from hash list */
702 *offp = q2e->q2e_next; 702 *offp = q2e->q2e_next;
703 /* add to free list */ 703 /* add to free list */
704 q2e->q2e_next = c->q2h->q2h_free; 704 q2e->q2e_next = c->q2h->q2h_free;
705 c->q2h->q2h_free = myoff; 705 c->q2h->q2h_free = myoff;
706 return Q2WL_ABORT; 706 return Q2WL_ABORT;
707 } 707 }
708 return 0; 708 return 0;
709} 709}
710int 710int
711quota2_handle_cmd_clear(struct ufsmount *ump, int type, int id, 711quota2_handle_cmd_clear(struct ufsmount *ump, int idtype, int id,
712 int defaultq, prop_dictionary_t data) 712 int defaultq)
713{ 713{
714 int error, i; 714 int error, i;
715 struct dquot *dq; 715 struct dquot *dq;
716 struct quota2_header *q2h; 716 struct quota2_header *q2h;
717 struct quota2_entry q2e, *q2ep; 717 struct quota2_entry q2e, *q2ep;
718 struct buf *hbp, *bp; 718 struct buf *hbp, *bp;
719 u_long hash_mask; 719 u_long hash_mask;
720 struct dq2clear_callback c; 720 struct dq2clear_callback c;
721 721
722 if (ump->um_quotas[type] == NULLVP) 722 if (ump->um_quotas[idtype] == NULLVP)
723 return ENODEV; 723 return ENODEV;
724 if (defaultq) 724 if (defaultq)
725 return EOPNOTSUPP; 725 return EOPNOTSUPP;
726 726
727 /* get the default entry before locking the entry's buffer */ 727 /* get the default entry before locking the entry's buffer */
728 mutex_enter(&dqlock); 728 mutex_enter(&dqlock);
729 error = getq2h(ump, type, &hbp, &q2h, 0); 729 error = getq2h(ump, idtype, &hbp, &q2h, 0);
730 if (error) { 730 if (error) {
731 mutex_exit(&dqlock); 731 mutex_exit(&dqlock);
732 return error; 732 return error;
733 } 733 }
734 /* we'll copy to another disk entry, so no need to swap */ 734 /* we'll copy to another disk entry, so no need to swap */
735 memcpy(&q2e, &q2h->q2h_defentry, sizeof(q2e)); 735 memcpy(&q2e, &q2h->q2h_defentry, sizeof(q2e));
736 mutex_exit(&dqlock); 736 mutex_exit(&dqlock);
737 brelse(hbp, 0); 737 brelse(hbp, 0);
738 738
739 error = dqget(NULLVP, id, ump, type, &dq); 739 error = dqget(NULLVP, id, ump, idtype, &dq);
740 if (error) 740 if (error)
741 return error; 741 return error;
742 742
743 mutex_enter(&dq->dq_interlock); 743 mutex_enter(&dq->dq_interlock);
744 if (dq->dq2_lblkno == 0 && dq->dq2_blkoff == 0) { 744 if (dq->dq2_lblkno == 0 && dq->dq2_blkoff == 0) {
745 /* already clear, nothing to do */ 745 /* already clear, nothing to do */
746 error = ENOENT; 746 error = ENOENT;
747 goto out_il; 747 goto out_il;
748 } 748 }
749 error = UFS_WAPBL_BEGIN(ump->um_mountp); 749 error = UFS_WAPBL_BEGIN(ump->um_mountp);
750 if (error) 750 if (error)
751 goto out_dq; 751 goto out_dq;
752  752
753 error = getq2e(ump, type, dq->dq2_lblkno, dq->dq2_blkoff, 753 error = getq2e(ump, idtype, dq->dq2_lblkno, dq->dq2_blkoff,
754 &bp, &q2ep, B_MODIFY); 754 &bp, &q2ep, B_MODIFY);
755 if (error) 755 if (error)
756 goto out_wapbl; 756 goto out_wapbl;
757 757
758 if (q2ep->q2e_val[QL_BLOCK].q2v_cur != 0 || 758 if (q2ep->q2e_val[QL_BLOCK].q2v_cur != 0 ||
759 q2ep->q2e_val[QL_FILE].q2v_cur != 0) { 759 q2ep->q2e_val[QL_FILE].q2v_cur != 0) {
760 /* can't free this entry; revert to default */ 760 /* can't free this entry; revert to default */
761 for (i = 0; i < N_QL; i++) { 761 for (i = 0; i < N_QL; i++) {
762 q2ep->q2e_val[i].q2v_softlimit = 762 q2ep->q2e_val[i].q2v_softlimit =
763 q2e.q2e_val[i].q2v_softlimit; 763 q2e.q2e_val[i].q2v_softlimit;
764 q2ep->q2e_val[i].q2v_hardlimit = 764 q2ep->q2e_val[i].q2v_hardlimit =
765 q2e.q2e_val[i].q2v_hardlimit; 765 q2e.q2e_val[i].q2v_hardlimit;
766 q2ep->q2e_val[i].q2v_grace = 766 q2ep->q2e_val[i].q2v_grace =
767 q2e.q2e_val[i].q2v_grace; 767 q2e.q2e_val[i].q2v_grace;
768 q2ep->q2e_val[i].q2v_time = 0; 768 q2ep->q2e_val[i].q2v_time = 0;
769 } 769 }
770 quota2_bwrite(ump->um_mountp, bp); 770 quota2_bwrite(ump->um_mountp, bp);
771 goto out_wapbl; 771 goto out_wapbl;
772 } 772 }
773 /* we can free it. release bp so we can walk the list */ 773 /* we can free it. release bp so we can walk the list */
774 brelse(bp, 0); 774 brelse(bp, 0);
775 mutex_enter(&dqlock); 775 mutex_enter(&dqlock);
776 error = getq2h(ump, type, &hbp, &q2h, 0); 776 error = getq2h(ump, idtype, &hbp, &q2h, 0);
777 if (error) 777 if (error)
778 goto out_dqlock; 778 goto out_dqlock;
779 779
780 hash_mask = ((1 << q2h->q2h_hash_shift) - 1); 780 hash_mask = ((1 << q2h->q2h_hash_shift) - 1);
781 c.dq = dq; 781 c.dq = dq;
782 c.id = id; 782 c.id = id;
783 c.q2h = q2h; 783 c.q2h = q2h;
784 error = quota2_walk_list(ump, hbp, type, 784 error = quota2_walk_list(ump, hbp, idtype,
785 &q2h->q2h_entries[id & hash_mask], B_MODIFY, &c, 785 &q2h->q2h_entries[id & hash_mask], B_MODIFY, &c,
786 dq2clear_callback); 786 dq2clear_callback);
787 787
788 bwrite(hbp); 788 bwrite(hbp);
789 789
790out_dqlock: 790out_dqlock:
791 mutex_exit(&dqlock); 791 mutex_exit(&dqlock);
792out_wapbl: 792out_wapbl:
793 UFS_WAPBL_END(ump->um_mountp); 793 UFS_WAPBL_END(ump->um_mountp);
794out_il: 794out_il:
795 mutex_exit(&dq->dq_interlock); 795 mutex_exit(&dq->dq_interlock);
796out_dq: 796out_dq:
797 dqrele(NULLVP, dq); 797 dqrele(NULLVP, dq);