QUOTACTLSection: Linux Programmer's Manual (2)
Index Return to Main Contents
NAMEquotactl - manipulate disk quota
#include <sys/quota.h> int quotactl(int cmd, const char *special, int id, caddr_t addr);
DESCRIPTIONThe quota system defines for each user and/or group a soft limit and a hard limit bounding the amount of disk space that can be used on a given file system. The hard limit cannot be crossed. The soft limit can be crossed, but warnings will ensue. Moreover, the user cannot be above the soft limit for more than one week (by default) at a time: after this week the soft limit counts as hard limit.
The quotactl() system call manipulates these quota. Its first argument is of the form QCMD(subcmd,type) where type is either USRQUOTA or GRPQUOTA (for user quota and group quota, respectively), and subcmd is described below.
The second argument special is the block special device these quota apply to. It must be mounted.
The third argument id is the user or group ID these quota apply to (when relevant).
The fourth argument addr is the address of a data structure, depending on the command.
The subcmd is one of
- Enable quota. The addr argument is the pathname of the file containing the quota for the file system.
- Disable quota.
- Get limits and current usage of disk space. The addr argument is a pointer to a dqblk structure (defined in <sys/quota.h>).
- Set limits and current usage; addr is as before.
- Set limits; addr is as before.
- Set usage.
- Sync disk copy of a file system's quota.
- Get collected stats.
RETURN VALUEOn success, quotactl() returns 0. On error, -1 is returned, and errno is set appropriately.
- The quota file is not an ordinary file.
- Q_QUOTAON was asked, but quotas were enabled already.
- Bad addr value.
- type is not a known quota type. Or, special could not be found.
- Cannot read or write the quota file.
- Too many open files: cannot open quota file.
- special cannot be found in the mount table.
- The kernel was compiled without quota support.
- special is not a block special device.
- The process was not root (for the file system), and Q_GETQUOTA was asked for another id than that of the process itself, or anything other than Q_GETSTATS or Q_SYNC was asked.
- Q_GETQUOTA or Q_SETQUOTA or Q_SETUSE or Q_SETQLIM was asked for a file system that didn't have quota enabled.
SEE ALSOquota(1), getrlimit(2), setrlimit(2), ulimit(3), quotacheck(8), quotaon(8)
COLOPHONThis page is part of release 3.21 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/.