retain use of bcopy as savings of playing with buffers seems minimal;
[unix-history] / usr / src / sys / ufs / ffs / quota.h
CommitLineData
b11be056 1/* quota.h 6.1 83/07/29 */
187ee005
RE
2
3/*
95222a8a 4 * MELBOURNE DISC QUOTAS
187ee005 5 *
95222a8a
SL
6 * Various junk to do with various quotas (etc) imposed upon
7 * the average user (big brother finally hits UNIX).
187ee005 8 *
95222a8a
SL
9 * The following structure exists in core for each logged on user.
10 * It contains global junk relevant to that user's quotas.
11 *
12 * The u_quota field of each user struct contains a pointer to
13 * the quota struct relevant to the current process, this is changed
14 * by 'setuid' sys call, &/or by the Q_SETUID quota() call.
187ee005 15 */
187ee005 16struct quota {
a9abb9eb 17 struct quota *q_forw, *q_back; /* hash chain, MUST be first */
187ee005
RE
18 short q_cnt; /* ref count (# processes) */
19 short q_uid; /* real uid of owner */
95222a8a 20 int q_flags; /* struct management flags */
a9abb9eb
SL
21#define Q_LOCK 0x01 /* quota struct locked (for disc i/o) */
22#define Q_WANT 0x02 /* issue a wakeup when lock goes off */
23#define Q_NEW 0x04 /* new quota - no proc1 msg sent yet */
24#define Q_NDQ 0x08 /* account has NO disc quota */
25 struct quota *q_freef, **q_freeb;
187ee005
RE
26 struct dquot *q_dq[NMOUNT]; /* disc quotas for mounted filesys's */
27};
187ee005 28
95222a8a
SL
29#define NOQUOTA ((struct quota *) 0)
30
54cc5e32 31#if defined(KERNEL) && defined(QUOTA)
a9abb9eb 32struct quota *quota, *quotaNQUOTA;
187ee005 33int nquota;
a9abb9eb 34struct quota *getquota(), *qfind();
187ee005
RE
35#endif
36
187ee005 37/*
95222a8a
SL
38 * The following structure defines the format of the disc quota file
39 * (as it appears on disc) - the file is an array of these structures
40 * indexed by user number. The setquota sys call establishes the inode
41 * for each quota file (a pointer is retained in the mount structure).
187ee005 42 *
95222a8a
SL
43 * The following constants define the number of warnings given a user
44 * before the soft limits are treated as hard limits (usually resulting
45 * in an allocation failure). The warnings are normally manipulated
46 * each time a user logs in through the Q_DOWARN quota call. If
47 * the user logs in and is under the soft limit the warning count
48 * is reset to MAX_*_WARN, otherwise a message is printed and the
49 * warning count is decremented. This makes MAX_*_WARN equivalent to
50 * the number of logins before soft limits are treated as hard limits.
187ee005 51 */
a9abb9eb 52#define MAX_IQ_WARN 3
187ee005 53#define MAX_DQ_WARN 3
95222a8a
SL
54
55struct dqblk {
56 u_long dqb_bhardlimit; /* absolute limit on disc blks alloc */
57 u_long dqb_bsoftlimit; /* preferred limit on disc blks */
58 u_long dqb_curblocks; /* current block count */
59 u_short dqb_ihardlimit; /* maximum # allocated inodes + 1 */
60 u_short dqb_isoftlimit; /* preferred inode limit */
61 u_short dqb_curinodes; /* current # allocated inodes */
62 u_char dqb_bwarn; /* # warnings left about excessive disc use */
63 u_char dqb_iwarn; /* # warnings left about excessive inodes */
a9abb9eb 64};
187ee005
RE
65
66/*
95222a8a
SL
67 * The following structure records disc usage for a user on a filesystem.
68 * There is one allocated for each quota that exists on any filesystem
69 * for the current user. A cache is kept of other recently used entries.
187ee005 70 */
187ee005 71struct dquot {
a9abb9eb 72 struct dquot *dq_forw, *dq_back;/* MUST be first entry */
187ee005 73 union {
a9abb9eb
SL
74 struct quota *Dq_own; /* the quota that points to this */
75 struct { /* free list */
76 struct dquot *Dq_freef, **Dq_freeb;
187ee005
RE
77 } dq_f;
78 } dq_u;
95222a8a 79 short dq_flags;
a9abb9eb
SL
80#define DQ_LOCK 0x01 /* this quota locked (no MODS) */
81#define DQ_WANT 0x02 /* wakeup on unlock */
82#define DQ_MOD 0x04 /* this quota modified since read */
83#define DQ_FAKE 0x08 /* no limits here, just usage */
84#define DQ_BLKS 0x10 /* has been warned about blk limit */
85#define DQ_INODS 0x20 /* has been warned about inode limit */
187ee005
RE
86 short dq_cnt; /* count of active references */
87 short dq_uid; /* user this applies to */
88 dev_t dq_dev; /* filesystem this relates to */
89 struct dqblk dq_dqb; /* actual usage & quotas */
90};
d6185698 91
187ee005
RE
92#define dq_own dq_u.Dq_own
93#define dq_freef dq_u.dq_f.Dq_freef
94#define dq_freeb dq_u.dq_f.Dq_freeb
95222a8a
SL
95#define dq_bhardlimit dq_dqb.dqb_bhardlimit
96#define dq_bsoftlimit dq_dqb.dqb_bsoftlimit
97#define dq_curblocks dq_dqb.dqb_curblocks
98#define dq_ihardlimit dq_dqb.dqb_ihardlimit
99#define dq_isoftlimit dq_dqb.dqb_isoftlimit
100#define dq_curinodes dq_dqb.dqb_curinodes
101#define dq_bwarn dq_dqb.dqb_bwarn
187ee005 102#define dq_iwarn dq_dqb.dqb_iwarn
95222a8a 103
187ee005
RE
104#define NODQUOT ((struct dquot *) 0)
105#define LOSTDQUOT ((struct dquot *) 1)
106
54cc5e32 107#if defined(KERNEL) && defined(QUOTA)
a9abb9eb 108struct dquot *dquot, *dquotNDQUOT;
187ee005 109int ndquot;
a9abb9eb 110struct dquot *discquota(), *inoquota(), *dqalloc(), *dqp();
187ee005
RE
111#endif
112
187ee005 113/*
95222a8a 114 * Definitions for the 'quota' system call.
187ee005
RE
115 */
116#define Q_SETDLIM 1 /* set disc limits & usage */
117#define Q_GETDLIM 2 /* get disc limits & usage */
118#define Q_SETDUSE 3 /* set disc usage only */
95222a8a 119#define Q_SYNC 4 /* update disc copy of quota usages */
187ee005 120#define Q_SETUID 16 /* change proc to use quotas for uid */
187ee005
RE
121#define Q_SETWARN 25 /* alter inode/block warning counts */
122#define Q_DOWARN 26 /* warn user about excessive space/inodes */
95222a8a
SL
123
124/*
125 * Used in Q_SETDUSE.
126 */
127struct dqusage {
128 u_short du_curinodes;
129 u_long du_curblocks;
130};
131
132/*
133 * Used in Q_SETWARN.
134 */
135struct dqwarn {
136 u_char dw_bwarn;
137 u_char dw_iwarn;
138};