home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Headers / bsd / sys / quota.h < prev    next >
Text File  |  1993-10-19  |  6KB  |  189 lines

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