home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / bsdss4.tz / bsdss4 / bsdss / server / ufs / quota.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-22  |  7.8 KB  |  217 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1992 Carnegie Mellon University
  4.  * All Rights Reserved.
  5.  * 
  6.  * Permission to use, copy, modify and distribute this software and its
  7.  * documentation is hereby granted, provided that both the copyright
  8.  * notice and this permission notice appear in all copies of the
  9.  * software, derivative works or modified versions, and any portions
  10.  * thereof, and that both notices appear in supporting documentation.
  11.  * 
  12.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15.  * 
  16.  * Carnegie Mellon requests users of this software to return to
  17.  * 
  18.  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  19.  *  School of Computer Science
  20.  *  Carnegie Mellon University
  21.  *  Pittsburgh PA 15213-3890
  22.  * 
  23.  * any improvements or extensions that they make and grant Carnegie Mellon 
  24.  * the rights to redistribute these changes.
  25.  */
  26. /*
  27.  * HISTORY
  28.  * $Log:    quota.h,v $
  29.  * Revision 2.1  92/04/21  17:18:24  rwd
  30.  * BSDSS
  31.  * 
  32.  *
  33.  */
  34.  
  35. /*
  36.  * Copyright (c) 1982, 1986 Regents of the University of California.
  37.  * All rights reserved.
  38.  *
  39.  * This code is derived from software contributed to Berkeley by
  40.  * Robert Elz at The University of Melbourne.
  41.  *
  42.  * Redistribution and use in source and binary forms, with or without
  43.  * modification, are permitted provided that the following conditions
  44.  * are met:
  45.  * 1. Redistributions of source code must retain the above copyright
  46.  *    notice, this list of conditions and the following disclaimer.
  47.  * 2. Redistributions in binary form must reproduce the above copyright
  48.  *    notice, this list of conditions and the following disclaimer in the
  49.  *    documentation and/or other materials provided with the distribution.
  50.  * 3. All advertising materials mentioning features or use of this software
  51.  *    must display the following acknowledgement:
  52.  *    This product includes software developed by the University of
  53.  *    California, Berkeley and its contributors.
  54.  * 4. Neither the name of the University nor the names of its contributors
  55.  *    may be used to endorse or promote products derived from this software
  56.  *    without specific prior written permission.
  57.  *
  58.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  59.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  60.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  61.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  62.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  63.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  64.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  65.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  66.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  67.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  68.  * SUCH DAMAGE.
  69.  *
  70.  *    @(#)quota.h    7.9 (Berkeley) 2/22/91
  71.  */
  72.  
  73. #ifndef _QUOTA_
  74. #define _QUOTA_
  75.  
  76. /*
  77.  * Definitions for disk quotas imposed on the average user
  78.  * (big brother finally hits UNIX).
  79.  *
  80.  * The following constants define the amount of time given a user
  81.  * before the soft limits are treated as hard limits (usually resulting
  82.  * in an allocation failure). The timer is started when the user crosses
  83.  * their soft limit, it is reset when they go below their soft limit.
  84.  */
  85. #define    MAX_IQ_TIME    (7*24*60*60)    /* 1 week */
  86. #define    MAX_DQ_TIME    (7*24*60*60)    /* 1 week */
  87.  
  88. /*
  89.  * The following constants define the usage of the quota file array
  90.  * in the ufsmount structure and dquot array in the inode structure.
  91.  * The semantics of the elements of these arrays are defined in the
  92.  * routine getinoquota; the remainder of the quota code treats them
  93.  * generically and need not be inspected when changing the size of
  94.  * the array.
  95.  */
  96. #define    MAXQUOTAS    2
  97. #define    USRQUOTA    0    /* element used for user quotas */
  98. #define    GRPQUOTA    1    /* element used for group quotas */
  99.  
  100. /*
  101.  * Definitions for the default names of the quotas files.
  102.  */
  103. #define INITQFNAMES { \
  104.     "user",        /* USRQUOTA */ \
  105.     "group",    /* GRPQUOTA */ \
  106.     "undefined", \
  107. };
  108. #define QUOTAFILENAME "quota"
  109. #define QUOTAGROUP "operator"
  110.  
  111. /*
  112.  * Command definitions for the 'quotactl' system call.
  113.  * The commands are broken into a main command defined below
  114.  * and a subcommand that is used to convey the type of
  115.  * quota that is being manipulated (see above).
  116.  */
  117. #define SUBCMDMASK    0x00ff
  118. #define SUBCMDSHIFT    8
  119. #define    QCMD(cmd, type)    (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
  120.  
  121. #define    Q_QUOTAON    0x0100    /* enable quotas */
  122. #define    Q_QUOTAOFF    0x0200    /* disable quotas */
  123. #define    Q_GETQUOTA    0x0300    /* get limits and usage */
  124. #define    Q_SETQUOTA    0x0400    /* set limits and usage */
  125. #define    Q_SETUSE    0x0500    /* set usage */
  126. #define    Q_SYNC        0x0600    /* sync disk copy of a filesystems quotas */
  127.  
  128. /*
  129.  * The following structure defines the format of the disk quota file
  130.  * (as it appears on disk) - the file is an array of these structures
  131.  * indexed by user or group number.  The setquota system call establishes
  132.  * the vnode for each quota file (a pointer is retained in the ufsmount
  133.  * structure).
  134.  */
  135. struct    dqblk {
  136.     u_long    dqb_bhardlimit;    /* absolute limit on disk blks alloc */
  137.     u_long    dqb_bsoftlimit;    /* preferred limit on disk blks */
  138.     u_long    dqb_curblocks;    /* current block count */
  139.     u_long    dqb_ihardlimit;    /* maximum # allocated inodes + 1 */
  140.     u_long    dqb_isoftlimit;    /* preferred inode limit */
  141.     u_long    dqb_curinodes;    /* current # allocated inodes */
  142.     time_t    dqb_btime;    /* time limit for excessive disk use */
  143.     time_t    dqb_itime;    /* time limit for excessive files */
  144. };
  145.  
  146. #ifdef KERNEL
  147. /*
  148.  * The following structure records disk usage for a user or group on a
  149.  * filesystem. There is one allocated for each quota that exists on any
  150.  * filesystem for the current user or group. A cache is kept of recently
  151.  * used entries.
  152.  */
  153. struct    dquot {
  154.     struct    dquot *dq_forw, *dq_back;/* MUST be first entry */
  155.     struct    dquot *dq_freef, **dq_freeb; /* free list */
  156.     short    dq_flags;        /* flags, see below */
  157.     short    dq_cnt;            /* count of active references */
  158.     short    dq_spare;        /* unused spare padding */
  159.     short    dq_type;        /* quota type of this dquot */
  160.     u_long    dq_id;            /* identifier this applies to */
  161.     struct    ufsmount *dq_ump;    /* filesystem that this is taken from */
  162.     struct    dqblk dq_dqb;        /* actual usage & quotas */
  163. };
  164. /*
  165.  * Flag values.
  166.  */
  167. #define    DQ_LOCK        0x01        /* this quota locked (no MODS) */
  168. #define    DQ_WANT        0x02        /* wakeup on unlock */
  169. #define    DQ_MOD        0x04        /* this quota modified since read */
  170. #define    DQ_FAKE        0x08        /* no limits here, just usage */
  171. #define    DQ_BLKS        0x10        /* has been warned about blk limit */
  172. #define    DQ_INODS    0x20        /* has been warned about inode limit */
  173. /*
  174.  * Shorthand notation.
  175.  */
  176. #define    dq_bhardlimit    dq_dqb.dqb_bhardlimit
  177. #define    dq_bsoftlimit    dq_dqb.dqb_bsoftlimit
  178. #define    dq_curblocks    dq_dqb.dqb_curblocks
  179. #define    dq_ihardlimit    dq_dqb.dqb_ihardlimit
  180. #define    dq_isoftlimit    dq_dqb.dqb_isoftlimit
  181. #define    dq_curinodes    dq_dqb.dqb_curinodes
  182. #define    dq_btime    dq_dqb.dqb_btime
  183. #define    dq_itime    dq_dqb.dqb_itime
  184.  
  185. /*
  186.  * If the system has never checked for a quota for this file,
  187.  * then it is set to NODQUOT. Once a write attempt is made
  188.  * the inode pointer is set to reference a dquot structure.
  189.  */
  190. #define    NODQUOT        ((struct dquot *) 0)
  191.  
  192. /*
  193.  * Flags to chkdq() and chkiq()
  194.  */
  195. #define    FORCE    0x01    /* force usage changes independent of limits */
  196. #define    CHOWN    0x02    /* (advisory) change initiated by chown */
  197.  
  198. /*
  199.  * Macros to avoid subroutine calls to trivial functions.
  200.  */
  201. #if !DIAGNOSTIC
  202. #define    DQREF(dq)    (dq)->dq_cnt++
  203. #else
  204. #define    DQREF(dq)    dqref(dq)
  205. #endif /* DIAGNOSTIC */
  206.  
  207. #else
  208.  
  209. #include <sys/cdefs.h>
  210.  
  211. __BEGIN_DECLS
  212. int    quotactl __P((const char *, int, int, void *));
  213. __END_DECLS
  214.  
  215. #endif /* KERNEL */
  216. #endif /* _QUOTA_ */
  217.