2 * Copyright (c) 1982, 1986 Regents of the University of California.
\r
3 * All rights reserved.
\r
5 * This code is derived from software contributed to Berkeley by
\r
6 * Robert Elz at The University of Melbourne.
\r
8 * Redistribution and use in source and binary forms, with or without
\r
9 * modification, are permitted provided that the following conditions
\r
11 * 1. Redistributions of source code must retain the above copyright
\r
12 * notice, this list of conditions and the following disclaimer.
\r
13 * 2. Redistributions in binary form must reproduce the above copyright
\r
14 * notice, this list of conditions and the following disclaimer in the
\r
15 * documentation and/or other materials provided with the distribution.
\r
16 * 3. All advertising materials mentioning features or use of this software
\r
17 * must display the following acknowledgement:
\r
18 * This product includes software developed by the University of
\r
19 * California, Berkeley and its contributors.
\r
20 * 4. Neither the name of the University nor the names of its contributors
\r
21 * may be used to endorse or promote products derived from this software
\r
22 * without specific prior written permission.
\r
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
\r
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\r
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
\r
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
\r
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
\r
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
\r
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
\r
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
\r
36 * from: @(#)quota.h 7.9 (Berkeley) 2/22/91
\r
37 * $FreeBSD: src/sys/i386/boot/dosboot/quota.h,v 1.6 1999/12/29 04:32:51 peter Exp $
\r
38 * $DragonFly: src/sys/i386/boot/dosboot/Attic/quota.h,v 1.3 2003/07/03 18:35:26 dillon Exp $
\r
45 * Definitions for disk quotas imposed on the average user
\r
46 * (big brother finally hits UNIX).
\r
48 * The following constants define the amount of time given a user
\r
49 * before the soft limits are treated as hard limits (usually resulting
\r
50 * in an allocation failure). The timer is started when the user crosses
\r
51 * their soft limit, it is reset when they go below their soft limit.
\r
53 #define MAX_IQ_TIME (7*24*60*60) /* 1 week */
\r
54 #define MAX_DQ_TIME (7*24*60*60) /* 1 week */
\r
57 * The following constants define the usage of the quota file array
\r
58 * in the ufsmount structure and dquot array in the inode structure.
\r
59 * The semantics of the elements of these arrays are defined in the
\r
60 * routine getinoquota; the remainder of the quota code treats them
\r
61 * generically and need not be inspected when changing the size of
\r
65 USRQUOTA = 0, /* element used for user quotas */
\r
66 GRPQUOTA = 1, /* element used for group quotas */
\r
71 * Definitions for the default names of the quotas files.
\r
73 #define INITQFNAMES { \
\r
74 "user", /* USRQUOTA */ \
\r
75 "group", /* GRPQUOTA */ \
\r
78 #define QUOTAFILENAME "quota"
\r
79 #define QUOTAGROUP "operator"
\r
82 * Command definitions for the 'quotactl' system call.
\r
83 * The commands are broken into a main command defined below
\r
84 * and a subcommand that is used to convey the type of
\r
85 * quota that is being manipulated (see above).
\r
87 #define SUBCMDMASK 0x00ff
\r
88 #define SUBCMDSHIFT 8
\r
89 #define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
\r
91 #define Q_QUOTAON 0x0100 /* enable quotas */
\r
92 #define Q_QUOTAOFF 0x0200 /* disable quotas */
\r
93 #define Q_GETQUOTA 0x0300 /* get limits and usage */
\r
94 #define Q_SETQUOTA 0x0400 /* set limits and usage */
\r
95 #define Q_SETUSE 0x0500 /* set usage */
\r
96 #define Q_SYNC 0x0600 /* sync disk copy of a filesystems quotas */
\r
99 * The following structure defines the format of the disk quota file
\r
100 * (as it appears on disk) - the file is an array of these structures
\r
101 * indexed by user or group number. The setquota system call establishes
\r
102 * the vnode for each quota file (a pointer is retained in the ufsmount
\r
106 u_long dqb_bhardlimit; /* absolute limit on disk blks alloc */
\r
107 u_long dqb_bsoftlimit; /* preferred limit on disk blks */
\r
108 u_long dqb_curblocks; /* current block count */
\r
109 u_long dqb_ihardlimit; /* maximum # allocated inodes + 1 */
\r
110 u_long dqb_isoftlimit; /* preferred inode limit */
\r
111 u_long dqb_curinodes; /* current # allocated inodes */
\r
112 time_t dqb_btime; /* time limit for excessive disk use */
\r
113 time_t dqb_itime; /* time limit for excessive files */
\r
118 * The following structure records disk usage for a user or group on a
\r
119 * filesystem. There is one allocated for each quota that exists on any
\r
120 * filesystem for the current user or group. A cache is kept of recently
\r
124 struct dquot *dq_forw, *dq_back;/* MUST be first entry */
\r
125 struct dquot *dq_freef, **dq_freeb; /* free list */
\r
126 short dq_flags; /* flags, see below */
\r
127 short dq_cnt; /* count of active references */
\r
128 short dq_spare; /* unused spare padding */
\r
129 short dq_type; /* quota type of this dquot */
\r
130 u_long dq_id; /* identifier this applies to */
\r
131 struct ufsmount *dq_ump; /* filesystem that this is taken from */
\r
132 struct dqblk dq_dqb; /* actual usage & quotas */
\r
137 #define DQ_LOCK 0x01 /* this quota locked (no MODS) */
\r
138 #define DQ_WANT 0x02 /* wakeup on unlock */
\r
139 #define DQ_MOD 0x04 /* this quota modified since read */
\r
140 #define DQ_FAKE 0x08 /* no limits here, just usage */
\r
141 #define DQ_BLKS 0x10 /* has been warned about blk limit */
\r
142 #define DQ_INODS 0x20 /* has been warned about inode limit */
\r
144 * Shorthand notation.
\r
146 #define dq_bhardlimit dq_dqb.dqb_bhardlimit
\r
147 #define dq_bsoftlimit dq_dqb.dqb_bsoftlimit
\r
148 #define dq_curblocks dq_dqb.dqb_curblocks
\r
149 #define dq_ihardlimit dq_dqb.dqb_ihardlimit
\r
150 #define dq_isoftlimit dq_dqb.dqb_isoftlimit
\r
151 #define dq_curinodes dq_dqb.dqb_curinodes
\r
152 #define dq_btime dq_dqb.dqb_btime
\r
153 #define dq_itime dq_dqb.dqb_itime
\r
156 * If the system has never checked for a quota for this file,
\r
157 * then it is set to NODQUOT. Once a write attempt is made
\r
158 * the inode pointer is set to reference a dquot structure.
\r
160 #define NODQUOT ((struct dquot *) 0)
\r
163 * Flags to chkdq() and chkiq()
\r
165 #define FORCE 0x01 /* force usage changes independent of limits */
\r
166 #define CHOWN 0x02 /* (advisory) change initiated by chown */
\r
169 * Macros to avoid subroutine calls to trivial functions.
\r
172 #define DQREF(dq) (dq)->dq_cnt++
\r
174 #define DQREF(dq) dqref(dq)
\r
175 #endif /* DIAGNOSTIC */
\r
177 struct inode; struct ucred; struct mount; struct vnode;
\r
179 int getinoquota(struct inode *);
\r
180 int chkdq(struct inode *, long, struct ucred *, int);
\r
181 int chkdqchg(struct inode *, long, struct ucred *, enum quotatype);
\r
182 int chkiq(struct inode *, long, struct ucred *, int);
\r
183 int chkiqchg(struct inode *, long, struct ucred *, enum quotatype);
\r
185 void chkdquot(struct inode *);
\r
187 int quotaon(struct thread *, struct mount *, enum quotatype, caddr_t);
\r
188 int quotaoff(struct thread *, struct mount *, enum quotatype);
\r
189 int getquota(struct mount *, u_long, enum quotatype, caddr_t);
\r
190 int setquota(struct mount *, u_long, enum quotatype, caddr_t);
\r
191 int setuse(struct mount *, u_long, enum quotatype, caddr_t);
\r
192 int qsync(struct mount *);
\r
194 int dqget(struct vnode *, u_long, struct ufsmount *, enum quotatype, struct dquot **);
\r
195 void dqref(struct dquot *);
\r
196 void dqrele(struct vnode *, struct dquot *);
\r
197 int dqsync(struct vnode *, struct dquot *);
\r
198 void dqflush(struct vnode *);
\r
205 int quotactl __P((const char *, int, int, void *));
\r
208 #endif /* _KERNEL */
\r
209 #endif /* _QUOTA_ */
\r