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