4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1999 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
40 #ifndef _SYS_FS_UFS_QUOTA_H
41 #define _SYS_FS_UFS_QUOTA_H
43 #pragma ident "%Z%%M% %I% %E% SMI"
50 * Lock order for the quota sub-system:
52 * vfs_dqrwlock > ip.i_contents > dq_cachelock > dquot.dq_lock > dq_freelock
53 * vfs_dqrwlock > ip.i_contents > dq_cachelock > dq_freelock
54 * vfs_dqrwlock > ip.i_contents > dquot.dq_lock > dq_freelock
55 * vfs_dqrwlock > ip.i_contents > dq_freelock
56 * vfs_dqrwlock > ip.i_contents > dq_cachelock > dquot.dq_lock > qip.i_contents
60 * The following constants define the default amount of time given a user
61 * before the soft limits are treated as hard limits (usually resulting
62 * in an allocation failure). These may be modified by the quotactl
63 * system call with the Q_SETQLIM or Q_SETQUOTA commands.
66 #define DQ_FTIMELIMIT (7 * 24*60*60) /* 1 week */
67 #define DQ_BTIMELIMIT (7 * 24*60*60) /* 1 week */
70 * The dqblk structure defines the format of the disk quota file
71 * (as it appears on disk) - the file is an array of these structures
72 * indexed by user number. The setquota sys call establishes the inode
73 * for each quota file (a pointer is retained in the mount structure).
77 uint32_t dqb_bhardlimit
; /* absolute limit on disk blks alloc */
78 uint32_t dqb_bsoftlimit
; /* preferred limit on disk blks */
79 uint32_t dqb_curblocks
; /* current block count */
80 uint32_t dqb_fhardlimit
; /* maximum # allocated files + 1 */
81 uint32_t dqb_fsoftlimit
; /* preferred file limit */
82 uint32_t dqb_curfiles
; /* current # allocated files */
83 uint32_t dqb_btimelimit
; /* time limit for excessive disk use */
84 uint32_t dqb_ftimelimit
; /* time limit for excessive files */
87 #define dqoff(UID) (((offset_t)(UID) * sizeof (struct dqblk)))
90 * The dquot structure records disk usage for a user on a filesystem.
91 * There is one allocated for each quota that exists on any filesystem
92 * for the current user. A cache is kept of recently used entries.
93 * Active inodes have a pointer to the dquot associated with them.
96 struct dquot
*dq_forw
, *dq_back
; /* hash list, MUST be first entry */
97 struct dquot
*dq_freef
, *dq_freeb
; /* free list */
99 #define DQ_ERROR 0x01 /* An error occurred reading dq */
100 #define DQ_MOD 0x04 /* this quota modified since read */
101 #define DQ_BLKS 0x10 /* has been warned about blk limit */
102 #define DQ_FILES 0x20 /* has been warned about file limit */
103 #define DQ_TRANS 0x40 /* logging ufs operation started */
104 ulong_t dq_cnt
; /* count of active references */
105 uid_t dq_uid
; /* user this applies to */
106 struct ufsvfs
*dq_ufsvfsp
; /* filesystem this relates to */
107 offset_t dq_mof
; /* master disk offset of quota record */
108 struct dqblk dq_dqb
; /* actual usage & quotas */
110 kmutex_t dq_lock
; /* per dq structure lock */
114 #define dq_bhardlimit dq_dqb.dqb_bhardlimit
115 #define dq_bsoftlimit dq_dqb.dqb_bsoftlimit
116 #define dq_curblocks dq_dqb.dqb_curblocks
117 #define dq_fhardlimit dq_dqb.dqb_fhardlimit
118 #define dq_fsoftlimit dq_dqb.dqb_fsoftlimit
119 #define dq_curfiles dq_dqb.dqb_curfiles
120 #define dq_btimelimit dq_dqb.dqb_btimelimit
121 #define dq_ftimelimit dq_dqb.dqb_ftimelimit
124 * flags for vfs_qflags in ufsvfs struct
126 #define MQ_ENABLED 0x01 /* quotas are enabled */
131 * dquot chach hash chain headers
133 #define NDQHASH 64 /* smallish power of two */
134 #define DQHASH(uid, mp) \
135 (((uintptr_t)(mp) + (unsigned)(uid)) & (NDQHASH-1))
138 struct dquot
*dqh_forw
; /* MUST be first */
139 struct dquot
*dqh_back
; /* MUST be second */
142 extern struct dqhead dqhead
[NDQHASH
];
144 extern struct dquot
*dquot
, *dquotNDQUOT
;
146 extern krwlock_t dq_rwlock
; /* quota sub-system init lock */
147 extern int quotas_initialized
; /* quota sub-system init flag */
149 extern void qtinit();
150 extern void qtinit2();
151 extern struct dquot
*getinoquota(struct inode
*);
152 extern int chkdq(struct inode
*ip
, long, int, struct cred
*, char **errp
,
154 extern int chkiq(struct ufsvfs
*, int, struct inode
*, uid_t
, int,
155 struct cred
*, char **errp
, size_t *lenp
);
156 extern void dqrele(struct dquot
*);
157 extern int closedq(struct ufsvfs
*, struct cred
*);
158 extern int qsync(struct ufsvfs
*);
160 extern int getdiskquota(uid_t
, struct ufsvfs
*, int, struct dquot
**);
161 extern void dqput(struct dquot
*);
162 extern void dqupdate(struct dquot
*);
163 extern void dqinval(struct dquot
*);
164 extern void invalidatedq(struct ufsvfs
*);
166 extern int quotactl(struct vnode
*, intptr_t, int flag
, struct cred
*);
171 * Definitions for the 'quotactl' system call.
173 #define Q_QUOTAON 1 /* turn quotas on */
174 #define Q_QUOTAOFF 2 /* turn quotas off */
175 #define Q_SETQUOTA 3 /* set disk limits & usage */
176 #define Q_GETQUOTA 4 /* get disk limits & usage */
177 #define Q_SETQLIM 5 /* set disk limits only */
178 #define Q_SYNC 6 /* update disk copy of quota usages */
179 #define Q_ALLSYNC 7 /* update disk copy of quota usages for all */
182 /* ILP32 compatible structure for LP64 kernel. */
188 #endif /* SYSCALL32 */
196 #define Q_QUOTACTL 0x00030189 /* ioctl command for quotactl */
202 #endif /* _SYS_FS_UFS_QUOTA_H */