home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilss / sockets / include / sys / h / quota < prev    next >
Encoding:
Text File  |  1995-01-11  |  5.6 KB  |  170 lines

  1. /*
  2.  * $Header: /ax/networking:include/sys/quota.h:networking  1.1  $
  3.  * $Source: /ax/networking:include/sys/quota.h: $
  4.  *
  5.  * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
  6.  *
  7.  * $Log:    quota.h,v $
  8.  * Revision 1.1  95/01/11  10:19:37  kwelton
  9.  * Initial revision
  10.  * 
  11.  * Revision 1.3  88/06/17  20:20:35  beta
  12.  * Acorn Unix initial beta version
  13.  * 
  14.  */
  15. /* @(#)quota.h    1.2 87/05/15 3.2/4.3NFSSRC */
  16. /*
  17.  * Copyright (c) 1982, 1986 Regents of the University of California.
  18.  * All rights reserved.  The Berkeley software License Agreement
  19.  * specifies the terms and conditions for redistribution.
  20.  *
  21.  *    @(#)quota.h    7.1 (Berkeley) 6/4/86
  22.  */
  23.  
  24. /*
  25.  * MELBOURNE DISC QUOTAS
  26.  *
  27.  * Various junk to do with various quotas (etc) imposed upon
  28.  * the average user (big brother finally hits UNIX).
  29.  *
  30.  * The following structure exists in core for each logged on user.
  31.  * It contains global junk relevant to that user's quotas.
  32.  *
  33.  * The u_quota field of each user struct contains a pointer to
  34.  * the quota struct relevant to the current process, this is changed
  35.  * by 'setuid' sys call, &/or by the Q_SETUID quota() call.
  36.  */
  37. struct quota {
  38.     struct    quota *q_forw, *q_back;    /* hash chain, MUST be first */
  39.     short    q_cnt;            /* ref count (# processes) */
  40.     uid_t    q_uid;            /* real uid of owner */
  41.     int    q_flags;        /* struct management flags */
  42. #define    Q_LOCK    0x01        /* quota struct locked (for disc i/o) */
  43. #define    Q_WANT    0x02        /* issue a wakeup when lock goes off */
  44. #define    Q_NEW    0x04        /* new quota - no proc1 msg sent yet */
  45. #define    Q_NDQ    0x08        /* account has NO disc quota */
  46.     struct    quota *q_freef, **q_freeb;
  47.     struct    dquot *q_dq[NMOUNT];    /* disc quotas for mounted filesys's */
  48. };
  49.  
  50. #define    NOQUOTA    ((struct quota *) 0)
  51.  
  52. #if defined(KERNEL) && defined(QUOTA)
  53. #ifdef    DYNALLOC
  54. struct    quota *quota, *quotaNQUOTA;
  55. #else    DYNALLOC
  56. struct    quota stat_quota[NQUOTA], *quota, *quotaNQUOTA;
  57. #endif    DYNALLOC
  58. int    nquota;
  59. struct    quota *getquota(), *qfind();
  60. #endif
  61.  
  62. /*
  63.  * The following structure defines the format of the disc quota file
  64.  * (as it appears on disc) - the file is an array of these structures
  65.  * indexed by user number.  The setquota sys call establishes the inode
  66.  * for each quota file (a pointer is retained in the mount structure).
  67.  *
  68.  * The following constants define the number of warnings given a user
  69.  * before the soft limits are treated as hard limits (usually resulting
  70.  * in an allocation failure).  The warnings are normally manipulated
  71.  * each time a user logs in through the Q_DOWARN quota call.  If
  72.  * the user logs in and is under the soft limit the warning count
  73.  * is reset to MAX_*_WARN, otherwise a message is printed and the
  74.  * warning count is decremented.  This makes MAX_*_WARN equivalent to
  75.  * the number of logins before soft limits are treated as hard limits.
  76.  */
  77. #define    MAX_IQ_WARN    3
  78. #define    MAX_DQ_WARN    3
  79.  
  80. struct    dqblk {
  81.     u_long    dqb_bhardlimit;    /* absolute limit on disc blks alloc */
  82.     u_long    dqb_bsoftlimit;    /* preferred limit on disc blks */
  83.     u_long    dqb_curblocks;    /* current block count */
  84.     u_short    dqb_ihardlimit;    /* maximum # allocated inodes + 1 */
  85.     u_short    dqb_isoftlimit;    /* preferred inode limit */
  86.     u_short    dqb_curinodes;    /* current # allocated inodes */
  87.     u_char    dqb_bwarn;    /* # warnings left about excessive disc use */
  88.     u_char    dqb_iwarn;    /* # warnings left about excessive inodes */
  89. };
  90.  
  91. /*
  92.  * The following structure records disc usage for a user on a filesystem.
  93.  * There is one allocated for each quota that exists on any filesystem
  94.  * for the current user. A cache is kept of other recently used entries.
  95.  */
  96. struct    dquot {
  97.     struct    dquot *dq_forw, *dq_back;/* MUST be first entry */
  98.     union    {
  99.         struct    quota *Dq_own;    /* the quota that points to this */
  100.         struct {        /* free list */
  101.             struct    dquot *Dq_freef, **Dq_freeb;
  102.         } dq_f;
  103.     } dq_u;
  104.     short    dq_flags;
  105. #define    DQ_LOCK        0x01        /* this quota locked (no MODS) */
  106. #define    DQ_WANT        0x02        /* wakeup on unlock */
  107. #define    DQ_MOD        0x04        /* this quota modified since read */
  108. #define    DQ_FAKE        0x08        /* no limits here, just usage */
  109. #define    DQ_BLKS        0x10        /* has been warned about blk limit */
  110. #define    DQ_INODS    0x20        /* has been warned about inode limit */
  111.     short    dq_cnt;            /* count of active references */
  112.     uid_t    dq_uid;            /* user this applies to */
  113.     dev_t    dq_dev;            /* filesystem this relates to */
  114.     struct dqblk dq_dqb;        /* actual usage & quotas */
  115. };
  116.  
  117. #define    dq_own        dq_u.Dq_own
  118. #define    dq_freef    dq_u.dq_f.Dq_freef
  119. #define    dq_freeb    dq_u.dq_f.Dq_freeb
  120. #define    dq_bhardlimit    dq_dqb.dqb_bhardlimit
  121. #define    dq_bsoftlimit    dq_dqb.dqb_bsoftlimit
  122. #define    dq_curblocks    dq_dqb.dqb_curblocks
  123. #define    dq_ihardlimit    dq_dqb.dqb_ihardlimit
  124. #define    dq_isoftlimit    dq_dqb.dqb_isoftlimit
  125. #define    dq_curinodes    dq_dqb.dqb_curinodes
  126. #define    dq_bwarn    dq_dqb.dqb_bwarn
  127. #define    dq_iwarn    dq_dqb.dqb_iwarn
  128.  
  129. #define    NODQUOT        ((struct dquot *) 0)
  130. #define    LOSTDQUOT    ((struct dquot *) 1)
  131.  
  132. #if defined(KERNEL) && defined(QUOTA)
  133. #ifdef    DYNALLOC
  134. struct    dquot *dquot, *dquotNDQUOT;
  135. #else    DYNALLOC
  136. struct    dquot stat_dquot[NDQUOT], *dquot, *dquotNDQUOT;
  137. #endif    DYNALLOC
  138. int    ndquot;
  139. struct    dquot *discquota(), *inoquota(), *dqalloc(), *dqp();
  140. #endif
  141.  
  142. /*
  143.  * Definitions for the 'quota' system call.
  144.  */
  145. #define    Q_SETDLIM    1    /* set disc limits & usage */
  146. #define    Q_GETDLIM    2    /* get disc limits & usage */
  147. #define    Q_SETDUSE    3    /* set disc usage only */
  148. #define    Q_SYNC        4    /* update disc copy of quota usages */
  149. #define    Q_SETUID    16    /* change proc to use quotas for uid */
  150. #define    Q_SETWARN    25    /* alter inode/block warning counts */
  151. #define    Q_DOWARN    26    /* warn user about excessive space/inodes */
  152.  
  153. /*
  154.  * Used in Q_SETDUSE.
  155.  */
  156. struct    dqusage {
  157.     u_short    du_curinodes;
  158.     u_long    du_curblocks;
  159. };
  160.  
  161. /*
  162.  * Used in Q_SETWARN.
  163.  */
  164. struct    dqwarn {
  165.     u_char    dw_bwarn;
  166.     u_char    dw_iwarn;
  167. };
  168.  
  169. /* EOF quota.h */
  170.