vfs_quotactl.c revision 1.38.4.2 1 1.38.4.2 mrg /* $NetBSD: vfs_quotactl.c,v 1.38.4.2 2012/02/18 07:35:34 mrg Exp $ */
2 1.38.4.2 mrg /*-
3 1.38.4.2 mrg * Copyright (c) 2012 The NetBSD Foundation, Inc.
4 1.38.4.2 mrg * All rights reserved.
5 1.38.4.2 mrg *
6 1.38.4.2 mrg * This code is derived from software contributed to The NetBSD Foundation
7 1.38.4.2 mrg * by David A. Holland.
8 1.38.4.2 mrg *
9 1.38.4.2 mrg * Redistribution and use in source and binary forms, with or without
10 1.38.4.2 mrg * modification, are permitted provided that the following conditions
11 1.38.4.2 mrg * are met:
12 1.38.4.2 mrg * 1. Redistributions of source code must retain the above copyright
13 1.38.4.2 mrg * notice, this list of conditions and the following disclaimer.
14 1.38.4.2 mrg * 2. Redistributions in binary form must reproduce the above copyright
15 1.38.4.2 mrg * notice, this list of conditions and the following disclaimer in the
16 1.38.4.2 mrg * documentation and/or other materials provided with the distribution.
17 1.38.4.2 mrg *
18 1.38.4.2 mrg * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 1.38.4.2 mrg * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 1.38.4.2 mrg * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 1.38.4.2 mrg * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 1.38.4.2 mrg * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 1.38.4.2 mrg * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 1.38.4.2 mrg * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 1.38.4.2 mrg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 1.38.4.2 mrg * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 1.38.4.2 mrg * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 1.38.4.2 mrg * POSSIBILITY OF SUCH DAMAGE.
29 1.38.4.2 mrg */
30 1.38.4.2 mrg
31 1.38.4.2 mrg #include <sys/cdefs.h>
32 1.38.4.2 mrg __KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.38.4.2 2012/02/18 07:35:34 mrg Exp $$");
33 1.38.4.2 mrg
34 1.38.4.2 mrg #include <sys/mount.h>
35 1.38.4.2 mrg #include <sys/quotactl.h>
36 1.38.4.2 mrg
37 1.38.4.2 mrg int
38 1.38.4.2 mrg vfs_quotactl_stat(struct mount *mp, struct quotastat *info)
39 1.38.4.2 mrg {
40 1.38.4.2 mrg struct quotactl_args args;
41 1.38.4.2 mrg
42 1.38.4.2 mrg args.qc_op = QUOTACTL_STAT;
43 1.38.4.2 mrg args.u.stat.qc_info = info;
44 1.38.4.2 mrg return VFS_QUOTACTL(mp, &args);
45 1.38.4.2 mrg }
46 1.38.4.2 mrg
47 1.38.4.2 mrg int
48 1.38.4.2 mrg vfs_quotactl_idtypestat(struct mount *mp, int idtype,
49 1.38.4.2 mrg struct quotaidtypestat *info)
50 1.38.4.2 mrg {
51 1.38.4.2 mrg struct quotactl_args args;
52 1.38.4.2 mrg
53 1.38.4.2 mrg args.qc_op = QUOTACTL_IDTYPESTAT;
54 1.38.4.2 mrg args.u.idtypestat.qc_idtype = idtype;
55 1.38.4.2 mrg args.u.idtypestat.qc_info = info;
56 1.38.4.2 mrg return VFS_QUOTACTL(mp, &args);
57 1.38.4.2 mrg }
58 1.38.4.2 mrg
59 1.38.4.2 mrg int
60 1.38.4.2 mrg vfs_quotactl_objtypestat(struct mount *mp, int objtype,
61 1.38.4.2 mrg struct quotaobjtypestat *info)
62 1.38.4.2 mrg {
63 1.38.4.2 mrg struct quotactl_args args;
64 1.38.4.2 mrg
65 1.38.4.2 mrg args.qc_op = QUOTACTL_OBJTYPESTAT;
66 1.38.4.2 mrg args.u.objtypestat.qc_objtype = objtype;
67 1.38.4.2 mrg args.u.objtypestat.qc_info = info;
68 1.38.4.2 mrg return VFS_QUOTACTL(mp, &args);
69 1.38.4.2 mrg }
70 1.38.4.2 mrg
71 1.38.4.2 mrg int
72 1.38.4.2 mrg vfs_quotactl_get(struct mount *mp, const struct quotakey *key,
73 1.38.4.2 mrg struct quotaval *val)
74 1.38.4.2 mrg {
75 1.38.4.2 mrg struct quotactl_args args;
76 1.38.4.2 mrg
77 1.38.4.2 mrg args.qc_op = QUOTACTL_GET;
78 1.38.4.2 mrg args.u.get.qc_key = key;
79 1.38.4.2 mrg args.u.get.qc_val = val;
80 1.38.4.2 mrg return VFS_QUOTACTL(mp, &args);
81 1.38.4.2 mrg }
82 1.38.4.2 mrg
83 1.38.4.2 mrg int
84 1.38.4.2 mrg vfs_quotactl_put(struct mount *mp, const struct quotakey *key,
85 1.38.4.2 mrg const struct quotaval *val)
86 1.38.4.2 mrg {
87 1.38.4.2 mrg struct quotactl_args args;
88 1.38.4.2 mrg
89 1.38.4.2 mrg args.qc_op = QUOTACTL_PUT;
90 1.38.4.2 mrg args.u.put.qc_key = key;
91 1.38.4.2 mrg args.u.put.qc_val = val;
92 1.38.4.2 mrg return VFS_QUOTACTL(mp, &args);
93 1.38.4.2 mrg }
94 1.38.4.2 mrg
95 1.38.4.2 mrg int
96 1.38.4.2 mrg vfs_quotactl_delete(struct mount *mp, const struct quotakey *key)
97 1.38.4.2 mrg {
98 1.38.4.2 mrg struct quotactl_args args;
99 1.38.4.2 mrg
100 1.38.4.2 mrg args.qc_op = QUOTACTL_DELETE;
101 1.38.4.2 mrg args.u.delete.qc_key = key;
102 1.38.4.2 mrg return VFS_QUOTACTL(mp, &args);
103 1.38.4.2 mrg }
104 1.38.4.2 mrg
105 1.38.4.2 mrg int
106 1.38.4.2 mrg vfs_quotactl_cursoropen(struct mount *mp, struct quotakcursor *cursor)
107 1.38.4.2 mrg {
108 1.38.4.2 mrg struct quotactl_args args;
109 1.38.4.2 mrg
110 1.38.4.2 mrg args.qc_op = QUOTACTL_CURSOROPEN;
111 1.38.4.2 mrg args.u.cursoropen.qc_cursor = cursor;
112 1.38.4.2 mrg return VFS_QUOTACTL(mp, &args);
113 1.38.4.2 mrg }
114 1.38.4.2 mrg
115 1.38.4.2 mrg int
116 1.38.4.2 mrg vfs_quotactl_cursorclose(struct mount *mp, struct quotakcursor *cursor)
117 1.38.4.2 mrg {
118 1.38.4.2 mrg struct quotactl_args args;
119 1.38.4.2 mrg
120 1.38.4.2 mrg args.qc_op = QUOTACTL_CURSORCLOSE;
121 1.38.4.2 mrg args.u.cursorclose.qc_cursor = cursor;
122 1.38.4.2 mrg return VFS_QUOTACTL(mp, &args);
123 1.38.4.2 mrg }
124 1.38.4.2 mrg
125 1.38.4.2 mrg int
126 1.38.4.2 mrg vfs_quotactl_cursorskipidtype(struct mount *mp, struct quotakcursor *cursor,
127 1.38.4.2 mrg int idtype)
128 1.38.4.2 mrg {
129 1.38.4.2 mrg struct quotactl_args args;
130 1.38.4.2 mrg
131 1.38.4.2 mrg args.qc_op = QUOTACTL_CURSORSKIPIDTYPE;
132 1.38.4.2 mrg args.u.cursorskipidtype.qc_cursor = cursor;
133 1.38.4.2 mrg args.u.cursorskipidtype.qc_idtype = idtype;
134 1.38.4.2 mrg return VFS_QUOTACTL(mp, &args);
135 1.38.4.2 mrg }
136 1.38.4.2 mrg
137 1.38.4.2 mrg int
138 1.38.4.2 mrg vfs_quotactl_cursorget(struct mount *mp, struct quotakcursor *cursor,
139 1.38.4.2 mrg struct quotakey *keys, struct quotaval *vals, unsigned maxnum,
140 1.38.4.2 mrg unsigned *ret)
141 1.38.4.2 mrg {
142 1.38.4.2 mrg struct quotactl_args args;
143 1.38.4.2 mrg
144 1.38.4.2 mrg args.qc_op = QUOTACTL_CURSORGET;
145 1.38.4.2 mrg args.u.cursorget.qc_cursor = cursor;
146 1.38.4.2 mrg args.u.cursorget.qc_keys = keys;
147 1.38.4.2 mrg args.u.cursorget.qc_vals = vals;
148 1.38.4.2 mrg args.u.cursorget.qc_maxnum = maxnum;
149 1.38.4.2 mrg args.u.cursorget.qc_ret = ret;
150 1.38.4.2 mrg return VFS_QUOTACTL(mp, &args);
151 1.38.4.2 mrg }
152 1.38.4.2 mrg
153 1.38.4.2 mrg int
154 1.38.4.2 mrg vfs_quotactl_cursoratend(struct mount *mp, struct quotakcursor *cursor,
155 1.38.4.2 mrg int *ret)
156 1.38.4.2 mrg {
157 1.38.4.2 mrg struct quotactl_args args;
158 1.38.4.2 mrg
159 1.38.4.2 mrg args.qc_op = QUOTACTL_CURSORATEND;
160 1.38.4.2 mrg args.u.cursoratend.qc_cursor = cursor;
161 1.38.4.2 mrg args.u.cursoratend.qc_ret = ret;
162 1.38.4.2 mrg return VFS_QUOTACTL(mp, &args);
163 1.38.4.2 mrg }
164 1.38.4.2 mrg
165 1.38.4.2 mrg int
166 1.38.4.2 mrg vfs_quotactl_cursorrewind(struct mount *mp, struct quotakcursor *cursor)
167 1.38.4.2 mrg {
168 1.38.4.2 mrg struct quotactl_args args;
169 1.38.4.2 mrg
170 1.38.4.2 mrg args.qc_op = QUOTACTL_CURSORREWIND;
171 1.38.4.2 mrg args.u.cursorrewind.qc_cursor = cursor;
172 1.38.4.2 mrg return VFS_QUOTACTL(mp, &args);
173 1.38.4.2 mrg }
174 1.38.4.2 mrg
175 1.38.4.2 mrg int
176 1.38.4.2 mrg vfs_quotactl_quotaon(struct mount *mp, int idtype, const char *path)
177 1.38.4.2 mrg {
178 1.38.4.2 mrg struct quotactl_args args;
179 1.38.4.2 mrg
180 1.38.4.2 mrg args.qc_op = QUOTACTL_QUOTAON;
181 1.38.4.2 mrg args.u.quotaon.qc_idtype = idtype;
182 1.38.4.2 mrg args.u.quotaon.qc_quotafile = path;
183 1.38.4.2 mrg return VFS_QUOTACTL(mp, &args);
184 1.38.4.2 mrg }
185 1.38.4.2 mrg
186 1.38.4.2 mrg int
187 1.38.4.2 mrg vfs_quotactl_quotaoff(struct mount *mp, int idtype)
188 1.38.4.2 mrg {
189 1.38.4.2 mrg struct quotactl_args args;
190 1.38.4.2 mrg
191 1.38.4.2 mrg args.qc_op = QUOTACTL_QUOTAOFF;
192 1.38.4.2 mrg args.u.quotaoff.qc_idtype = idtype;
193 1.38.4.2 mrg return VFS_QUOTACTL(mp, &args);
194 1.38.4.2 mrg }
195