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