Configure test in lib/sysquotas.c

Stefan Metzmacher metze at metzemix.de
Tue Oct 7 11:01:51 GMT 2003


Jelmer Vernooij schrieb:

> On Mon, 2003-10-06 at 07:42, Stefan Metzmacher wrote:
> 
>>Jelmer Vernooij wrote:
>>
>>>Hi, 
>>>
>>>Why is there a configure test in the bottom of lib/sysquotas.c? Can't
>>>it be in a seperate file in the test/ directory? Currently, the basic structure 
>>>of the file is :
>>>
>>>#ifndef AUTOCONF_TEST
>>>/* sysquota functionality */
>>>
>>>#else 
>>>	/* testcase for configure, including main() */ 
>>>#endif
>>>
>>>Which is (imho) very ugly. This way we're doing two compiles
>>>on this file (once in configure, once in the make process) and there
>>>already is a seperate directory for large configure tests.
>>
>>I'll create a patch to move this stuff, ok?
> 
> Ok. Thanks!
here is it...


-- 

metze

-------------------------------------------
Stefan (metze) Metzmacher <metze at metzemix.de>
-------------- next part --------------
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=tdbsam2_parse_info.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=autom4te.cache --exclude=build_options.c* 3_0/source/configure.in 3_0-vfs/source/configure.in
--- 3_0/source/configure.in	Tue Oct  7 11:12:19 2003
+++ 3_0-vfs/source/configure.in	Mon Oct  6 07:55:18 2003
@@ -3083,7 +3083,7 @@ AC_TRY_RUN_STRICT([
 #define HAVE_QUOTACTL_4A 1
 #define AUTOCONF_TEST 1
 #include "confdefs.h"
-#include "${srcdir-.}/lib/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
+#include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
            samba_cv_HAVE_QUOTACTL_4A=yes,samba_cv_HAVE_QUOTACTL_4A=no,samba_cv_HAVE_QUOTACTL_4A=cross)])
 if test x"$samba_cv_HAVE_QUOTACTL_4A" = x"yes"; then
     samba_cv_SYSQUOTA_FOUND=yes;AC_DEFINE(HAVE_QUOTACTL_4A,1,[Whether long quotactl(int cmd, char *special, qid_t id, caddr_t addr) is available])
@@ -3096,7 +3096,7 @@ AC_TRY_RUN_STRICT([
 #define HAVE_QUOTACTL_4B 1
 #define AUTOCONF_TEST 1
 #include "confdefs.h"
-#include "${srcdir-.}/lib/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
+#include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
            samba_cv_HAVE_QUOTACTL_4B=yes,samba_cv_HAVE_QUOTACTL_4B=no,samba_cv_HAVE_QUOTACTL_4B=cross)])
 if test x"$samba_cv_HAVE_QUOTACTL_4B" = x"yes"; then
     echo "int quotactl(const char *path, int cmd, int id, char *addr) is not reworked for the new sys_quota api"
@@ -3110,7 +3110,7 @@ AC_TRY_RUN_STRICT([
 #define HAVE_QUOTACTL_3 1
 #define AUTOCONF_TEST 1
 #include "confdefs.h"
-#include "${srcdir-.}/lib/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
+#include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
            samba_cv_HAVE_QUOTACTL_3=yes,samba_cv_HAVE_QUOTACTL_3=no,samba_cv_HAVE_QUOTACTL_3=cross)])
 if test x"$samba_cv_HAVE_QUOTACTL_3" = x"yes"; then
     echo "CRAY int quotactl (char *spec, int request, char *arg) is NOT reworked for the sys_quota api"
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=tdbsam2_parse_info.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=autom4te.cache --exclude=build_options.c* 3_0/source/lib/sysquotas.c 3_0-vfs/source/lib/sysquotas.c
--- 3_0/source/lib/sysquotas.c	Fri Aug  1 07:18:29 2003
+++ 3_0-vfs/source/lib/sysquotas.c	Mon Oct  6 07:50:29 2003
@@ -19,8 +19,6 @@
 */
 
 
-#ifndef AUTOCONF_TEST
-
 #include "includes.h"
 
 #ifdef HAVE_SYS_QUOTAS
@@ -742,7 +740,7 @@ static int command_get_quota(const char 
 		if (lines) {
 			char *line = lines[0];
 
-			DEBUG (3, ("Read output from get_quota, \"r%s\"\n", line));
+			DEBUG (3, ("Read output from get_quota, \"%s\"\n", line));
 
 			/* we need to deal with long long unsigned here, if supported */
 
@@ -1011,99 +1009,3 @@ int sys_set_quota(const char *path, enum
 }
 #endif /* HAVE_SYS_QUOTAS */
 
-#else /* ! AUTOCONF_TEST */
-/* this is the autoconf driver to test witch quota system we should use */
-
-#if defined(HAVE_QUOTACTL_4A)
-/* long quotactl(int cmd, char *special, qid_t id, caddr_t addr) */
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#ifdef HAVE_ASM_TYPES_H
-#include <asm/types.h>
-#endif
-
-#if defined(HAVE_LINUX_QUOTA_H)
-# include <linux/quota.h>
-# 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 <sys/quota.h>
-#endif
-
-#ifndef SYS_DQBLK
-#define SYS_DQBLK dqblk
-#endif
-
- 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_QUOTA_H
-#include <sys/quota.h>
-#else /* *BSD */
-#include <sys/types.h>
-#include <ufs/ufs/quota.h>
-#include <machine/param.h>
-#endif
-
- int autoconf_quota(void)
-{
-	int ret = -1;
-	struct dqblk D;
-
-	ret = quotactl("/",Q_GETQUOTA,0,(char *) &D);
-
-	return ret;
-}
-
-#elif defined(HAVE_QUOTACTL_3)
-/* int quotactl (char *spec, int request, char *arg); */
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_QUOTA_H
-#include <sys/quota.h>
-#endif
-
- int autoconf_quota(void)
-{
-	int ret = -1;
-	struct q_request request;
-
-	ret = quotactl("/", Q_GETQUOTA, &request);
-
-	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;
-}
-#endif /* AUTOCONF_TEST */
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=tdbsam2_parse_info.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=autom4te.cache --exclude=build_options.c* 3_0/source/tests/sysquotas.c 3_0-vfs/source/tests/sysquotas.c
--- 3_0/source/tests/sysquotas.c	Thu Jan  1 01:00:00 1970
+++ 3_0-vfs/source/tests/sysquotas.c	Mon Oct  6 07:53:14 2003
@@ -0,0 +1,94 @@
+/* this test should find out what quota api is avalable on the os */
+
+#if defined(HAVE_QUOTACTL_4A)
+/* long quotactl(int cmd, char *special, qid_t id, caddr_t addr) */
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef HAVE_ASM_TYPES_H
+#include <asm/types.h>
+#endif
+
+#if defined(HAVE_LINUX_QUOTA_H)
+# include <linux/quota.h>
+# 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 <sys/quota.h>
+#endif
+
+#ifndef SYS_DQBLK
+#define SYS_DQBLK dqblk
+#endif
+
+ 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_QUOTA_H
+#include <sys/quota.h>
+#else /* *BSD */
+#include <sys/types.h>
+#include <ufs/ufs/quota.h>
+#include <machine/param.h>
+#endif
+
+ int autoconf_quota(void)
+{
+	int ret = -1;
+	struct dqblk D;
+
+	ret = quotactl("/",Q_GETQUOTA,0,(char *) &D);
+
+	return ret;
+}
+
+#elif defined(HAVE_QUOTACTL_3)
+/* int quotactl (char *spec, int request, char *arg); */
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_QUOTA_H
+#include <sys/quota.h>
+#endif
+
+ int autoconf_quota(void)
+{
+	int ret = -1;
+	struct q_request request;
+
+	ret = quotactl("/", Q_GETQUOTA, &request);
+
+	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;
+}


More information about the samba-technical mailing list