Aditya Kali | f239fef | 2011-07-20 11:40:02 -0700 | [diff] [blame] | 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 | * |
Aditya Kali | a86d55d | 2011-11-14 10:55:54 -0500 | [diff] [blame] | 13 | * quota_init_context(&qctx, fs, -1); |
Aditya Kali | f239fef | 2011-07-20 11:40:02 -0700 | [diff] [blame] | 14 | * { |
Aditya Kali | a86d55d | 2011-11-14 10:55:54 -0500 | [diff] [blame] | 15 | * quota_compute_usage(qctx, -1); |
Aditya Kali | f239fef | 2011-07-20 11:40:02 -0700 | [diff] [blame] | 16 | * AND/OR |
| 17 | * quota_data_add/quota_data_sub/quota_data_inodes(); |
| 18 | * } |
Aditya Kali | a86d55d | 2011-11-14 10:55:54 -0500 | [diff] [blame] | 19 | * quota_write_inode(qctx, USRQUOTA); |
| 20 | * quota_write_inode(qctx, GRPQUOTA); |
| 21 | * quota_release_context(&qctx); |
Aditya Kali | f239fef | 2011-07-20 11:40:02 -0700 | [diff] [blame] | 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" |
Jan Kara | 2ae58b6 | 2012-06-04 12:51:55 -0400 | [diff] [blame] | 35 | #include "quotaio.h" |
Aditya Kali | f239fef | 2011-07-20 11:40:02 -0700 | [diff] [blame] | 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 | |
Aditya Kali | a86d55d | 2011-11-14 10:55:54 -0500 | [diff] [blame] | 45 | /* In mkquota.c */ |
| 46 | errcode_t quota_init_context(quota_ctx_t *qctx, ext2_filsys fs, int qtype); |
Aditya Kali | f239fef | 2011-07-20 11:40:02 -0700 | [diff] [blame] | 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); |
Aditya Kali | a86d55d | 2011-11-14 10:55:54 -0500 | [diff] [blame] | 53 | errcode_t quota_write_inode(quota_ctx_t qctx, int qtype); |
Aditya Kali | 5027751 | 2012-07-13 15:25:06 -0700 | [diff] [blame] | 54 | errcode_t quota_update_limits(quota_ctx_t qctx, ext2_ino_t qf_ino, int type); |
Aditya Kali | a86d55d | 2011-11-14 10:55:54 -0500 | [diff] [blame] | 55 | errcode_t quota_compute_usage(quota_ctx_t qctx); |
| 56 | void quota_release_context(quota_ctx_t *qctx); |
Aditya Kali | f239fef | 2011-07-20 11:40:02 -0700 | [diff] [blame] | 57 | |
Aditya Kali | a86d55d | 2011-11-14 10:55:54 -0500 | [diff] [blame] | 58 | errcode_t quota_remove_inode(ext2_filsys fs, int qtype); |
Aditya Kali | a86d55d | 2011-11-14 10:55:54 -0500 | [diff] [blame] | 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); |
Aditya Kali | 7943ccf | 2012-04-24 14:46:08 -0400 | [diff] [blame] | 61 | errcode_t quota_compare_and_update(quota_ctx_t qctx, int qtype, |
| 62 | int *usage_inconsistent); |
Aditya Kali | a86d55d | 2011-11-14 10:55:54 -0500 | [diff] [blame] | 63 | |
Aditya Kali | f239fef | 2011-07-20 11:40:02 -0700 | [diff] [blame] | 64 | #endif /* __QUOTA_QUOTAIO_H__ */ |