From 006bdc0be0bf2ef70b3eb24d679bd49f6d8079fd Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 29 Sep 2012 14:28:57 +1000 Subject: build: Fix quota tests, including move of sysquotas.c to the top level This correctly detects quotas on FreeBSD Andrew Bartlett --- tests/sysquotas.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 tests/sysquotas.c (limited to 'tests/sysquotas.c') diff --git a/tests/sysquotas.c b/tests/sysquotas.c new file mode 100644 index 0000000000..afec3f1624 --- /dev/null +++ b/tests/sysquotas.c @@ -0,0 +1,90 @@ +/* this test should find out what quota api is available on the os */ + + int autoconf_quota(void); + +#if defined(HAVE_QUOTACTL_4A) +/* long quotactl(int cmd, char *special, qid_t id, caddr_t addr) */ + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_ASM_TYPES_H +#include +#endif + +#if defined(HAVE_LINUX_QUOTA_H) +# include +# if defined(HAVE_STRUCT_IF_DQBLK) +# define SYS_DQBLK if_dqblk +# elif defined(HAVE_STRUCT_MEM_DQBLK) +# define SYS_DQBLK mem_dqblk +# endif +#elif defined(HAVE_SYS_QUOTA_H) +# include +#endif + +#ifdef HPUX +/* HPUX has no prototype for quotactl but we test compile with strict + error checks, which would fail without function prototype */ +extern int quotactl(int cmd, const char *special, uid_t uid, void *addr); +#endif + +#ifndef SYS_DQBLK +#define SYS_DQBLK dqblk +#endif + + int autoconf_quota(void); + + int autoconf_quota(void) +{ + int ret = -1; + struct SYS_DQBLK D; + + ret = quotactl(Q_GETQUOTA,"/dev/hda1",0,(void *)&D); + + return ret; +} + +#elif defined(HAVE_QUOTACTL_4B) +/* int quotactl(const char *path, int cmd, int id, char *addr); */ + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_SYS_QUOTA_H +#include +#else /* *BSD */ +#include +#ifdef HAVE_UFS_UFS_QUOTA_H +#include +#endif +#include +#endif + + int autoconf_quota(void) +{ + int ret = -1; + struct dqblk D; + + ret = quotactl("/",Q_GETQUOTA,0,(char *) &D); + + return ret; +} + +#elif defined(HAVE_QUOTACTL_2) + +#error HAVE_QUOTACTL_2 not implemented + +#else + +#error Unknow QUOTACTL prototype + +#endif + + int main(void) +{ + autoconf_quota(); + return 0; +} -- cgit