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