mkquota.h revision a86d55da8bf41335aa2fc5ec16ca63859d918e81
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@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 "quota.h"
36#include "../e2fsck/dict.h"
37
38typedef struct quota_ctx *quota_ctx_t;
39
40struct quota_ctx {
41	ext2_filsys	fs;
42	dict_t		*quota_dict[MAXQUOTAS];
43};
44
45/* In mkquota.c */
46errcode_t quota_init_context(quota_ctx_t *qctx, ext2_filsys fs, int qtype);
47void quota_data_inodes(quota_ctx_t qctx, struct ext2_inode *inode, ext2_ino_t ino,
48		int adjust);
49void quota_data_add(quota_ctx_t qctx, struct ext2_inode *inode, ext2_ino_t ino,
50		qsize_t space);
51void quota_data_sub(quota_ctx_t qctx, struct ext2_inode *inode, ext2_ino_t ino,
52		qsize_t space);
53errcode_t quota_write_inode(quota_ctx_t qctx, int qtype);
54errcode_t quota_compute_usage(quota_ctx_t qctx);
55void quota_release_context(quota_ctx_t *qctx);
56
57errcode_t quota_remove_inode(ext2_filsys fs, int qtype);
58int quota_is_on(ext2_filsys fs, int type);
59int quota_file_exists(ext2_filsys fs, int qtype, int fmt);
60void quota_set_sb_inum(ext2_filsys fs, ext2_ino_t ino, int qtype);
61
62/* In quotaio.c */
63const char *quota_get_qf_name(int type, int fmt, char *buf);
64const char *quota_get_qf_path(const char *mntpt, int qtype, int fmt,
65			      char *path_buf, size_t path_buf_size);
66
67#endif  /* __QUOTA_QUOTAIO_H__ */
68