/* quota_ufs.c 6.1 83/07/29 */
* Routines used in checking limits on file system usage.
* Find the dquot structure that should
* be used in checking i/o on inode ip.
register struct inode
*ip
;
register struct quota
*q
;
register struct dquot
**dqq
;
register struct mount
*mp
;
for (mp
= mount
; mp
< &mount
[NMOUNT
]; mp
++)
if (mp
->m_bufp
&& mp
->m_dev
== ip
->i_dev
)
return (discquota(ip
->i_uid
, mp
->m_qinod
));
* We have a quota struct in core (most likely our own) that
* belongs to the same user as the inode
if (q
->q_flags
& Q_LOCK
) {
sleep((caddr_t
)q
, PINOD
+1);
goto top
; /* might just have been freed */
index
= getfsx(ip
->i_dev
);
*dqq
= discquota(q
->q_uid
, mount
[index
].m_qinod
);
q
->q_flags
&= ~(Q_LOCK
| Q_WANT
);
* Update disc usage, and take corrective action.
register struct inode
*ip
;
register struct dquot
*dq
;
if (dq
->dq_bsoftlimit
== 0)
if ((int)dq
->dq_curblocks
+ change
>= 0)
dq
->dq_curblocks
+= change
;
dq
->dq_flags
&= ~DQ_BLKS
;
* If user is over quota, or has run out of warnings, then
* disallow space allocation (except su's are never stopped).
if (!force
&& dq
->dq_bwarn
== 0) {
if ((dq
->dq_flags
& DQ_BLKS
) == 0 && dq
->dq_own
== u
.u_quota
) {
uprintf("\nOVER DISC QUOTA: (%s) NO MORE DISC SPACE\n",
if (dq
->dq_curblocks
< dq
->dq_bsoftlimit
) {
dq
->dq_curblocks
+= change
;
if (dq
->dq_curblocks
< dq
->dq_bsoftlimit
)
if (dq
->dq_own
== u
.u_quota
)
uprintf("\nWARNING: disc quota (%s) exceeded\n",
if (!force
&& dq
->dq_bhardlimit
&&
dq
->dq_curblocks
+ change
>= dq
->dq_bhardlimit
) {
if ((dq
->dq_flags
& DQ_BLKS
) == 0 && dq
->dq_own
== u
.u_quota
) {
uprintf("\nDISC LIMIT REACHED (%s) - WRITE FAILED\n",
* User is over quota, but not over limit
* or is over limit, but we have been told
* there is nothing we can do.
dq
->dq_curblocks
+= change
;
* Check the inode limit, applying corrective action.
chkiq(dev
, ip
, uid
, force
)
register struct inode
*ip
;
register struct dquot
*dq
;
register struct quota
*q
;
if (ip
== NULL
) { /* allocation */
dq
= discquota(uid
, mount
[getfsx(dev
)].m_qinod
);
if (dq
->dq_isoftlimit
== 0) {
dq
->dq_flags
&= ~DQ_INODS
;
* The following shouldn't be necessary, as if u.u_uid == 0
* then dq == NODQUOT & we wouldn't get here at all, but
* then again, its not going to harm anything ...
if (u
.u_uid
== 0) /* su's musn't be stopped */
if (!force
&& dq
->dq_iwarn
== 0) {
if ((dq
->dq_flags
& DQ_INODS
) == 0 && dq
->dq_own
== u
.u_quota
) {
uprintf("\nOVER FILE QUOTA - NO MORE FILES (%s)\n",
getfs(dq
->dq_dev
)->fs_fsmnt
);
dq
->dq_flags
|= DQ_INODS
;
if (dq
->dq_curinodes
< dq
->dq_isoftlimit
) {
if (++dq
->dq_curinodes
>= dq
->dq_isoftlimit
&&
uprintf("\nWARNING - too many files (%s)\n",
getfs(dq
->dq_dev
)->fs_fsmnt
);
if (!force
&& dq
->dq_ihardlimit
&&
dq
->dq_curinodes
+ 1 >= dq
->dq_ihardlimit
) {
if ((dq
->dq_flags
& DQ_INODS
) == 0 && dq
->dq_own
== u
.u_quota
) {
uprintf("\nFILE LIMIT REACHED - CREATE FAILED (%s)\n",
getfs(dq
->dq_dev
)->fs_fsmnt
);
dq
->dq_flags
|= DQ_INODS
;
* Over quota but not at limit;
* or over limit, but we aren't