Commit | Line | Data |
---|---|---|
da7c5cc6 | 1 | /* |
1810611d | 2 | * Copyright (c) 1982, 1986 Regents of the University of California. |
f9ac90b4 | 3 | * All rights reserved. |
da7c5cc6 | 4 | * |
f9ac90b4 | 5 | * Redistribution and use in source and binary forms are permitted |
50c7758a KB |
6 | * provided that the above copyright notice and this paragraph are |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
f9ac90b4 | 16 | * |
50c7758a | 17 | * @(#)quota.h 7.3 (Berkeley) %G% |
da7c5cc6 | 18 | */ |
187ee005 RE |
19 | |
20 | /* | |
95222a8a | 21 | * MELBOURNE DISC QUOTAS |
187ee005 | 22 | * |
95222a8a SL |
23 | * Various junk to do with various quotas (etc) imposed upon |
24 | * the average user (big brother finally hits UNIX). | |
187ee005 | 25 | * |
95222a8a SL |
26 | * The following structure exists in core for each logged on user. |
27 | * It contains global junk relevant to that user's quotas. | |
28 | * | |
29 | * The u_quota field of each user struct contains a pointer to | |
30 | * the quota struct relevant to the current process, this is changed | |
31 | * by 'setuid' sys call, &/or by the Q_SETUID quota() call. | |
187ee005 | 32 | */ |
187ee005 | 33 | struct quota { |
a9abb9eb | 34 | struct quota *q_forw, *q_back; /* hash chain, MUST be first */ |
187ee005 | 35 | short q_cnt; /* ref count (# processes) */ |
adc65074 | 36 | uid_t q_uid; /* real uid of owner */ |
95222a8a | 37 | int q_flags; /* struct management flags */ |
a9abb9eb SL |
38 | #define Q_LOCK 0x01 /* quota struct locked (for disc i/o) */ |
39 | #define Q_WANT 0x02 /* issue a wakeup when lock goes off */ | |
40 | #define Q_NEW 0x04 /* new quota - no proc1 msg sent yet */ | |
41 | #define Q_NDQ 0x08 /* account has NO disc quota */ | |
42 | struct quota *q_freef, **q_freeb; | |
187ee005 RE |
43 | struct dquot *q_dq[NMOUNT]; /* disc quotas for mounted filesys's */ |
44 | }; | |
187ee005 | 45 | |
95222a8a SL |
46 | #define NOQUOTA ((struct quota *) 0) |
47 | ||
54cc5e32 | 48 | #if defined(KERNEL) && defined(QUOTA) |
a9abb9eb | 49 | struct quota *quota, *quotaNQUOTA; |
187ee005 | 50 | int nquota; |
a9abb9eb | 51 | struct quota *getquota(), *qfind(); |
187ee005 RE |
52 | #endif |
53 | ||
187ee005 | 54 | /* |
95222a8a SL |
55 | * The following structure defines the format of the disc quota file |
56 | * (as it appears on disc) - the file is an array of these structures | |
57 | * indexed by user number. The setquota sys call establishes the inode | |
58 | * for each quota file (a pointer is retained in the mount structure). | |
187ee005 | 59 | * |
95222a8a SL |
60 | * The following constants define the number of warnings given a user |
61 | * before the soft limits are treated as hard limits (usually resulting | |
62 | * in an allocation failure). The warnings are normally manipulated | |
63 | * each time a user logs in through the Q_DOWARN quota call. If | |
64 | * the user logs in and is under the soft limit the warning count | |
65 | * is reset to MAX_*_WARN, otherwise a message is printed and the | |
66 | * warning count is decremented. This makes MAX_*_WARN equivalent to | |
67 | * the number of logins before soft limits are treated as hard limits. | |
187ee005 | 68 | */ |
a9abb9eb | 69 | #define MAX_IQ_WARN 3 |
187ee005 | 70 | #define MAX_DQ_WARN 3 |
95222a8a SL |
71 | |
72 | struct dqblk { | |
73 | u_long dqb_bhardlimit; /* absolute limit on disc blks alloc */ | |
74 | u_long dqb_bsoftlimit; /* preferred limit on disc blks */ | |
75 | u_long dqb_curblocks; /* current block count */ | |
76 | u_short dqb_ihardlimit; /* maximum # allocated inodes + 1 */ | |
77 | u_short dqb_isoftlimit; /* preferred inode limit */ | |
78 | u_short dqb_curinodes; /* current # allocated inodes */ | |
79 | u_char dqb_bwarn; /* # warnings left about excessive disc use */ | |
80 | u_char dqb_iwarn; /* # warnings left about excessive inodes */ | |
a9abb9eb | 81 | }; |
187ee005 RE |
82 | |
83 | /* | |
95222a8a SL |
84 | * The following structure records disc usage for a user on a filesystem. |
85 | * There is one allocated for each quota that exists on any filesystem | |
86 | * for the current user. A cache is kept of other recently used entries. | |
187ee005 | 87 | */ |
187ee005 | 88 | struct dquot { |
a9abb9eb | 89 | struct dquot *dq_forw, *dq_back;/* MUST be first entry */ |
187ee005 | 90 | union { |
a9abb9eb SL |
91 | struct quota *Dq_own; /* the quota that points to this */ |
92 | struct { /* free list */ | |
93 | struct dquot *Dq_freef, **Dq_freeb; | |
187ee005 RE |
94 | } dq_f; |
95 | } dq_u; | |
95222a8a | 96 | short dq_flags; |
a9abb9eb SL |
97 | #define DQ_LOCK 0x01 /* this quota locked (no MODS) */ |
98 | #define DQ_WANT 0x02 /* wakeup on unlock */ | |
99 | #define DQ_MOD 0x04 /* this quota modified since read */ | |
100 | #define DQ_FAKE 0x08 /* no limits here, just usage */ | |
101 | #define DQ_BLKS 0x10 /* has been warned about blk limit */ | |
102 | #define DQ_INODS 0x20 /* has been warned about inode limit */ | |
187ee005 | 103 | short dq_cnt; /* count of active references */ |
adc65074 | 104 | uid_t dq_uid; /* user this applies to */ |
187ee005 RE |
105 | dev_t dq_dev; /* filesystem this relates to */ |
106 | struct dqblk dq_dqb; /* actual usage & quotas */ | |
107 | }; | |
d6185698 | 108 | |
187ee005 RE |
109 | #define dq_own dq_u.Dq_own |
110 | #define dq_freef dq_u.dq_f.Dq_freef | |
111 | #define dq_freeb dq_u.dq_f.Dq_freeb | |
95222a8a SL |
112 | #define dq_bhardlimit dq_dqb.dqb_bhardlimit |
113 | #define dq_bsoftlimit dq_dqb.dqb_bsoftlimit | |
114 | #define dq_curblocks dq_dqb.dqb_curblocks | |
115 | #define dq_ihardlimit dq_dqb.dqb_ihardlimit | |
116 | #define dq_isoftlimit dq_dqb.dqb_isoftlimit | |
117 | #define dq_curinodes dq_dqb.dqb_curinodes | |
118 | #define dq_bwarn dq_dqb.dqb_bwarn | |
187ee005 | 119 | #define dq_iwarn dq_dqb.dqb_iwarn |
95222a8a | 120 | |
187ee005 RE |
121 | #define NODQUOT ((struct dquot *) 0) |
122 | #define LOSTDQUOT ((struct dquot *) 1) | |
123 | ||
54cc5e32 | 124 | #if defined(KERNEL) && defined(QUOTA) |
a9abb9eb | 125 | struct dquot *dquot, *dquotNDQUOT; |
187ee005 | 126 | int ndquot; |
a9abb9eb | 127 | struct dquot *discquota(), *inoquota(), *dqalloc(), *dqp(); |
187ee005 RE |
128 | #endif |
129 | ||
187ee005 | 130 | /* |
95222a8a | 131 | * Definitions for the 'quota' system call. |
187ee005 RE |
132 | */ |
133 | #define Q_SETDLIM 1 /* set disc limits & usage */ | |
134 | #define Q_GETDLIM 2 /* get disc limits & usage */ | |
135 | #define Q_SETDUSE 3 /* set disc usage only */ | |
95222a8a | 136 | #define Q_SYNC 4 /* update disc copy of quota usages */ |
187ee005 | 137 | #define Q_SETUID 16 /* change proc to use quotas for uid */ |
187ee005 RE |
138 | #define Q_SETWARN 25 /* alter inode/block warning counts */ |
139 | #define Q_DOWARN 26 /* warn user about excessive space/inodes */ | |
95222a8a SL |
140 | |
141 | /* | |
142 | * Used in Q_SETDUSE. | |
143 | */ | |
144 | struct dqusage { | |
145 | u_short du_curinodes; | |
146 | u_long du_curblocks; | |
147 | }; | |
148 | ||
149 | /* | |
150 | * Used in Q_SETWARN. | |
151 | */ | |
152 | struct dqwarn { | |
153 | u_char dw_bwarn; | |
154 | u_char dw_iwarn; | |
155 | }; |