1: /*
2: * Copyright (c) 1982, 1986 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: *
6: * @(#)quota.h 7.1 (Berkeley) 6/4/86
7: */
8:
9: /*
10: * MELBOURNE DISC QUOTAS
11: *
12: * Various junk to do with various quotas (etc) imposed upon
13: * the average user (big brother finally hits UNIX).
14: *
15: * The following structure exists in core for each logged on user.
16: * It contains global junk relevant to that user's quotas.
17: *
18: * The u_quota field of each user struct contains a pointer to
19: * the quota struct relevant to the current process, this is changed
20: * by 'setuid' sys call, &/or by the Q_SETUID quota() call.
21: */
22: struct quota {
23: struct quota *q_forw, *q_back; /* hash chain, MUST be first */
24: short q_cnt; /* ref count (# processes) */
25: uid_t q_uid; /* real uid of owner */
26: int q_flags; /* struct management flags */
27: #define Q_LOCK 0x01 /* quota struct locked (for disc i/o) */
28: #define Q_WANT 0x02 /* issue a wakeup when lock goes off */
29: #define Q_NEW 0x04 /* new quota - no proc1 msg sent yet */
30: #define Q_NDQ 0x08 /* account has NO disc quota */
31: struct quota *q_freef, **q_freeb;
32: struct dquot *q_dq[NMOUNT]; /* disc quotas for mounted filesys's */
33: };
34:
35: #define NOQUOTA ((struct quota *) 0)
36:
37: #if defined(KERNEL) && defined(QUOTA)
38: struct quota *quota, *quotaNQUOTA;
39: int nquota;
40: struct quota *getquota(), *qfind();
41: #endif
42:
43: /*
44: * The following structure defines the format of the disc quota file
45: * (as it appears on disc) - the file is an array of these structures
46: * indexed by user number. The setquota sys call establishes the inode
47: * for each quota file (a pointer is retained in the mount structure).
48: *
49: * The following constants define the number of warnings given a user
50: * before the soft limits are treated as hard limits (usually resulting
51: * in an allocation failure). The warnings are normally manipulated
52: * each time a user logs in through the Q_DOWARN quota call. If
53: * the user logs in and is under the soft limit the warning count
54: * is reset to MAX_*_WARN, otherwise a message is printed and the
55: * warning count is decremented. This makes MAX_*_WARN equivalent to
56: * the number of logins before soft limits are treated as hard limits.
57: */
58: #define MAX_IQ_WARN 3
59: #define MAX_DQ_WARN 3
60:
61: struct dqblk {
62: u_long dqb_bhardlimit; /* absolute limit on disc blks alloc */
63: u_long dqb_bsoftlimit; /* preferred limit on disc blks */
64: u_long dqb_curblocks; /* current block count */
65: u_short dqb_ihardlimit; /* maximum # allocated inodes + 1 */
66: u_short dqb_isoftlimit; /* preferred inode limit */
67: u_short dqb_curinodes; /* current # allocated inodes */
68: u_char dqb_bwarn; /* # warnings left about excessive disc use */
69: u_char dqb_iwarn; /* # warnings left about excessive inodes */
70: };
71:
72: /*
73: * The following structure records disc usage for a user on a filesystem.
74: * There is one allocated for each quota that exists on any filesystem
75: * for the current user. A cache is kept of other recently used entries.
76: */
77: struct dquot {
78: struct dquot *dq_forw, *dq_back;/* MUST be first entry */
79: union {
80: struct quota *Dq_own; /* the quota that points to this */
81: struct { /* free list */
82: struct dquot *Dq_freef, **Dq_freeb;
83: } dq_f;
84: } dq_u;
85: short dq_flags;
86: #define DQ_LOCK 0x01 /* this quota locked (no MODS) */
87: #define DQ_WANT 0x02 /* wakeup on unlock */
88: #define DQ_MOD 0x04 /* this quota modified since read */
89: #define DQ_FAKE 0x08 /* no limits here, just usage */
90: #define DQ_BLKS 0x10 /* has been warned about blk limit */
91: #define DQ_INODS 0x20 /* has been warned about inode limit */
92: short dq_cnt; /* count of active references */
93: uid_t dq_uid; /* user this applies to */
94: dev_t dq_dev; /* filesystem this relates to */
95: struct dqblk dq_dqb; /* actual usage & quotas */
96: };
97:
98: #define dq_own dq_u.Dq_own
99: #define dq_freef dq_u.dq_f.Dq_freef
100: #define dq_freeb dq_u.dq_f.Dq_freeb
101: #define dq_bhardlimit dq_dqb.dqb_bhardlimit
102: #define dq_bsoftlimit dq_dqb.dqb_bsoftlimit
103: #define dq_curblocks dq_dqb.dqb_curblocks
104: #define dq_ihardlimit dq_dqb.dqb_ihardlimit
105: #define dq_isoftlimit dq_dqb.dqb_isoftlimit
106: #define dq_curinodes dq_dqb.dqb_curinodes
107: #define dq_bwarn dq_dqb.dqb_bwarn
108: #define dq_iwarn dq_dqb.dqb_iwarn
109:
110: #define NODQUOT ((struct dquot *) 0)
111: #define LOSTDQUOT ((struct dquot *) 1)
112:
113: #if defined(KERNEL) && defined(QUOTA)
114: struct dquot *dquot, *dquotNDQUOT;
115: int ndquot;
116: struct dquot *discquota(), *inoquota(), *dqalloc(), *dqp();
117: #endif
118:
119: /*
120: * Definitions for the 'quota' system call.
121: */
122: #define Q_SETDLIM 1 /* set disc limits & usage */
123: #define Q_GETDLIM 2 /* get disc limits & usage */
124: #define Q_SETDUSE 3 /* set disc usage only */
125: #define Q_SYNC 4 /* update disc copy of quota usages */
126: #define Q_SETUID 16 /* change proc to use quotas for uid */
127: #define Q_SETWARN 25 /* alter inode/block warning counts */
128: #define Q_DOWARN 26 /* warn user about excessive space/inodes */
129:
130: /*
131: * Used in Q_SETDUSE.
132: */
133: struct dqusage {
134: u_short du_curinodes;
135: u_long du_curblocks;
136: };
137:
138: /*
139: * Used in Q_SETWARN.
140: */
141: struct dqwarn {
142: u_char dw_bwarn;
143: u_char dw_iwarn;
144: };
Defined variables
quota
defined in line
38; used 9 times
Defined struct's
dqblk
defined in line
61; used 18 times
dquot
defined in line
77; used 71 times
- in line 32,
78-82(4),
114-116(4)
- in /usr/src/sys/GENERIC/param.c line
83(2)
- in /usr/src/sys/conf/param.c line
83(2)
- in /usr/src/sys/sys/quota_kern.c line
62-64(4),
74(2),
130(2),
248(2),
305-312(6),
386-393(6),
426(2),
487(2),
514(2),
611(2),
659(2)
- in /usr/src/sys/sys/quota_subr.c line
26-31(4),
86(2)
- in /usr/src/sys/sys/quota_sys.c line
136(2),
204(2),
224(2),
262(2),
295(2)
- in /usr/src/sys/sys/quota_ufs.c line
30-35(4),
83(2),
165(2)
- in /usr/src/sys/vax/machdep.c line
123(2)
quota
defined in line
22; used 66 times
- in line 23(2),
31(2),
38-40(4),
80(2)
- in /usr/src/sys/GENERIC/param.c line
82(2)
- in /usr/src/sys/conf/param.c line
82(2)
- in /usr/src/sys/sys/quota_kern.c line
42-43(4),
72(2),
123-132(6),
246(2),
394(2),
574-578(4),
610(2),
661(2)
- in /usr/src/sys/sys/quota_subr.c line
28(2),
57(2),
78(2)
- in /usr/src/sys/sys/quota_sys.c line
68(2),
131(2),
200(2),
220(2),
258(2),
292(2),
321(2),
347(2)
- in /usr/src/sys/sys/quota_ufs.c line
34(2),
166(2)
- in /usr/src/sys/vax/machdep.c line
122(2)
Defined macros
DQ_MOD
defined in line
88; used 10 times
NODQUOT
defined in line
110; used 51 times
- in /usr/src/sys/sys/quota_kern.c line
115,
168,
222,
229,
235,
316,
330,
344,
353,
376,
408,
415,
423,
431,
447-449(2),
465,
491,
518,
533,
540,
646,
673,
690
- in /usr/src/sys/sys/quota_subr.c line
35-45(4)
- in /usr/src/sys/sys/quota_sys.c line
146-153(3),
176-181(2),
187,
208,
231,
269,
301,
309
- in /usr/src/sys/sys/quota_ufs.c line
53,
64,
70,
88,
176-179(2)
- in /usr/src/sys/sys/ufs_inode.c line
210,
221,
292,
677
- in /usr/src/sys/sys/ufs_syscalls.c line
1104,
1186
NOQUOTA
defined in line
35; used 22 times
- in /usr/src/sys/sys/quota_kern.c line
95,
139,
149-153(2),
184,
190,
201,
223,
287,
294,
335,
423,
447,
479,
587,
598
- in /usr/src/sys/sys/quota_subr.c line
34,
59
- in /usr/src/sys/sys/quota_sys.c line
80,
177
- in /usr/src/sys/sys/quota_ufs.c line
41,
170
Q_NDQ
defined in line
30; used 7 times
Q_NEW
defined in line
29; used 2 times
dq_own
defined in line
98; used 17 times
- in /usr/src/sys/sys/quota_kern.c line
169,
223,
232,
335,
479,
647
- in /usr/src/sys/sys/quota_subr.c line
43
- in /usr/src/sys/sys/quota_sys.c line
151,
177
- in /usr/src/sys/sys/quota_ufs.c line
65,
99,
122,
133,
140,
202,
212,
220
Usage of this include