Commit | Line | Data |
---|---|---|
a9abb9eb | 1 | /* quota.h 4.3 83/05/21 */ |
187ee005 | 2 | |
6e7edb25 | 3 | #ifdef QUOTA |
187ee005 RE |
4 | /* |
5 | * Various junk to do with various quotas (etc) imposed upon | |
6 | * the average user (big brother finally hits unix) | |
7 | * | |
8 | * The following structure exists in core for each logged on user | |
9 | * It contains global junk relevant to that user's quotas | |
10 | * | |
11 | * The u_quota field of each user struct contains a pointer to | |
12 | * the quota struct relevant to the current process, this is changed | |
13 | * by 'setuid' sys call, &/or by the Q_SETUID quota() call | |
14 | */ | |
187ee005 RE |
15 | #ifdef KERNEL |
16 | struct 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 */ | |
a9abb9eb SL |
20 | char q_flg; /* struct management flags */ |
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 | }; | |
28 | #define NOQUOT ((struct quota *) 0) | |
187ee005 RE |
29 | #endif |
30 | ||
187ee005 | 31 | #ifdef KERNEL |
a9abb9eb | 32 | struct quota *quota, *quotaNQUOTA; |
187ee005 | 33 | int nquota; |
a9abb9eb | 34 | struct quota *getquota(), *qfind(); |
187ee005 RE |
35 | #endif |
36 | ||
187ee005 RE |
37 | /* |
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. A sys call (setquota) establishes the | |
41 | * inode for each applicable file (a pointer is retained in the mount | |
42 | * structure) | |
43 | * | |
44 | * nb: warning fields contain the number of warnings left before | |
45 | * allocation is halted completely | |
46 | */ | |
187ee005 RE |
47 | typedef unsigned short dlim_t; |
48 | ||
49 | struct dqblk { | |
50 | dlim_t dqb_ilim; /* max num allocated inodes + 1 */ | |
51 | dlim_t dqb_iq; /* preferred inode limit */ | |
52 | dlim_t dqb_inod; /* current num allocated inodes */ | |
53 | dlim_t dqb_iwarn; /* # warnings about excessive inodes */ | |
a9abb9eb | 54 | #define MAX_IQ_WARN 3 |
187ee005 RE |
55 | dlim_t dqb_blim; /* abs limit on disc blks alloc */ |
56 | dlim_t dqb_quot; /* preferred limit on disc blks */ | |
57 | dlim_t dqb_blks; /* current block count */ | |
58 | dlim_t dqb_dwarn; /* # warnings about excessive disc use */ | |
187ee005 | 59 | #define MAX_DQ_WARN 3 |
a9abb9eb | 60 | }; |
187ee005 RE |
61 | |
62 | /* | |
63 | * The following structure records disc usage for a user on a filesystem | |
64 | * There is one allocated for each quota that exists on any filesystem | |
65 | * for the current user. A cache is kept of other recently used entries. | |
66 | */ | |
187ee005 | 67 | struct dquot { |
a9abb9eb | 68 | struct dquot *dq_forw, *dq_back;/* MUST be first entry */ |
187ee005 | 69 | union { |
a9abb9eb SL |
70 | struct quota *Dq_own; /* the quota that points to this */ |
71 | struct { /* free list */ | |
72 | struct dquot *Dq_freef, **Dq_freeb; | |
187ee005 RE |
73 | } dq_f; |
74 | } dq_u; | |
75 | short dq_flg; | |
a9abb9eb SL |
76 | #define DQ_LOCK 0x01 /* this quota locked (no MODS) */ |
77 | #define DQ_WANT 0x02 /* wakeup on unlock */ | |
78 | #define DQ_MOD 0x04 /* this quota modified since read */ | |
79 | #define DQ_FAKE 0x08 /* no limits here, just usage */ | |
80 | #define DQ_BLKS 0x10 /* has been warned about blk limit */ | |
81 | #define DQ_INODS 0x20 /* has been warned about inode limit */ | |
187ee005 RE |
82 | short dq_cnt; /* count of active references */ |
83 | short dq_uid; /* user this applies to */ | |
84 | dev_t dq_dev; /* filesystem this relates to */ | |
85 | struct dqblk dq_dqb; /* actual usage & quotas */ | |
86 | }; | |
87 | #define dq_own dq_u.Dq_own | |
88 | #define dq_freef dq_u.dq_f.Dq_freef | |
89 | #define dq_freeb dq_u.dq_f.Dq_freeb | |
90 | #define dq_ilim dq_dqb.dqb_ilim | |
91 | #define dq_iq dq_dqb.dqb_iq | |
92 | #define dq_inod dq_dqb.dqb_inod | |
93 | #define dq_iwarn dq_dqb.dqb_iwarn | |
94 | #define dq_blim dq_dqb.dqb_blim | |
95 | #define dq_quot dq_dqb.dqb_quot | |
96 | #define dq_blks dq_dqb.dqb_blks | |
97 | #define dq_dwarn dq_dqb.dqb_dwarn | |
98 | #define NODQUOT ((struct dquot *) 0) | |
99 | #define LOSTDQUOT ((struct dquot *) 1) | |
100 | ||
101 | #ifdef KERNEL | |
a9abb9eb | 102 | struct dquot *dquot, *dquotNDQUOT; |
187ee005 | 103 | int ndquot; |
a9abb9eb | 104 | struct dquot *discquota(), *inoquota(), *dqalloc(), *dqp(); |
187ee005 RE |
105 | #endif |
106 | ||
187ee005 RE |
107 | /* |
108 | * Commands for the 'quota' system call | |
109 | */ | |
110 | #define Q_SETDLIM 1 /* set disc limits & usage */ | |
111 | #define Q_GETDLIM 2 /* get disc limits & usage */ | |
112 | #define Q_SETDUSE 3 /* set disc usage only */ | |
113 | #define Q_SYNC 4 /* update disc copy if quota usages */ | |
187ee005 | 114 | #define Q_SETUID 16 /* change proc to use quotas for uid */ |
187ee005 RE |
115 | #define Q_SETWARN 25 /* alter inode/block warning counts */ |
116 | #define Q_DOWARN 26 /* warn user about excessive space/inodes */ | |
187ee005 | 117 | #endif |