xref: /minix3/lib/libc/sys/__quotactl.2 (revision f14fb602092e015ff630df58e17c2a9cd57d29b3)
1.\"	$NetBSD: __quotactl.2,v 1.3 2012/02/13 19:50:15 dholland Exp $
2.\"
3.\" Copyright (c) 1983, 1990, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" This code is derived from software contributed to Berkeley by
7.\" Robert Elz at The University of Melbourne.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. Neither the name of the University nor the names of its contributors
18.\"    may be used to endorse or promote products derived from this software
19.\"    without specific prior written permission.
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE.
32.\"
33.\"	@(#)quotactl.2	8.2 (Berkeley) 3/10/95
34.\"
35.Dd February 11, 2012
36.Dt __QUOTACTL 2
37.Os
38.Sh NAME
39.Nm __quotactl
40.Nd manipulate file system quotas
41.Sh LIBRARY
42.Lb libc
43.Sh SYNOPSIS
44.In sys/quota.h
45.In sys/quotactl.h
46.Ft int
47.Fn __quotactl "const char *path" "struct quotactl_args *args"
48.Sh DESCRIPTION
49The
50.Fn __quotactl
51call manipulates file system quotas.
52This is an internal interface and is documented for reference purposes
53only.
54All application and utility code should use the
55.Xr libquota 3
56interface.
57.Pp
58The
59.Fn __quotactl
60function performs one of several quota-related operations on the file
61system named by
62.Fa path .
63The operation and arguments to that operation are passed in the
64.Fa args
65argument.
66The operation is stored in the
67.Fa qc_op
68member of
69.Fa args .
70The arguments are placed in a union such that the first and second
71arguments of the operation
72.Dv QUOTACTL_EXAMPLE
73are found as the members
74.Fa u.example.qc_arg1
75and
76.Fa u.example.qc_arg2 .
77The descriptions below will refer to the operations as functions of
78the form
79.Fn QUOTACTL_EXAMPLE "int arg1" "int arg2"
80and elide the encoding of these arguments into the
81.Fa args
82structure.
83Explicit mention of the
84.Fa path
85argument is also omitted.
86.Pp
87There are fourteen quota control operations.
88These are:
89.Bl -tag -width abcdef
90.\" ************************************************************
91.It Fn QUOTACTL_STAT "struct quotastat *info"
92Information about the quota implementation on the selected volume is
93returned in
94.Fa info .
95The
96.Dv quotastat
97structure contains the following members:
98.Bl -tag -width qs_restrictions
99.It qs_implname
100A human-readable string describing the underlying implementation of
101quotas.
102This is suitable for display to users
103.Pq and system administrators
104but should not be interpreted by software.
105See
106.Xr quota_getimplname 3 .
107.It qs_numidtypes
108The number of ID types supported by this implementation.
109See
110.Xr quota_getnumidtypes 3 .
111.It qs_numobjtypes
112The number of object types supported by this implementation.
113See
114.Xr quota_getnumobjtypes 3 .
115.It qs_restrictions
116Flags identifying specific semantic limitations of the implementation.
117See
118.Xr quota_getrestrictions 3 .
119.El
120.\" ************************************************************
121.It Fn QUOTACTL_IDTYPESTAT "int idtype" "struct quotaidtypestat *info"
122Information about a particular ID type on the selected volume is
123returned in
124.Fa info .
125The
126.Dv quotaidtypestat
127structure contains the following members:
128.Bl -tag -width qs_restrictions
129.It qis_name
130The name of the ID type.
131See
132.Xr quota_idtype_getname 3 .
133.El
134.\" ************************************************************
135.It Fn QUOTACTL_OBJYPESTAT "int objtype" "struct quotaobjtypestat *info"
136Information about a particular object type on the selected volume is
137returned in
138.Fa info .
139The
140.Dv quotaobjtypestat
141structure contains the following members:
142.Bl -tag -width qs_restrictions
143.It qos_name
144The name of the object type.
145See
146.Xr quota_objtype_getname 3 .
147.It qos_isbytes
148A flag that is nonzero if the object type is something measured in
149bytes.
150See
151.Xr quota_objtype_isbytes 3 .
152.El
153.\" ************************************************************
154.It Fn QUOTACTL_GET "const struct quotakey *key" "struct quotaval *val"
155Return in
156.Fa val
157the quota information selected by
158.Fa key .
159See
160.Xr quota_get 3 .
161.\" ************************************************************
162.It Fn QUOTACTL_PUT "const struct quotakey *key" "const struct quotaval *val"
163The quota information selected by
164.Fa key
165is updated to the values provided in
166.Fa val .
167Note that the current usage information, which is file system
168meta-data, cannot be updated via this interface.
169If the usage information is incorrect a tool such as
170.Xr fsck 8
171or
172.Xr quotacheck 8
173with file-system-specific knowledge must be used to repair the
174on-disk information.
175See
176.Xr quota_put 3 .
177.\" ************************************************************
178.It Fn QUOTACTL_DELETE "const struct quotakey *key"
179The quota information selected by
180.Fa key
181is removed.
182See
183.Xr quota_delete 3 .
184.\" ************************************************************
185.It Fn QUOTACTL_CURSOROPEN "struct quotakcursor *cursor"
186A cursor for iterating the quota information is created.
187The
188.Dv quotakcursor
189structure is a semi-opaque type holding the iteration state used by
190the quota implementation.
191The caller is responsible for allocating and maintaining storage for
192the cursor.
193Every cursor that is opened should be closed.
194It is not specified whether a cursor remains valid if
195.Xr memcpy 3
196is used to move it to a different location in user memory.
197It is not specified whether or how a cursor may be duplicated.
198Passing an uninitialized, corrupted, or closed cursor to operations
199other than
200.Fn QUOTACTL_CURSOROPEN
201will produce unspecified behavior.
202As per general standards for system calls such actions must not
203produce undefined or materially adverse behavior in the kernel;
204however, the effect on a user process may be arbitrary.
205The
206.Xr libquota 3
207interface wraps the system call level quota cursors in a friendlier
208interface.
209See
210.Xr quota_opencursor 3 .
211.\" ************************************************************
212.It Fn QUOTACTL_CURSORCLOSE "struct quotakcursor *cursor"
213The cursor passed in is closed.
214See
215.Xr quotacursor_close 3 .
216.\" ************************************************************
217.It Fn QUOTACTL_CURSORSKIPIDTYPE "struct quotakcursor *cursor" "int idtype"
218This operation provides a hint that iteration can skip over a
219particular ID type.
220The implementation is not obliged to honor the hint.
221See
222.Xr quotacursor_skipidtype 3 .
223.\" ************************************************************
224.It Fn QUOTACTL_CURSORGET "struct quotakcursor *cursor" "struct quotakey *keys" "struct quotaval *vals" "unsigned maxnum" "unsigned *ret"
225This operation retrieves data at the current cursor position and
226advances it.
227Up to
228.Fa maxnum
229quota records are retrieved and stored into the arrays named by
230.Fa keys
231and
232.Fa vals .
233The number of records retrieved is stored into the variable pointed to
234by
235.Fa ret .
236See
237.Xr quotacursor_get 3
238and
239.Xr quotacursor_getn 3 .
240.\" ************************************************************
241.It Fn QUOTACTL_CURSORATEND "struct quotakcursor *cursor" "int *ret"
242This operation generates a nonzero value if the cursor has reached the
243end of the available quota information and zero otherwise.
244The generated value is stored into the variable pointed to by
245.Fa ret .
246See
247.Xr quotacursor_atend 3 .
248.\" ************************************************************
249.It Fn QUOTACTL_CURSORREWIND "struct quotakcursor *cursor"
250This operation updates the cursor state so that further calls to
251.Fn QUOTACTL_CURSORGET
252will begin again at the start of the iteration.
253See
254.Xr quotacursor_rewind 3 .
255.\" ************************************************************
256.It Fn QUOTACTL_QUOTAON "int idtype" "const char *quotafile"
257This operation is accepted only by old-style
258.Pq Dq quota1
259quota implementations.
260Quotas for the ID type named by
261.Fa idtype
262are switched on, and the file
263.Fa quotafile
264is used to hold the quota information.
265This operation can also be used when quotas are already switched on
266to change the file used to hold the quota information.
267Note however that as the current usage information in the file must be
268consistent with the current state of the file system, in general it is
269not safe to call
270.Fn QUOTACTL_QUOTAON
271except in single-user mode.
272See
273.Xr quotaon 8
274for more information.
275Normally
276quotaon 8
277is run during the boot sequence after
278quotacheck 8 .
279Also see
280.Xr quota_quotaon 3 .
281.\" ************************************************************
282.It Fn QUOTACTL_QUOTAOFF "int idtype"
283This operation is accepted only by old-style
284.Pq Dq quota1
285quota implementations.
286Quotas for the ID type named by
287.Fa idtype
288are switched off.
289Once quotas are switched off the file system behaves as if no quotas
290are present.
291Normally
292quotaoff 8
293is run during the shutdown sequence.
294Also see
295.Xr quota_quotaoff 3 .
296.\" ************************************************************
297.El
298.Sh RETURN VALUES
299On success,
300.Fn __quotactl
301returns 0.
302Otherwise the value \-1 is returned and an error code reflecting the
303reason for the failure is placed in
304.Va errno .
305.Sh ERRORS
306.Fn __quotactl
307failures include:
308.Bl -tag -width Er
309.It Bq Er EFAULT
310A pointer points outside the process's allocated address space.
311.It Bq Er EINVAL
312The operation code was out of range; or
313a requested ID or object type was out of range; or
314a corrupted or invalid cursor was passed in.
315.It Bq Er ENODEV
316The requested action was inappropriate for
317.Pq or not supported by
318the selected volume.
319.It Bq Er ENOENT
320No quota information exists for the requested key.
321.It Bq Er ENOMEM
322Memory could not be allocated within the kernel.
323.It Bq Er ENXIO
324The target file system type is capable of supporting quotas, but
325quotas are not enabled on the selected volume.
326.It Bq Er EOPNOTSUPP
327The target file system does not support quotas.
328.El
329.Sh SEE ALSO
330.Xr quota 1 ,
331.Xr libquota 3 ,
332.Xr fstab 5 ,
333.Xr edquota 8 ,
334.Xr quotacheck 8 ,
335.Xr quotaon 8 ,
336.Xr quotarestore 8 ,
337.Xr repquota 8
338.Sh HISTORY
339The original
340.Fn quotactl
341function call appeared in
342.Bx 4.3 Reno .
343The current
344.Fn __quotactl
345interface appeared in
346.Nx 6.0 .
347.Sh BUGS
348As of this writing the error returns that occur in practice are not
349always completely consistent with the intent documented above.
350.Pp
351There should be some way to integrate this call with the resource
352limit interface provided by
353.Xr setrlimit 2
354and
355.Xr getrlimit 2 .
356