xref: /freebsd/lib/libsys/quotactl.2 (revision 96190b4fef3b4a0cc3ca0606b0c4e3e69a5e6717)
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. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.Dd March 30, 2020
32.Dt QUOTACTL 2
33.Os
34.Sh NAME
35.Nm quotactl
36.Nd manipulate file system quotas
37.Sh LIBRARY
38.Lb libc
39.Sh SYNOPSIS
40.In sys/types.h
41.In ufs/ufs/quota.h
42.Ft int
43.Fn quotactl "const char *path" "int cmd" "int id" "void *addr"
44.Sh DESCRIPTION
45The
46.Fn quotactl
47system call enables, disables and
48manipulates file system quotas.
49A quota control command
50given by
51.Fa cmd
52operates on the given filename
53.Fa path
54for the given user or group
55.Fa id .
56(NOTE: One should use the QCMD macro defined in
57.In ufs/ufs/quota.h
58to formulate the value for
59.Fa cmd . )
60The address of an optional command specific data structure,
61.Fa addr ,
62may be given; its interpretation
63is discussed below with each command.
64.Pp
65For commands that use the
66.Fa id
67identifier, it must be either -1 or any positive value.
68The value of -1 indicates that the current UID or GID should be used.
69Any other negative value will return an error.
70.Pp
71Currently quotas are supported only for the
72.Dq ufs
73file system.
74For
75.Dq ufs ,
76a command is composed of a primary command (see below)
77and a command type used to interpret the
78.Fa id .
79Types are supported for interpretation of user identifiers (USRQUOTA)
80and group identifiers (GRPQUOTA).
81The
82.Dq ufs
83specific commands are:
84.Bl -tag -width Q_GETQUOTASIZEx
85.It Dv Q_QUOTAON
86Enable disk quotas for the file system specified by
87.Fa path .
88The command type specifies the type of the quotas being enabled.
89The
90.Fa addr
91argument specifies a file from which to take the quotas.
92The quota file must exist;
93it is normally created with the
94.Xr quotacheck 8
95program.
96The
97.Fa id
98argument is unused.
99Only the super-user may turn quotas on.
100.It Dv Q_QUOTAOFF
101Disable disk quotas for the file system specified by
102.Fa path .
103The command type specifies the type of the quotas being disabled.
104The
105.Fa addr
106and
107.Fa id
108arguments are unused.
109Only the super-user may turn quotas off.
110.It Dv Q_GETQUOTASIZE
111Get the wordsize used to represent the quotas for the user or group
112(as determined by the command type).
113Possible values are 32 for the old-style quota file
114and 64 for the new-style quota file.
115The
116.Fa addr
117argument is a pointer to an integer into which the size is stored.
118The identifier
119.Fa id
120is not used.
121.It Dv Q_GETQUOTA
122Get disk quota limits and current usage for the user or group
123(as determined by the command type) with identifier
124.Fa id .
125The
126.Fa addr
127argument
128is a pointer to a
129.Fa struct dqblk
130structure (defined in
131.In ufs/ufs/quota.h ) .
132.It Dv Q_SETQUOTA
133Set disk quota limits for the user or group
134(as determined by the command type) with identifier
135.Fa id .
136The
137.Fa addr
138argument
139is a pointer to a
140.Fa struct dqblk
141structure (defined in
142.In ufs/ufs/quota.h ) .
143The usage fields of the
144.Fa dqblk
145structure are ignored.
146This system call is restricted to the super-user.
147.It Dv Q_SETUSE
148Set disk usage limits for the user or group
149(as determined by the command type) with identifier
150.Fa id .
151The
152.Fa addr
153argument
154is a pointer to a
155.Fa struct dqblk
156structure (defined in
157.In ufs/ufs/quota.h ) .
158Only the usage fields are used.
159This system call is restricted to the super-user.
160.It Dv Q_SYNC
161Update the on-disk copy of quota usages.
162The command type specifies which type of quotas are to be updated.
163The
164.Fa id
165and
166.Fa addr
167arguments are ignored.
168.El
169.Sh RETURN VALUES
170.Rv -std quotactl
171.Sh ERRORS
172The
173.Fn quotactl
174system call will fail if:
175.Bl -tag -width Er
176.It Bq Er EOPNOTSUPP
177The kernel has not been compiled with the
178.Dv QUOTA
179option.
180.It Bq Er EUSERS
181The quota table cannot be expanded.
182.It Bq Er EINVAL
183The
184.Fa cmd
185argument
186or the command type is invalid.
187In
188.Dv Q_GETQUOTASIZE ,
189.Dv Q_GETQUOTA ,
190.Dv Q_SETQUOTA ,
191and
192.Dv Q_SETUSE ,
193quotas are not currently enabled for this file system.
194.Pp
195The
196.Fa id
197argument to
198.Dv Q_GETQUOTA ,
199.Dv Q_SETQUOTA
200or
201.Dv Q_SETUSE
202is a negative value.
203.It Bq Er EACCES
204In
205.Dv Q_QUOTAON ,
206the quota file is not a plain file.
207.It Bq Er EACCES
208Search permission is denied for a component of a path prefix.
209.It Bq Er ENOTDIR
210A component of a path prefix was not a directory.
211.It Bq Er ENAMETOOLONG
212A component of either pathname exceeded 255 characters,
213or the entire length of either path name exceeded 1023 characters.
214.It Bq Er ENOENT
215A filename does not exist.
216.It Bq Er ELOOP
217Too many symbolic links were encountered in translating a pathname.
218.It Bq Er EROFS
219In
220.Dv Q_QUOTAON ,
221either the file system on which quotas are to be enabled is mounted read-only
222or the quota file resides on a read-only file system.
223.It Bq Er EIO
224An
225.Tn I/O
226error occurred while reading from or writing
227to a file containing quotas.
228.It Bq Er EINTEGRITY
229Corrupted data was detected while reading from the file system.
230.It Bq Er EFAULT
231An invalid
232.Fa addr
233was supplied; the associated structure could not be copied in or out
234of the kernel.
235.It Bq Er EFAULT
236The
237.Fa path
238argument
239points outside the process's allocated address space.
240.It Bq Er EPERM
241The call was privileged and the caller was not the super-user.
242.El
243.Sh SEE ALSO
244.Xr quota 1 ,
245.Xr fstab 5 ,
246.Xr edquota 8 ,
247.Xr quotacheck 8 ,
248.Xr quotaon 8 ,
249.Xr repquota 8
250.Sh HISTORY
251The
252.Fn quotactl
253system call appeared in
254.Bx 4.3 Reno .
255.Sh BUGS
256There should be some way to integrate this call with the resource
257limit interface provided by
258.Xr setrlimit 2
259and
260.Xr getrlimit 2 .
261