Add QUOTACTL_CURSORSKIPIDTYPE, QUOTACTL_CURSORATEND, QUOTACTL_CURSORREWIND. This change requires a kernel version bump.diff -r1.28 -r1.29 src/sys/kern/vfs_quotactl.c
(dholland)
--- src/sys/kern/vfs_quotactl.c 2012/01/29 07:08:58 1.28
+++ src/sys/kern/vfs_quotactl.c 2012/01/29 07:09:52 1.29
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: vfs_quotactl.c,v 1.28 2012/01/29 07:08:58 dholland Exp $ */ | 1 | /* $NetBSD: vfs_quotactl.c,v 1.29 2012/01/29 07:09:52 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.28 2012/01/29 07:08:58 dholland Exp $"); | 83 | __KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.29 2012/01/29 07:09:52 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 | |||
91 | static int | 91 | static int | |
92 | vfs_quotactl_getversion(struct mount *mp, | 92 | vfs_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; | |
@@ -550,34 +550,34 @@ vfs_quotactl_getall(struct mount *mp, | @@ -550,34 +550,34 @@ vfs_quotactl_getall(struct mount *mp, | |||
550 | keys = malloc(loopmax * sizeof(keys[0]), M_TEMP, M_WAITOK); | 550 | keys = malloc(loopmax * sizeof(keys[0]), M_TEMP, M_WAITOK); | |
551 | vals = malloc(loopmax * sizeof(vals[0]), M_TEMP, M_WAITOK); | 551 | vals = malloc(loopmax * sizeof(vals[0]), M_TEMP, M_WAITOK); | |
552 | 552 | |||
553 | replies = prop_array_create(); | 553 | replies = prop_array_create(); | |
554 | if (replies == NULL) { | 554 | if (replies == NULL) { | |
555 | error = ENOMEM; | 555 | error = ENOMEM; | |
556 | goto err; | 556 | goto err; | |
557 | } | 557 | } | |
558 | 558 | |||
559 | thisreply = NULL; | 559 | thisreply = NULL; | |
560 | lastid = 0; /* value not actually referenced */ | 560 | lastid = 0; /* value not actually referenced */ | |
561 | 561 | |||
562 | while (1) { | 562 | while (1) { | |
563 | args.qc_type = QCT_GETALL; | 563 | args.qc_type = QCT_CURSORGET; | |
564 | args.u.getall.qc_cursor = &cursor; | 564 | args.u.cursorget.qc_cursor = &cursor; | |
565 | args.u.getall.qc_keys = keys; | 565 | args.u.cursorget.qc_keys = keys; | |
566 | args.u.getall.qc_vals = vals; | 566 | args.u.cursorget.qc_vals = vals; | |
567 | args.u.getall.qc_maxnum = loopmax; | 567 | args.u.cursorget.qc_maxnum = loopmax; | |
568 | args.u.getall.qc_ret = &loopnum; | 568 | args.u.cursorget.qc_ret = &loopnum; | |
569 | 569 | |||
570 | error = VFS_QUOTACTL(mp, QUOTACTL_GETALL, &args); | 570 | error = VFS_QUOTACTL(mp, QUOTACTL_CURSORGET, &args); | |
571 | if (error) { | 571 | if (error) { | |
572 | goto err; | 572 | goto err; | |
573 | } | 573 | } | |
574 | 574 | |||
575 | if (loopnum == 0) { | 575 | if (loopnum == 0) { | |
576 | /* end of iteration */ | 576 | /* end of iteration */ | |
577 | break; | 577 | break; | |
578 | } | 578 | } | |
579 | 579 | |||
580 | for (i = 0; i < loopnum; i++) { | 580 | for (i = 0; i < loopnum; i++) { | |
581 | key = &keys[i]; | 581 | key = &keys[i]; | |
582 | val = &vals[i]; | 582 | val = &vals[i]; | |
583 | 583 |
--- src/sys/sys/quotactl.h 2012/01/29 07:08:58 1.25
+++ src/sys/sys/quotactl.h 2012/01/29 07:09:52 1.26
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: quotactl.h,v 1.25 2012/01/29 07:08:58 dholland Exp $ */ | 1 | /* $NetBSD: quotactl.h,v 1.26 2012/01/29 07:09:52 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 | |
@@ -47,41 +47,47 @@ | @@ -47,41 +47,47 @@ | |||
47 | struct quotakcursor { | 47 | struct quotakcursor { | |
48 | union { | 48 | union { | |
49 | char qkc_space[64]; | 49 | char qkc_space[64]; | |
50 | uintmax_t __qkc_forcealign; | 50 | uintmax_t __qkc_forcealign; | |
51 | } u; | 51 | } u; | |
52 | }; | 52 | }; | |
53 | 53 | |||
54 | /* Command codes. */ | 54 | /* Command codes. */ | |
55 | #define QUOTACTL_GETVERSION 0 | 55 | #define QUOTACTL_GETVERSION 0 | |
56 | #define QUOTACTL_QUOTAON 1 | 56 | #define QUOTACTL_QUOTAON 1 | |
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_GETALL 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 | |||
65 | #define QUOTACTL_CURSORATEND 10 | |||
66 | #define QUOTACTL_CURSORREWIND 11 | |||
64 | 67 | |||
65 | /* Argument encoding. */ | 68 | /* Argument encoding. */ | |
66 | enum vfs_quotactl_argtypes { | 69 | enum vfs_quotactl_argtypes { | |
67 | QCT_PROPLIB, /* quotaon/off */ | 70 | QCT_PROPLIB, /* quotaon/off */ | |
68 | QCT_GETVERSION, /* getversion */ | 71 | QCT_GETVERSION, /* getversion */ | |
69 | QCT_GET, /* get */ | 72 | QCT_GET, /* get */ | |
70 | QCT_PUT, /* put */ | 73 | QCT_PUT, /* put */ | |
71 | QCT_DELETE, /* delete */ | 74 | QCT_DELETE, /* delete */ | |
72 | QCT_CURSOROPEN, /* open cursor */ | 75 | QCT_CURSOROPEN, /* open cursor */ | |
73 | QCT_CURSORCLOSE,/* close cursor */ | 76 | QCT_CURSORCLOSE,/* close cursor */ | |
74 | QCT_GETALL, /* get all */ | 77 | QCT_CURSORGET, /* get from cursor */ | |
78 | QCT_CURSORSKIPIDTYPE, /* iteration hint */ | |||
79 | QCT_CURSORATEND,/* test cursor */ | |||
80 | QCT_CURSORREWIND,/* reset cursor */ | |||
75 | }; | 81 | }; | |
76 | struct vfs_quotactl_args { | 82 | struct vfs_quotactl_args { | |
77 | enum vfs_quotactl_argtypes qc_type; | 83 | enum vfs_quotactl_argtypes qc_type; | |
78 | union { | 84 | union { | |
79 | struct { | 85 | struct { | |
80 | prop_dictionary_t qc_cmddict; | 86 | prop_dictionary_t qc_cmddict; | |
81 | int qc_q2type; | 87 | int qc_q2type; | |
82 | prop_array_t qc_datas; | 88 | prop_array_t qc_datas; | |
83 | } proplib; | 89 | } proplib; | |
84 | struct { | 90 | struct { | |
85 | int *qc_version_ret; | 91 | int *qc_version_ret; | |
86 | } getversion; | 92 | } getversion; | |
87 | struct { | 93 | struct { | |
@@ -93,22 +99,33 @@ struct vfs_quotactl_args { | @@ -93,22 +99,33 @@ struct vfs_quotactl_args { | |||
93 | const struct quotaval *qc_val; | 99 | const struct quotaval *qc_val; | |
94 | } put; | 100 | } put; | |
95 | struct { | 101 | struct { | |
96 | const struct quotakey *qc_key; | 102 | const struct quotakey *qc_key; | |
97 | } delete; | 103 | } delete; | |
98 | struct { | 104 | struct { | |
99 | struct quotakcursor *qc_cursor; | 105 | struct quotakcursor *qc_cursor; | |
100 | } cursoropen; | 106 | } cursoropen; | |
101 | struct { | 107 | struct { | |
102 | struct quotakcursor *qc_cursor; | 108 | struct quotakcursor *qc_cursor; | |
103 | } cursorclose; | 109 | } cursorclose; | |
104 | struct { | 110 | struct { | |
105 | struct quotakcursor *qc_cursor; | 111 | struct quotakcursor *qc_cursor; | |
112 | unsigned qc_idtype; | |||
113 | } cursorskipidtype; | |||
114 | struct { | |||
115 | struct quotakcursor *qc_cursor; | |||
106 | struct quotakey *qc_keys; | 116 | struct quotakey *qc_keys; | |
107 | struct quotaval *qc_vals; | 117 | struct quotaval *qc_vals; | |
108 | unsigned qc_maxnum; | 118 | unsigned qc_maxnum; | |
109 | unsigned *qc_ret; | 119 | unsigned *qc_ret; | |
110 | } getall; | 120 | } cursorget; | |
121 | struct { | |||
122 | struct quotakcursor *qc_cursor; | |||
123 | int *qc_ret; /* really boolean */ | |||
124 | } cursoratend; | |||
125 | struct { | |||
126 | struct quotakcursor *qc_cursor; | |||
127 | } cursorrewind; | |||
111 | } u; | 128 | } u; | |
112 | }; | 129 | }; | |
113 | 130 | |||
114 | #endif /* _SYS_QUOTACTL_H_ */ | 131 | #endif /* _SYS_QUOTACTL_H_ */ |
--- src/sys/ufs/ufs/ufs_quota.c 2012/01/29 07:08:58 1.97
+++ src/sys/ufs/ufs/ufs_quota.c 2012/01/29 07:09:52 1.98
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ufs_quota.c,v 1.97 2012/01/29 07:08:58 dholland Exp $ */ | 1 | /* $NetBSD: ufs_quota.c,v 1.98 2012/01/29 07:09:52 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.97 2012/01/29 07:08:58 dholland Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.98 2012/01/29 07:09:52 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> | |
@@ -67,38 +67,44 @@ kcondvar_t dqcv; | @@ -67,38 +67,44 @@ kcondvar_t dqcv; | |||
67 | #define DQHASH(dqvp, id) \ | 67 | #define DQHASH(dqvp, id) \ | |
68 | (((((long)(dqvp)) >> 8) + id) & dqhash) | 68 | (((((long)(dqvp)) >> 8) + id) & dqhash) | |
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_cursorget(struct mount *, struct lwp *, | |
81 | struct vfs_quotactl_args *args); | 81 | struct vfs_quotactl_args *args); | |
82 | static int quota_handle_cmd_delete(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 | static int quota_handle_cmd_cursoropen(struct mount *, struct lwp *, | 88 | static int quota_handle_cmd_cursoropen(struct mount *, struct lwp *, | |
89 | struct vfs_quotactl_args *args); | 89 | struct vfs_quotactl_args *args); | |
90 | static int quota_handle_cmd_cursorclose(struct mount *, struct lwp *, | 90 | static int quota_handle_cmd_cursorclose(struct mount *, struct lwp *, | |
91 | struct vfs_quotactl_args *args); | 91 | struct vfs_quotactl_args *args); | |
92 | static int quota_handle_cmd_cursorskipidtype(struct mount *, struct lwp *, | |||
93 | struct vfs_quotactl_args *args); | |||
94 | static int quota_handle_cmd_cursoratend(struct mount *, struct lwp *, | |||
95 | struct vfs_quotactl_args *args); | |||
96 | static int quota_handle_cmd_cursorrewind(struct mount *, struct lwp *, | |||
97 | struct vfs_quotactl_args *args); | |||
92 | 98 | |||
93 | /* | 99 | /* | |
94 | * Initialize the quota fields of an inode. | 100 | * Initialize the quota fields of an inode. | |
95 | */ | 101 | */ | |
96 | void | 102 | void | |
97 | ufsquota_init(struct inode *ip) | 103 | ufsquota_init(struct inode *ip) | |
98 | { | 104 | { | |
99 | int i; | 105 | int i; | |
100 | 106 | |||
101 | for (i = 0; i < MAXQUOTAS; i++) | 107 | for (i = 0; i < MAXQUOTAS; i++) | |
102 | ip->i_dquot[i] = NODQUOT; | 108 | ip->i_dquot[i] = NODQUOT; | |
103 | } | 109 | } | |
104 | 110 | |||
@@ -169,38 +175,47 @@ quota_handle_cmd(struct mount *mp, struc | @@ -169,38 +175,47 @@ quota_handle_cmd(struct mount *mp, struc | |||
169 | break; | 175 | break; | |
170 | case QUOTACTL_QUOTAON: | 176 | case QUOTACTL_QUOTAON: | |
171 | error = quota_handle_cmd_quotaon(mp, l, args); | 177 | error = quota_handle_cmd_quotaon(mp, l, args); | |
172 | break; | 178 | break; | |
173 | case QUOTACTL_QUOTAOFF: | 179 | case QUOTACTL_QUOTAOFF: | |
174 | error = quota_handle_cmd_quotaoff(mp, l, args); | 180 | error = quota_handle_cmd_quotaoff(mp, l, args); | |
175 | break; | 181 | break; | |
176 | case QUOTACTL_GET: | 182 | case QUOTACTL_GET: | |
177 | error = quota_handle_cmd_get(mp, l, args); | 183 | error = quota_handle_cmd_get(mp, l, args); | |
178 | break; | 184 | break; | |
179 | case QUOTACTL_PUT: | 185 | case QUOTACTL_PUT: | |
180 | error = quota_handle_cmd_put(mp, l, args); | 186 | error = quota_handle_cmd_put(mp, l, args); | |
181 | break; | 187 | break; | |
182 | case QUOTACTL_GETALL: | 188 | case QUOTACTL_CURSORGET: | |
183 | error = quota_handle_cmd_getall(mp, l, args); | 189 | error = quota_handle_cmd_cursorget(mp, l, args); | |
184 | break; | 190 | break; | |
185 | case QUOTACTL_DELETE: | 191 | case QUOTACTL_DELETE: | |
186 | error = quota_handle_cmd_delete(mp, l, args); | 192 | error = quota_handle_cmd_delete(mp, l, args); | |
187 | break; | 193 | break; | |
188 | case QUOTACTL_CURSOROPEN: | 194 | case QUOTACTL_CURSOROPEN: | |
189 | error = quota_handle_cmd_cursoropen(mp, l, args); | 195 | error = quota_handle_cmd_cursoropen(mp, l, args); | |
190 | break; | 196 | break; | |
191 | case QUOTACTL_CURSORCLOSE: | 197 | case QUOTACTL_CURSORCLOSE: | |
192 | error = quota_handle_cmd_cursorclose(mp, l, args); | 198 | error = quota_handle_cmd_cursorclose(mp, l, args); | |
193 | break; | 199 | break; | |
200 | case QUOTACTL_CURSORSKIPIDTYPE: | |||
201 | error = quota_handle_cmd_cursorskipidtype(mp, l, args); | |||
202 | break; | |||
203 | case QUOTACTL_CURSORATEND: | |||
204 | error = quota_handle_cmd_cursoratend(mp, l, args); | |||
205 | break; | |||
206 | case QUOTACTL_CURSORREWIND: | |||
207 | error = quota_handle_cmd_cursorrewind(mp, l, args); | |||
208 | break; | |||
194 | default: | 209 | default: | |
195 | panic("Invalid quotactl operation %d\n", op); | 210 | panic("Invalid quotactl operation %d\n", op); | |
196 | } | 211 | } | |
197 | 212 | |||
198 | return error; | 213 | return error; | |
199 | } | 214 | } | |
200 | 215 | |||
201 | static int | 216 | static int | |
202 | quota_handle_cmd_get_version(struct mount *mp, struct lwp *l, | 217 | quota_handle_cmd_get_version(struct mount *mp, struct lwp *l, | |
203 | struct vfs_quotactl_args *args) | 218 | struct vfs_quotactl_args *args) | |
204 | { | 219 | { | |
205 | struct ufsmount *ump = VFSTOUFS(mp); | 220 | struct ufsmount *ump = VFSTOUFS(mp); | |
206 | int *version_ret; | 221 | int *version_ret; | |
@@ -355,59 +370,59 @@ quota_handle_cmd_delete(struct mount *mp | @@ -355,59 +370,59 @@ quota_handle_cmd_delete(struct mount *mp | |||
355 | #endif | 370 | #endif | |
356 | panic("quota_handle_cmd_get: no support ?"); | 371 | panic("quota_handle_cmd_get: no support ?"); | |
357 | 372 | |||
358 | if (error && error != ENOENT) | 373 | if (error && error != ENOENT) | |
359 | goto err; | 374 | goto err; | |
360 | } | 375 | } | |
361 | 376 | |||
362 | return 0; | 377 | return 0; | |
363 | err: | 378 | err: | |
364 | return error; | 379 | return error; | |
365 | } | 380 | } | |
366 | 381 | |||
367 | static int | 382 | static int | |
368 | quota_handle_cmd_getall(struct mount *mp, struct lwp *l, | 383 | quota_handle_cmd_cursorget(struct mount *mp, struct lwp *l, | |
369 | struct vfs_quotactl_args *args) | 384 | struct vfs_quotactl_args *args) | |
370 | { | 385 | { | |
371 | struct ufsmount *ump = VFSTOUFS(mp); | 386 | struct ufsmount *ump = VFSTOUFS(mp); | |
372 | struct quotakcursor *cursor; | 387 | struct quotakcursor *cursor; | |
373 | struct quotakey *keys; | 388 | struct quotakey *keys; | |
374 | struct quotaval *vals; | 389 | struct quotaval *vals; | |
375 | unsigned maxnum; | 390 | unsigned maxnum; | |
376 | unsigned *ret; | 391 | unsigned *ret; | |
377 | int error; | 392 | int error; | |
378 | 393 | |||
379 | KASSERT(args->qc_type == QCT_GETALL); | 394 | KASSERT(args->qc_type == QCT_CURSORGET); | |
380 | cursor = args->u.getall.qc_cursor; | 395 | cursor = args->u.cursorget.qc_cursor; | |
381 | keys = args->u.getall.qc_keys; | 396 | keys = args->u.cursorget.qc_keys; | |
382 | vals = args->u.getall.qc_vals; | 397 | vals = args->u.cursorget.qc_vals; | |
383 | maxnum = args->u.getall.qc_maxnum; | 398 | maxnum = args->u.cursorget.qc_maxnum; | |
384 | ret = args->u.getall.qc_ret; | 399 | ret = args->u.cursorget.qc_ret; | |
385 | 400 | |||
386 | if ((ump->um_flags & UFS_QUOTA2) == 0) | 401 | if ((ump->um_flags & UFS_QUOTA2) == 0) | |
387 | return EOPNOTSUPP; | 402 | return EOPNOTSUPP; | |
388 | 403 | |||
389 | error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA, | 404 | error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA, | |
390 | KAUTH_REQ_SYSTEM_FS_QUOTA_GET, mp, NULL, NULL); | 405 | KAUTH_REQ_SYSTEM_FS_QUOTA_GET, mp, NULL, NULL); | |
391 | if (error) | 406 | if (error) | |
392 | return error; | 407 | return error; | |
393 | 408 | |||
394 | #ifdef QUOTA2 | 409 | #ifdef QUOTA2 | |
395 | if (ump->um_flags & UFS_QUOTA2) { | 410 | if (ump->um_flags & UFS_QUOTA2) { | |
396 | error = quota2_handle_cmd_getall(ump, cursor, | 411 | error = quota2_handle_cmd_cursorget(ump, cursor, keys, vals, | |
397 | keys, vals, maxnum, ret); | 412 | maxnum, ret); | |
398 | } else | 413 | } else | |
399 | #endif | 414 | #endif | |
400 | panic("quota_handle_cmd_getall: no support ?"); | 415 | panic("quota_handle_cmd_cursorget: no support ?"); | |
401 | 416 | |||
402 | return error; | 417 | return error; | |
403 | } | 418 | } | |
404 | 419 | |||
405 | static int | 420 | static int | |
406 | quota_handle_cmd_cursoropen(struct mount *mp, struct lwp *l, | 421 | quota_handle_cmd_cursoropen(struct mount *mp, struct lwp *l, | |
407 | struct vfs_quotactl_args *args) | 422 | struct vfs_quotactl_args *args) | |
408 | { | 423 | { | |
409 | struct ufsmount *ump = VFSTOUFS(mp); | 424 | struct ufsmount *ump = VFSTOUFS(mp); | |
410 | struct quotakcursor *cursor; | 425 | struct quotakcursor *cursor; | |
411 | int error; | 426 | int error; | |
412 | 427 | |||
413 | KASSERT(args->qc_type == QCT_CURSOROPEN); | 428 | KASSERT(args->qc_type == QCT_CURSOROPEN); | |
@@ -445,26 +460,93 @@ quota_handle_cmd_cursorclose(struct moun | @@ -445,26 +460,93 @@ quota_handle_cmd_cursorclose(struct moun | |||
445 | return error; | 460 | return error; | |
446 | 461 | |||
447 | #ifdef QUOTA2 | 462 | #ifdef QUOTA2 | |
448 | if (ump->um_flags & UFS_QUOTA2) { | 463 | if (ump->um_flags & UFS_QUOTA2) { | |
449 | error = quota2_handle_cmd_cursorclose(ump, cursor); | 464 | error = quota2_handle_cmd_cursorclose(ump, cursor); | |
450 | } else | 465 | } else | |
451 | #endif | 466 | #endif | |
452 | error = EOPNOTSUPP; | 467 | error = EOPNOTSUPP; | |
453 | 468 | |||
454 | return error; | 469 | return error; | |
455 | } | 470 | } | |
456 | 471 | |||
457 | static int | 472 | static int | |
473 | quota_handle_cmd_cursorskipidtype(struct mount *mp, struct lwp *l, | |||
474 | struct vfs_quotactl_args *args) | |||
475 | { | |||
476 | struct ufsmount *ump = VFSTOUFS(mp); | |||
477 | struct quotakcursor *cursor; | |||
478 | int idtype; | |||
479 | int error; | |||
480 | ||||
481 | KASSERT(args->qc_type == QCT_CURSORSKIPIDTYPE); | |||
482 | cursor = args->u.cursorskipidtype.qc_cursor; | |||
483 | idtype = args->u.cursorskipidtype.qc_idtype; | |||
484 | ||||
485 | #ifdef QUOTA2 | |||
486 | if (ump->um_flags & UFS_QUOTA2) { | |||
487 | error = quota2_handle_cmd_cursorskipidtype(ump, cursor, idtype); | |||
488 | } else | |||
489 | #endif | |||
490 | error = EOPNOTSUPP; | |||
491 | ||||
492 | return error; | |||
493 | } | |||
494 | ||||
495 | static int | |||
496 | quota_handle_cmd_cursoratend(struct mount *mp, struct lwp *l, | |||
497 | struct vfs_quotactl_args *args) | |||
498 | { | |||
499 | struct ufsmount *ump = VFSTOUFS(mp); | |||
500 | struct quotakcursor *cursor; | |||
501 | int *ret; | |||
502 | int error; | |||
503 | ||||
504 | KASSERT(args->qc_type == QCT_CURSORATEND); | |||
505 | cursor = args->u.cursoratend.qc_cursor; | |||
506 | ret = args->u.cursoratend.qc_ret; | |||
507 | ||||
508 | #ifdef QUOTA2 | |||
509 | if (ump->um_flags & UFS_QUOTA2) { | |||
510 | error = quota2_handle_cmd_cursoratend(ump, cursor, ret); | |||
511 | } else | |||
512 | #endif | |||
513 | error = EOPNOTSUPP; | |||
514 | ||||
515 | return error; | |||
516 | } | |||
517 | ||||
518 | static int | |||
519 | quota_handle_cmd_cursorrewind(struct mount *mp, struct lwp *l, | |||
520 | struct vfs_quotactl_args *args) | |||
521 | { | |||
522 | struct ufsmount *ump = VFSTOUFS(mp); | |||
523 | struct quotakcursor *cursor; | |||
524 | int error; | |||
525 | ||||
526 | KASSERT(args->qc_type == QCT_CURSORREWIND); | |||
527 | cursor = args->u.cursorrewind.qc_cursor; | |||
528 | ||||
529 | #ifdef QUOTA2 | |||
530 | if (ump->um_flags & UFS_QUOTA2) { | |||
531 | error = quota2_handle_cmd_cursorrewind(ump, cursor); | |||
532 | } else | |||
533 | #endif | |||
534 | error = EOPNOTSUPP; | |||
535 | ||||
536 | return error; | |||
537 | } | |||
538 | ||||
539 | static int | |||
458 | quota_handle_cmd_quotaon(struct mount *mp, struct lwp *l, | 540 | quota_handle_cmd_quotaon(struct mount *mp, struct lwp *l, | |
459 | struct vfs_quotactl_args *args) | 541 | struct vfs_quotactl_args *args) | |
460 | { | 542 | { | |
461 | prop_dictionary_t data; | 543 | prop_dictionary_t data; | |
462 | struct ufsmount *ump = VFSTOUFS(mp); | 544 | struct ufsmount *ump = VFSTOUFS(mp); | |
463 | int error; | 545 | int error; | |
464 | const char *qfile; | 546 | const char *qfile; | |
465 | prop_dictionary_t cmddict; | 547 | prop_dictionary_t cmddict; | |
466 | int q2type; | 548 | int q2type; | |
467 | prop_array_t datas; | 549 | prop_array_t datas; | |
468 | 550 | |||
469 | KASSERT(args->qc_type == QCT_PROPLIB); | 551 | KASSERT(args->qc_type == QCT_PROPLIB); | |
470 | cmddict = args->u.proplib.qc_cmddict; | 552 | cmddict = args->u.proplib.qc_cmddict; |
--- src/sys/ufs/ufs/ufs_quota.h 2012/01/29 07:08:58 1.19
+++ src/sys/ufs/ufs/ufs_quota.h 2012/01/29 07:09:52 1.20
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ufs_quota.h,v 1.19 2012/01/29 07:08:58 dholland Exp $ */ | 1 | /* $NetBSD: ufs_quota.h,v 1.20 2012/01/29 07:09:52 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. | |
@@ -121,20 +121,25 @@ int quota1_handle_cmd_get(struct ufsmoun | @@ -121,20 +121,25 @@ int quota1_handle_cmd_get(struct ufsmoun | |||
121 | int quota1_handle_cmd_put(struct ufsmount *, const struct quotakey *, | 121 | int quota1_handle_cmd_put(struct ufsmount *, const struct quotakey *, | |
122 | const struct quotaval *); | 122 | const struct quotaval *); | |
123 | int quota1_handle_cmd_quotaon(struct lwp *, struct ufsmount *, int, | 123 | int quota1_handle_cmd_quotaon(struct lwp *, struct ufsmount *, int, | |
124 | const char *); | 124 | const char *); | |
125 | int quota1_handle_cmd_quotaoff(struct lwp *, struct ufsmount *, int); | 125 | int quota1_handle_cmd_quotaoff(struct lwp *, struct ufsmount *, int); | |
126 | 126 | |||
127 | int chkdq2(struct inode *, int64_t, kauth_cred_t, int); | 127 | int chkdq2(struct inode *, int64_t, kauth_cred_t, int); | |
128 | int chkiq2(struct inode *, int32_t, kauth_cred_t, int); | 128 | int chkiq2(struct inode *, int32_t, kauth_cred_t, int); | |
129 | int quota2_handle_cmd_get(struct ufsmount *, const struct quotakey *, | 129 | int quota2_handle_cmd_get(struct ufsmount *, const struct quotakey *, | |
130 | struct quotaval *); | 130 | struct quotaval *); | |
131 | int quota2_handle_cmd_put(struct ufsmount *, const struct quotakey *, | 131 | int quota2_handle_cmd_put(struct ufsmount *, const struct quotakey *, | |
132 | const struct quotaval *); | 132 | const struct quotaval *); | |
133 | int quota2_handle_cmd_delete(struct ufsmount *, const struct quotakey *); | 133 | int quota2_handle_cmd_delete(struct ufsmount *, const struct quotakey *); | |
134 | int quota2_handle_cmd_getall(struct ufsmount *, struct quotakcursor *, | 134 | int quota2_handle_cmd_cursorget(struct ufsmount *, struct quotakcursor *, | |
135 | struct quotakey *, struct quotaval *, unsigned, unsigned *); | 135 | struct quotakey *, struct quotaval *, unsigned, unsigned *); | |
136 | int quota2_handle_cmd_cursoropen(struct ufsmount *, struct quotakcursor *); | 136 | int quota2_handle_cmd_cursoropen(struct ufsmount *, struct quotakcursor *); | |
137 | int quota2_handle_cmd_cursorclose(struct ufsmount *, struct quotakcursor *); | 137 | int quota2_handle_cmd_cursorclose(struct ufsmount *, struct quotakcursor *); | |
138 | int quota2_handle_cmd_cursorskipidtype(struct ufsmount *, struct quotakcursor *, | |||
139 | int); | |||
140 | int quota2_handle_cmd_cursoratend(struct ufsmount *, struct quotakcursor *, | |||
141 | int *); | |||
142 | int quota2_handle_cmd_cursorrewind(struct ufsmount *, struct quotakcursor *); | |||
138 | int q2sync(struct mount *); | 143 | int q2sync(struct mount *); | |
139 | int dq2get(struct vnode *, u_long, struct ufsmount *, int, struct dquot *); | 144 | int dq2get(struct vnode *, u_long, struct ufsmount *, int, struct dquot *); | |
140 | int dq2sync(struct vnode *, struct dquot *); | 145 | int dq2sync(struct vnode *, struct dquot *); |
--- src/sys/ufs/ufs/ufs_quota2.c 2012/01/29 07:08:58 1.25
+++ src/sys/ufs/ufs/ufs_quota2.c 2012/01/29 07:09:52 1.26
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ufs_quota2.c,v 1.25 2012/01/29 07:08:58 dholland Exp $ */ | 1 | /* $NetBSD: ufs_quota2.c,v 1.26 2012/01/29 07:09:52 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.25 2012/01/29 07:08:58 dholland Exp $"); | 29 | __KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.26 2012/01/29 07:09:52 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> | |
@@ -1040,27 +1040,27 @@ quota2_getuids_callback(struct ufsmount | @@ -1040,27 +1040,27 @@ quota2_getuids_callback(struct ufsmount | |||
1040 | gu->uids = newuids; | 1040 | gu->uids = newuids; | |
1041 | gu->maxuids = newmax; | 1041 | gu->maxuids = newmax; | |
1042 | } | 1042 | } | |
1043 | gu->uids[gu->nuids] = ufs_rw32(q2ep->q2e_uid, needswap); | 1043 | gu->uids[gu->nuids] = ufs_rw32(q2ep->q2e_uid, needswap); | |
1044 | gu->nuids++; | 1044 | gu->nuids++; | |
1045 | gu->seen++; | 1045 | gu->seen++; | |
1046 | if (gu->nuids == gu->limit) { | 1046 | if (gu->nuids == gu->limit) { | |
1047 | return Q2WL_ABORT; | 1047 | return Q2WL_ABORT; | |
1048 | } | 1048 | } | |
1049 | return 0; | 1049 | return 0; | |
1050 | } | 1050 | } | |
1051 | 1051 | |||
1052 | int | 1052 | int | |
1053 | quota2_handle_cmd_getall(struct ufsmount *ump, struct quotakcursor *qkc, | 1053 | quota2_handle_cmd_cursorget(struct ufsmount *ump, struct quotakcursor *qkc, | |
1054 | struct quotakey *keys, struct quotaval *vals, unsigned maxreturn, | 1054 | struct quotakey *keys, struct quotaval *vals, unsigned maxreturn, | |
1055 | unsigned *ret) | 1055 | unsigned *ret) | |
1056 | { | 1056 | { | |
1057 | int error; | 1057 | int error; | |
1058 | struct ufsq2_cursor *cursor; | 1058 | struct ufsq2_cursor *cursor; | |
1059 | struct quota2_header *q2h; | 1059 | struct quota2_header *q2h; | |
1060 | struct quota2_entry q2e; | 1060 | struct quota2_entry q2e; | |
1061 | struct buf *hbp; | 1061 | struct buf *hbp; | |
1062 | uint64_t offset; | 1062 | uint64_t offset; | |
1063 | int idtype; | 1063 | int idtype; | |
1064 | int can_switch_idtype; | 1064 | int can_switch_idtype; | |
1065 | int i, j; | 1065 | int i, j; | |
1066 | int quota2_hash_size; | 1066 | int quota2_hash_size; | |
@@ -1270,26 +1270,94 @@ quota2_handle_cmd_cursorclose(struct ufs | @@ -1270,26 +1270,94 @@ quota2_handle_cmd_cursorclose(struct ufs | |||
1270 | 1270 | |||
1271 | cursor = Q2CURSOR(qkc); | 1271 | cursor = Q2CURSOR(qkc); | |
1272 | error = q2cursor_check(cursor); | 1272 | error = q2cursor_check(cursor); | |
1273 | if (error) { | 1273 | if (error) { | |
1274 | return error; | 1274 | return error; | |
1275 | } | 1275 | } | |
1276 | 1276 | |||
1277 | /* nothing to do */ | 1277 | /* nothing to do */ | |
1278 | 1278 | |||
1279 | return 0; | 1279 | return 0; | |
1280 | } | 1280 | } | |
1281 | 1281 | |||
1282 | int | 1282 | int | |
1283 | quota2_handle_cmd_cursorskipidtype(struct ufsmount *ump, | |||
1284 | struct quotakcursor *qkc, int idtype) | |||
1285 | { | |||
1286 | struct ufsq2_cursor *cursor; | |||
1287 | int error; | |||
1288 | ||||
1289 | cursor = Q2CURSOR(qkc); | |||
1290 | error = q2cursor_check(cursor); | |||
1291 | if (error) { | |||
1292 | return error; | |||
1293 | } | |||
1294 | ||||
1295 | switch (idtype) { | |||
1296 | case QUOTA_IDTYPE_USER: | |||
1297 | cursor->q2c_users_done = 1; | |||
1298 | break; | |||
1299 | case QUOTA_IDTYPE_GROUP: | |||
1300 | cursor->q2c_groups_done = 1; | |||
1301 | break; | |||
1302 | default: | |||
1303 | return EINVAL; | |||
1304 | } | |||
1305 | ||||
1306 | return 0; | |||
1307 | } | |||
1308 | ||||
1309 | int | |||
1310 | quota2_handle_cmd_cursoratend(struct ufsmount *ump, struct quotakcursor *qkc, | |||
1311 | int *ret) | |||
1312 | { | |||
1313 | struct ufsq2_cursor *cursor; | |||
1314 | int error; | |||
1315 | ||||
1316 | cursor = Q2CURSOR(qkc); | |||
1317 | error = q2cursor_check(cursor); | |||
1318 | if (error) { | |||
1319 | return error; | |||
1320 | } | |||
1321 | ||||
1322 | *ret = (cursor->q2c_users_done && cursor->q2c_groups_done); | |||
1323 | return 0; | |||
1324 | } | |||
1325 | ||||
1326 | int | |||
1327 | quota2_handle_cmd_cursorrewind(struct ufsmount *ump, struct quotakcursor *qkc) | |||
1328 | { | |||
1329 | struct ufsq2_cursor *cursor; | |||
1330 | int error; | |||
1331 | ||||
1332 | cursor = Q2CURSOR(qkc); | |||
1333 | error = q2cursor_check(cursor); | |||
1334 | if (error) { | |||
1335 | return error; | |||
1336 | } | |||
1337 | ||||
1338 | cursor->q2c_hashsize = 0; | |||
1339 | ||||
1340 | cursor->q2c_users_done = 0; | |||
1341 | cursor->q2c_groups_done = 0; | |||
1342 | cursor->q2c_defaults_done = 0; | |||
1343 | cursor->q2c_hashpos = 0; | |||
1344 | cursor->q2c_uidpos = 0; | |||
1345 | cursor->q2c_blocks_done = 0; | |||
1346 | ||||
1347 | return 0; | |||
1348 | } | |||
1349 | ||||
1350 | int | |||
1283 | q2sync(struct mount *mp) | 1351 | q2sync(struct mount *mp) | |
1284 | { | 1352 | { | |
1285 | return 0; | 1353 | return 0; | |
1286 | } | 1354 | } | |
1287 | 1355 | |||
1288 | struct dq2get_callback { | 1356 | struct dq2get_callback { | |
1289 | uid_t id; | 1357 | uid_t id; | |
1290 | struct dquot *dq; | 1358 | struct dquot *dq; | |
1291 | }; | 1359 | }; | |
1292 | 1360 | |||
1293 | static int | 1361 | static int | |
1294 | dq2get_callback(struct ufsmount *ump, uint64_t *offp, struct quota2_entry *q2e, | 1362 | dq2get_callback(struct ufsmount *ump, uint64_t *offp, struct quota2_entry *q2e, | |
1295 | uint64_t off, void *v) | 1363 | uint64_t off, void *v) |