Back to index

glibc  2.9
quota.h
Go to the documentation of this file.
00001 /* This just represents the non-kernel parts of <linux/quota.h>.
00002  *
00003  * here's the corresponding copyright:
00004  * Copyright (c) 1982, 1986 Regents of the University of California.
00005  * All rights reserved.
00006  *
00007  * This code is derived from software contributed to Berkeley by
00008  * Robert Elz at The University of Melbourne.
00009  *
00010  * Redistribution and use in source and binary forms, with or without
00011  * modification, are permitted provided that the following conditions
00012  * are met:
00013  * 1. Redistributions of source code must retain the above copyright
00014  *    notice, this list of conditions and the following disclaimer.
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in the
00017  *    documentation and/or other materials provided with the distribution.
00018  * 4. Neither the name of the University nor the names of its contributors
00019  *    may be used to endorse or promote products derived from this software
00020  *    without specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00023  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00025  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00026  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00028  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00029  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00031  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00032  * SUCH DAMAGE.
00033  */
00034 
00035 #ifndef _SYS_QUOTA_H
00036 #define _SYS_QUOTA_H 1
00037 
00038 #include <features.h>
00039 #include <sys/types.h>
00040 
00041 /*
00042  * Select between different incompatible quota versions.
00043  * Default to the version used by Linux kernel version 2.4.22
00044  * or later.  */
00045 #ifndef _LINUX_QUOTA_VERSION
00046 # define _LINUX_QUOTA_VERSION 2
00047 #endif
00048 
00049 /*
00050  * Convert diskblocks to blocks and the other way around.
00051  * currently only to fool the BSD source. :-)
00052  */
00053 #define dbtob(num) ((num) << 10)
00054 #define btodb(num) ((num) >> 10)
00055 
00056 /*
00057  * Convert count of filesystem blocks to diskquota blocks, meant
00058  * for filesystems where i_blksize != BLOCK_SIZE
00059  */
00060 #define fs_to_dq_blocks(num, blksize) (((num) * (blksize)) / BLOCK_SIZE)
00061 
00062 /*
00063  * Definitions for disk quotas imposed on the average user
00064  * (big brother finally hits Linux).
00065  *
00066  * The following constants define the amount of time given a user
00067  * before the soft limits are treated as hard limits (usually resulting
00068  * in an allocation failure). The timer is started when the user crosses
00069  * their soft limit, it is reset when they go below their soft limit.
00070  */
00071 #define MAX_IQ_TIME  604800 /* (7*24*60*60) 1 week */
00072 #define MAX_DQ_TIME  604800 /* (7*24*60*60) 1 week */
00073 
00074 #define MAXQUOTAS 2
00075 #define USRQUOTA  0         /* element used for user quotas */
00076 #define GRPQUOTA  1         /* element used for group quotas */
00077 
00078 /*
00079  * Definitions for the default names of the quotas files.
00080  */
00081 #define INITQFNAMES { \
00082    "user",      /* USRQUOTA */ \
00083    "group",   /* GRPQUOTA */ \
00084    "undefined", \
00085 };
00086 
00087 #define QUOTAFILENAME "quota"
00088 #define QUOTAGROUP "staff"
00089 
00090 #define NR_DQHASH 43          /* Just an arbitrary number any suggestions ? */
00091 #define NR_DQUOTS 256         /* Number of quotas active at one time */
00092 
00093 /*
00094  * Command definitions for the 'quotactl' system call.
00095  * The commands are broken into a main command defined below
00096  * and a subcommand that is used to convey the type of
00097  * quota that is being manipulated (see above).
00098  */
00099 #define SUBCMDMASK  0x00ff
00100 #define SUBCMDSHIFT 8
00101 #define QCMD(cmd, type)  (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
00102 
00103 #if _LINUX_QUOTA_VERSION < 2
00104 # define Q_QUOTAON  0x0100  /* enable quotas */
00105 # define Q_QUOTAOFF 0x0200  /* disable quotas */
00106 # define Q_GETQUOTA 0x0300  /* get limits and usage */
00107 # define Q_SETQUOTA 0x0400  /* set limits and usage */
00108 # define Q_SETUSE   0x0500  /* set usage */
00109 # define Q_SYNC     0x0600  /* sync disk copy of a filesystems quotas */
00110 # define Q_SETQLIM  0x0700  /* set limits */
00111 # define Q_GETSTATS 0x0800  /* get collected stats */
00112 # define Q_RSQUASH  0x1000  /* set root_squash option */
00113 #else
00114 # define Q_SYNC     0x800001       /* sync disk copy of a filesystems quotas */
00115 # define Q_QUOTAON  0x800002       /* turn quotas on */
00116 # define Q_QUOTAOFF 0x800003       /* turn quotas off */
00117 # define Q_GETFMT   0x800004       /* get quota format used on given filesystem */
00118 # define Q_GETINFO  0x800005       /* get information about quota files */
00119 # define Q_SETINFO  0x800006       /* set information about quota files */
00120 # define Q_GETQUOTA 0x800007       /* get user quota structure */
00121 # define Q_SETQUOTA 0x800008       /* set user quota structure */
00122 #endif
00123 
00124 /*
00125  * The following structure defines the format of the disk quota file
00126  * (as it appears on disk) - the file is an array of these structures
00127  * indexed by user or group number.
00128  */
00129 #if _LINUX_QUOTA_VERSION < 2
00130 struct dqblk
00131   {
00132     u_int32_t dqb_bhardlimit;      /* absolute limit on disk blks alloc */
00133     u_int32_t dqb_bsoftlimit;      /* preferred limit on disk blks */
00134     u_int32_t dqb_curblocks;       /* current block count */
00135     u_int32_t dqb_ihardlimit;      /* maximum # allocated inodes */
00136     u_int32_t dqb_isoftlimit;      /* preferred inode limit */
00137     u_int32_t dqb_curinodes;       /* current # allocated inodes */
00138     time_t dqb_btime;              /* time limit for excessive disk use */
00139     time_t dqb_itime;              /* time limit for excessive files */
00140   };
00141 #else
00142 
00143 /* Flags that indicate which fields in dqblk structure are valid.  */
00144 #define QIF_BLIMITS  1
00145 #define QIF_SPACE    2
00146 #define QIF_ILIMITS  4
00147 #define QIF_INODES   8
00148 #define QIF_BTIME    16
00149 #define QIF_ITIME    32
00150 #define QIF_LIMITS   (QIF_BLIMITS | QIF_ILIMITS)
00151 #define QIF_USAGE    (QIF_SPACE | QIF_INODES)
00152 #define QIF_TIMES    (QIF_BTIME | QIF_ITIME)
00153 #define QIF_ALL             (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
00154 
00155 struct dqblk
00156   {
00157     u_int64_t dqb_bhardlimit;      /* absolute limit on disk quota blocks alloc */
00158     u_int64_t dqb_bsoftlimit;      /* preferred limit on disk quota blocks */
00159     u_int64_t dqb_curspace; /* current quota block count */
00160     u_int64_t dqb_ihardlimit;      /* maximum # allocated inodes */
00161     u_int64_t dqb_isoftlimit;      /* preferred inode limit */
00162     u_int64_t dqb_curinodes;       /* current # allocated inodes */
00163     u_int64_t dqb_btime;    /* time limit for excessive disk use */
00164     u_int64_t dqb_itime;    /* time limit for excessive files */
00165     u_int32_t dqb_valid;    /* bitmask of QIF_* constants */
00166   };
00167 #endif
00168 
00169 /*
00170  * Shorthand notation.
00171  */
00172 #define       dq_bhardlimit dq_dqb.dqb_bhardlimit
00173 #define       dq_bsoftlimit dq_dqb.dqb_bsoftlimit
00174 #if _LINUX_QUOTA_VERSION < 2
00175 # define dq_curblocks       dq_dqb.dqb_curblocks
00176 #else
00177 # define dq_curspace dq_dqb.dqb_curspace
00178 # define dq_valid    dq_dqb.dqb_valid
00179 #endif
00180 #define       dq_ihardlimit dq_dqb.dqb_ihardlimit
00181 #define       dq_isoftlimit dq_dqb.dqb_isoftlimit
00182 #define       dq_curinodes  dq_dqb.dqb_curinodes
00183 #define       dq_btime      dq_dqb.dqb_btime
00184 #define       dq_itime      dq_dqb.dqb_itime
00185 
00186 #define dqoff(UID)      ((loff_t)((UID) * sizeof (struct dqblk)))
00187 
00188 #if _LINUX_QUOTA_VERSION < 2
00189 struct dqstats
00190   {
00191     u_int32_t lookups;
00192     u_int32_t drops;
00193     u_int32_t reads;
00194     u_int32_t writes;
00195     u_int32_t cache_hits;
00196     u_int32_t pages_allocated;
00197     u_int32_t allocated_dquots;
00198     u_int32_t free_dquots;
00199     u_int32_t syncs;
00200   };
00201 #else
00202 
00203 /* Flags that indicate which fields in dqinfo structure are valid.  */
00204 # define IIF_BGRACE  1
00205 # define IIF_IGRACE  2
00206 # define IIF_FLAGS   4
00207 # define IIF_ALL     (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
00208 
00209 struct dqinfo
00210   {
00211     u_int64_t dqi_bgrace;
00212     u_int64_t dqi_igrace;
00213     u_int32_t dqi_flags;
00214     u_int32_t dqi_valid;
00215   };
00216 #endif
00217 
00218 __BEGIN_DECLS
00219 
00220 extern int quotactl (int __cmd, const char *__special, int __id,
00221                    caddr_t __addr) __THROW;
00222 
00223 __END_DECLS
00224 
00225 #endif /* sys/quota.h */