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