Whamcloud - gitweb
libquota: fix get_dq()
[tools/e2fsprogs.git] / lib / quota / quotaio_tree.h
1 /*
2  * Definitions of structures for vfsv0 quota format
3  */
4
5 #ifndef _LINUX_QUOTA_TREE_H
6 #define _LINUX_QUOTA_TREE_H
7
8 #include <sys/types.h>
9 #include "quota.h"
10
11 #define QT_TREEOFF      1       /* Offset of tree in file in blocks */
12 #define QT_TREEDEPTH    4       /* Depth of quota tree */
13 #define QT_BLKSIZE_BITS 10
14 #define QT_BLKSIZE (1 << QT_BLKSIZE_BITS)       /* Size of block with quota
15                                                  * structures */
16
17 /*
18  *  Structure of header of block with quota structures. It is padded to 16 bytes
19  *  so there will be space for exactly 21 quota-entries in a block
20  */
21 struct qt_disk_dqdbheader {
22         u_int32_t dqdh_next_free;       /* Number of next block with free
23                                          * entry */
24         u_int32_t dqdh_prev_free; /* Number of previous block with free
25                                    * entry */
26         u_int16_t dqdh_entries; /* Number of valid entries in block */
27         u_int16_t dqdh_pad1;
28         u_int32_t dqdh_pad2;
29 } __attribute__ ((packed));
30
31 struct dquot;
32 struct quota_handle;
33
34 /* Operations */
35 struct qtree_fmt_operations {
36         /* Convert given entry from in memory format to disk one */
37         void (*mem2disk_dqblk)(void *disk, struct dquot *dquot);
38         /* Convert given entry from disk format to in memory one */
39         void (*disk2mem_dqblk)(struct dquot *dquot, void *disk);
40         /* Is this structure for given id? */
41         int (*is_id)(void *disk, struct dquot *dquot);
42 };
43
44 /* Inmemory copy of version specific information */
45 struct qtree_mem_dqinfo {
46         unsigned int dqi_blocks;        /* # of blocks in quota file */
47         unsigned int dqi_free_blk;      /* First block in list of free blocks */
48         unsigned int dqi_free_entry;    /* First block with free entry */
49         unsigned int dqi_entry_size;    /* Size of quota entry in quota file */
50         struct qtree_fmt_operations *dqi_ops;   /* Operations for entry
51                                                  * manipulation */
52 };
53
54 void qtree_write_dquot(struct dquot *dquot);
55 struct dquot *qtree_read_dquot(struct quota_handle *h, qid_t id);
56 void qtree_delete_dquot(struct dquot *dquot);
57 int qtree_entry_unused(struct qtree_mem_dqinfo *info, char *disk);
58 int qtree_scan_dquots(struct quota_handle *h,
59                 int (*process_dquot) (struct dquot *, void *), void *data);
60
61 int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info);
62
63 #endif /* _LINUX_QUOTAIO_TREE_H */