xref: /linux/include/uapi/linux/quota.h (revision a1c613ae4c322ddd58d5a8539dbfba2a0380a8c0)
1607ca46eSDavid Howells /*
2607ca46eSDavid Howells  * Copyright (c) 1982, 1986 Regents of the University of California.
3607ca46eSDavid Howells  * All rights reserved.
4607ca46eSDavid Howells  *
5607ca46eSDavid Howells  * This code is derived from software contributed to Berkeley by
6607ca46eSDavid Howells  * Robert Elz at The University of Melbourne.
7607ca46eSDavid Howells  *
8607ca46eSDavid Howells  * Redistribution and use in source and binary forms, with or without
9607ca46eSDavid Howells  * modification, are permitted provided that the following conditions
10607ca46eSDavid Howells  * are met:
11607ca46eSDavid Howells  * 1. Redistributions of source code must retain the above copyright
12607ca46eSDavid Howells  *    notice, this list of conditions and the following disclaimer.
13607ca46eSDavid Howells  * 2. Redistributions in binary form must reproduce the above copyright
14607ca46eSDavid Howells  *    notice, this list of conditions and the following disclaimer in the
15607ca46eSDavid Howells  *    documentation and/or other materials provided with the distribution.
16607ca46eSDavid Howells  * 3. Neither the name of the University nor the names of its contributors
17607ca46eSDavid Howells  *    may be used to endorse or promote products derived from this software
18607ca46eSDavid Howells  *    without specific prior written permission.
19607ca46eSDavid Howells  *
20607ca46eSDavid Howells  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21607ca46eSDavid Howells  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22607ca46eSDavid Howells  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23607ca46eSDavid Howells  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24607ca46eSDavid Howells  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25607ca46eSDavid Howells  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26607ca46eSDavid Howells  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27607ca46eSDavid Howells  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28607ca46eSDavid Howells  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29607ca46eSDavid Howells  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30607ca46eSDavid Howells  * SUCH DAMAGE.
31607ca46eSDavid Howells  */
32607ca46eSDavid Howells 
33607ca46eSDavid Howells #ifndef _UAPI_LINUX_QUOTA_
34607ca46eSDavid Howells #define _UAPI_LINUX_QUOTA_
35607ca46eSDavid Howells 
36607ca46eSDavid Howells #include <linux/types.h>
37607ca46eSDavid Howells 
38847aac64SLi Xi #define __DQUOT_VERSION__	"dquot_6.6.0"
39607ca46eSDavid Howells 
40847aac64SLi Xi #define MAXQUOTAS 3
41607ca46eSDavid Howells #define USRQUOTA  0		/* element used for user quotas */
42607ca46eSDavid Howells #define GRPQUOTA  1		/* element used for group quotas */
43847aac64SLi Xi #define PRJQUOTA  2		/* element used for project quotas */
44607ca46eSDavid Howells 
45607ca46eSDavid Howells /*
46607ca46eSDavid Howells  * Definitions for the default names of the quotas files.
47607ca46eSDavid Howells  */
48607ca46eSDavid Howells #define INITQFNAMES { \
49607ca46eSDavid Howells 	"user",    /* USRQUOTA */ \
50607ca46eSDavid Howells 	"group",   /* GRPQUOTA */ \
51847aac64SLi Xi 	"project", /* PRJQUOTA */ \
52607ca46eSDavid Howells 	"undefined", \
53607ca46eSDavid Howells };
54607ca46eSDavid Howells 
55607ca46eSDavid Howells /*
56607ca46eSDavid Howells  * Command definitions for the 'quotactl' system call.
57607ca46eSDavid Howells  * The commands are broken into a main command defined below
58607ca46eSDavid Howells  * and a subcommand that is used to convey the type of
59607ca46eSDavid Howells  * quota that is being manipulated (see above).
60607ca46eSDavid Howells  */
61607ca46eSDavid Howells #define SUBCMDMASK  0x00ff
62607ca46eSDavid Howells #define SUBCMDSHIFT 8
63607ca46eSDavid Howells #define QCMD(cmd, type)  (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
64607ca46eSDavid Howells 
65607ca46eSDavid Howells #define Q_SYNC     0x800001	/* sync disk copy of a filesystems quotas */
66607ca46eSDavid Howells #define Q_QUOTAON  0x800002	/* turn quotas on */
67607ca46eSDavid Howells #define Q_QUOTAOFF 0x800003	/* turn quotas off */
68607ca46eSDavid Howells #define Q_GETFMT   0x800004	/* get quota format used on given filesystem */
69607ca46eSDavid Howells #define Q_GETINFO  0x800005	/* get information about quota files */
70607ca46eSDavid Howells #define Q_SETINFO  0x800006	/* set information about quota files */
71607ca46eSDavid Howells #define Q_GETQUOTA 0x800007	/* get user quota structure */
72607ca46eSDavid Howells #define Q_SETQUOTA 0x800008	/* set user quota structure */
73926132c0SEric Sandeen #define Q_GETNEXTQUOTA 0x800009	/* get disk limits and usage >= ID */
74607ca46eSDavid Howells 
75607ca46eSDavid Howells /* Quota format type IDs */
76607ca46eSDavid Howells #define	QFMT_VFS_OLD 1
77607ca46eSDavid Howells #define	QFMT_VFS_V0 2
78607ca46eSDavid Howells #define QFMT_OCFS2 3
79607ca46eSDavid Howells #define	QFMT_VFS_V1 4
80*eafc474eSCarlos Maiolino #define	QFMT_SHMEM 5
81607ca46eSDavid Howells 
82607ca46eSDavid Howells /* Size of block in which space limits are passed through the quota
83607ca46eSDavid Howells  * interface */
84607ca46eSDavid Howells #define QIF_DQBLKSIZE_BITS 10
85607ca46eSDavid Howells #define QIF_DQBLKSIZE (1 << QIF_DQBLKSIZE_BITS)
86607ca46eSDavid Howells 
87607ca46eSDavid Howells /*
88607ca46eSDavid Howells  * Quota structure used for communication with userspace via quotactl
89607ca46eSDavid Howells  * Following flags are used to specify which fields are valid
90607ca46eSDavid Howells  */
91607ca46eSDavid Howells enum {
92607ca46eSDavid Howells 	QIF_BLIMITS_B = 0,
93607ca46eSDavid Howells 	QIF_SPACE_B,
94607ca46eSDavid Howells 	QIF_ILIMITS_B,
95607ca46eSDavid Howells 	QIF_INODES_B,
96607ca46eSDavid Howells 	QIF_BTIME_B,
97607ca46eSDavid Howells 	QIF_ITIME_B,
98607ca46eSDavid Howells };
99607ca46eSDavid Howells 
100607ca46eSDavid Howells #define QIF_BLIMITS	(1 << QIF_BLIMITS_B)
101607ca46eSDavid Howells #define QIF_SPACE	(1 << QIF_SPACE_B)
102607ca46eSDavid Howells #define QIF_ILIMITS	(1 << QIF_ILIMITS_B)
103607ca46eSDavid Howells #define QIF_INODES	(1 << QIF_INODES_B)
104607ca46eSDavid Howells #define QIF_BTIME	(1 << QIF_BTIME_B)
105607ca46eSDavid Howells #define QIF_ITIME	(1 << QIF_ITIME_B)
106607ca46eSDavid Howells #define QIF_LIMITS	(QIF_BLIMITS | QIF_ILIMITS)
107607ca46eSDavid Howells #define QIF_USAGE	(QIF_SPACE | QIF_INODES)
108607ca46eSDavid Howells #define QIF_TIMES	(QIF_BTIME | QIF_ITIME)
109607ca46eSDavid Howells #define QIF_ALL		(QIF_LIMITS | QIF_USAGE | QIF_TIMES)
110607ca46eSDavid Howells 
111607ca46eSDavid Howells struct if_dqblk {
112607ca46eSDavid Howells 	__u64 dqb_bhardlimit;
113607ca46eSDavid Howells 	__u64 dqb_bsoftlimit;
114607ca46eSDavid Howells 	__u64 dqb_curspace;
115607ca46eSDavid Howells 	__u64 dqb_ihardlimit;
116607ca46eSDavid Howells 	__u64 dqb_isoftlimit;
117607ca46eSDavid Howells 	__u64 dqb_curinodes;
118607ca46eSDavid Howells 	__u64 dqb_btime;
119607ca46eSDavid Howells 	__u64 dqb_itime;
120607ca46eSDavid Howells 	__u32 dqb_valid;
121607ca46eSDavid Howells };
122607ca46eSDavid Howells 
123926132c0SEric Sandeen struct if_nextdqblk {
124926132c0SEric Sandeen 	__u64 dqb_bhardlimit;
125926132c0SEric Sandeen 	__u64 dqb_bsoftlimit;
126926132c0SEric Sandeen 	__u64 dqb_curspace;
127926132c0SEric Sandeen 	__u64 dqb_ihardlimit;
128926132c0SEric Sandeen 	__u64 dqb_isoftlimit;
129926132c0SEric Sandeen 	__u64 dqb_curinodes;
130926132c0SEric Sandeen 	__u64 dqb_btime;
131926132c0SEric Sandeen 	__u64 dqb_itime;
132926132c0SEric Sandeen 	__u32 dqb_valid;
133926132c0SEric Sandeen 	__u32 dqb_id;
134926132c0SEric Sandeen };
135926132c0SEric Sandeen 
136607ca46eSDavid Howells /*
137607ca46eSDavid Howells  * Structure used for setting quota information about file via quotactl
138607ca46eSDavid Howells  * Following flags are used to specify which fields are valid
139607ca46eSDavid Howells  */
140607ca46eSDavid Howells #define IIF_BGRACE	1
141607ca46eSDavid Howells #define IIF_IGRACE	2
142607ca46eSDavid Howells #define IIF_FLAGS	4
143607ca46eSDavid Howells #define IIF_ALL		(IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
144607ca46eSDavid Howells 
1459c45101eSJan Kara enum {
1469c45101eSJan Kara 	DQF_ROOT_SQUASH_B = 0,
1479c45101eSJan Kara 	DQF_SYS_FILE_B = 16,
1489c45101eSJan Kara 	/* Kernel internal flags invisible to userspace */
1499c45101eSJan Kara 	DQF_PRIVATE
1509c45101eSJan Kara };
1519c45101eSJan Kara 
1529c45101eSJan Kara /* Root squash enabled (for v1 quota format) */
1539c45101eSJan Kara #define DQF_ROOT_SQUASH	(1 << DQF_ROOT_SQUASH_B)
1549c45101eSJan Kara /* Quota stored in a system file */
1559c45101eSJan Kara #define DQF_SYS_FILE	(1 << DQF_SYS_FILE_B)
1569c45101eSJan Kara 
157607ca46eSDavid Howells struct if_dqinfo {
158607ca46eSDavid Howells 	__u64 dqi_bgrace;
159607ca46eSDavid Howells 	__u64 dqi_igrace;
1609c45101eSJan Kara 	__u32 dqi_flags;	/* DFQ_* */
161607ca46eSDavid Howells 	__u32 dqi_valid;
162607ca46eSDavid Howells };
163607ca46eSDavid Howells 
164607ca46eSDavid Howells /*
165607ca46eSDavid Howells  * Definitions for quota netlink interface
166607ca46eSDavid Howells  */
167607ca46eSDavid Howells #define QUOTA_NL_NOWARN 0
168607ca46eSDavid Howells #define QUOTA_NL_IHARDWARN 1		/* Inode hardlimit reached */
169607ca46eSDavid Howells #define QUOTA_NL_ISOFTLONGWARN 2 	/* Inode grace time expired */
170607ca46eSDavid Howells #define QUOTA_NL_ISOFTWARN 3		/* Inode softlimit reached */
171607ca46eSDavid Howells #define QUOTA_NL_BHARDWARN 4		/* Block hardlimit reached */
172607ca46eSDavid Howells #define QUOTA_NL_BSOFTLONGWARN 5	/* Block grace time expired */
173607ca46eSDavid Howells #define QUOTA_NL_BSOFTWARN 6		/* Block softlimit reached */
174607ca46eSDavid Howells #define QUOTA_NL_IHARDBELOW 7		/* Usage got below inode hardlimit */
175607ca46eSDavid Howells #define QUOTA_NL_ISOFTBELOW 8		/* Usage got below inode softlimit */
176607ca46eSDavid Howells #define QUOTA_NL_BHARDBELOW 9		/* Usage got below block hardlimit */
177607ca46eSDavid Howells #define QUOTA_NL_BSOFTBELOW 10		/* Usage got below block softlimit */
178607ca46eSDavid Howells 
179607ca46eSDavid Howells enum {
180607ca46eSDavid Howells 	QUOTA_NL_C_UNSPEC,
181607ca46eSDavid Howells 	QUOTA_NL_C_WARNING,
182607ca46eSDavid Howells 	__QUOTA_NL_C_MAX,
183607ca46eSDavid Howells };
184607ca46eSDavid Howells #define QUOTA_NL_C_MAX (__QUOTA_NL_C_MAX - 1)
185607ca46eSDavid Howells 
186607ca46eSDavid Howells enum {
187607ca46eSDavid Howells 	QUOTA_NL_A_UNSPEC,
188607ca46eSDavid Howells 	QUOTA_NL_A_QTYPE,
189607ca46eSDavid Howells 	QUOTA_NL_A_EXCESS_ID,
190607ca46eSDavid Howells 	QUOTA_NL_A_WARNING,
191607ca46eSDavid Howells 	QUOTA_NL_A_DEV_MAJOR,
192607ca46eSDavid Howells 	QUOTA_NL_A_DEV_MINOR,
193607ca46eSDavid Howells 	QUOTA_NL_A_CAUSED_ID,
1943c6f3714SNicolas Dichtel 	QUOTA_NL_A_PAD,
195607ca46eSDavid Howells 	__QUOTA_NL_A_MAX,
196607ca46eSDavid Howells };
197607ca46eSDavid Howells #define QUOTA_NL_A_MAX (__QUOTA_NL_A_MAX - 1)
198607ca46eSDavid Howells 
199607ca46eSDavid Howells 
200607ca46eSDavid Howells #endif /* _UAPI_LINUX_QUOTA_ */
201