68f8a1c97622ad68a8397f39412941ee7ee5fc55
[metze/samba/wip.git] / source3 / tests / sysquotas.c
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 #ifndef SYS_DQBLK
28 #define SYS_DQBLK dqblk
29 #endif
30
31  int autoconf_quota(void);
32
33  int autoconf_quota(void)
34 {
35         int ret = -1;
36         struct SYS_DQBLK D;
37
38         ret = quotactl(Q_GETQUOTA,"/dev/hda1",0,(void *)&D);
39         
40         return ret;
41 }
42
43 #elif defined(HAVE_QUOTACTL_4B)
44 /* int quotactl(const char *path, int cmd, int id, char *addr); */
45
46 #ifdef HAVE_SYS_TYPES_H
47 #include <sys/types.h>
48 #endif
49
50 #ifdef HAVE_SYS_QUOTA_H
51 #include <sys/quota.h>
52 #else /* *BSD */
53 #include <sys/types.h>
54 #ifdef HAVE_UFS_UFS_QUOTA_H
55 #include <ufs/ufs/quota.h>
56 #endif
57 #include <machine/param.h>
58 #endif
59
60  int autoconf_quota(void)
61 {
62         int ret = -1;
63         struct dqblk D;
64
65         ret = quotactl("/",Q_GETQUOTA,0,(char *) &D);
66
67         return ret;
68 }
69
70 #elif defined(HAVE_QUOTACTL_2)
71
72 #error HAVE_QUOTACTL_2 not implemented
73
74 #else
75
76 #error Unknow QUOTACTL prototype
77
78 #endif
79
80  int main(void)
81 {       
82         autoconf_quota();
83         return 0;
84 }