1: /*
   2:  * Copyright (c) 1982, 1986 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)quota_subr.c	7.1 (Berkeley) 6/5/86
   7:  */
   8: 
   9: /*
  10:  * MELBOURNE QUOTAS
  11:  *
  12:  * Miscellaneous subroutines.
  13:  */
  14: #include "param.h"
  15: #ifdef QUOTA
  16: #include "systm.h"
  17: #include "user.h"
  18: #include "proc.h"
  19: #include "inode.h"
  20: #include "quota.h"
  21: #include "fs.h"
  22: #include "mount.h"
  23: #include "uio.h"
  24: 
  25: struct dquot *
  26: dqp(q, dev)
  27:     struct quota *q;
  28:     dev_t dev;
  29: {
  30:     register struct dquot **dqq;
  31:     register i;
  32: 
  33:     if (q == NOQUOTA || q->q_flags & Q_NDQ)
  34:         return (NODQUOT);
  35:     i = getfsx(dev);
  36:     if (i < 0 || i >= NMOUNT)
  37:         return (NODQUOT);
  38:     dqq = &q->q_dq[i];
  39:     if (*dqq == LOSTDQUOT) {
  40:         *dqq = discquota(q->q_uid, mount[i].m_qinod);
  41:         if (*dqq != NODQUOT)
  42:             (*dqq)->dq_own = q;
  43:     }
  44:     if (*dqq != NODQUOT)
  45:         (*dqq)->dq_cnt++;
  46:     return (*dqq);
  47: }
  48: 
  49: /*
  50:  * Quota cleanup at process exit, or when
  51:  * switching to another user.
  52:  */
  53: qclean()
  54: {
  55:     register struct quota *q = u.u_quota;
  56: 
  57:     if (q == NOQUOTA)
  58:         return;
  59:     /*
  60: 	 * Before we rid ourselves of this quota, we must be sure that
  61: 	 * we no longer reference it (otherwise clock might do nasties).
  62: 	 * But we have to have some quota (or clock will get upset).
  63: 	 * (Who is this clock anyway ??). So we will give ourselves
  64: 	 * root's quota for a short while, without counting this as
  65: 	 * a reference in the ref count (as either this proc is just
  66: 	 * about to die, in which case it refers to nothing, or it is
  67: 	 * about to be given a new quota, which will just overwrite this
  68: 	 * one).
  69: 	 */
  70:     u.u_quota = quota;
  71:     delquota(q);
  72: }
  73: 
  74: qstart(q)
  75:     register struct quota *q;
  76: {
  77: 
  78:     u.u_quota = q;
  79: }
  80: 
  81: qwarn(dq)
  82:     register struct dquot *dq;
  83: {
  84:     register struct fs *fs = NULL;
  85: 
  86:     if (dq->dq_isoftlimit && dq->dq_curinodes >= dq->dq_isoftlimit) {
  87:         dq->dq_flags |= DQ_MOD;
  88:         fs = getfs(dq->dq_dev);
  89:         if (dq->dq_iwarn && --dq->dq_iwarn)
  90:             uprintf(
  91:                 "Warning: too many files on %s, %d warning%s left\n"
  92:                 , fs->fs_fsmnt
  93:                 , dq->dq_iwarn
  94:                 , dq->dq_iwarn > 1 ? "s" : ""
  95:             );
  96:         else
  97:             uprintf(
  98:                 "WARNING: too many files on %s, NO MORE!!\n"
  99:                 , fs->fs_fsmnt
 100:             );
 101:     } else
 102:         dq->dq_iwarn = MAX_IQ_WARN;
 103: 
 104:     if (dq->dq_bsoftlimit && dq->dq_curblocks >= dq->dq_bsoftlimit) {
 105:         dq->dq_flags |= DQ_MOD;
 106:         if (fs == NULL)
 107:             fs = getfs(dq->dq_dev);
 108:         if (dq->dq_bwarn && --dq->dq_bwarn)
 109:             uprintf(
 110:             "Warning: too much disc space on %s, %d warning%s left\n"
 111:                 , fs->fs_fsmnt
 112:                 , dq->dq_bwarn
 113:                 , dq->dq_bwarn > 1 ? "s" : ""
 114:             );
 115:         else
 116:             uprintf(
 117:             "WARNING: too much disc space on %s, NO MORE!!\n"
 118:                 , fs->fs_fsmnt
 119:             );
 120:     } else
 121:         dq->dq_bwarn = MAX_DQ_WARN;
 122: }
 123: #endif

Defined functions

dqp defined in line 25; used 7 times
qstart defined in line 74; used 2 times
qwarn defined in line 81; used 2 times
Last modified: 1993-03-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2538
Valid CSS Valid XHTML 1.0 Strict