xref: /aosp_15_r20/external/f2fs-tools/include/quota.h (revision 59bfda1f02d633cd6b8b69f31eee485d40f6eef6)
1*59bfda1fSAndroid Build Coastguard Worker /*
2*59bfda1fSAndroid Build Coastguard Worker  *
3*59bfda1fSAndroid Build Coastguard Worker  * Header file for disk format of new quotafile format
4*59bfda1fSAndroid Build Coastguard Worker  *
5*59bfda1fSAndroid Build Coastguard Worker  * Copied essential definitions and structures for mkfs.f2fs from quotaio.h
6*59bfda1fSAndroid Build Coastguard Worker  *
7*59bfda1fSAndroid Build Coastguard Worker  * Aditya Kali <[email protected]>
8*59bfda1fSAndroid Build Coastguard Worker  * Jan Kara <[email protected]>
9*59bfda1fSAndroid Build Coastguard Worker  * Hyojun Kim <[email protected]> - Ported to f2fs-tools
10*59bfda1fSAndroid Build Coastguard Worker  *
11*59bfda1fSAndroid Build Coastguard Worker  */
12*59bfda1fSAndroid Build Coastguard Worker #ifndef F2FS_QUOTA_H
13*59bfda1fSAndroid Build Coastguard Worker #define F2FS_QUOTA_H
14*59bfda1fSAndroid Build Coastguard Worker 
15*59bfda1fSAndroid Build Coastguard Worker enum quota_type {
16*59bfda1fSAndroid Build Coastguard Worker 	USRQUOTA = 0,
17*59bfda1fSAndroid Build Coastguard Worker 	GRPQUOTA = 1,
18*59bfda1fSAndroid Build Coastguard Worker 	PRJQUOTA = 2,
19*59bfda1fSAndroid Build Coastguard Worker 	MAXQUOTAS = 3,
20*59bfda1fSAndroid Build Coastguard Worker };
21*59bfda1fSAndroid Build Coastguard Worker 
22*59bfda1fSAndroid Build Coastguard Worker #if MAXQUOTAS > 32
23*59bfda1fSAndroid Build Coastguard Worker #error "cannot have more than 32 quota types to fit in qtype_bits"
24*59bfda1fSAndroid Build Coastguard Worker #endif
25*59bfda1fSAndroid Build Coastguard Worker 
26*59bfda1fSAndroid Build Coastguard Worker #define QUOTA_USR_BIT (1 << USRQUOTA)
27*59bfda1fSAndroid Build Coastguard Worker #define QUOTA_GRP_BIT (1 << GRPQUOTA)
28*59bfda1fSAndroid Build Coastguard Worker #define QUOTA_PRJ_BIT (1 << PRJQUOTA)
29*59bfda1fSAndroid Build Coastguard Worker #define QUOTA_ALL_BIT (QUOTA_USR_BIT | QUOTA_GRP_BIT | QUOTA_PRJ_BIT)
30*59bfda1fSAndroid Build Coastguard Worker 
31*59bfda1fSAndroid Build Coastguard Worker /*
32*59bfda1fSAndroid Build Coastguard Worker  * Definitions of magics and versions of current quota files
33*59bfda1fSAndroid Build Coastguard Worker  */
34*59bfda1fSAndroid Build Coastguard Worker #define INITQMAGICS {\
35*59bfda1fSAndroid Build Coastguard Worker 	0xd9c01f11,	/* USRQUOTA */\
36*59bfda1fSAndroid Build Coastguard Worker 	0xd9c01927,	/* GRPQUOTA */\
37*59bfda1fSAndroid Build Coastguard Worker 	0xd9c03f14      /* PRJQUOTA */\
38*59bfda1fSAndroid Build Coastguard Worker }
39*59bfda1fSAndroid Build Coastguard Worker 
40*59bfda1fSAndroid Build Coastguard Worker #define V2_DQINFOOFF	sizeof(struct v2_disk_dqheader)	/* Offset of info header in file */
41*59bfda1fSAndroid Build Coastguard Worker 
42*59bfda1fSAndroid Build Coastguard Worker #define MAX_IQ_TIME  604800	/* (7*24*60*60) 1 week */
43*59bfda1fSAndroid Build Coastguard Worker #define MAX_DQ_TIME  604800	/* (7*24*60*60) 1 week */
44*59bfda1fSAndroid Build Coastguard Worker 
45*59bfda1fSAndroid Build Coastguard Worker #define QT_TREEOFF	1	/* Offset of tree in file in blocks */
46*59bfda1fSAndroid Build Coastguard Worker 
47*59bfda1fSAndroid Build Coastguard Worker struct v2_disk_dqheader {
48*59bfda1fSAndroid Build Coastguard Worker 	uint32_t dqh_magic;	/* Magic number identifying file */
49*59bfda1fSAndroid Build Coastguard Worker 	uint32_t dqh_version;	/* File version */
50*59bfda1fSAndroid Build Coastguard Worker };
51*59bfda1fSAndroid Build Coastguard Worker 
52*59bfda1fSAndroid Build Coastguard Worker static_assert(sizeof(struct v2_disk_dqheader) == 8, "");
53*59bfda1fSAndroid Build Coastguard Worker 
54*59bfda1fSAndroid Build Coastguard Worker /* Header with type and version specific information */
55*59bfda1fSAndroid Build Coastguard Worker struct v2_disk_dqinfo {
56*59bfda1fSAndroid Build Coastguard Worker 	uint32_t dqi_bgrace;	/* Time before block soft limit becomes hard limit */
57*59bfda1fSAndroid Build Coastguard Worker 	uint32_t dqi_igrace;	/* Time before inode soft limit becomes hard limit */
58*59bfda1fSAndroid Build Coastguard Worker 	uint32_t dqi_flags;	/* Flags for quotafile (DQF_*) */
59*59bfda1fSAndroid Build Coastguard Worker 	uint32_t dqi_blocks;	/* Number of blocks in file */
60*59bfda1fSAndroid Build Coastguard Worker 	uint32_t dqi_free_blk;	/* Number of first free block in the list */
61*59bfda1fSAndroid Build Coastguard Worker 	uint32_t dqi_free_entry;	/* Number of block with at least one free entry */
62*59bfda1fSAndroid Build Coastguard Worker };
63*59bfda1fSAndroid Build Coastguard Worker 
64*59bfda1fSAndroid Build Coastguard Worker static_assert(sizeof(struct v2_disk_dqinfo) == 24, "");
65*59bfda1fSAndroid Build Coastguard Worker 
66*59bfda1fSAndroid Build Coastguard Worker struct v2r1_disk_dqblk {
67*59bfda1fSAndroid Build Coastguard Worker 	__le32 dqb_id;  	/* id this quota applies to */
68*59bfda1fSAndroid Build Coastguard Worker 	__le32 dqb_pad;
69*59bfda1fSAndroid Build Coastguard Worker 	__le64 dqb_ihardlimit;  /* absolute limit on allocated inodes */
70*59bfda1fSAndroid Build Coastguard Worker 	__le64 dqb_isoftlimit;  /* preferred inode limit */
71*59bfda1fSAndroid Build Coastguard Worker 	__le64 dqb_curinodes;   /* current # allocated inodes */
72*59bfda1fSAndroid Build Coastguard Worker 	__le64 dqb_bhardlimit;  /* absolute limit on disk space
73*59bfda1fSAndroid Build Coastguard Worker 				 * (in QUOTABLOCK_SIZE) */
74*59bfda1fSAndroid Build Coastguard Worker 	__le64 dqb_bsoftlimit;  /* preferred limit on disk space
75*59bfda1fSAndroid Build Coastguard Worker 				 * (in QUOTABLOCK_SIZE) */
76*59bfda1fSAndroid Build Coastguard Worker 	__le64 dqb_curspace;    /* current space occupied (in bytes) */
77*59bfda1fSAndroid Build Coastguard Worker 	__le64 dqb_btime;       /* time limit for excessive disk use */
78*59bfda1fSAndroid Build Coastguard Worker 	__le64 dqb_itime;       /* time limit for excessive inode use */
79*59bfda1fSAndroid Build Coastguard Worker };
80*59bfda1fSAndroid Build Coastguard Worker 
81*59bfda1fSAndroid Build Coastguard Worker static_assert(sizeof(struct v2r1_disk_dqblk) == 72, "");
82*59bfda1fSAndroid Build Coastguard Worker 
83*59bfda1fSAndroid Build Coastguard Worker #endif
84