#include <sys/quota.h>
sys/quota.h
macroMAX_IQ_TIME
Definitions for disk quotas imposed on the average user
(big brother finally hits UNIX).
The following constants define the amount of time given a user before the
soft limits are treated as hard limits (usually resulting in an allocation
failure). The timer is started when the user crosses their soft limit, it
is reset when they go below their soft limit.
#define MAX_IQ_TIME (7*24*60*60)
seconds in 1 week
macroMAXQUOTAS
The following constants define the usage of the quota file array in the
file system mount structure and dquot array in the inode structure. The semantics
of the elements of these arrays are defined in the routine getinoquota;
the remainder of the quota code treats them generically and need not be
inspected when changing the size of the array.
#define MAXQUOTAS 2
macroINITQFNAMES
Definitions for the default names of the quotas files.
#define INITQFNAMES {
"user", /* USRQUOTA */
"group", /* GRPQUOTA */
"undefined",
};macroQUOTAFILENAME
#define QUOTAFILENAME ".quota"
macroQUOTAOPSNAME
#define QUOTAOPSNAME ".quota.ops"
macroQUOTAGROUP
#define QUOTAGROUP "operator"
macroSUBCMDMASK
Command definitions for the 'quotactl' system call. The commands are
broken into a main command defined below and a subcommand that is used
to convey the type of quota that is being manipulated (see above).
#define SUBCMDMASK 0x00ff
macroSUBCMDSHIFT
#define SUBCMDSHIFT 8
macroQCMD
#define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
structdqfilehdr
The following two structures define the format of the disk
quota file (as it appears on disk) - the file contains a
header followed by a hash table of dqblk entries. To find
a particular entry, the user or group number (id) is first
converted to an index into this table by means of the hash
function dqhash1. If there is a collision at that index
location then a second hash value is computed which using
dqhash2. This second hash value is then used as an offset
to the next location to probe. ID = 0 is used to indicate
an empty (unused) entry. So there can never be an entry in
the quota file for user 0 or group 0 (which is OK since disk
quotas are never enforced for user 0).
The setquota system call establishes the vnode for each quota
file (a pointer is retained in the filesystem mount structure).
| u_int32_t | dqh_magic | |
| u_int32_t | dqh_version | == QF_VERSION |
| u_int32_t | dqh_maxentries | must be a power of 2 |
| u_int32_t | dqh_entrycnt | count of active entries |
| u_int32_t | dqh_flags | reserved for now (0) |
| u_int32_t | dqh_chktime | time of last quota check |
| u_int32_t | dqh_btime | time limit for excessive disk use |
| u_int32_t | dqh_itime | time limit for excessive files |
| char[16] | dqh_string | tag string |
| u_int32_t[4] | dqh_spare | pad struct to power of 2 |
structdqblk
| u_int64_t | dqb_bhardlimit | absolute limit on disk bytes alloc |
| u_int64_t | dqb_bsoftlimit | preferred limit on disk bytes |
| u_int64_t | dqb_curbytes | current byte count |
| u_int32_t | dqb_ihardlimit | maximum # allocated inodes + 1 |
| u_int32_t | dqb_isoftlimit | preferred inode limit |
| u_int32_t | dqb_curinodes | current # allocated inodes |
| u_int32_t | dqb_btime | time limit for excessive disk use |
| u_int32_t | dqb_itime | time limit for excessive files |
| u_int32_t | dqb_id | identifier (0 for empty entries) |
| u_int32_t[4] | dqb_spare | pad struct to power of 2 |
macroINITQMAGICS
#define INITQMAGICS {
0xff31ff35, /* USRQUOTA */
0xff31ff27, /* GRPQUOTA */
}macroQF_VERSION
#define QF_VERSION 1
macroQF_STRING_TAG
#define QF_STRING_TAG "QUOTA HASH FILE"
macroQF_USERS_PER_GB
#define QF_USERS_PER_GB 256
macroQF_MIN_USERS
#define QF_MIN_USERS 2048
macroQF_MAX_USERS
#define QF_MAX_USERS (2048*1024)
macroQF_GROUPS_PER_GB
#define QF_GROUPS_PER_GB 32
macroQF_MIN_GROUPS
#define QF_MIN_GROUPS 2048
macroQF_MAX_GROUPS
#define QF_MAX_GROUPS (256*1024)
macrodqhash1
The primary and secondary multiplicative hash functions are
derived from Knuth (vol. 3). They use a prime that is in
golden ratio to the machine's word size.
#define dqhash1(id, shift, mask) ((((id) * 2654435761U) >> (shift)) & (mask))
macrodqoffset
Compute a disk offset into a quota file.
#define dqoffset(index) (sizeof (struct dqfilehdr) + ((index) * sizeof (struct dqblk)))
functiondqhashshift
static __inline int dqhashshift(u_int32_t)
Compute the hash shift value.
It is the word size, in bits, minus the hash table size, in bits.
functiondqhashshift
static __inline int dqhashshift(u_int32_t size)
functionquotactl
int quotactl(const char *, int, int, caddr_t)
man page · June 4, 1993
quotactl(2) — manipulate filesystem quotas