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 git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@872 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
parent
e34eecdad0
commit
f1254372b7
229
configure.ac
229
configure.ac
@ -23,6 +23,7 @@ AC_CHECK_HEADER(sys/strtio.h, AC_DEFINE(HAVE_SYS_STRTIO_H))
|
||||
AC_CHECK_HEADER(locale.h, AC_DEFINE(HAVE_LOCALE_H))
|
||||
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=""
|
||||
|
||||
@ -389,6 +390,234 @@ AC_DEFUN([TYPE_SOCKLEN_T],
|
||||
|
||||
TYPE_SOCKLEN_T
|
||||
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
112
disk.c
112
disk.c
@ -18,7 +18,6 @@
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "rdesktop.h"
|
||||
#include "disk.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -38,51 +37,90 @@
|
||||
#define DIRFD(a) ((a)->DIR_FD_MEMBER_NAME)
|
||||
#endif
|
||||
|
||||
/* TODO: let autoconf figure out everything below... */
|
||||
#if (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
|
||||
#define SOLARIS
|
||||
/* 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
|
||||
|
||||
#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)
|
||||
#ifdef HAVE_SYS_VFS_H
|
||||
#include <sys/vfs.h>
|
||||
#endif
|
||||
|
||||
#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>
|
||||
#ifdef HAVE_SYS_STATVFS_H
|
||||
#include <sys/statvfs.h>
|
||||
#define STATFS_FN(path, buf) (statvfs(path,buf))
|
||||
#define STATFS_T statvfs
|
||||
#define F_NAMELEN(buf) ((buf).f_namemax)
|
||||
#endif
|
||||
|
||||
#elif (defined(__alpha) && !defined(linux))
|
||||
#include <sys/mount.h> /* osf1 statfs */
|
||||
#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 F_NAMELEN(buf) (255)
|
||||
#define USE_STATFS
|
||||
#endif
|
||||
|
||||
#else
|
||||
#include <sys/vfs.h> /* linux statfs */
|
||||
#include <mntent.h>
|
||||
#define HAVE_MNTENT_H
|
||||
#define MNTENT_PATH "/etc/mtab"
|
||||
#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[];
|
||||
|
||||
FILEINFO g_fileinfo[MAX_OPEN_FILES];
|
||||
@ -335,7 +373,7 @@ disk_create(uint32 device_id, uint32 accessmask, uint32 sharemode, uint32 create
|
||||
break;
|
||||
}
|
||||
|
||||
/*printf("Open: \"%s\" flags: %X, accessmask: %X sharemode: %X create disp: %X\n", path, flags_and_attributes, accessmask, sharemode, create_disposition);*/
|
||||
/*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 */
|
||||
if ((stat(path, &filestat) == 0) && (S_ISDIR(filestat.st_mode)))
|
||||
@ -835,7 +873,7 @@ disk_check_notify(NTHANDLE handle)
|
||||
|
||||
if (memcmp(&pfinfo->notify, ¬ify, sizeof(NOTIFY)))
|
||||
{
|
||||
/*printf("disk_check_notify found changed event\n");*/
|
||||
/*printf("disk_check_notify found changed event\n"); */
|
||||
memcpy(&pfinfo->notify, ¬ify, sizeof(NOTIFY));
|
||||
status = STATUS_NOTIFY_ENUM_DIR;
|
||||
}
|
||||
@ -926,7 +964,7 @@ FsVolumeInfo(char *fpath)
|
||||
{
|
||||
|
||||
static FsInfoType info;
|
||||
#ifdef HAVE_MNTENT_H
|
||||
#ifdef USE_SETMNTENT
|
||||
FILE *fdfs;
|
||||
struct mntent *e;
|
||||
#endif
|
||||
@ -936,7 +974,7 @@ FsVolumeInfo(char *fpath)
|
||||
strcpy(info.label, "RDESKTOP");
|
||||
strcpy(info.type, "RDPFS");
|
||||
|
||||
#ifdef HAVE_MNTENT_H
|
||||
#ifdef USE_SETMNTENT
|
||||
fdfs = setmntent(MNTENT_PATH, "r");
|
||||
if (!fdfs)
|
||||
return &info;
|
||||
|
@ -4,6 +4,8 @@ rdesktop (1.?.?)
|
||||
* libao sound-driver (for Mac OSX and others)
|
||||
* Unicode support for transmitted strings/filenames
|
||||
* Added korean keymap
|
||||
* Xembed fixes to work with krdc correctly
|
||||
* Portability fixes
|
||||
|
||||
rdesktop (1.4.0)
|
||||
* Basic disk-, parallel-, printer- and serial-redirection
|
||||
|
Loading…
Reference in New Issue
Block a user