xref: /original-bsd/lib/libc/sys/quotactl.2 (revision 2d1a7683)
1.\" Copyright (c) 1983, 1990, 1991 Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Robert Elz at The University of Melbourne.
6.\" %sccs.include.redist.man%
7.\"
8.\"     @(#)quotactl.2	6.12 (Berkeley) 03/10/91
9.\"
10.Dd
11.Dt QUOTACTL 2
12.Os BSD 4.4
13.Sh NAME
14.Nm quotactl
15.Nd manipulate filesystem quotas
16.Sh SYNOPSIS
17.Ft #include <ufs/quota.h>	/* for ufs quotas */
18.Ft int
19.Fn quotactl "const char *path" "int cmd" "int id" "char *addr"
20.Sh DESCRIPTION
21The
22.Fn quotactl
23call enables, disables and
24manipulates filesystem quotas.
25A quota control command
26given by
27.Fa cmd
28operates on the given filename
29.Fa path
30for the given user
31.Fa id .
32The address of an optional command specific data structure,
33.Fa addr ,
34may be given; its interpretation
35is discussed below with each command.
36.Pp
37Currently quotas are supported only for the ``ufs'' filesystem.
38For ``ufs'',
39a command is composed of a primary command (see below)
40and a command type used to interpret the
41.Fa id .
42Types are supported for interpretation of user identifiers
43and group identifiers.
44The ``ufs'' specific commands are:
45.Bl -tag -width Q_QUOTAON
46.It Dv Q_QUOTAON
47Enable disk quotas for the filesystem specified by
48.Fa path .
49The command type specifies the type of the quotas being enabled.
50The
51.Fa addr
52argument specifies a file from which to take the quotas.
53The quota file must exist;
54it is normally created with the
55.Xr quotacheck 8
56program.
57The
58.Fa id
59argument is unused.
60Only the super-user may turn quotas on.
61.It Dv Q_QUOTAOFF
62Disable disk quotas for the filesystem specified by
63.Fa path .
64The command type specifies the type of the quotas being disabled.
65The
66.Fa addr
67and
68.Fa id
69arguments are unused.
70Only the super-user may turn quotas off.
71.It Dv Q_GETQUOTA
72Get disk quota limits and current usage for the user or group
73(as determined by the command type) with identifier
74.Fa id .
75.Fa Addr
76is a pointer to a
77.Fa struct dqblk
78structure (defined in
79.Ao Pa ufs/quota.h Ac ) .
80.It Dv Q_SETQUOTA
81Set disk quota limits for the user or group
82(as determined by the command type) with identifier
83.Fa id .
84.Fa Addr
85is a pointer to a
86.Fa struct dqblk
87structure (defined in
88.Ao Pa ufs/quota.h Ac ) .
89The usage fields of the
90.Fa dqblk
91structure are ignored.
92This call is restricted to the super-user.
93.It Dv Q_SETUSE
94Set disk usage limits for the user or group
95(as determined by the command type) with identifier
96.Fa id .
97.Fa Addr
98is a pointer to a
99.Fa struct dqblk
100structure (defined in
101.Ao Pa ufs/quota.h Ac ) .
102Only the usage fields are used.
103This call is restricted to the super-user.
104.It Dv Q_SYNC
105Update the on-disk copy of quota usages.
106The command type specifies which type of quotas are to be updated.
107The
108.Fa id
109and
110.Fa addr
111parameters are ignored.
112.El
113.Sh RETURN VALUES
114A successful call returns 0,
115otherwise the value -1 is returned and the global variable
116.Va errno
117indicates the reason for the failure.
118.Sh ERRORS
119A
120.Fn quotactl
121call will fail if:
122.Bl -tag -width ENAMETOOLONGAA
123.It Bq Er EOPNOTSUPP
124The kernel has not been compiled with the
125.Dv QUOTA
126option.
127.It Bq Er EUSERS
128The quota table cannot be expanded.
129.It Bq Er EINVAL
130.Fa Cmd
131or the command type is invalid.
132.It Bq Er EINVAL
133A pathname contains a character with the high-order bit set.
134.It Bq Er EACCES
135In
136.Dv Q_QUOTAON ,
137the quota file is not a plain file.
138.It Bq Er EACCES
139Search permission is denied for a component of a path prefix.
140.It Bq Er ENOTDIR
141A component of a path prefix was not a directory.
142.It Bq Er ENAMETOOLONG
143A component of either pathname exceeded 255 characters,
144or the entire length of either path name exceeded 1023 characters.
145.It Bq Er ENOENT
146A filename does not exist.
147.It Bq Er ELOOP
148Too many symbolic links were encountered in translating a pathname.
149.It Bq Er EROFS
150In
151.Dv Q_QUOTAON ,
152the quota file resides on a read-only filesystem.
153.It Bq Er EIO
154An I/O error occurred while reading from or writing
155to a file containing quotas.
156.It Bq Er EFAULT
157An invalid
158.Fa addr
159was supplied; the associated structure could not be copied in or out
160of the kernel.
161.It Bq Er EFAULT
162.Fa Path
163points outside the process's allocated address space.
164.It Bq Er EPERM
165The call was privileged and the caller was not the super-user.
166.El
167.Sh SEE ALSO
168.Xr quota 1 ,
169.Xr fstab 5 ,
170.Xr edquota 8 ,
171.Xr quotacheck 8 ,
172.Xr quotaon 8 ,
173.Xr repquota 8
174.Sh BUGS
175There should be some way to integrate this call with the resource
176limit interface provided by
177.Xr setrlimit 2
178and
179.Xr getrlimit 2 .
180.Sh HISTORY
181The
182.Nm
183function call appeared in
184.Bx 4.3 Reno .
185