blob: 6ee54c996394547c2f27b84fce776c92762eb97b [file] [log] [blame]
Aditya Kalif239fef2011-07-20 11:40:02 -07001/*
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>
Jan Kara2ae58b62012-06-04 12:51:55 -04009
10typedef u_int32_t qid_t; /* Type in which we store ids in memory */
Aditya Kalif239fef2011-07-20 11:40:02 -070011
12#define QT_TREEOFF 1 /* Offset of tree in file in blocks */
13#define QT_TREEDEPTH 4 /* Depth of quota tree */
14#define QT_BLKSIZE_BITS 10
15#define QT_BLKSIZE (1 << QT_BLKSIZE_BITS) /* Size of block with quota
16 * structures */
17
18/*
19 * Structure of header of block with quota structures. It is padded to 16 bytes
20 * so there will be space for exactly 21 quota-entries in a block
21 */
22struct qt_disk_dqdbheader {
23 u_int32_t dqdh_next_free; /* Number of next block with free
24 * entry */
25 u_int32_t dqdh_prev_free; /* Number of previous block with free
26 * entry */
27 u_int16_t dqdh_entries; /* Number of valid entries in block */
28 u_int16_t dqdh_pad1;
29 u_int32_t dqdh_pad2;
30} __attribute__ ((packed));
31
32struct dquot;
33struct quota_handle;
34
35/* Operations */
36struct qtree_fmt_operations {
37 /* Convert given entry from in memory format to disk one */
38 void (*mem2disk_dqblk)(void *disk, struct dquot *dquot);
39 /* Convert given entry from disk format to in memory one */
40 void (*disk2mem_dqblk)(struct dquot *dquot, void *disk);
41 /* Is this structure for given id? */
42 int (*is_id)(void *disk, struct dquot *dquot);
43};
44
45/* Inmemory copy of version specific information */
46struct qtree_mem_dqinfo {
47 unsigned int dqi_blocks; /* # of blocks in quota file */
48 unsigned int dqi_free_blk; /* First block in list of free blocks */
49 unsigned int dqi_free_entry; /* First block with free entry */
50 unsigned int dqi_entry_size; /* Size of quota entry in quota file */
51 struct qtree_fmt_operations *dqi_ops; /* Operations for entry
52 * manipulation */
53};
54
55void qtree_write_dquot(struct dquot *dquot);
56struct dquot *qtree_read_dquot(struct quota_handle *h, qid_t id);
57void qtree_delete_dquot(struct dquot *dquot);
58int qtree_entry_unused(struct qtree_mem_dqinfo *info, char *disk);
59int qtree_scan_dquots(struct quota_handle *h,
Niu198d20f2011-11-14 10:58:28 -050060 int (*process_dquot) (struct dquot *, void *), void *data);
Aditya Kalif239fef2011-07-20 11:40:02 -070061
62int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info);
63
64#endif /* _LINUX_QUOTAIO_TREE_H */