1 | /* this test should find out what quota api is available on the os */
|
---|
2 |
|
---|
3 | int autoconf_quota(void);
|
---|
4 |
|
---|
5 | #if defined(HAVE_QUOTACTL_4A)
|
---|
6 | /* long quotactl(int cmd, char *special, qid_t id, caddr_t addr) */
|
---|
7 |
|
---|
8 | #ifdef HAVE_SYS_TYPES_H
|
---|
9 | #include <sys/types.h>
|
---|
10 | #endif
|
---|
11 |
|
---|
12 | #ifdef HAVE_ASM_TYPES_H
|
---|
13 | #include <asm/types.h>
|
---|
14 | #endif
|
---|
15 |
|
---|
16 | #if defined(HAVE_LINUX_QUOTA_H)
|
---|
17 | # include <linux/quota.h>
|
---|
18 | # if defined(HAVE_STRUCT_IF_DQBLK)
|
---|
19 | # define SYS_DQBLK if_dqblk
|
---|
20 | # elif defined(HAVE_STRUCT_MEM_DQBLK)
|
---|
21 | # define SYS_DQBLK mem_dqblk
|
---|
22 | # endif
|
---|
23 | #elif defined(HAVE_SYS_QUOTA_H)
|
---|
24 | # include <sys/quota.h>
|
---|
25 | #endif
|
---|
26 |
|
---|
27 | #ifdef HPUX
|
---|
28 | /* HPUX has no prototype for quotactl but we test compile with strict
|
---|
29 | error checks, which would fail without function prototype */
|
---|
30 | extern int quotactl(int cmd, const char *special, uid_t uid, void *addr);
|
---|
31 | #endif
|
---|
32 |
|
---|
33 | #ifndef SYS_DQBLK
|
---|
34 | #define SYS_DQBLK dqblk
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | int autoconf_quota(void);
|
---|
38 |
|
---|
39 | int autoconf_quota(void)
|
---|
40 | {
|
---|
41 | int ret = -1;
|
---|
42 | struct SYS_DQBLK D;
|
---|
43 |
|
---|
44 | ret = quotactl(Q_GETQUOTA,"/dev/hda1",0,(void *)&D);
|
---|
45 |
|
---|
46 | return ret;
|
---|
47 | }
|
---|
48 |
|
---|
49 | #elif defined(HAVE_QUOTACTL_4B)
|
---|
50 | /* int quotactl(const char *path, int cmd, int id, char *addr); */
|
---|
51 |
|
---|
52 | #ifdef HAVE_SYS_TYPES_H
|
---|
53 | #include <sys/types.h>
|
---|
54 | #endif
|
---|
55 |
|
---|
56 | #ifdef HAVE_SYS_QUOTA_H
|
---|
57 | #include <sys/quota.h>
|
---|
58 | #else /* *BSD */
|
---|
59 | #include <sys/types.h>
|
---|
60 | #ifdef HAVE_UFS_UFS_QUOTA_H
|
---|
61 | #include <ufs/ufs/quota.h>
|
---|
62 | #endif
|
---|
63 | #include <machine/param.h>
|
---|
64 | #endif
|
---|
65 |
|
---|
66 | int autoconf_quota(void)
|
---|
67 | {
|
---|
68 | int ret = -1;
|
---|
69 | struct dqblk D;
|
---|
70 |
|
---|
71 | ret = quotactl("/",Q_GETQUOTA,0,(char *) &D);
|
---|
72 |
|
---|
73 | return ret;
|
---|
74 | }
|
---|
75 |
|
---|
76 | #elif defined(HAVE_QUOTACTL_2)
|
---|
77 |
|
---|
78 | #error HAVE_QUOTACTL_2 not implemented
|
---|
79 |
|
---|
80 | #else
|
---|
81 |
|
---|
82 | #error Unknow QUOTACTL prototype
|
---|
83 |
|
---|
84 | #endif
|
---|
85 |
|
---|
86 | int main(void)
|
---|
87 | {
|
---|
88 | autoconf_quota();
|
---|
89 | return 0;
|
---|
90 | }
|
---|