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