include/samba_linux_quota.h

説明を見る。
00001 #ifndef _SAMBA_LINUX_QUOTA_H_
00002 #define _SAMBA_LINUX_QUOTA_H_
00003 /*
00004    Unix SMB/CIFS implementation.
00005    Copyright (C) Andrew Tridgell 1994-2002
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program; if not, write to the Free Software
00019    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 */
00021 
00022 /*
00023         This file is needed because Quota support on Linux has
00024         been broken since Linus kernel 2.4.x. It will only get
00025         better (and this file be removed) when all the distributions
00026         ship a glibc with a working quota.h file. This is very
00027         bad. JRA.
00028 
00029         Original file came from Christoph Hellwig <hch@infradead.org>.
00030         Massaged into one nasty include file (to stop us having to
00031         add multiple files into Samba just for Linux braindamage)
00032         by JRA.
00033 */
00034 
00035 #undef QUOTABLOCK_SIZE
00036 
00037 #ifndef _QUOTAIO_LINUX_V1
00038 #define _QUOTAIO_LINUX_V1
00039 
00040 /*
00041  *      Headerfile for old quotafile format
00042  */
00043 
00044 #include <sys/types.h>
00045 
00046 #define V1_DQBLK_SIZE_BITS 10
00047 #define V1_DQBLK_SIZE (1 << V1_DQBLK_SIZE_BITS) /* Size of one quota block in bytes in old format */
00048 
00049 #define V1_DQOFF(__id) ((loff_t) ((__id) * sizeof(struct v1_disk_dqblk)))
00050 
00051 /* Structure of quota on disk */
00052 struct v1_disk_dqblk {
00053         u_int32_t dqb_bhardlimit;       /* absolute limit on disk blks alloc */
00054         u_int32_t dqb_bsoftlimit;       /* preferred limit on disk blks */
00055         u_int32_t dqb_curblocks;        /* current block count */
00056         u_int32_t dqb_ihardlimit;       /* maximum # allocated inodes */
00057         u_int32_t dqb_isoftlimit;       /* preferred limit on inodes */
00058         u_int32_t dqb_curinodes;        /* current # allocated inodes */
00059         time_t dqb_btime;       /* time limit for excessive disk use */
00060         time_t dqb_itime;       /* time limit for excessive files */
00061 } __attribute__ ((packed));
00062 
00063 /* Structure used for communication with kernel */
00064 struct v1_kern_dqblk {
00065         u_int32_t dqb_bhardlimit;       /* absolute limit on disk blks alloc */
00066         u_int32_t dqb_bsoftlimit;       /* preferred limit on disk blks */
00067         u_int32_t dqb_curblocks;        /* current block count */
00068         u_int32_t dqb_ihardlimit;       /* maximum # allocated inodes */
00069         u_int32_t dqb_isoftlimit;       /* preferred inode limit */
00070         u_int32_t dqb_curinodes;        /* current # allocated inodes */
00071         time_t dqb_btime;       /* time limit for excessive disk use */
00072         time_t dqb_itime;       /* time limit for excessive files */
00073 };
00074 
00075 struct v1_dqstats {
00076         u_int32_t lookups;
00077         u_int32_t drops;
00078         u_int32_t reads;
00079         u_int32_t writes;
00080         u_int32_t cache_hits;
00081         u_int32_t allocated_dquots;
00082         u_int32_t free_dquots;
00083         u_int32_t syncs;
00084 };                                                                               
00085 
00086 #ifndef Q_V1_GETQUOTA
00087 #define Q_V1_GETQUOTA  0x300
00088 #endif
00089 #ifndef Q_V1_SETQUOTA
00090 #define Q_V1_SETQUOTA  0x400
00091 #endif
00092 
00093 #endif /* _QUOTAIO_LINUX_V1 */
00094 
00095 /*
00096  *
00097  *      Header file for disk format of new quotafile format
00098  *
00099  */
00100 
00101 #ifndef _QUOTAIO_LINUX_V2
00102 #define _QUOTAIO_LINUX_V2
00103 
00104 #include <sys/types.h>
00105 
00106 #ifndef _QUOTA_LINUX
00107 #define _QUOTA_LINUX
00108 
00109 #include <sys/types.h>
00110 
00111 typedef u_int32_t qid_t;        /* Type in which we store ids in memory */
00112 typedef u_int64_t qsize_t;      /* Type in which we store size limitations */
00113 
00114 #define MAXQUOTAS 2
00115 #define USRQUOTA  0             /* element used for user quotas */
00116 #define GRPQUOTA  1             /* element used for group quotas */
00117 
00118 /*
00119  * Definitions for the default names of the quotas files.
00120  */
00121 #define INITQFNAMES { \
00122         "user",    /* USRQUOTA */ \
00123         "group",   /* GRPQUOTA */ \
00124         "undefined", \
00125 }
00126 
00127 /*
00128  * Definitions of magics and versions of current quota files
00129  */
00130 #define INITQMAGICS {\
00131         0xd9c01f11,     /* USRQUOTA */\
00132         0xd9c01927      /* GRPQUOTA */\
00133 }
00134 
00135 /* Size of blocks in which are counted size limits in generic utility parts */
00136 #define QUOTABLOCK_BITS 10
00137 #define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
00138 
00139 /* Conversion routines from and to quota blocks */
00140 #define qb2kb(x) ((x) << (QUOTABLOCK_BITS-10))
00141 #define kb2qb(x) ((x) >> (QUOTABLOCK_BITS-10))
00142 #define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS)
00143 
00144 /*
00145  * Command definitions for the 'quotactl' system call.
00146  * The commands are broken into a main command defined below
00147  * and a subcommand that is used to convey the type of
00148  * quota that is being manipulated (see above).
00149  */
00150 #define SUBCMDMASK  0x00ff
00151 #define SUBCMDSHIFT 8
00152 #define QCMD(cmd, type)  (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
00153 
00154 #define Q_6_5_QUOTAON  0x0100   /* enable quotas */
00155 #define Q_6_5_QUOTAOFF 0x0200   /* disable quotas */
00156 #define Q_6_5_SYNC     0x0600   /* sync disk copy of a filesystems quotas */
00157 
00158 #define Q_SYNC     0x800001     /* sync disk copy of a filesystems quotas */
00159 #define Q_QUOTAON  0x800002     /* turn quotas on */
00160 #define Q_QUOTAOFF 0x800003     /* turn quotas off */
00161 #define Q_GETFMT   0x800004     /* get quota format used on given filesystem */
00162 #define Q_GETINFO  0x800005     /* get information about quota files */
00163 #define Q_SETINFO  0x800006     /* set information about quota files */
00164 #define Q_GETQUOTA 0x800007     /* get user quota structure */
00165 #define Q_SETQUOTA 0x800008     /* set user quota structure */
00166 
00167 /*
00168  * Quota structure used for communication with userspace via quotactl
00169  * Following flags are used to specify which fields are valid
00170  */
00171 #define QIF_BLIMITS     1
00172 #define QIF_SPACE       2
00173 #define QIF_ILIMITS     4
00174 #define QIF_INODES      8
00175 #define QIF_BTIME       16
00176 #define QIF_ITIME       32
00177 #define QIF_LIMITS      (QIF_BLIMITS | QIF_ILIMITS)
00178 #define QIF_USAGE       (QIF_SPACE | QIF_INODES)
00179 #define QIF_TIMES       (QIF_BTIME | QIF_ITIME)
00180 #define QIF_ALL         (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
00181 
00182 struct if_dqblk {
00183         u_int64_t dqb_bhardlimit;
00184         u_int64_t dqb_bsoftlimit;
00185         u_int64_t dqb_curspace;
00186         u_int64_t dqb_ihardlimit;
00187         u_int64_t dqb_isoftlimit;
00188         u_int64_t dqb_curinodes;
00189         u_int64_t dqb_btime;
00190         u_int64_t dqb_itime;
00191         u_int32_t dqb_valid;
00192 };
00193 
00194 /*
00195  * Structure used for setting quota information about file via quotactl
00196  * Following flags are used to specify which fields are valid
00197  */
00198 #define IIF_BGRACE      1
00199 #define IIF_IGRACE      2
00200 #define IIF_FLAGS       4
00201 #define IIF_ALL         (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
00202 
00203 struct if_dqinfo {
00204         u_int64_t dqi_bgrace;
00205         u_int64_t dqi_igrace;
00206         u_int32_t dqi_flags;
00207         u_int32_t dqi_valid;
00208 };
00209 
00210 /* Quota format identifiers */
00211 #define QFMT_VFS_OLD 1
00212 #define QFMT_VFS_V0  2
00213 
00214 /* Flags supported by kernel */
00215 #define V1_DQF_RSQUASH 1
00216 
00217 /* Ioctl for getting quota size */
00218 #include <sys/ioctl.h>
00219 #ifndef FIOQSIZE
00220         #if defined(__alpha__) || defined(__powerpc__) || defined(__sh__) || defined(__sparc__) || defined(__sparc64__)
00221                 #define FIOQSIZE _IOR('f', 128, loff_t)
00222         #elif defined(__arm__) || defined(__mc68000__) || defined(__s390__)
00223                 #define FIOQSIZE 0x545E
00224         #elif defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__ia64__) || defined(__parisc__) || defined(__cris__) || defined(__hppa__)
00225                 #define FIOQSIZE 0x5460
00226         #elif defined(__mips__) || defined(__mips64__)
00227                 #define FIOQSIZE 0x6667
00228         #endif
00229 #endif
00230 
00231 long quotactl __P((int, const char *, qid_t, caddr_t));
00232 
00233 #endif /* _QUOTA_LINUX */
00234 
00235 #define V2_DQINFOOFF    sizeof(struct v2_disk_dqheader) /* Offset of info header in file */
00236 #define V2_DQBLKSIZE_BITS       10
00237 #define V2_DQBLKSIZE    (1 << V2_DQBLKSIZE_BITS)        /* Size of block with quota structures */
00238 #define V2_DQTREEOFF    1       /* Offset of tree in file in blOcks */
00239 #define V2_DQTREEDEPTH  4       /* Depth of quota tree */
00240 #define V2_DQSTRINBLK   ((V2_DQBLKSIZE - sizeof(struct v2_disk_dqdbheader)) / sizeof(struct v2_disk_dqblk))     /* Number of entries in one blocks */
00241 #define V2_GETIDINDEX(id, depth) (((id) >> ((V2_DQTREEDEPTH-(depth)-1)*8)) & 0xff)
00242 #define V2_GETENTRIES(buf) ((struct v2_disk_dqblk *)(((char *)(buf)) + sizeof(struct v2_disk_dqdbheader)))
00243 #define INIT_V2_VERSIONS { 0, 0}
00244 
00245 struct v2_disk_dqheader {
00246         u_int32_t dqh_magic;    /* Magic number identifying file */
00247         u_int32_t dqh_version;  /* File version */
00248 } __attribute__ ((packed));
00249 
00250 /* Flags for version specific files */
00251 #define V2_DQF_MASK  0x0000     /* Mask for all valid ondisk flags */
00252 
00253 /* Header with type and version specific information */
00254 struct v2_disk_dqinfo {
00255         u_int32_t dqi_bgrace;   /* Time before block soft limit becomes hard limit */
00256         u_int32_t dqi_igrace;   /* Time before inode soft limit becomes hard limit */
00257         u_int32_t dqi_flags;    /* Flags for quotafile (DQF_*) */
00258         u_int32_t dqi_blocks;   /* Number of blocks in file */
00259         u_int32_t dqi_free_blk; /* Number of first free block in the list */
00260         u_int32_t dqi_free_entry;       /* Number of block with at least one free entry */
00261 } __attribute__ ((packed));
00262 
00263 /*
00264  *  Structure of header of block with quota structures. It is padded to 16 bytes so
00265  *  there will be space for exactly 18 quota-entries in a block
00266  */
00267 struct v2_disk_dqdbheader {
00268         u_int32_t dqdh_next_free;       /* Number of next block with free entry */
00269         u_int32_t dqdh_prev_free;       /* Number of previous block with free entry */
00270         u_int16_t dqdh_entries; /* Number of valid entries in block */
00271         u_int16_t dqdh_pad1;
00272         u_int32_t dqdh_pad2;
00273 } __attribute__ ((packed));
00274 
00275 /* Structure of quota for one user on disk */
00276 struct v2_disk_dqblk {
00277         u_int32_t dqb_id;       /* id this quota applies to */
00278         u_int32_t dqb_ihardlimit;       /* absolute limit on allocated inodes */
00279         u_int32_t dqb_isoftlimit;       /* preferred inode limit */
00280         u_int32_t dqb_curinodes;        /* current # allocated inodes */
00281         u_int32_t dqb_bhardlimit;       /* absolute limit on disk space (in QUOTABLOCK_SIZE) */
00282         u_int32_t dqb_bsoftlimit;       /* preferred limit on disk space (in QUOTABLOCK_SIZE) */
00283         u_int64_t dqb_curspace; /* current space occupied (in bytes) */
00284         u_int64_t dqb_btime;    /* time limit for excessive disk use */
00285         u_int64_t dqb_itime;    /* time limit for excessive inode use */
00286 } __attribute__ ((packed));
00287 
00288 /* Structure of quota for communication with kernel */
00289 struct v2_kern_dqblk {
00290         unsigned int dqb_ihardlimit;
00291         unsigned int dqb_isoftlimit;
00292         unsigned int dqb_curinodes;
00293         unsigned int dqb_bhardlimit;
00294         unsigned int dqb_bsoftlimit;
00295         qsize_t dqb_curspace;
00296         time_t dqb_btime;
00297         time_t dqb_itime;
00298 };
00299 
00300 /* Structure of quotafile info for communication with kernel */
00301 struct v2_kern_dqinfo {
00302         unsigned int dqi_bgrace;
00303         unsigned int dqi_igrace;
00304         unsigned int dqi_flags;
00305         unsigned int dqi_blocks;
00306         unsigned int dqi_free_blk;
00307         unsigned int dqi_free_entry;
00308 };
00309 
00310 /* Structure with gathered statistics from kernel */
00311 struct v2_dqstats {
00312         u_int32_t lookups;
00313         u_int32_t drops;
00314         u_int32_t reads;
00315         u_int32_t writes;
00316         u_int32_t cache_hits;
00317         u_int32_t allocated_dquots;
00318         u_int32_t free_dquots;
00319         u_int32_t syncs;
00320         u_int32_t version;
00321 };
00322 
00323 #ifndef Q_V2_GETQUOTA
00324 #define Q_V2_GETQUOTA  0x0D00
00325 #endif
00326 #ifndef Q_V2_SETQUOTA
00327 #define Q_V2_SETQUOTA  0x0E00
00328 #endif
00329 
00330 #endif /* _QUOTAIO_LINUX_V2 */
00331 
00332 #ifndef QUOTABLOCK_SIZE
00333 #define QUOTABLOCK_SIZE        1024
00334 #endif
00335 
00336 #endif /* _SAMBA_LINUX_QUOTA_H_ */

Sambaに対してSat Aug 29 21:22:57 2009に生成されました。  doxygen 1.4.7