Prva inačica za buster
[sysadmin-cn.git] / quota.h
1 #ifndef _QUOTA_H
2 #define _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 u_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  */
16 #define INITQFNAMES { \
17         "user",    /* USRQUOTA */ \
18         "group",   /* GRPQUOTA */ \
19         "undefined", \
20 }
21
22 /*
23  * Definitions of magics and versions of current quota files
24  */
25 #define INITQMAGICS {\
26         0xd9c01f11,     /* USRQUOTA */\
27         0xd9c01927      /* GRPQUOTA */\
28 }
29
30 /* Size of blocks in which are counted size limits in generic utility parts */
31 #define QUOTABLOCK_BITS 10
32 #define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
33
34 /* Conversion routines from and to quota blocks */
35 #define qb2kb(x) ((x) << (QUOTABLOCK_BITS-10))
36 #define kb2qb(x) ((x) >> (QUOTABLOCK_BITS-10))
37 #define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS)
38
39 /*
40  * Command definitions for the 'quotactl' system call.
41  * The commands are broken into a main command defined below
42  * and a subcommand that is used to convey the type of
43  * quota that is being manipulated (see above).
44  */
45 #define SUBCMDMASK  0x00ff
46 #define SUBCMDSHIFT 8
47 #define QCMD(cmd, type)  (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
48
49 #define Q_6_5_QUOTAON  0x0100   /* enable quotas */
50 #define Q_6_5_QUOTAOFF 0x0200   /* disable quotas */
51 #define Q_6_5_SYNC     0x0600   /* sync disk copy of a filesystems quotas */
52
53 #define Q_SYNC     0x800001     /* sync disk copy of a filesystems quotas */
54 #define Q_QUOTAON  0x800002     /* turn quotas on */
55 #define Q_QUOTAOFF 0x800003     /* turn quotas off */
56 #define Q_GETFMT   0x800004     /* get quota format used on given filesystem */
57 #define Q_GETINFO  0x800005     /* get information about quota files */
58 #define Q_SETINFO  0x800006     /* set information about quota files */
59 #define Q_GETQUOTA 0x800007     /* get user quota structure */
60 #define Q_SETQUOTA 0x800008     /* set user quota structure */
61
62 /*
63  * Quota structure used for communication with userspace via quotactl
64  * Following flags are used to specify which fields are valid
65  */
66 #define QIF_BLIMITS     1
67 #define QIF_SPACE       2
68 #define QIF_ILIMITS     4
69 #define QIF_INODES      8
70 #define QIF_BTIME       16
71 #define QIF_ITIME       32
72 #define QIF_LIMITS      (QIF_BLIMITS | QIF_ILIMITS)
73 #define QIF_USAGE       (QIF_SPACE | QIF_INODES)
74 #define QIF_TIMES       (QIF_BTIME | QIF_ITIME)
75 #define QIF_ALL         (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
76
77 struct if_dqblk {
78         u_int64_t dqb_bhardlimit;
79         u_int64_t dqb_bsoftlimit;
80         u_int64_t dqb_curspace;
81         u_int64_t dqb_ihardlimit;
82         u_int64_t dqb_isoftlimit;
83         u_int64_t dqb_curinodes;
84         u_int64_t dqb_btime;
85         u_int64_t dqb_itime;
86         u_int32_t dqb_valid;
87 };
88
89 /*
90  * Structure used for setting quota information about file via quotactl
91  * Following flags are used to specify which fields are valid
92  */
93 #define IIF_BGRACE      1
94 #define IIF_IGRACE      2
95 #define IIF_FLAGS       4
96 #define IIF_ALL         (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
97
98 struct if_dqinfo {
99         u_int64_t dqi_bgrace;
100         u_int64_t dqi_igrace;
101         u_int32_t dqi_flags;
102         u_int32_t dqi_valid;
103 };
104
105 /* Quota format identifiers */
106 #define QFMT_VFS_OLD 1
107 #define QFMT_VFS_V0  2
108
109 /* Flags supported by kernel */
110 #define V1_DQF_RSQUASH 1
111
112 /* Ioctl for getting quota size */
113 #include <sys/ioctl.h>
114 #ifndef FIOQSIZE
115         #if defined(__alpha__) || defined(__powerpc__) || defined(__sh__) || defined(__sparc__) || defined(__sparc64__)
116                 #define FIOQSIZE _IOR('f', 128, loff_t)
117         #elif defined(__arm__) || defined(__mc68000__) || defined(__s390__)
118                 #define FIOQSIZE 0x545E
119         #elif defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__ia64__) || defined(__parisc__) || defined(__cris__) || defined(__hppa__) || defined(__x86_64__)
120                 #define FIOQSIZE 0x5460
121         #elif defined(__mips__) || defined(__mips64__)
122                 #define FIOQSIZE 0x6667
123         #endif
124 #endif
125
126 long quotactl __P((int, const char *, qid_t, caddr_t));
127
128 #endif /* _QUOTA_ */