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