1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) 2017-2021 FUJITSU LIMITED. All rights reserved
4 * Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
5 * Author: Yang Xu <xuyang2018.jy@fujitsu.com>
6 */
7
8 #ifndef LAPI_QUOTACTL_H__
9 #define LAPI_QUOTACTL_H__
10
11 #include "config.h"
12 #include <sys/quota.h>
13 #include "lapi/syscalls.h"
14
15 #ifndef HAVE_QUOTACTL_FD
quotactl_fd(int fd,int cmd,int id,caddr_t addr)16 static inline int quotactl_fd(int fd, int cmd, int id, caddr_t addr)
17 {
18 return tst_syscall(__NR_quotactl_fd, fd, cmd, id, addr);
19 }
20 #endif
21
22 #ifdef HAVE_STRUCT_IF_NEXTDQBLK
23 # include <linux/quota.h>
24 #else
25 # include <stdint.h>
26 struct if_nextdqblk {
27 uint64_t dqb_bhardlimit;
28 uint64_t dqb_bsoftlimit;
29 uint64_t dqb_curspace;
30 uint64_t dqb_ihardlimit;
31 uint64_t dqb_isoftlimit;
32 uint64_t dqb_curinodes;
33 uint64_t dqb_btime;
34 uint64_t dqb_itime;
35 uint32_t dqb_valid;
36 uint32_t dqb_id;
37 };
38 #endif /* HAVE_STRUCT_IF_NEXTDQBLK */
39
40 #ifndef HAVE_STRUCT_FS_QUOTA_STATV
41 # include <stdint.h>
42 struct fs_qfilestatv {
43 uint64_t qfs_ino;
44 uint64_t qfs_nblks;
45 uint32_t qfs_nextents;
46 uint32_t qfs_pad;
47 };
48
49 struct fs_quota_statv {
50 int8_t qs_version;
51 uint8_t qs_pad1;
52 uint16_t qs_flags;
53 uint32_t qs_incoredqs;
54 struct fs_qfilestatv qs_uquota;
55 struct fs_qfilestatv qs_gquota;
56 struct fs_qfilestatv qs_pquota;
57 int32_t qs_btimelimit;
58 int32_t qs_itimelimit;
59 int32_t qs_rtbtimelimit;
60 uint16_t qs_bwarnlimit;
61 uint16_t qs_iwarnlimit;
62 uint64_t qs_pad2[8];
63 };
64 # define FS_QSTATV_VERSION1 1
65 #endif /* HAVE_STRUCT_FS_QUOTA_STATV */
66
67 #ifndef PRJQUOTA
68 # define PRJQUOTA 2
69 #endif
70
71 #ifndef Q_XQUOTARM
72 # define Q_XQUOTARM XQM_CMD(6)
73 #endif
74
75 #ifndef Q_XGETQSTATV
76 # define Q_XGETQSTATV XQM_CMD(8)
77 #endif
78
79 #ifndef Q_XGETNEXTQUOTA
80 # define Q_XGETNEXTQUOTA XQM_CMD(9)
81 #endif
82
83 #ifndef Q_GETNEXTQUOTA
84 # define Q_GETNEXTQUOTA 0x800009 /* get disk limits and usage >= ID */
85 #endif
86
87 #ifndef QFMT_VFS_V0
88 # define QFMT_VFS_V0 2
89 #endif
90
91 #ifndef QFMT_VFS_V1
92 # define QFMT_VFS_V1 4
93 #endif
94
95 #endif /* LAPI_QUOTACTL_H__ */
96