QUOTACTL_CLEAR -> QUOTACTL_DELETE to match intended API and user API.diff -r1.18 -r1.19 src/sys/kern/vfs_quotactl.c
(dholland)
--- src/sys/kern/vfs_quotactl.c 2012/01/29 06:53:35 1.18
+++ src/sys/kern/vfs_quotactl.c 2012/01/29 06:54:34 1.19
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: vfs_quotactl.c,v 1.18 2012/01/29 06:53:35 dholland Exp $ */ | 1 | /* $NetBSD: vfs_quotactl.c,v 1.19 2012/01/29 06:54:34 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.18 2012/01/29 06:53:35 dholland Exp $"); | 83 | __KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.19 2012/01/29 06:54:34 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 | |||
90 | static int | 90 | static int | |
91 | vfs_quotactl_getversion(struct mount *mp, | 91 | vfs_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; | |
@@ -481,42 +481,42 @@ vfs_quotactl_clear(struct mount *mp, | @@ -481,42 +481,42 @@ vfs_quotactl_clear(struct mount *mp, | |||
481 | while ((data = prop_object_iterator_next(iter)) != NULL) { | 481 | while ((data = prop_object_iterator_next(iter)) != NULL) { | |
482 | if (!prop_dictionary_get_uint32(data, "id", &id)) { | 482 | if (!prop_dictionary_get_uint32(data, "id", &id)) { | |
483 | if (!prop_dictionary_get_cstring_nocopy(data, "id", | 483 | if (!prop_dictionary_get_cstring_nocopy(data, "id", | |
484 | &idstr)) | 484 | &idstr)) | |
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_DELETE; | |
495 | args.u.clear.qc_idtype = q2type; | 495 | args.u.delete.qc_idtype = q2type; | |
496 | args.u.clear.qc_id = id; | 496 | args.u.delete.qc_id = id; | |
497 | args.u.clear.qc_defaultq = defaultq; | 497 | args.u.delete.qc_defaultq = defaultq; | |
498 | args.u.clear.qc_objtype = QUOTA_OBJTYPE_BLOCKS; | 498 | args.u.delete.qc_objtype = QUOTA_OBJTYPE_BLOCKS; | |
499 | error = VFS_QUOTACTL(mp, QUOTACTL_CLEAR, &args); | 499 | error = VFS_QUOTACTL(mp, QUOTACTL_DELETE, &args); | |
500 | if (error) { | 500 | if (error) { | |
501 | goto err; | 501 | goto err; | |
502 | } | 502 | } | |
503 | 503 | |||
504 | args.qc_type = QCT_CLEAR; | 504 | args.qc_type = QCT_DELETE; | |
505 | args.u.clear.qc_idtype = q2type; | 505 | args.u.delete.qc_idtype = q2type; | |
506 | args.u.clear.qc_id = id; | 506 | args.u.delete.qc_id = id; | |
507 | args.u.clear.qc_defaultq = defaultq; | 507 | args.u.delete.qc_defaultq = defaultq; | |
508 | args.u.clear.qc_objtype = QUOTA_OBJTYPE_FILES; | 508 | args.u.delete.qc_objtype = QUOTA_OBJTYPE_FILES; | |
509 | error = VFS_QUOTACTL(mp, QUOTACTL_CLEAR, &args); | 509 | error = VFS_QUOTACTL(mp, QUOTACTL_DELETE, &args); | |
510 | if (error) { | 510 | if (error) { | |
511 | goto err; | 511 | goto err; | |
512 | } | 512 | } | |
513 | } | 513 | } | |
514 | 514 | |||
515 | prop_object_iterator_release(iter); | 515 | prop_object_iterator_release(iter); | |
516 | if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) { | 516 | if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) { | |
517 | error = ENOMEM; | 517 | error = ENOMEM; | |
518 | } else { | 518 | } else { | |
519 | error = 0; | 519 | error = 0; | |
520 | } | 520 | } | |
521 | return error; | 521 | return error; | |
522 | err: | 522 | err: |
--- src/sys/sys/quotactl.h 2012/01/29 06:53:35 1.16
+++ src/sys/sys/quotactl.h 2012/01/29 06:54:34 1.17
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: quotactl.h,v 1.16 2012/01/29 06:53:35 dholland Exp $ */ | 1 | /* $NetBSD: quotactl.h,v 1.17 2012/01/29 06:54:34 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 | |
@@ -34,52 +34,52 @@ | @@ -34,52 +34,52 @@ | |||
34 | /* | 34 | /* | |
35 | * Note - this is an internal interface. Application code (and, | 35 | * Note - this is an internal interface. Application code (and, | |
36 | * really, anything that isn't libquota or inside the kernel) should | 36 | * really, anything that isn't libquota or inside the kernel) should | |
37 | * use the <quota.h> API instead. | 37 | * use the <quota.h> API instead. | |
38 | */ | 38 | */ | |
39 | 39 | |||
40 | /* Command codes. */ | 40 | /* Command codes. */ | |
41 | #define QUOTACTL_GETVERSION 0 | 41 | #define QUOTACTL_GETVERSION 0 | |
42 | #define QUOTACTL_QUOTAON 1 | 42 | #define QUOTACTL_QUOTAON 1 | |
43 | #define QUOTACTL_QUOTAOFF 2 | 43 | #define QUOTACTL_QUOTAOFF 2 | |
44 | #define QUOTACTL_GET 3 | 44 | #define QUOTACTL_GET 3 | |
45 | #define QUOTACTL_PUT 4 | 45 | #define QUOTACTL_PUT 4 | |
46 | #define QUOTACTL_GETALL 5 | 46 | #define QUOTACTL_GETALL 5 | |
47 | #define QUOTACTL_CLEAR 6 | 47 | #define QUOTACTL_DELETE 6 | |
48 | 48 | |||
49 | /* Argument encoding. */ | 49 | /* Argument encoding. */ | |
50 | enum vfs_quotactl_argtypes { | 50 | enum vfs_quotactl_argtypes { | |
51 | QCT_PROPLIB, /* quotaon/off, get, set, getall, clear */ | 51 | QCT_PROPLIB, /* quotaon/off, getall */ | |
52 | QCT_GETVERSION, /* getversion */ | 52 | QCT_GETVERSION, /* getversion */ | |
53 | QCT_GET, /* get */ | 53 | QCT_GET, /* get */ | |
54 | QCT_PUT, /* put */ | 54 | QCT_PUT, /* put */ | |
55 | QCT_CLEAR, /* clear */ | 55 | QCT_DELETE, /* delete */ | |
56 | }; | 56 | }; | |
57 | struct vfs_quotactl_args { | 57 | struct vfs_quotactl_args { | |
58 | enum vfs_quotactl_argtypes qc_type; | 58 | enum vfs_quotactl_argtypes qc_type; | |
59 | union { | 59 | union { | |
60 | struct { | 60 | struct { | |
61 | prop_dictionary_t qc_cmddict; | 61 | prop_dictionary_t qc_cmddict; | |
62 | int qc_q2type; | 62 | int qc_q2type; | |
63 | prop_array_t qc_datas; | 63 | prop_array_t qc_datas; | |
64 | } proplib; | 64 | } proplib; | |
65 | struct { | 65 | struct { | |
66 | int *qc_version_ret; | 66 | int *qc_version_ret; | |
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 | int qc_objtype; | 80 | int qc_objtype; | |
81 | } clear; | 81 | } delete; | |
82 | } u; | 82 | } u; | |
83 | }; | 83 | }; | |
84 | 84 | |||
85 | #endif /* _SYS_QUOTACTL_H_ */ | 85 | #endif /* _SYS_QUOTACTL_H_ */ |
--- src/sys/ufs/ufs/ufs_quota.c 2012/01/29 06:53:35 1.90
+++ src/sys/ufs/ufs/ufs_quota.c 2012/01/29 06:54:34 1.91
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ufs_quota.c,v 1.90 2012/01/29 06:53:35 dholland Exp $ */ | 1 | /* $NetBSD: ufs_quota.c,v 1.91 2012/01/29 06:54:34 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.90 2012/01/29 06:53:35 dholland Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.91 2012/01/29 06:54:34 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> | |
@@ -69,27 +69,27 @@ kcondvar_t dqcv; | @@ -69,27 +69,27 @@ kcondvar_t dqcv; | |||
69 | static LIST_HEAD(dqhashhead, dquot) *dqhashtbl; | 69 | static LIST_HEAD(dqhashhead, dquot) *dqhashtbl; | |
70 | static u_long dqhash; | 70 | static u_long dqhash; | |
71 | static pool_cache_t dquot_cache; | 71 | static pool_cache_t dquot_cache; | |
72 | 72 | |||
73 | 73 | |||
74 | static int quota_handle_cmd_get_version(struct mount *, struct lwp *, | 74 | static int quota_handle_cmd_get_version(struct mount *, struct lwp *, | |
75 | struct vfs_quotactl_args *args); | 75 | struct vfs_quotactl_args *args); | |
76 | static int quota_handle_cmd_get(struct mount *, struct lwp *, | 76 | static int quota_handle_cmd_get(struct mount *, struct lwp *, | |
77 | struct vfs_quotactl_args *args); | 77 | struct vfs_quotactl_args *args); | |
78 | static int quota_handle_cmd_put(struct mount *, struct lwp *, | 78 | static int quota_handle_cmd_put(struct mount *, struct lwp *, | |
79 | struct vfs_quotactl_args *args); | 79 | struct vfs_quotactl_args *args); | |
80 | static int quota_handle_cmd_getall(struct mount *, struct lwp *, | 80 | static int quota_handle_cmd_getall(struct mount *, struct lwp *, | |
81 | struct vfs_quotactl_args *args); | 81 | struct vfs_quotactl_args *args); | |
82 | static int quota_handle_cmd_clear(struct mount *, struct lwp *, | 82 | static int quota_handle_cmd_delete(struct mount *, struct lwp *, | |
83 | struct vfs_quotactl_args *args); | 83 | struct vfs_quotactl_args *args); | |
84 | static int quota_handle_cmd_quotaon(struct mount *, struct lwp *, | 84 | static int quota_handle_cmd_quotaon(struct mount *, struct lwp *, | |
85 | struct vfs_quotactl_args *args); | 85 | struct vfs_quotactl_args *args); | |
86 | static int quota_handle_cmd_quotaoff(struct mount *, struct lwp *, | 86 | static int quota_handle_cmd_quotaoff(struct mount *, struct lwp *, | |
87 | struct vfs_quotactl_args *args); | 87 | struct vfs_quotactl_args *args); | |
88 | 88 | |||
89 | /* | 89 | /* | |
90 | * Initialize the quota fields of an inode. | 90 | * Initialize the quota fields of an inode. | |
91 | */ | 91 | */ | |
92 | void | 92 | void | |
93 | ufsquota_init(struct inode *ip) | 93 | ufsquota_init(struct inode *ip) | |
94 | { | 94 | { | |
95 | int i; | 95 | int i; | |
@@ -168,28 +168,28 @@ quota_handle_cmd(struct mount *mp, struc | @@ -168,28 +168,28 @@ quota_handle_cmd(struct mount *mp, struc | |||
168 | break; | 168 | break; | |
169 | case QUOTACTL_QUOTAOFF: | 169 | case QUOTACTL_QUOTAOFF: | |
170 | error = quota_handle_cmd_quotaoff(mp, l, args); | 170 | error = quota_handle_cmd_quotaoff(mp, l, args); | |
171 | break; | 171 | break; | |
172 | case QUOTACTL_GET: | 172 | case QUOTACTL_GET: | |
173 | error = quota_handle_cmd_get(mp, l, args); | 173 | error = quota_handle_cmd_get(mp, l, args); | |
174 | break; | 174 | break; | |
175 | case QUOTACTL_PUT: | 175 | case QUOTACTL_PUT: | |
176 | error = quota_handle_cmd_put(mp, l, args); | 176 | error = quota_handle_cmd_put(mp, l, args); | |
177 | break; | 177 | break; | |
178 | case QUOTACTL_GETALL: | 178 | case QUOTACTL_GETALL: | |
179 | error = quota_handle_cmd_getall(mp, l, args); | 179 | error = quota_handle_cmd_getall(mp, l, args); | |
180 | break; | 180 | break; | |
181 | case QUOTACTL_CLEAR: | 181 | case QUOTACTL_DELETE: | |
182 | error = quota_handle_cmd_clear(mp, l, args); | 182 | error = quota_handle_cmd_delete(mp, l, args); | |
183 | break; | 183 | break; | |
184 | default: | 184 | default: | |
185 | panic("Invalid quotactl operation %d\n", op); | 185 | panic("Invalid quotactl operation %d\n", op); | |
186 | } | 186 | } | |
187 | 187 | |||
188 | return error; | 188 | return error; | |
189 | } | 189 | } | |
190 | 190 | |||
191 | static int | 191 | static int | |
192 | quota_handle_cmd_get_version(struct mount *mp, struct lwp *l, | 192 | quota_handle_cmd_get_version(struct mount *mp, struct lwp *l, | |
193 | struct vfs_quotactl_args *args) | 193 | struct vfs_quotactl_args *args) | |
194 | { | 194 | { | |
195 | struct ufsmount *ump = VFSTOUFS(mp); | 195 | struct ufsmount *ump = VFSTOUFS(mp); | |
@@ -302,54 +302,54 @@ quota_handle_cmd_put(struct mount *mp, s | @@ -302,54 +302,54 @@ quota_handle_cmd_put(struct mount *mp, s | |||
302 | error = quota2_handle_cmd_put(ump, qk, qv); | 302 | error = quota2_handle_cmd_put(ump, qk, qv); | |
303 | } else | 303 | } else | |
304 | #endif | 304 | #endif | |
305 | panic("quota_handle_cmd_get: no support ?"); | 305 | panic("quota_handle_cmd_get: no support ?"); | |
306 | 306 | |||
307 | if (error == ENOENT) { | 307 | if (error == ENOENT) { | |
308 | error = 0; | 308 | error = 0; | |
309 | } | 309 | } | |
310 | 310 | |||
311 | return error; | 311 | return error; | |
312 | } | 312 | } | |
313 | 313 | |||
314 | static int | 314 | static int | |
315 | quota_handle_cmd_clear(struct mount *mp, struct lwp *l, | 315 | quota_handle_cmd_delete(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 | int objtype; | 322 | int objtype; | |
323 | int error; | 323 | int error; | |
324 | 324 | |||
325 | KASSERT(args->qc_type == QCT_CLEAR); | 325 | KASSERT(args->qc_type == QCT_DELETE); | |
326 | idtype = args->u.clear.qc_idtype; | 326 | idtype = args->u.delete.qc_idtype; | |
327 | id = args->u.clear.qc_id; | 327 | id = args->u.delete.qc_id; | |
328 | defaultq = args->u.clear.qc_defaultq; | 328 | defaultq = args->u.delete.qc_defaultq; | |
329 | objtype = args->u.clear.qc_objtype; | 329 | objtype = args->u.delete.qc_objtype; | |
330 | 330 | |||
331 | if ((ump->um_flags & UFS_QUOTA2) == 0) | 331 | if ((ump->um_flags & UFS_QUOTA2) == 0) | |
332 | return EOPNOTSUPP; | 332 | return EOPNOTSUPP; | |
333 | 333 | |||
334 | /* avoid whitespace changes */ | 334 | /* avoid whitespace changes */ | |
335 | { | 335 | { | |
336 | error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA, | 336 | error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA, | |
337 | KAUTH_REQ_SYSTEM_FS_QUOTA_MANAGE, mp, KAUTH_ARG(id), NULL); | 337 | KAUTH_REQ_SYSTEM_FS_QUOTA_MANAGE, mp, KAUTH_ARG(id), NULL); | |
338 | if (error != 0) | 338 | if (error != 0) | |
339 | goto err; | 339 | goto err; | |
340 | #ifdef QUOTA2 | 340 | #ifdef QUOTA2 | |
341 | if (ump->um_flags & UFS_QUOTA2) { | 341 | if (ump->um_flags & UFS_QUOTA2) { | |
342 | error = quota2_handle_cmd_clear(ump, idtype, id, | 342 | error = quota2_handle_cmd_delete(ump, idtype, id, | |
343 | defaultq, objtype); | 343 | defaultq, objtype); | |
344 | } else | 344 | } else | |
345 | #endif | 345 | #endif | |
346 | panic("quota_handle_cmd_get: no support ?"); | 346 | panic("quota_handle_cmd_get: no support ?"); | |
347 | 347 | |||
348 | if (error && error != ENOENT) | 348 | if (error && error != ENOENT) | |
349 | goto err; | 349 | goto err; | |
350 | } | 350 | } | |
351 | 351 | |||
352 | return 0; | 352 | return 0; | |
353 | err: | 353 | err: | |
354 | return error; | 354 | return error; | |
355 | } | 355 | } |
--- src/sys/ufs/ufs/ufs_quota.h 2012/01/29 06:53:35 1.12
+++ src/sys/ufs/ufs/ufs_quota.h 2012/01/29 06:54:34 1.13
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ufs_quota.h,v 1.12 2012/01/29 06:53:35 dholland Exp $ */ | 1 | /* $NetBSD: ufs_quota.h,v 1.13 2012/01/29 06:54:34 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 *); | |
118 | int quota1_handle_cmd_put(struct ufsmount *, const struct quotakey *, | 118 | int quota1_handle_cmd_put(struct ufsmount *, const struct quotakey *, | |
119 | const struct quotaval *); | 119 | const struct quotaval *); | |
120 | int quota1_handle_cmd_quotaon(struct lwp *, struct ufsmount *, int, | 120 | int quota1_handle_cmd_quotaon(struct lwp *, struct ufsmount *, int, | |
121 | const char *); | 121 | const char *); | |
122 | int quota1_handle_cmd_quotaoff(struct lwp *, struct ufsmount *, int); | 122 | int quota1_handle_cmd_quotaoff(struct lwp *, struct ufsmount *, int); | |
123 | 123 | |||
124 | int chkdq2(struct inode *, int64_t, kauth_cred_t, int); | 124 | int chkdq2(struct inode *, int64_t, kauth_cred_t, int); | |
125 | int chkiq2(struct inode *, int32_t, kauth_cred_t, int); | 125 | int chkiq2(struct inode *, int32_t, kauth_cred_t, int); | |
126 | int quota2_handle_cmd_get(struct ufsmount *, const struct quotakey *, | 126 | int quota2_handle_cmd_get(struct ufsmount *, const struct quotakey *, | |
127 | struct quotaval *); | 127 | struct quotaval *); | |
128 | int quota2_handle_cmd_put(struct ufsmount *, const struct quotakey *, | 128 | int quota2_handle_cmd_put(struct ufsmount *, const struct quotakey *, | |
129 | const struct quotaval *); | 129 | const struct quotaval *); | |
130 | int quota2_handle_cmd_clear(struct ufsmount *, int, int, int, int); | 130 | int quota2_handle_cmd_delete(struct ufsmount *, int, int, int, int); | |
131 | int quota2_handle_cmd_getall(struct ufsmount *, int, prop_array_t); | 131 | int quota2_handle_cmd_getall(struct ufsmount *, int, prop_array_t); | |
132 | int q2sync(struct mount *); | 132 | int q2sync(struct mount *); | |
133 | int dq2get(struct vnode *, u_long, struct ufsmount *, int, struct dquot *); | 133 | int dq2get(struct vnode *, u_long, struct ufsmount *, int, struct dquot *); | |
134 | int dq2sync(struct vnode *, struct dquot *); | 134 | int dq2sync(struct vnode *, struct dquot *); |
--- src/sys/ufs/ufs/ufs_quota2.c 2012/01/29 06:53:36 1.13
+++ src/sys/ufs/ufs/ufs_quota2.c 2012/01/29 06:54:34 1.14
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ufs_quota2.c,v 1.13 2012/01/29 06:53:36 dholland Exp $ */ | 1 | /* $NetBSD: ufs_quota2.c,v 1.14 2012/01/29 06:54:34 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.13 2012/01/29 06:53:36 dholland Exp $"); | 29 | __KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.14 2012/01/29 06:54:34 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,27 +698,27 @@ dq2clear_callback(struct ufsmount *ump, | @@ -698,27 +698,27 @@ 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 | } | |
710 | int | 710 | int | |
711 | quota2_handle_cmd_clear(struct ufsmount *ump, int idtype, int id, | 711 | quota2_handle_cmd_delete(struct ufsmount *ump, int idtype, int id, | |
712 | int defaultq, int objtype) | 712 | int defaultq, int objtype) | |
713 | { | 713 | { | |
714 | int error, i, canfree; | 714 | int error, i, canfree; | |
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[idtype] == NULLVP) | 722 | if (ump->um_quotas[idtype] == NULLVP) | |
723 | return ENODEV; | 723 | return ENODEV; | |
724 | if (defaultq) | 724 | if (defaultq) |