Annotation of 42BSD/sys/sys/quota_subr.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.