"Fossies" - the Fresh Open Source Software Archive

Member "usr/include/sys/quota.h" (19 Aug 2019, 8242 Bytes) of package /windows/misc/cygwin-20190819-x86.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /* Copyright (c) 1982, 1986 Regents of the University of California.
    2  * All rights reserved.
    3  *
    4  * This code is derived from software contributed to Berkeley by
    5  * Robert Elz at The University of Melbourne.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 4. Neither the name of the University nor the names of its contributors
   16  *    may be used to endorse or promote products derived from this software
   17  *    without specific prior written permission.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29  * SUCH DAMAGE.
   30  */
   31 
   32 #ifndef _SYS_QUOTA_H
   33 #define _SYS_QUOTA_H 1
   34 
   35 #include <features.h>
   36 #include <sys/types.h>
   37 
   38 /* This file is copied from Linux and kept verbatim, except for the below
   39    Cygwin-specific blocks. */
   40 
   41 #ifdef __CYGWIN__
   42 /* On Linux these defines live in <linux/quota.h>.  Move them here for easier
   43    access. */
   44 /* Quota format type IDs */
   45 #define QFMT_VFS_OLD 1
   46 #define QFMT_VFS_V0 2
   47 #define QFMT_OCFS2 3
   48 #define QFMT_VFS_V1 4
   49 #endif
   50 
   51 /*
   52  * Select between different incompatible quota versions.
   53  * Default to the version used by Linux kernel version 2.4.22
   54  * or later.  */
   55 #ifndef _LINUX_QUOTA_VERSION
   56 # define _LINUX_QUOTA_VERSION 2
   57 #endif
   58 
   59 #if defined (__CYGWIN__) && _LINUX_QUOTA_VERSION != 2
   60 #error Cygwin only supports quota version 2.
   61 #endif
   62 
   63 /*
   64  * Convert diskblocks to blocks and the other way around.
   65  * currently only to fool the BSD source. :-)
   66  */
   67 #define dbtob(num) ((num) << 10)
   68 #define btodb(num) ((num) >> 10)
   69 
   70 /*
   71  * Convert count of filesystem blocks to diskquota blocks, meant
   72  * for filesystems where i_blksize != BLOCK_SIZE
   73  */
   74 #define fs_to_dq_blocks(num, blksize) (((num) * (blksize)) / BLOCK_SIZE)
   75 
   76 /*
   77  * Definitions for disk quotas imposed on the average user
   78  * (big brother finally hits Linux).
   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  604800 /* (7*24*60*60) 1 week */
   86 #define MAX_DQ_TIME  604800 /* (7*24*60*60) 1 week */
   87 
   88 #define MAXQUOTAS 2
   89 #define USRQUOTA  0     /* element used for user quotas */
   90 #define GRPQUOTA  1     /* element used for group quotas */
   91 
   92 /*
   93  * Definitions for the default names of the quotas files.
   94  */
   95 #define INITQFNAMES { \
   96    "user",      /* USRQUOTA */ \
   97    "group",   /* GRPQUOTA */ \
   98    "undefined", \
   99 };
  100 
  101 #define QUOTAFILENAME "quota"
  102 #define QUOTAGROUP "staff"
  103 
  104 #define NR_DQHASH 43          /* Just an arbitrary number any suggestions ? */
  105 #define NR_DQUOTS 256         /* Number of quotas active at one time */
  106 
  107 /*
  108  * Command definitions for the 'quotactl' system call.
  109  * The commands are broken into a main command defined below
  110  * and a subcommand that is used to convey the type of
  111  * quota that is being manipulated (see above).
  112  */
  113 #define SUBCMDMASK  0x00ff
  114 #define SUBCMDSHIFT 8
  115 #define QCMD(cmd, type)  (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
  116 
  117 #if _LINUX_QUOTA_VERSION < 2
  118 # define Q_QUOTAON  0x0100  /* enable quotas */
  119 # define Q_QUOTAOFF 0x0200  /* disable quotas */
  120 # define Q_GETQUOTA 0x0300  /* get limits and usage */
  121 # define Q_SETQUOTA 0x0400  /* set limits and usage */
  122 # define Q_SETUSE   0x0500  /* set usage */
  123 # define Q_SYNC     0x0600  /* sync disk copy of a filesystems quotas */
  124 # define Q_SETQLIM  0x0700  /* set limits */
  125 # define Q_GETSTATS 0x0800  /* get collected stats */
  126 # define Q_RSQUASH  0x1000  /* set root_squash option */
  127 #else
  128 # define Q_SYNC     0x800001    /* sync disk copy of a filesystems quotas */
  129 # define Q_QUOTAON  0x800002    /* turn quotas on */
  130 # define Q_QUOTAOFF 0x800003    /* turn quotas off */
  131 # define Q_GETFMT   0x800004    /* get quota format used on given filesystem */
  132 # define Q_GETINFO  0x800005    /* get information about quota files */
  133 # define Q_SETINFO  0x800006    /* set information about quota files */
  134 # define Q_GETQUOTA 0x800007    /* get user quota structure */
  135 # define Q_SETQUOTA 0x800008    /* set user quota structure */
  136 #endif
  137 
  138 /*
  139  * The following structure defines the format of the disk quota file
  140  * (as it appears on disk) - the file is an array of these structures
  141  * indexed by user or group number.
  142  */
  143 #if _LINUX_QUOTA_VERSION < 2
  144 struct dqblk
  145   {
  146     u_int32_t dqb_bhardlimit;   /* absolute limit on disk blks alloc */
  147     u_int32_t dqb_bsoftlimit;   /* preferred limit on disk blks */
  148     u_int32_t dqb_curblocks;    /* current block count */
  149     u_int32_t dqb_ihardlimit;   /* maximum # allocated inodes */
  150     u_int32_t dqb_isoftlimit;   /* preferred inode limit */
  151     u_int32_t dqb_curinodes;    /* current # allocated inodes */
  152     time_t dqb_btime;       /* time limit for excessive disk use */
  153     time_t dqb_itime;       /* time limit for excessive files */
  154   };
  155 #else
  156 
  157 /* Flags that indicate which fields in dqblk structure are valid.  */
  158 #define QIF_BLIMITS 1
  159 #define QIF_SPACE   2
  160 #define QIF_ILIMITS 4
  161 #define QIF_INODES  8
  162 #define QIF_BTIME   16
  163 #define QIF_ITIME   32
  164 #define QIF_LIMITS  (QIF_BLIMITS | QIF_ILIMITS)
  165 #define QIF_USAGE   (QIF_SPACE | QIF_INODES)
  166 #define QIF_TIMES   (QIF_BTIME | QIF_ITIME)
  167 #define QIF_ALL     (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
  168 
  169 struct dqblk
  170   {
  171     u_int64_t dqb_bhardlimit;   /* absolute limit on disk quota blocks alloc */
  172     u_int64_t dqb_bsoftlimit;   /* preferred limit on disk quota blocks */
  173     u_int64_t dqb_curspace; /* current quota block count */
  174     u_int64_t dqb_ihardlimit;   /* maximum # allocated inodes */
  175     u_int64_t dqb_isoftlimit;   /* preferred inode limit */
  176     u_int64_t dqb_curinodes;    /* current # allocated inodes */
  177     u_int64_t dqb_btime;    /* time limit for excessive disk use */
  178     u_int64_t dqb_itime;    /* time limit for excessive files */
  179     u_int32_t dqb_valid;    /* bitmask of QIF_* constants */
  180   };
  181 #endif
  182 
  183 /*
  184  * Shorthand notation.
  185  */
  186 #define dq_bhardlimit   dq_dqb.dqb_bhardlimit
  187 #define dq_bsoftlimit   dq_dqb.dqb_bsoftlimit
  188 #if _LINUX_QUOTA_VERSION < 2
  189 # define dq_curblocks   dq_dqb.dqb_curblocks
  190 #else
  191 # define dq_curspace    dq_dqb.dqb_curspace
  192 # define dq_valid   dq_dqb.dqb_valid
  193 #endif
  194 #define dq_ihardlimit   dq_dqb.dqb_ihardlimit
  195 #define dq_isoftlimit   dq_dqb.dqb_isoftlimit
  196 #define dq_curinodes    dq_dqb.dqb_curinodes
  197 #define dq_btime    dq_dqb.dqb_btime
  198 #define dq_itime    dq_dqb.dqb_itime
  199 
  200 #define dqoff(UID)      ((loff_t)((UID) * sizeof (struct dqblk)))
  201 
  202 #if _LINUX_QUOTA_VERSION < 2
  203 struct dqstats
  204   {
  205     u_int32_t lookups;
  206     u_int32_t drops;
  207     u_int32_t reads;
  208     u_int32_t writes;
  209     u_int32_t cache_hits;
  210     u_int32_t pages_allocated;
  211     u_int32_t allocated_dquots;
  212     u_int32_t free_dquots;
  213     u_int32_t syncs;
  214   };
  215 #else
  216 
  217 /* Flags that indicate which fields in dqinfo structure are valid.  */
  218 # define IIF_BGRACE 1
  219 # define IIF_IGRACE 2
  220 # define IIF_FLAGS  4
  221 # define IIF_ALL    (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
  222 
  223 struct dqinfo
  224   {
  225     u_int64_t dqi_bgrace;
  226     u_int64_t dqi_igrace;
  227     u_int32_t dqi_flags;
  228     u_int32_t dqi_valid;
  229   };
  230 #endif
  231 
  232 __BEGIN_DECLS
  233 
  234 extern int quotactl (int __cmd, const char *__special, int __id,
  235              caddr_t __addr) __THROW;
  236 
  237 __END_DECLS
  238 
  239 #endif /* sys/quota.h */