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 | * |
c4a75ca5 | 10 | * @(#)quota.h 7.10 (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 | * |
c4a75ca5 KB |
20 | * The following constants define the amount of time given a user before the |
21 | * soft limits are treated as hard limits (usually resulting in an allocation | |
22 | * failure). The timer is started when the user crosses their soft limit, it | |
23 | * 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 | 28 | /* |
c4a75ca5 KB |
29 | * The following constants define the usage of the quota file array in the |
30 | * ufsmount structure and dquot array in the inode structure. The semantics | |
31 | * of the elements of these arrays are defined in the routine getinoquota; | |
32 | * the remainder of the quota code treats them generically and need not be | |
33 | * inspected when changing the size of the array. | |
833afa18 KM |
34 | */ |
35 | #define MAXQUOTAS 2 | |
36 | #define USRQUOTA 0 /* element used for user quotas */ | |
37 | #define GRPQUOTA 1 /* element used for group quotas */ | |
95222a8a | 38 | |
833afa18 KM |
39 | /* |
40 | * Definitions for the default names of the quotas files. | |
41 | */ | |
42 | #define INITQFNAMES { \ | |
43 | "user", /* USRQUOTA */ \ | |
44 | "group", /* GRPQUOTA */ \ | |
45 | "undefined", \ | |
46 | }; | |
c4a75ca5 KB |
47 | #define QUOTAFILENAME "quota" |
48 | #define QUOTAGROUP "operator" | |
187ee005 | 49 | |
187ee005 | 50 | /* |
c4a75ca5 KB |
51 | * Command definitions for the 'quotactl' system call. The commands are |
52 | * broken into a main command defined below and a subcommand that is used | |
53 | * to convey the type of quota that is being manipulated (see above). | |
187ee005 | 54 | */ |
833afa18 KM |
55 | #define SUBCMDMASK 0x00ff |
56 | #define SUBCMDSHIFT 8 | |
57 | #define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK)) | |
95222a8a | 58 | |
833afa18 KM |
59 | #define Q_QUOTAON 0x0100 /* enable quotas */ |
60 | #define Q_QUOTAOFF 0x0200 /* disable quotas */ | |
61 | #define Q_GETQUOTA 0x0300 /* get limits and usage */ | |
62 | #define Q_SETQUOTA 0x0400 /* set limits and usage */ | |
63 | #define Q_SETUSE 0x0500 /* set usage */ | |
64 | #define Q_SYNC 0x0600 /* sync disk copy of a filesystems quotas */ | |
65 | ||
66 | /* | |
67 | * The following structure defines the format of the disk quota file | |
68 | * (as it appears on disk) - the file is an array of these structures | |
69 | * indexed by user or group number. The setquota system call establishes | |
70 | * the vnode for each quota file (a pointer is retained in the ufsmount | |
71 | * structure). | |
72 | */ | |
95222a8a | 73 | struct dqblk { |
833afa18 KM |
74 | u_long dqb_bhardlimit; /* absolute limit on disk blks alloc */ |
75 | u_long dqb_bsoftlimit; /* preferred limit on disk blks */ | |
95222a8a | 76 | u_long dqb_curblocks; /* current block count */ |
833afa18 KM |
77 | u_long dqb_ihardlimit; /* maximum # allocated inodes + 1 */ |
78 | u_long dqb_isoftlimit; /* preferred inode limit */ | |
79 | u_long dqb_curinodes; /* current # allocated inodes */ | |
80 | time_t dqb_btime; /* time limit for excessive disk use */ | |
81 | time_t dqb_itime; /* time limit for excessive files */ | |
a9abb9eb | 82 | }; |
187ee005 RE |
83 | |
84 | /* | |
833afa18 KM |
85 | * The following structure records disk usage for a user or group on a |
86 | * filesystem. There is one allocated for each quota that exists on any | |
87 | * filesystem for the current user or group. A cache is kept of recently | |
88 | * used entries. | |
187ee005 | 89 | */ |
187ee005 | 90 | struct dquot { |
a9abb9eb | 91 | struct dquot *dq_forw, *dq_back;/* MUST be first entry */ |
833afa18 KM |
92 | struct dquot *dq_freef, **dq_freeb; /* free list */ |
93 | short dq_flags; /* flags, see below */ | |
94 | short dq_cnt; /* count of active references */ | |
95 | short dq_spare; /* unused spare padding */ | |
96 | short dq_type; /* quota type of this dquot */ | |
97 | u_long dq_id; /* identifier this applies to */ | |
98 | struct ufsmount *dq_ump; /* filesystem that this is taken from */ | |
99 | struct dqblk dq_dqb; /* actual usage & quotas */ | |
100 | }; | |
101 | /* | |
102 | * Flag values. | |
103 | */ | |
a9abb9eb SL |
104 | #define DQ_LOCK 0x01 /* this quota locked (no MODS) */ |
105 | #define DQ_WANT 0x02 /* wakeup on unlock */ | |
106 | #define DQ_MOD 0x04 /* this quota modified since read */ | |
107 | #define DQ_FAKE 0x08 /* no limits here, just usage */ | |
108 | #define DQ_BLKS 0x10 /* has been warned about blk limit */ | |
109 | #define DQ_INODS 0x20 /* has been warned about inode limit */ | |
833afa18 KM |
110 | /* |
111 | * Shorthand notation. | |
112 | */ | |
95222a8a SL |
113 | #define dq_bhardlimit dq_dqb.dqb_bhardlimit |
114 | #define dq_bsoftlimit dq_dqb.dqb_bsoftlimit | |
115 | #define dq_curblocks dq_dqb.dqb_curblocks | |
116 | #define dq_ihardlimit dq_dqb.dqb_ihardlimit | |
117 | #define dq_isoftlimit dq_dqb.dqb_isoftlimit | |
118 | #define dq_curinodes dq_dqb.dqb_curinodes | |
833afa18 KM |
119 | #define dq_btime dq_dqb.dqb_btime |
120 | #define dq_itime dq_dqb.dqb_itime | |
187ee005 | 121 | |
187ee005 | 122 | /* |
c4a75ca5 KB |
123 | * If the system has never checked for a quota for this file, then it is set |
124 | * to NODQUOT. Once a write attempt is made the inode pointer is set to | |
125 | * reference a dquot structure. | |
187ee005 | 126 | */ |
833afa18 | 127 | #define NODQUOT ((struct dquot *) 0) |
95222a8a SL |
128 | |
129 | /* | |
833afa18 | 130 | * Flags to chkdq() and chkiq() |
95222a8a | 131 | */ |
833afa18 KM |
132 | #define FORCE 0x01 /* force usage changes independent of limits */ |
133 | #define CHOWN 0x02 /* (advisory) change initiated by chown */ | |
95222a8a SL |
134 | |
135 | /* | |
833afa18 | 136 | * Macros to avoid subroutine calls to trivial functions. |
95222a8a | 137 | */ |
c4a75ca5 | 138 | #ifdef DIAGNOSTIC |
833afa18 | 139 | #define DQREF(dq) dqref(dq) |
114ba1ab | 140 | #else |
c4a75ca5 KB |
141 | #define DQREF(dq) (dq)->dq_cnt++ |
142 | #endif | |
114ba1ab DS |
143 | |
144 | #include <sys/cdefs.h> | |
145 | ||
c4a75ca5 KB |
146 | struct dquot; |
147 | struct inode; | |
148 | struct mount; | |
149 | struct proc; | |
150 | struct ucred; | |
151 | struct ufsmount; | |
152 | struct vnode; | |
153 | __BEGIN_DECLS | |
154 | int chkdq __P((struct inode *, long, struct ucred *, int)); | |
155 | int chkdqchg __P((struct inode *, long, struct ucred *, int)); | |
156 | int chkiq __P((struct inode *, long, struct ucred *, int)); | |
157 | int chkiqchg __P((struct inode *, long, struct ucred *, int)); | |
158 | void dqflush __P((struct vnode *)); | |
159 | int dqget __P((struct vnode *, | |
160 | u_long, struct ufsmount *, int, struct dquot **)); | |
161 | void dqinit __P((void)); | |
162 | void dqref __P((struct dquot *)); | |
163 | void dqrele __P((struct vnode *, struct dquot *)); | |
164 | int dqsync __P((struct vnode *, struct dquot *)); | |
165 | int getinoquota __P((struct inode *)); | |
166 | int getquota __P((struct mount *, u_long, int, caddr_t)); | |
167 | int qsync __P((struct mount *mp)); | |
168 | int quotaoff __P((struct proc *, struct mount *, int)); | |
169 | int quotaon __P((struct proc *, struct mount *, int, caddr_t)); | |
170 | int setquota __P((struct mount *, u_long, int, caddr_t)); | |
171 | int setuse __P((struct mount *, u_long, int, caddr_t)); | |
172 | int ufs_quotactl __P((struct mount *, int, u_int, caddr_t, struct proc *)); | |
173 | __END_DECLS | |
174 | ||
175 | #ifdef DIAGNOSTIC | |
114ba1ab | 176 | __BEGIN_DECLS |
c4a75ca5 | 177 | void chkdquot __P((struct inode *)); |
114ba1ab | 178 | __END_DECLS |
c4a75ca5 | 179 | #endif |
114ba1ab | 180 | |
89fb6508 | 181 | #endif /* _QUOTA_ */ |