softlink
[sysadmin-cn.git] / quotaio_v2.h
1 /*
2  *
3  *      Header file for disk format of new quotafile format
4  *
5  */
6
7 #ifndef _QUOTAIO_V2_H
8 #define _QUOTAIO_V2_H
9
10 #include <sys/types.h>
11 #include "quota.h"
12
13 #define V2_DQINFOOFF    sizeof(struct v2_disk_dqheader) /* Offset of info header in file */
14 #define V2_DQBLKSIZE_BITS       10
15 #define V2_DQBLKSIZE    (1 << V2_DQBLKSIZE_BITS)        /* Size of block with quota structures */
16 #define V2_DQTREEOFF    1       /* Offset of tree in file in blocks */
17 #define V2_DQTREEDEPTH  4       /* Depth of quota tree */
18 #define V2_DQSTRINBLK   ((V2_DQBLKSIZE - sizeof(struct v2_disk_dqdbheader)) / sizeof(struct v2_disk_dqblk))     /* Number of entries in one blocks */
19 #define V2_GETIDINDEX(id, depth) (((id) >> ((V2_DQTREEDEPTH-(depth)-1)*8)) & 0xff)
20 #define V2_GETENTRIES(buf) ((struct v2_disk_dqblk *)(((char *)(buf)) + sizeof(struct v2_disk_dqdbheader)))
21 #define INIT_V2_VERSIONS { 0, 0}
22
23 struct v2_disk_dqheader {
24         u_int32_t dqh_magic;    /* Magic number identifying file */
25         u_int32_t dqh_version;  /* File version */
26 } __attribute__ ((packed));
27
28 /* Flags for version specific files */
29 #define V2_DQF_MASK  0x0000     /* Mask for all valid ondisk flags */
30
31 /* Header with type and version specific information */
32 struct v2_disk_dqinfo {
33         u_int32_t dqi_bgrace;   /* Time before block soft limit becomes hard limit */
34         u_int32_t dqi_igrace;   /* Time before inode soft limit becomes hard limit */
35         u_int32_t dqi_flags;    /* Flags for quotafile (DQF_*) */
36         u_int32_t dqi_blocks;   /* Number of blocks in file */
37         u_int32_t dqi_free_blk; /* Number of first free block in the list */
38         u_int32_t dqi_free_entry;       /* Number of block with at least one free entry */
39 } __attribute__ ((packed));
40
41 /*
42  *  Structure of header of block with quota structures. It is padded to 16 bytes so
43  *  there will be space for exactly 18 quota-entries in a block
44  */
45 struct v2_disk_dqdbheader {
46         u_int32_t dqdh_next_free;       /* Number of next block with free entry */
47         u_int32_t dqdh_prev_free;       /* Number of previous block with free entry */
48         u_int16_t dqdh_entries; /* Number of valid entries in block */
49         u_int16_t dqdh_pad1;
50         u_int32_t dqdh_pad2;
51 } __attribute__ ((packed));
52
53 /* Structure of quota for one user on disk */
54 struct v2_disk_dqblk {
55         u_int32_t dqb_id;       /* id this quota applies to */
56         u_int32_t dqb_ihardlimit;       /* absolute limit on allocated inodes */
57         u_int32_t dqb_isoftlimit;       /* preferred inode limit */
58         u_int32_t dqb_curinodes;        /* current # allocated inodes */
59         u_int32_t dqb_bhardlimit;       /* absolute limit on disk space (in QUOTABLOCK_SIZE) */
60         u_int32_t dqb_bsoftlimit;       /* preferred limit on disk space (in QUOTABLOCK_SIZE) */
61         u_int64_t dqb_curspace; /* current space occupied (in bytes) */
62         u_int64_t dqb_btime;    /* time limit for excessive disk use */
63         u_int64_t dqb_itime;    /* time limit for excessive inode use */
64 } __attribute__ ((packed));
65
66 /* Structure of quota for communication with kernel */
67 struct v2_kern_dqblk {
68         unsigned int dqb_ihardlimit;
69         unsigned int dqb_isoftlimit;
70         unsigned int dqb_curinodes;
71         unsigned int dqb_bhardlimit;
72         unsigned int dqb_bsoftlimit;
73         qsize_t dqb_curspace;
74         time_t dqb_btime;
75         time_t dqb_itime;
76 };
77
78 /* Structure of quotafile info for communication with kernel */
79 struct v2_kern_dqinfo {
80         unsigned int dqi_bgrace;
81         unsigned int dqi_igrace;
82         unsigned int dqi_flags;
83         unsigned int dqi_blocks;
84         unsigned int dqi_free_blk;
85         unsigned int dqi_free_entry;
86 };
87
88 /* Structure with gathered statistics from kernel */
89 struct v2_dqstats {
90         u_int32_t lookups;
91         u_int32_t drops;
92         u_int32_t reads;
93         u_int32_t writes;
94         u_int32_t cache_hits;
95         u_int32_t allocated_dquots;
96         u_int32_t free_dquots;
97         u_int32_t syncs;
98         u_int32_t version;
99 };
100
101 #endif