CVS: rdesktop configure.ac,1.12,1.13 disk.c,1.46,1.47

Michael Gernoth <[email protected]>
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21814

Modified Files:
	configure.ac disk.c 
Log Message:
Use configure to determine stat(v)fs and setmntent
Tested on:
 * Debian GNU/Linux 3.1
 * Solaris 9/10
 * Mac OSX 10.3
 * HP/UX 10.20
 * OpenBSD 3.4


Index: configure.ac
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/configure.ac,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** configure.ac	31 Mar 2005 10:49:59 -0000	1.12
--- configure.ac	2 Apr 2005 17:31:27 -0000	1.13
***************
*** 24,27 ****
--- 24,28 ----
  AC_CHECK_HEADER(langinfo.h, AC_DEFINE(HAVE_LANGINFO_H))
  AC_CHECK_HEADER(iconv.h, AC_DEFINE(HAVE_ICONV_H))
+ AC_CHECK_HEADER(unistd.h, AC_DEFINE(HAVE_UNISTD_H))
  
  rpath=""
***************
*** 391,394 ****
--- 392,623 ----
  
  #
+ # statfs stuff
+ #
+ AC_CHECK_HEADERS(sys/vfs.h)
+ AC_CHECK_HEADERS(sys/statvfs.h)
+ AC_CHECK_HEADERS(sys/statfs.h)
+ AC_CHECK_HEADERS(sys/param.h)
+ AC_CHECK_HEADERS(sys/mount.h)
+ 
+ #################################################
+ # these tests are taken from the GNU fileutils package
+ AC_CHECKING(how to get filesystem space usage)
+ space=no
+ 
+ # Test for statvfs64.
+ if test $space = no; then
+   # SVR4
+   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
+   [AC_TRY_RUN([
+ #if defined(HAVE_UNISTD_H)
+ #include <unistd.h>
+ #endif
+ #include <sys/types.h>
+ #include <sys/statvfs.h>
+   main ()
+   {
+     struct statvfs64 fsd;
+     exit (statvfs64 (".", &fsd));
+   }],
+   fu_cv_sys_stat_statvfs64=yes,
+   fu_cv_sys_stat_statvfs64=no,
+   fu_cv_sys_stat_statvfs64=cross)])
+   if test $fu_cv_sys_stat_statvfs64 = yes; then
+     space=yes
+     AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
+   fi
+ fi
+ 
+ # Perform only the link test since it seems there are no variants of the
+ # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
+ # because that got a false positive on SCO OSR5.  Adding the declaration
+ # of a `struct statvfs' causes this test to fail (as it should) on such
+ # systems.  That system is reported to work fine with STAT_STATFS4 which
+ # is what it gets when this test fails.
+ if test $space = no; then
+   # SVR4
+   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
+                  [AC_TRY_LINK([#include <sys/types.h>
+ #include <sys/statvfs.h>],
+                               [struct statvfs fsd; statvfs (0, &fsd);],
+                               fu_cv_sys_stat_statvfs=yes,
+                               fu_cv_sys_stat_statvfs=no)])
+   if test $fu_cv_sys_stat_statvfs = yes; then
+     space=yes
+     AC_DEFINE(STAT_STATVFS,1,[Whether statvfs() is available])
+   fi
+ fi
+ 
+ if test $space = no; then
+   # DEC Alpha running OSF/1
+   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
+   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
+   [AC_TRY_RUN([
+ #include <sys/param.h>
+ #include <sys/types.h>
+ #include <sys/mount.h>
+   main ()
+   {
+     struct statfs fsd;
+     fsd.f_fsize = 0;
+     exit (statfs (".", &fsd, sizeof (struct statfs)));
+   }],
+   fu_cv_sys_stat_statfs3_osf1=yes,
+   fu_cv_sys_stat_statfs3_osf1=no,
+   fu_cv_sys_stat_statfs3_osf1=no)])
+ 
+ 
+ #C_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
+   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
+     space=yes
+     AC_DEFINE(STAT_STATFS3_OSF1,1,[Whether statfs requires 3 arguments])
+   fi
+ fi
+ 
+ if test $space = no; then
+ # AIX
+   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
+ member (AIX, 4.3BSD)])
+   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
+   [AC_TRY_RUN([
+ #ifdef HAVE_SYS_PARAM_H
+ #include <sys/param.h>
+ #endif
+ #ifdef HAVE_SYS_MOUNT_H
+ #include <sys/mount.h>
+ #endif
+ #ifdef HAVE_SYS_VFS_H
+ #include <sys/vfs.h>
+ #endif
+   main ()
+   {
+   struct statfs fsd;
+   fsd.f_bsize = 0;
+   exit (statfs (".", &fsd));
+   }],
+   fu_cv_sys_stat_statfs2_bsize=yes,
+   fu_cv_sys_stat_statfs2_bsize=no,
+   fu_cv_sys_stat_statfs2_bsize=no)])
+   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
+   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
+     space=yes
+     AC_DEFINE(STAT_STATFS2_BSIZE,1,[Whether statfs requires two arguments and struct statfs has bsize property])
+   fi
+ fi
+ 
+ if test $space = no; then
+ # SVR3
+   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
+   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
+   [AC_TRY_RUN([#include <sys/types.h>
+ #include <sys/statfs.h>
+   main ()
+   {
+   struct statfs fsd;
+   exit (statfs (".", &fsd, sizeof fsd, 0));
+   }],
+     fu_cv_sys_stat_statfs4=yes,
+     fu_cv_sys_stat_statfs4=no,
+     fu_cv_sys_stat_statfs4=no)])
+   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
+   if test $fu_cv_sys_stat_statfs4 = yes; then
+     space=yes
+     AC_DEFINE(STAT_STATFS4,1,[Whether statfs requires 4 arguments])
+   fi
+ fi
+ 
+ if test $space = no; then
+ # 4.4BSD and NetBSD
+   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
+ member (4.4BSD and NetBSD)])
+   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
+   [AC_TRY_RUN([#include <sys/types.h>
+ #ifdef HAVE_SYS_PARAM_H
+ #include <sys/param.h>
+ #endif
+ #ifdef HAVE_SYS_MOUNT_H
+ #include <sys/mount.h>
+ #endif
+   main ()
+   {
+   struct statfs fsd;
+   fsd.f_fsize = 0;
+   exit (statfs (".", &fsd));
+   }],
+   fu_cv_sys_stat_statfs2_fsize=yes,
+   fu_cv_sys_stat_statfs2_fsize=no,
+   fu_cv_sys_stat_statfs2_fsize=no)])
+   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
+   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
+     space=yes
+         AC_DEFINE(STAT_STATFS2_FSIZE,1,[Whether statfs requires 2 arguments and struct statfs has fsize])
+   fi
+ fi
+ 
+ if test $space = no; then
+   # Ultrix
+   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
+   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
+   [AC_TRY_RUN([#include <sys/types.h>
+ #ifdef HAVE_SYS_PARAM_H
+ #include <sys/param.h>
+ #endif
+ #ifdef HAVE_SYS_MOUNT_H
+ #include <sys/mount.h>
+ #endif
+ #ifdef HAVE_SYS_FS_TYPES_H
+ #include <sys/fs_types.h>
+ #endif
+   main ()
+   {
+   struct fs_data fsd;
+   /* Ultrix's statfs returns 1 for success,
+      0 for not mounted, -1 for failure.  */
+   exit (statfs (".", &fsd) != 1);
+   }],
+   fu_cv_sys_stat_fs_data=yes,
+   fu_cv_sys_stat_fs_data=no,
+   fu_cv_sys_stat_fs_data=no)])
+   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
+   if test $fu_cv_sys_stat_fs_data = yes; then
+     space=yes
+     AC_DEFINE(STAT_STATFS2_FS_DATA,1,[Whether statfs requires 2 arguments and struct fs_data is available])
+   fi
+ fi
+ 
+   statxfs_includes="\
+ $ac_includes_default
+ #if HAVE_SYS_STATVFS_H
+ # include <sys/statvfs.h>
+ #endif
+ #if HAVE_SYS_VFS_H
+ # include <sys/vfs.h>
+ #endif
+ #if !HAVE_SYS_STATVFS_H && !HAVE_SYS_VFS_H
+ # if HAVE_SYS_MOUNT_H && HAVE_SYS_PARAM_H
+ /* NetBSD 1.5.2 needs these, for the declaration of struct statfs. */
+ #  include <sys/param.h>
+ #  include <sys/mount.h>
+ # elif HAVE_NETINET_IN_H && HAVE_NFS_NFS_CLNT_H && HAVE_NFS_VFS_H
+ /* Ultrix 4.4 needs these for the declaration of struct statfs.  */
+ #  include <netinet/in.h>
+ #  include <nfs/nfs_clnt.h>
+ #  include <nfs/vfs.h>
+ # endif
+ #endif
+ "
+ 
+ AC_CHECK_MEMBERS([struct statfs.f_namemax],,,[$statxfs_includes])
+ AC_CHECK_MEMBERS([struct statvfs.f_namemax],,,[$statxfs_includes])
+ AC_CHECK_MEMBERS([struct statfs.f_namelen],,,[$statxfs_includes])
+ AC_CHECK_MEMBERS([struct statvfs.f_namelen],,,[$statxfs_includes])
+ 
+ 
+ # mntent
+ #
+ AC_CHECK_HEADER(mntent.h, AC_DEFINE(HAVE_MNTENT_H))
+ AC_CHECK_FUNCS(setmntent)
+ 
+ #
  # IPv6
  #

Index: disk.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/disk.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** disk.c	15 Mar 2005 11:25:49 -0000	1.46
--- disk.c	2 Apr 2005 17:31:27 -0000	1.47
***************
*** 19,23 ****
  */
  
- #include "rdesktop.h"
  #include "disk.h"
  
--- 19,22 ----
***************
*** 39,87 ****
  #endif
  
! /* TODO: let autoconf figure out everything below... */
! #if (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
! #define SOLARIS
  #endif
  
! #if (defined(SOLARIS) || defined (__hpux) || defined(__BEOS__))
! #include <sys/statvfs.h>	/* solaris statvfs */
! /* TODO: Fix mntent-handling for solaris/hpux
!  * #include <sys/mntent.h> */
! #undef HAVE_MNTENT_H
! #define MNTENT_PATH "/etc/mnttab"
! #define STATFS_FN(path, buf) (statvfs(path,buf))
! #define STATFS_T statvfs
! #define F_NAMELEN(buf) ((buf).f_namemax)
  
! #elif (defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__APPLE__))
  #include <sys/param.h>
  #include <sys/mount.h>
! #define STATFS_FN(path, buf) (statfs(path,buf))
  #define STATFS_T statfs
! #define F_NAMELEN(buf) (NAME_MAX)
  
! #elif (defined(__SGI_IRIX__))
! #include <sys/types.h>
! #include <sys/statvfs.h>
  #define STATFS_FN(path, buf) (statvfs(path,buf))
  #define STATFS_T statvfs
! #define F_NAMELEN(buf) ((buf).f_namemax)
  
! #elif (defined(__alpha) && !defined(linux))
! #include <sys/mount.h>		/* osf1 statfs */
! #define STATFS_FN(path, buf) (statfs(path,buf,sizeof(buf)))
! #define STATFS_T statfs
! #define F_NAMELEN(buf) (255)
  
! #else
! #include <sys/vfs.h>		/* linux statfs */
! #include <mntent.h>
! #define HAVE_MNTENT_H
! #define MNTENT_PATH "/etc/mtab"
  #define STATFS_FN(path, buf) (statfs(path,buf))
  #define STATFS_T statfs
  #define F_NAMELEN(buf) ((buf).f_namelen)
  #endif
  
  extern RDPDR_DEVICE g_rdpdr_device[];
  
--- 38,125 ----
  #endif
  
! /* TODO: Fix mntent-handling for solaris
!  * #include <sys/mntent.h> */
! #if (defined(HAVE_MNTENT_H) && defined(HAVE_SETMNTENT))
! #include <mntent.h>
! #define MNTENT_PATH "/etc/mtab"
! #define USE_SETMNTENT
  #endif
  
! #ifdef HAVE_SYS_VFS_H
! #include <sys/vfs.h>
! #endif
  
! #ifdef HAVE_SYS_STATVFS_H
! #include <sys/statvfs.h>
! #endif
! 
! #ifdef HAVE_SYS_STATFS_H
! #include <sys/statfs.h>
! #endif
! 
! #ifdef HAVE_SYS_PARAM_H
  #include <sys/param.h>
+ #endif
+ 
+ #ifdef HAVE_SYS_MOUNT_H
  #include <sys/mount.h>
! #endif
! 
! #include "rdesktop.h"
! 
! #ifdef STAT_STATFS3_OSF1
! #define STATFS_FN(path, buf) (statfs(path,buf,sizeof(buf)))
  #define STATFS_T statfs
! #define USE_STATFS
! #endif
  
! #ifdef STAT_STATVFS
  #define STATFS_FN(path, buf) (statvfs(path,buf))
  #define STATFS_T statvfs
! #define USE_STATVFS
! #endif
  
! #ifdef STAT_STATVFS64
! #define STATFS_FN(path, buf) (statvfs64(path,buf))
! #define STATFS_T statvfs64
! #define USE_STATVFS
! #endif
  
! #if (defined(STAT_STATFS2_FS_DATA) || defined(STAT_STATFS2_BSIZE) || defined(STAT_STATFS2_FSIZE))
  #define STATFS_FN(path, buf) (statfs(path,buf))
  #define STATFS_T statfs
+ #define USE_STATFS
+ #endif
+ 
+ #ifdef STAT_STATFS4
+ #define STATFS_FN(path, buf) (statfs(path,buf,sizeof(buf),0))
+ #define STATFS_T statfs
+ #define USE_STATFS
+ #endif
+ 
+ #if ((defined(USE_STATFS) && defined(HAVE_STRUCT_STATFS_F_NAMEMAX)) || (defined(USE_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_NAMEMAX)))
+ #define F_NAMELEN(buf) ((buf).f_namemax)
+ #endif
+ 
+ #if ((defined(USE_STATFS) && defined(HAVE_STRUCT_STATFS_F_NAMELEN)) || (defined(USE_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_NAMELEN)))
  #define F_NAMELEN(buf) ((buf).f_namelen)
  #endif
  
+ #ifndef F_NAMELEN
+ #define F_NAMELEN(buf) (255)
+ #endif
+ 
+ /* Dummy statfs fallback */
+ #ifndef STATFS_T
+ struct dummy_statfs_t
+ {
+ 	long f_bfree = 1;
+ 	long f_bsize = 512;
+ 	long f_blocks = 1;
+ };
+ #define STATFS_T dummy_statfs_t
+ #define STATFS_FN(path,buf) 0
+ #endif
+ 
  extern RDPDR_DEVICE g_rdpdr_device[];
  
***************
*** 336,340 ****
  	}
  
! 	/*printf("Open: \"%s\"  flags: %X, accessmask: %X sharemode: %X create disp: %X\n", path, flags_and_attributes, accessmask, sharemode, create_disposition);*/
  
  	/* Get information about file and set that flag ourselfs */
--- 374,378 ----
  	}
  
! 	/*printf("Open: \"%s\"  flags: %X, accessmask: %X sharemode: %X create disp: %X\n", path, flags_and_attributes, accessmask, sharemode, create_disposition); */
  
  	/* Get information about file and set that flag ourselfs */
***************
*** 836,840 ****
  	if (memcmp(&pfinfo->notify, &notify, sizeof(NOTIFY)))
  	{
! 		/*printf("disk_check_notify found changed event\n");*/
  		memcpy(&pfinfo->notify, &notify, sizeof(NOTIFY));
  		status = STATUS_NOTIFY_ENUM_DIR;
--- 874,878 ----
  	if (memcmp(&pfinfo->notify, &notify, sizeof(NOTIFY)))
  	{
! 		/*printf("disk_check_notify found changed event\n"); */
  		memcpy(&pfinfo->notify, &notify, sizeof(NOTIFY));
  		status = STATUS_NOTIFY_ENUM_DIR;
***************
*** 927,931 ****
  
  	static FsInfoType info;
! #ifdef HAVE_MNTENT_H
  	FILE *fdfs;
  	struct mntent *e;
--- 965,969 ----
  
  	static FsInfoType info;
! #ifdef USE_SETMNTENT
  	FILE *fdfs;
  	struct mntent *e;
***************
*** 937,941 ****
  	strcpy(info.type, "RDPFS");
  
! #ifdef HAVE_MNTENT_H
  	fdfs = setmntent(MNTENT_PATH, "r");
  	if (!fdfs)
--- 975,979 ----
  	strcpy(info.type, "RDPFS");
  
! #ifdef USE_SETMNTENT
  	fdfs = setmntent(MNTENT_PATH, "r");
  	if (!fdfs)



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.