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