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 10typedef u_int32_t qid_t; /* Type in which we store ids in memory */ 11 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, 60 int (*process_dquot) (struct dquot *, void *), void *data); 61 62int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info); 63 64#endif /* _LINUX_QUOTAIO_TREE_H */ 65