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

Defined functions

dqp defined in line 26; used 7 times
qwarn defined in line 85; used 2 times
Last modified: 1986-06-05
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 893
Valid CSS Valid XHTML 1.0 Strict