Home | History | Annotate | Download | only in fsck
      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 } __attribute__ ((packed));
     37 
     38 struct dquot;
     39 struct quota_handle;
     40 
     41 /* Operations */
     42 struct qtree_fmt_operations {
     43 	/* Convert given entry from in memory format to disk one */
     44 	void (*mem2disk_dqblk)(void *disk, struct dquot *dquot);
     45 	/* Convert given entry from disk format to in memory one */
     46 	void (*disk2mem_dqblk)(struct dquot *dquot, void *disk);
     47 	/* Is this structure for given id? */
     48 	int (*is_id)(void *disk, struct dquot *dquot);
     49 };
     50 
     51 /* Inmemory copy of version specific information */
     52 struct qtree_mem_dqinfo {
     53 	unsigned int dqi_blocks;	/* # of blocks in quota file */
     54 	unsigned int dqi_free_blk;	/* First block in list of free blocks */
     55 	unsigned int dqi_free_entry;	/* First block with free entry */
     56 	unsigned int dqi_entry_size;	/* Size of quota entry in quota file */
     57 	struct qtree_fmt_operations *dqi_ops;	/* Operations for entry
     58 						 * manipulation */
     59 };
     60 
     61 int qtree_write_dquot(struct dquot *dquot);
     62 struct dquot *qtree_read_dquot(struct quota_handle *h, qid_t id);
     63 void qtree_delete_dquot(struct dquot *dquot);
     64 int qtree_entry_unused(struct qtree_mem_dqinfo *info, char *disk);
     65 int qtree_scan_dquots(struct quota_handle *h,
     66 		int (*process_dquot) (struct dquot *, void *), void *data);
     67 
     68 int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info);
     69 
     70 #endif /* _LINUX_QUOTAIO_TREE_H */
     71