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