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