1 /* This just represents the non-kernel parts of <linux/quota.h>.
3 * here's the corresponding copyright:
4 * Copyright (c) 1982, 1986 Regents of the University of California.
7 * This code is derived from software contributed to Berkeley by
8 * Robert Elz at The University of Melbourne.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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 * 4. 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.
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
36 #define _SYS_QUOTA_H 1
39 #include <sys/types.h>
42 # undef _LINUX_QUOTA_VERSION
43 # define _LINUX_QUOTA_VERSION 1
47 * Select between different incompatible quota versions.
48 * Default to the version used by Linux kernel version 2.4.22
50 #ifndef _LINUX_QUOTA_VERSION
51 # define _LINUX_QUOTA_VERSION 2
55 * Convert diskblocks to blocks and the other way around.
56 * currently only to fool the BSD source. :-)
58 #define dbtob(num) ((num) << 10)
59 #define btodb(num) ((num) >> 10)
62 * Convert count of filesystem blocks to diskquota blocks, meant
63 * for filesystems where i_blksize != BLOCK_SIZE
65 #define fs_to_dq_blocks(num, blksize) (((num) * (blksize)) / BLOCK_SIZE)
68 * Definitions for disk quotas imposed on the average user
69 * (big brother finally hits Linux).
71 * The following constants define the amount of time given a user
72 * before the soft limits are treated as hard limits (usually resulting
73 * in an allocation failure). The timer is started when the user crosses
74 * their soft limit, it is reset when they go below their soft limit.
76 #define MAX_IQ_TIME 604800 /* (7*24*60*60) 1 week */
77 #define MAX_DQ_TIME 604800 /* (7*24*60*60) 1 week */
80 #define USRQUOTA 0 /* element used for user quotas */
81 #define GRPQUOTA 1 /* element used for group quotas */
84 * Definitions for the default names of the quotas files.
86 #define INITQFNAMES { \
87 "user", /* USRQUOTA */ \
88 "group", /* GRPQUOTA */ \
92 #define QUOTAFILENAME "quota"
93 #define QUOTAGROUP "staff"
95 #define NR_DQHASH 43 /* Just an arbitrary number any suggestions ? */
96 #define NR_DQUOTS 256 /* Number of quotas active at one time */
99 * Command definitions for the 'quotactl' system call.
100 * The commands are broken into a main command defined below
101 * and a subcommand that is used to convey the type of
102 * quota that is being manipulated (see above).
104 #define SUBCMDMASK 0x00ff
105 #define SUBCMDSHIFT 8
106 #define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
108 #if _LINUX_QUOTA_VERSION < 2
109 # define Q_QUOTAON 0x0100 /* enable quotas */
110 # define Q_QUOTAOFF 0x0200 /* disable quotas */
111 # define Q_GETQUOTA 0x0300 /* get limits and usage */
112 # define Q_SETQUOTA 0x0400 /* set limits and usage */
113 # define Q_SETUSE 0x0500 /* set usage */
114 # define Q_SYNC 0x0600 /* sync disk copy of a filesystems quotas */
115 # define Q_SETQLIM 0x0700 /* set limits */
116 # define Q_GETSTATS 0x0800 /* get collected stats */
117 # define Q_RSQUASH 0x1000 /* set root_squash option */
119 # define Q_SYNC 0x800001 /* sync disk copy of a filesystems quotas */
120 # define Q_QUOTAON 0x800002 /* turn quotas on */
121 # define Q_QUOTAOFF 0x800003 /* turn quotas off */
122 # define Q_GETFMT 0x800004 /* get quota format used on given filesystem */
123 # define Q_GETINFO 0x800005 /* get information about quota files */
124 # define Q_SETINFO 0x800006 /* set information about quota files */
125 # define Q_GETQUOTA 0x800007 /* get user quota structure */
126 # define Q_SETQUOTA 0x800008 /* set user quota structure */
130 * The following structure defines the format of the disk quota file
131 * (as it appears on disk) - the file is an array of these structures
132 * indexed by user or group number.
134 #if _LINUX_QUOTA_VERSION < 2
137 u_int32_t dqb_bhardlimit; /* absolute limit on disk blks alloc */
138 u_int32_t dqb_bsoftlimit; /* preferred limit on disk blks */
139 u_int32_t dqb_curblocks; /* current block count */
140 u_int32_t dqb_ihardlimit; /* maximum # allocated inodes */
141 u_int32_t dqb_isoftlimit; /* preferred inode limit */
142 u_int32_t dqb_curinodes; /* current # allocated inodes */
143 time_t dqb_btime; /* time limit for excessive disk use */
144 time_t dqb_itime; /* time limit for excessive files */
148 /* Flags that indicate which fields in dqblk structure are valid. */
149 #define QIF_BLIMITS 1
151 #define QIF_ILIMITS 4
155 #define QIF_LIMITS (QIF_BLIMITS | QIF_ILIMITS)
156 #define QIF_USAGE (QIF_SPACE | QIF_INODES)
157 #define QIF_TIMES (QIF_BTIME | QIF_ITIME)
158 #define QIF_ALL (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
162 u_int64_t dqb_bhardlimit; /* absolute limit on disk quota blocks alloc */
163 u_int64_t dqb_bsoftlimit; /* preferred limit on disk quota blocks */
164 u_int64_t dqb_curspace; /* current quota block count */
165 u_int64_t dqb_ihardlimit; /* maximum # allocated inodes */
166 u_int64_t dqb_isoftlimit; /* preferred inode limit */
167 u_int64_t dqb_curinodes; /* current # allocated inodes */
168 u_int64_t dqb_btime; /* time limit for excessive disk use */
169 u_int64_t dqb_itime; /* time limit for excessive files */
170 u_int32_t dqb_valid; /* bitmask of QIF_* constants */
175 * Shorthand notation.
177 #define dq_bhardlimit dq_dqb.dqb_bhardlimit
178 #define dq_bsoftlimit dq_dqb.dqb_bsoftlimit
179 #if _LINUX_QUOTA_VERSION < 2
180 # define dq_curblocks dq_dqb.dqb_curblocks
182 # define dq_curspace dq_dqb.dqb_curspace
183 # define dq_valid dq_dqb.dqb_valid
185 #define dq_ihardlimit dq_dqb.dqb_ihardlimit
186 #define dq_isoftlimit dq_dqb.dqb_isoftlimit
187 #define dq_curinodes dq_dqb.dqb_curinodes
188 #define dq_btime dq_dqb.dqb_btime
189 #define dq_itime dq_dqb.dqb_itime
191 #define dqoff(UID) ((loff_t)((UID) * sizeof (struct dqblk)))
193 #if _LINUX_QUOTA_VERSION < 2
200 u_int32_t cache_hits;
201 u_int32_t pages_allocated;
202 u_int32_t allocated_dquots;
203 u_int32_t free_dquots;
208 /* Flags that indicate which fields in dqinfo structure are valid. */
209 # define IIF_BGRACE 1
210 # define IIF_IGRACE 2
212 # define IIF_ALL (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
216 u_int64_t dqi_bgrace;
217 u_int64_t dqi_igrace;
225 extern int quotactl (int __cmd, const char *__special, int __id,
226 caddr_t __addr) __THROW;
230 #endif /* sys/quota.h */