Update to latest version of quota.
[profile/ivi/quota.git] / quota.h
1 #ifndef GUARD_QUOTA_H
2 #define GUARD_QUOTA_H
3
4 #include <sys/types.h>
5
6 typedef u_int32_t qid_t;        /* Type in which we store ids in memory */
7 typedef int64_t qsize_t;        /* Type in which we store size limitations */
8
9 #define MAXQUOTAS 2
10 #define USRQUOTA  0             /* element used for user quotas */
11 #define GRPQUOTA  1             /* element used for group quotas */
12
13 /*
14  * Definitions for the default names of the quotas files.
15  * N_ is gettext magic for static strings
16  */
17 #define N_(x) (x)
18 #define INITQFNAMES { \
19         N_("user"),    /* USRQUOTA */ \
20         N_("group"),   /* GRPQUOTA */ \
21         N_("undefined"), \
22 }
23
24 /*
25  * Definitions of magics and versions of current quota files
26  */
27 #define INITQMAGICS {\
28         0xd9c01f11,     /* USRQUOTA */\
29         0xd9c01927      /* GRPQUOTA */\
30 }
31
32 /* Size of blocks in which are counted size limits in generic utility parts */
33 #define QUOTABLOCK_BITS 10
34 #define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
35
36 /* Conversion routines from and to quota blocks */
37 #define qb2kb(x) ((x) << (QUOTABLOCK_BITS-10))
38 #define kb2qb(x) ((x) >> (QUOTABLOCK_BITS-10))
39 #define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS)
40
41 /*
42  * Command definitions for the 'quotactl' system call.
43  * The commands are broken into a main command defined below
44  * and a subcommand that is used to convey the type of
45  * quota that is being manipulated (see above).
46  */
47 #define SUBCMDMASK  0x00ff
48 #define SUBCMDSHIFT 8
49 #define QCMD(cmd, type)  (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
50
51 #define Q_6_5_QUOTAON  0x0100   /* enable quotas */
52 #define Q_6_5_QUOTAOFF 0x0200   /* disable quotas */
53 #define Q_6_5_SYNC     0x0600   /* sync disk copy of a filesystems quotas */
54
55 #define Q_SYNC     0x800001     /* sync disk copy of a filesystems quotas */
56 #define Q_QUOTAON  0x800002     /* turn quotas on */
57 #define Q_QUOTAOFF 0x800003     /* turn quotas off */
58 #define Q_GETFMT   0x800004     /* get quota format used on given filesystem */
59 #define Q_GETINFO  0x800005     /* get information about quota files */
60 #define Q_SETINFO  0x800006     /* set information about quota files */
61 #define Q_GETQUOTA 0x800007     /* get user quota structure */
62 #define Q_SETQUOTA 0x800008     /* set user quota structure */
63
64 /*
65  * Quota structure used for communication with userspace via quotactl
66  * Following flags are used to specify which fields are valid
67  */
68 #define QIF_BLIMITS     1
69 #define QIF_SPACE       2
70 #define QIF_ILIMITS     4
71 #define QIF_INODES      8
72 #define QIF_BTIME       16
73 #define QIF_ITIME       32
74 #define QIF_LIMITS      (QIF_BLIMITS | QIF_ILIMITS)
75 #define QIF_USAGE       (QIF_SPACE | QIF_INODES)
76 #define QIF_TIMES       (QIF_BTIME | QIF_ITIME)
77 #define QIF_ALL         (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
78
79 struct if_dqblk {
80         u_int64_t dqb_bhardlimit;
81         u_int64_t dqb_bsoftlimit;
82         u_int64_t dqb_curspace;
83         u_int64_t dqb_ihardlimit;
84         u_int64_t dqb_isoftlimit;
85         u_int64_t dqb_curinodes;
86         u_int64_t dqb_btime;
87         u_int64_t dqb_itime;
88         u_int32_t dqb_valid;
89 };
90
91 /*
92  * Structure used for setting quota information about file via quotactl
93  * Following flags are used to specify which fields are valid
94  */
95 #define IIF_BGRACE      1
96 #define IIF_IGRACE      2
97 #define IIF_FLAGS       4
98 #define IIF_ALL         (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
99
100 #define DQF_SYS_FILE    0x10000         /* Quota stored in a system file */
101
102 struct if_dqinfo {
103         u_int64_t dqi_bgrace;
104         u_int64_t dqi_igrace;
105         u_int32_t dqi_flags;
106         u_int32_t dqi_valid;
107 };
108
109 /*
110  * Definitions for quota netlink interface
111  */
112 #define QUOTA_NL_NOWARN 0
113 #define QUOTA_NL_IHARDWARN 1            /* Inode hardlimit reached */
114 #define QUOTA_NL_ISOFTLONGWARN 2        /* Inode grace time expired */
115 #define QUOTA_NL_ISOFTWARN 3            /* Inode softlimit reached */
116 #define QUOTA_NL_BHARDWARN 4            /* Block hardlimit reached */
117 #define QUOTA_NL_BSOFTLONGWARN 5        /* Block grace time expired */
118 #define QUOTA_NL_BSOFTWARN 6            /* Block softlimit reached */
119 #define QUOTA_NL_IHARDBELOW 7           /* Usage got below inode hardlimit */
120 #define QUOTA_NL_ISOFTBELOW 8           /* Usage got below inode softlimit */
121 #define QUOTA_NL_BHARDBELOW 9           /* Usage got below block hardlimit */
122 #define QUOTA_NL_BSOFTBELOW 10          /* Usage got below block softlimit */
123
124 enum {
125         QUOTA_NL_C_UNSPEC,
126         QUOTA_NL_C_WARNING,
127         ENUM_QUOTA_NL_C_MAX,
128 };
129 #define QUOTA_NL_C_MAX (ENUM_QUOTA_NL_C_MAX - 1)
130
131 enum {
132         QUOTA_NL_A_UNSPEC,
133         QUOTA_NL_A_QTYPE,
134         QUOTA_NL_A_EXCESS_ID,
135         QUOTA_NL_A_WARNING,
136         QUOTA_NL_A_DEV_MAJOR,
137         QUOTA_NL_A_DEV_MINOR,
138         QUOTA_NL_A_CAUSED_ID,
139         ENUM_QUOTA_NL_A_MAX,
140 };
141 #define QUOTA_NL_A_MAX (ENUM_QUOTA_NL_A_MAX - 1)
142
143 /* Quota format identifiers */
144 #define QFMT_VFS_OLD 1
145 #define QFMT_VFS_V0  2
146 #define QFMT_OCFS2   3
147 #define QFMT_VFS_V1  4
148
149 /* Flags supported by kernel */
150 #define V1_DQF_RSQUASH 1
151
152 /* Ioctl for getting quota size */
153 #include <sys/ioctl.h>
154 #ifndef FIOQSIZE
155         #if defined(__alpha__) || defined(__powerpc__) || defined(__sh__) || defined(__sparc__) || defined(__sparc64__)
156                 #define FIOQSIZE _IOR('f', 128, loff_t)
157         #elif defined(__arm__) || defined(__mc68000__) || defined(__s390__)
158                 #define FIOQSIZE 0x545E
159         #elif defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__ia64__) || defined(__parisc__) || defined(__cris__) || defined(__hppa__) || defined(__x86_64__)
160                 #define FIOQSIZE 0x5460
161         #elif defined(__mips__) || defined(__mips64__)
162                 #define FIOQSIZE 0x6667
163         #endif
164 #endif
165
166 long quotactl __P((int, const char *, qid_t, caddr_t));
167
168 #endif /* _QUOTA_ */