Home | History | Annotate | Download | only in quota
      1 /** mkquota.h
      2  *
      3  * Interface to the quota library.
      4  *
      5  * The quota library provides interface for creating and updating the quota
      6  * files and the ext4 superblock fields. It supports the new VFS_V1 quota
      7  * format. The quota library also provides support for keeping track of quotas
      8  * in memory.
      9  * The typical way to use the quota library is as follows:
     10  * {
     11  *	quota_ctx_t qctx;
     12  *
     13  *	quota_init_context(&qctx, fs, -1);
     14  *	{
     15  *		quota_compute_usage(qctx, -1);
     16  *		AND/OR
     17  *		quota_data_add/quota_data_sub/quota_data_inodes();
     18  *	}
     19  *	quota_write_inode(qctx, USRQUOTA);
     20  *	quota_write_inode(qctx, GRPQUOTA);
     21  *	quota_release_context(&qctx);
     22  * }
     23  *
     24  * This initial version does not support reading the quota files. This support
     25  * will be added in near future.
     26  *
     27  * Aditya Kali <adityakali (at) google.com>
     28  */
     29 
     30 #ifndef __QUOTA_QUOTAIO_H__
     31 #define __QUOTA_QUOTAIO_H__
     32 
     33 #include "ext2fs/ext2_fs.h"
     34 #include "ext2fs/ext2fs.h"
     35 #include "quotaio.h"
     36 #include "../e2fsck/dict.h"
     37 
     38 typedef struct quota_ctx *quota_ctx_t;
     39 
     40 struct quota_ctx {
     41 	ext2_filsys	fs;
     42 	dict_t		*quota_dict[MAXQUOTAS];
     43 };
     44 
     45 /* In mkquota.c */
     46 errcode_t quota_init_context(quota_ctx_t *qctx, ext2_filsys fs, int qtype);
     47 void quota_data_inodes(quota_ctx_t qctx, struct ext2_inode *inode, ext2_ino_t ino,
     48 		int adjust);
     49 void quota_data_add(quota_ctx_t qctx, struct ext2_inode *inode, ext2_ino_t ino,
     50 		qsize_t space);
     51 void quota_data_sub(quota_ctx_t qctx, struct ext2_inode *inode, ext2_ino_t ino,
     52 		qsize_t space);
     53 errcode_t quota_write_inode(quota_ctx_t qctx, int qtype);
     54 errcode_t quota_update_limits(quota_ctx_t qctx, ext2_ino_t qf_ino, int type);
     55 errcode_t quota_compute_usage(quota_ctx_t qctx);
     56 void quota_release_context(quota_ctx_t *qctx);
     57 
     58 errcode_t quota_remove_inode(ext2_filsys fs, int qtype);
     59 int quota_file_exists(ext2_filsys fs, int qtype, int fmt);
     60 void quota_set_sb_inum(ext2_filsys fs, ext2_ino_t ino, int qtype);
     61 errcode_t quota_compare_and_update(quota_ctx_t qctx, int qtype,
     62 				   int *usage_inconsistent);
     63 
     64 #endif  /* __QUOTA_QUOTAIO_H__ */
     65