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