Commit | Line | Data |
---|---|---|
da7c5cc6 | 1 | /* |
1810611d | 2 | * Copyright (c) 1982, 1986 Regents of the University of California. |
f9ac90b4 | 3 | * All rights reserved. |
da7c5cc6 | 4 | * |
833afa18 KM |
5 | * This code is derived from software contributed to Berkeley by |
6 | * Robert Elz at The University of Melbourne. | |
7 | * | |
b702c21d | 8 | * %sccs.include.redist.c% |
f9ac90b4 | 9 | * |
114ba1ab | 10 | * @(#)quota.h 7.9 (Berkeley) %G% |
da7c5cc6 | 11 | */ |
187ee005 | 12 | |
89fb6508 KM |
13 | #ifndef _QUOTA_ |
14 | #define _QUOTA_ | |
15 | ||
187ee005 | 16 | /* |
833afa18 KM |
17 | * Definitions for disk quotas imposed on the average user |
18 | * (big brother finally hits UNIX). | |
187ee005 | 19 | * |
833afa18 KM |
20 | * The following constants define the amount of time given a user |
21 | * before the soft limits are treated as hard limits (usually resulting | |
22 | * in an allocation failure). The timer is started when the user crosses | |
23 | * their soft limit, it is reset when they go below their soft limit. | |
187ee005 | 24 | */ |
833afa18 KM |
25 | #define MAX_IQ_TIME (7*24*60*60) /* 1 week */ |
26 | #define MAX_DQ_TIME (7*24*60*60) /* 1 week */ | |
187ee005 | 27 | |
833afa18 KM |
28 | /* |
29 | * The following constants define the usage of the quota file array | |
30 | * in the ufsmount structure and dquot array in the inode structure. | |
31 | * The semantics of the elements of these arrays are defined in the | |
32 | * routine getinoquota; the remainder of the quota code treats them | |
33 | * generically and need not be inspected when changing the size of | |
34 | * the array. | |
35 | */ | |
36 | #define MAXQUOTAS 2 | |
37 | #define USRQUOTA 0 /* element used for user quotas */ | |
38 | #define GRPQUOTA 1 /* element used for group quotas */ | |
95222a8a | 39 | |
833afa18 KM |
40 | /* |
41 | * Definitions for the default names of the quotas files. | |
42 | */ | |
43 | #define INITQFNAMES { \ | |
44 | "user", /* USRQUOTA */ \ | |
45 | "group", /* GRPQUOTA */ \ | |
46 | "undefined", \ | |
47 | }; | |
39c00e33 KM |
48 | #define QUOTAFILENAME "quota" |
49 | #define QUOTAGROUP "operator" | |
187ee005 | 50 | |
187ee005 | 51 | /* |
833afa18 KM |
52 | * Command definitions for the 'quotactl' system call. |
53 | * The commands are broken into a main command defined below | |
54 | * and a subcommand that is used to convey the type of | |
55 | * quota that is being manipulated (see above). | |
187ee005 | 56 | */ |
833afa18 KM |
57 | #define SUBCMDMASK 0x00ff |
58 | #define SUBCMDSHIFT 8 | |
59 | #define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK)) | |
95222a8a | 60 | |
833afa18 KM |
61 | #define Q_QUOTAON 0x0100 /* enable quotas */ |
62 | #define Q_QUOTAOFF 0x0200 /* disable quotas */ | |
63 | #define Q_GETQUOTA 0x0300 /* get limits and usage */ | |
64 | #define Q_SETQUOTA 0x0400 /* set limits and usage */ | |
65 | #define Q_SETUSE 0x0500 /* set usage */ | |
66 | #define Q_SYNC 0x0600 /* sync disk copy of a filesystems quotas */ | |
67 | ||
68 | /* | |
69 | * The following structure defines the format of the disk quota file | |
70 | * (as it appears on disk) - the file is an array of these structures | |
71 | * indexed by user or group number. The setquota system call establishes | |
72 | * the vnode for each quota file (a pointer is retained in the ufsmount | |
73 | * structure). | |
74 | */ | |
95222a8a | 75 | struct dqblk { |
833afa18 KM |
76 | u_long dqb_bhardlimit; /* absolute limit on disk blks alloc */ |
77 | u_long dqb_bsoftlimit; /* preferred limit on disk blks */ | |
95222a8a | 78 | u_long dqb_curblocks; /* current block count */ |
833afa18 KM |
79 | u_long dqb_ihardlimit; /* maximum # allocated inodes + 1 */ |
80 | u_long dqb_isoftlimit; /* preferred inode limit */ | |
81 | u_long dqb_curinodes; /* current # allocated inodes */ | |
82 | time_t dqb_btime; /* time limit for excessive disk use */ | |
83 | time_t dqb_itime; /* time limit for excessive files */ | |
a9abb9eb | 84 | }; |
187ee005 | 85 | |
833afa18 | 86 | #ifdef KERNEL |
187ee005 | 87 | /* |
833afa18 KM |
88 | * The following structure records disk usage for a user or group on a |
89 | * filesystem. There is one allocated for each quota that exists on any | |
90 | * filesystem for the current user or group. A cache is kept of recently | |
91 | * used entries. | |
187ee005 | 92 | */ |
187ee005 | 93 | struct dquot { |
a9abb9eb | 94 | struct dquot *dq_forw, *dq_back;/* MUST be first entry */ |
833afa18 KM |
95 | struct dquot *dq_freef, **dq_freeb; /* free list */ |
96 | short dq_flags; /* flags, see below */ | |
97 | short dq_cnt; /* count of active references */ | |
98 | short dq_spare; /* unused spare padding */ | |
99 | short dq_type; /* quota type of this dquot */ | |
100 | u_long dq_id; /* identifier this applies to */ | |
101 | struct ufsmount *dq_ump; /* filesystem that this is taken from */ | |
102 | struct dqblk dq_dqb; /* actual usage & quotas */ | |
103 | }; | |
104 | /* | |
105 | * Flag values. | |
106 | */ | |
a9abb9eb SL |
107 | #define DQ_LOCK 0x01 /* this quota locked (no MODS) */ |
108 | #define DQ_WANT 0x02 /* wakeup on unlock */ | |
109 | #define DQ_MOD 0x04 /* this quota modified since read */ | |
110 | #define DQ_FAKE 0x08 /* no limits here, just usage */ | |
111 | #define DQ_BLKS 0x10 /* has been warned about blk limit */ | |
112 | #define DQ_INODS 0x20 /* has been warned about inode limit */ | |
833afa18 KM |
113 | /* |
114 | * Shorthand notation. | |
115 | */ | |
95222a8a SL |
116 | #define dq_bhardlimit dq_dqb.dqb_bhardlimit |
117 | #define dq_bsoftlimit dq_dqb.dqb_bsoftlimit | |
118 | #define dq_curblocks dq_dqb.dqb_curblocks | |
119 | #define dq_ihardlimit dq_dqb.dqb_ihardlimit | |
120 | #define dq_isoftlimit dq_dqb.dqb_isoftlimit | |
121 | #define dq_curinodes dq_dqb.dqb_curinodes | |
833afa18 KM |
122 | #define dq_btime dq_dqb.dqb_btime |
123 | #define dq_itime dq_dqb.dqb_itime | |
187ee005 | 124 | |
187ee005 | 125 | /* |
833afa18 KM |
126 | * If the system has never checked for a quota for this file, |
127 | * then it is set to NODQUOT. Once a write attempt is made | |
128 | * the inode pointer is set to reference a dquot structure. | |
187ee005 | 129 | */ |
833afa18 | 130 | #define NODQUOT ((struct dquot *) 0) |
95222a8a SL |
131 | |
132 | /* | |
833afa18 | 133 | * Flags to chkdq() and chkiq() |
95222a8a | 134 | */ |
833afa18 KM |
135 | #define FORCE 0x01 /* force usage changes independent of limits */ |
136 | #define CHOWN 0x02 /* (advisory) change initiated by chown */ | |
95222a8a SL |
137 | |
138 | /* | |
833afa18 | 139 | * Macros to avoid subroutine calls to trivial functions. |
95222a8a | 140 | */ |
833afa18 KM |
141 | #ifndef DIAGNOSTIC |
142 | #define DQREF(dq) (dq)->dq_cnt++ | |
143 | #else | |
144 | #define DQREF(dq) dqref(dq) | |
145 | #endif /* DIAGNOSTIC */ | |
114ba1ab DS |
146 | |
147 | #else | |
148 | ||
149 | #include <sys/cdefs.h> | |
150 | ||
151 | __BEGIN_DECLS | |
152 | int quotactl __P((const char *, int, int, void *)); | |
153 | __END_DECLS | |
154 | ||
833afa18 | 155 | #endif /* KERNEL */ |
89fb6508 | 156 | #endif /* _QUOTA_ */ |