Initial import from FreeBSD RELENG_4:
[dragonfly.git] / lib / libcr / sys / quotactl.2
1 .\" Copyright (c) 1983, 1990, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Robert Elz at The University of Melbourne.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\" 3. All advertising materials mentioning features or use of this software
16 .\"    must display the following acknowledgement:
17 .\"     This product includes software developed by the University of
18 .\"     California, Berkeley and its contributors.
19 .\" 4. Neither the name of the University nor the names of its contributors
20 .\"    may be used to endorse or promote products derived from this software
21 .\"    without specific prior written permission.
22 .\"
23 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .\" SUCH DAMAGE.
34 .\"
35 .\"     @(#)quotactl.2  8.2 (Berkeley) 3/10/95
36 .\" $FreeBSD: src/lib/libc/sys/quotactl.2,v 1.12.2.7 2002/05/20 09:06:37 roam Exp $
37 .\"
38 .Dd March 5, 1999
39 .Dt QUOTACTL 2
40 .Os
41 .Sh NAME
42 .Nm quotactl
43 .Nd manipulate filesystem quotas
44 .Sh LIBRARY
45 .Lb libc
46 .Sh SYNOPSIS
47 .In sys/types.h
48 .In ufs/ufs/quota.h
49 .Ft int
50 .Fn quotactl "const char *path" "int cmd" "int id" "void *addr"
51 .Sh DESCRIPTION
52 The
53 .Fn quotactl
54 call enables, disables and
55 manipulates filesystem quotas.
56 A quota control command
57 given by
58 .Fa cmd
59 operates on the given filename
60 .Fa path
61 for the given user
62 .Fa id .
63 (NOTE: One should use the QCMD macro defined in
64 .Ao Pa ufs/ufs/quota.h Ac
65 to formulate the value for
66 .Fa cmd . )
67 The address of an optional command specific data structure,
68 .Fa addr ,
69 may be given; its interpretation
70 is discussed below with each command.
71 .Pp
72 Currently quotas are supported only for the
73 .Dq ufs
74 filesystem.
75 For
76 .Dq ufs ,
77 a command is composed of a primary command (see below)
78 and a command type used to interpret the
79 .Fa id .
80 Types are supported for interpretation of user identifiers (USRQUOTA)
81 and group identifiers (GRPQUOTA).
82 The
83 .Dq ufs
84 specific commands are:
85 .Bl -tag -width Q_QUOTAOFFxx
86 .It Dv Q_QUOTAON
87 Enable disk quotas for the filesystem specified by
88 .Fa path .
89 The command type specifies the type of the quotas being enabled.
90 The
91 .Fa addr
92 argument specifies a file from which to take the quotas.
93 The quota file must exist;
94 it is normally created with the
95 .Xr quotacheck 8
96 program.
97 The
98 .Fa id
99 argument is unused.
100 Only the super-user may turn quotas on.
101 .It Dv Q_QUOTAOFF
102 Disable disk quotas for the filesystem specified by
103 .Fa path .
104 The command type specifies the type of the quotas being disabled.
105 The
106 .Fa addr
107 and
108 .Fa id
109 arguments are unused.
110 Only the super-user may turn quotas off.
111 .It Dv Q_GETQUOTA
112 Get disk quota limits and current usage for the user or group
113 (as determined by the command type) with identifier
114 .Fa id .
115 .Fa Addr
116 is a pointer to a
117 .Fa struct dqblk
118 structure (defined in
119 .Ao Pa ufs/ufs/quota.h Ac ) .
120 .It Dv Q_SETQUOTA
121 Set disk quota limits for the user or group
122 (as determined by the command type) with identifier
123 .Fa id .
124 .Fa Addr
125 is a pointer to a
126 .Fa struct dqblk
127 structure (defined in
128 .Ao Pa ufs/ufs/quota.h Ac ) .
129 The usage fields of the
130 .Fa dqblk
131 structure are ignored.
132 This call is restricted to the super-user.
133 .It Dv Q_SETUSE
134 Set disk usage limits for the user or group
135 (as determined by the command type) with identifier
136 .Fa id .
137 .Fa Addr
138 is a pointer to a
139 .Fa struct dqblk
140 structure (defined in
141 .Ao Pa ufs/ufs/quota.h Ac ) .
142 Only the usage fields are used.
143 This call is restricted to the super-user.
144 .It Dv Q_SYNC
145 Update the on-disk copy of quota usages.
146 The command type specifies which type of quotas are to be updated.
147 The
148 .Fa id
149 and
150 .Fa addr
151 parameters are ignored.
152 .El
153 .Sh RETURN VALUES
154 .Rv -std quotactl
155 .Sh ERRORS
156 A
157 .Fn quotactl
158 call will fail if:
159 .Bl -tag -width Er
160 .It Bq Er EOPNOTSUPP
161 The kernel has not been compiled with the
162 .Dv QUOTA
163 option.
164 .It Bq Er EUSERS
165 The quota table cannot be expanded.
166 .It Bq Er EINVAL
167 .Fa Cmd
168 or the command type is invalid.
169 In
170 .Dv Q_GETQUOTA
171 and
172 .Dv Q_SETQUOTA ,
173 quotas are not currently enabled for this filesystem.
174 .It Bq Er EACCES
175 In
176 .Dv Q_QUOTAON ,
177 the quota file is not a plain file.
178 .It Bq Er EACCES
179 Search permission is denied for a component of a path prefix.
180 .It Bq Er ENOTDIR
181 A component of a path prefix was not a directory.
182 .It Bq Er ENAMETOOLONG
183 A component of either pathname exceeded 255 characters,
184 or the entire length of either path name exceeded 1023 characters.
185 .It Bq Er ENOENT
186 A filename does not exist.
187 .It Bq Er ELOOP
188 Too many symbolic links were encountered in translating a pathname.
189 .It Bq Er EROFS
190 In
191 .Dv Q_QUOTAON ,
192 the quota file resides on a read-only filesystem.
193 .It Bq Er EIO
194 An
195 .Tn I/O
196 error occurred while reading from or writing
197 to a file containing quotas.
198 .It Bq Er EFAULT
199 An invalid
200 .Fa addr
201 was supplied; the associated structure could not be copied in or out
202 of the kernel.
203 .It Bq Er EFAULT
204 .Fa Path
205 points outside the process's allocated address space.
206 .It Bq Er EPERM
207 The call was privileged and the caller was not the super-user.
208 .El
209 .Sh SEE ALSO
210 .Xr quota 1 ,
211 .Xr fstab 5 ,
212 .Xr edquota 8 ,
213 .Xr quotacheck 8 ,
214 .Xr quotaon 8 ,
215 .Xr repquota 8
216 .Sh BUGS
217 There should be some way to integrate this call with the resource
218 limit interface provided by
219 .Xr setrlimit 2
220 and
221 .Xr getrlimit 2 .
222 .Sh HISTORY
223 The
224 .Fn quotactl
225 function call appeared in
226 .Bx 4.3 Reno .