diff --git a/src/mpi/romio/adio/common/ad_fstype.c b/src/mpi/romio/adio/common/ad_fstype.c index 1882644c7b0..ec8ee535b88 100644 --- a/src/mpi/romio/adio/common/ad_fstype.c +++ b/src/mpi/romio/adio/common/ad_fstype.c @@ -52,7 +52,6 @@ * Otherwise we'll fall back on some OS-specific approach. */ -#ifdef HAVE_STRUCT_STATFS #ifdef HAVE_SYS_VFS_H #include #endif @@ -64,24 +63,26 @@ #endif #ifdef HAVE_SYS_MOUNT_H #include +#endif +#ifdef HAVE_SYS_STAT_H +#include #endif /* On Linux platforms, linux/nfs_fs.h is all messed up and cannot be * reliably included. */ -#if defined(ROMIO_NFS) && !defined(NFS_SUPER_MAGIC) +#if !defined(NFS_SUPER_MAGIC) #define NFS_SUPER_MAGIC 0x6969 #endif -#if defined(ROMIO_PANFS) && !defined(PAN_KERNEL_FS_CLIENT_SUPER_MAGIC) +#if !defined(PAN_KERNEL_FS_CLIENT_SUPER_MAGIC) #define PAN_KERNEL_FS_CLIENT_SUPER_MAGIC 0xAAD7AAEA #endif -#endif -#if defined(ROMIO_XFS) && !defined(XFS_SUPER_MAGIC) +#if !defined(XFS_SUPER_MAGIC) #define XFS_SUPER_MAGIC 0x58465342 #endif -#if defined(ROMIO_XFS) && !defined(EXFS_SUPER_MAGIC) +#if !defined(EXFS_SUPER_MAGIC) #define EXFS_SUPER_MAGIC 0x45584653 #endif @@ -89,15 +90,21 @@ #define PVFS2_SUPER_MAGIC (0x20030528) #endif -#if defined(ROMIO_GPFS) && !defined(GPFS_SUPER_MAGIC) +#if !defined(GPFS_SUPER_MAGIC) #define GPFS_SUPER_MAGIC 0x47504653 #endif +#ifndef LL_SUPER_MAGIC +#define LL_SUPER_MAGIC 0x0BD00BD0 +#endif + #if !defined(DAOS_SUPER_MAGIC) #define DAOS_SUPER_MAGIC (0xDA05AD10) #endif -#ifdef ROMIO_HAVE_STRUCT_STATVFS_WITH_F_BASETYPE +#define UNKNOWN_SUPER_MAGIC (0xDEADBEEF) + +#ifdef HAVE_STRUCT_STATVFS_WITH_F_BASETYPE #ifdef HAVE_SYS_STATVFS_H #include #endif @@ -112,7 +119,7 @@ #endif #endif -#ifdef ROMIO_HAVE_STRUCT_STAT_WITH_ST_FSTYPE +#ifdef HAVE_STRUCT_STAT_WITH_ST_FSTYPE #ifdef HAVE_SYS_TYPES_H #include #endif @@ -121,17 +128,19 @@ #endif #endif -/* ADIO_FileSysType_parentdir is only used if one of these is defined. - By including this test, we avoid warnings about unused static functions - from the compiler */ -#if defined(ROMIO_HAVE_STRUCT_STATVFS_WITH_F_BASETYPE) || \ - defined(HAVE_STRUCT_STATFS) || \ - defined(ROMIO_HAVE_STRUCT_STAT_WITH_ST_FSTYPE) +#ifdef HAVE_STRUCT_STAT_WITH_ST_FSID +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_MOUNT_H +#include +#endif +#endif + #ifndef ROMIO_NTFS #define ROMIO_NEEDS_ADIOPARENTDIR static void ADIO_FileSysType_parentdir(const char *filename, char **dirnamep); #endif -#endif static void ADIO_FileSysType_prefix(const char *filename, int *fstype, ADIOI_Fns ** ops, int *error_code); static void ADIO_FileSysType_fncall(const char *filename, int *fstype, int *error_code); @@ -139,6 +148,7 @@ struct ADIO_FSTypes { ADIOI_Fns *fileops; /* function table */ int fstype; /* ADIO_xxx constant */ const char *prefix; /* file prefix */ + int64_t magic; /* identifier for file system, or UNKNOWN */ }; /* @@ -149,39 +159,45 @@ struct ADIO_FSTypes { */ static struct ADIO_FSTypes fstypes[] = { #ifdef ROMIO_UFS - {&ADIO_UFS_operations, ADIO_UFS, "ufs:"}, + {&ADIO_UFS_operations, ADIO_UFS, "ufs:", UNKNOWN_SUPER_MAGIC}, #endif #ifdef ROMIO_NFS - {&ADIO_NFS_operations, ADIO_NFS, "nfs:"}, + {&ADIO_NFS_operations, ADIO_NFS, "nfs:", NFS_SUPER_MAGIC}, #endif #ifdef ROMIO_XFS - {&ADIO_XFS_operations, ADIO_XFS, "xfs:"}, + {&ADIO_XFS_operations, ADIO_XFS, "xfs:", XFS_SUPER_MAGIC}, + /* rare, but could be on some systems. Both magic values use the same ROMIO + * driver, though */ + {&ADIO_XFS_operations, ADIO_XFS, "xfs:", EXFS_SUPER_MAGIC}, #endif #ifdef ROMIO_PVFS2 - {&ADIO_PVFS2_operations, ADIO_PVFS2, "pvfs2:"}, + {&ADIO_PVFS2_operations, ADIO_PVFS2, "pvfs2:", PVFS2_SUPER_MAGIC}, #endif #ifdef ROMIO_GPFS - {&ADIO_GPFS_operations, ADIO_GPFS, "gpfs:"}, + {&ADIO_GPFS_operations, ADIO_GPFS, "gpfs:", GPFS_SUPER_MAGIC}, #endif #ifdef ROMIO_PANFS - {&ADIO_PANFS_operations, ADIO_PANFS, "panfs:"}, + {&ADIO_PANFS_operations, ADIO_PANFS, "panfs:", PAN_KERNEL_FS_CLIENT_SUPER_MAGIC}, #endif #ifdef ROMIO_LUSTRE - {&ADIO_LUSTRE_operations, ADIO_LUSTRE, "lustre:"}, + {&ADIO_LUSTRE_operations, ADIO_LUSTRE, "lustre:", LL_SUPER_MAGIC}, #endif #ifdef ROMIO_DAOS - {&ADIO_DAOS_operations, ADIO_DAOS, "daos:"}, + {&ADIO_DAOS_operations, ADIO_DAOS, "daos:", DAOS_SUPER_MAGIC}, #endif #ifdef ROMIO_TESTFS - {&ADIO_TESTFS_operations, ADIO_TESTFS, "testfs:"}, + /* never selected automatically */ + {&ADIO_TESTFS_operations, ADIO_TESTFS, "testfs:", 0}, #endif #ifdef ROMIO_IME - {&ADIO_IME_operations, ADIO_IME, "ime:"}, + /* userspace driver only selected via prefix */ + {&ADIO_IME_operations, ADIO_IME, "ime:", 0}, #endif #ifdef ROMIO_QUOBYTEFS - {&ADIO_QUOBYTEFS_operations, ADIO_QUOBYTEFS, "quobyte:"}, + /* userspace driver only selected via prefix */ + {&ADIO_QUOBYTEFS_operations, ADIO_QUOBYTEFS, "quobyte:", 0}, #endif - {0, 0, 0} /* guard entry */ + {0, 0, 0, 0} /* guard entry */ }; @@ -272,6 +288,74 @@ static void ADIO_FileSysType_parentdir(const char *filename, char **dirnamep) } #endif /* ROMIO_NTFS */ + +static int romio_statfs(const char *filename, int64_t * file_id) +{ + + int err = 0; + +#ifdef HAVE_STRUCT_STATVFS_WITH_F_BASETYPE + /* rare: old solaris machines */ + struct statvfs vfsbuf; +#endif +#if defined(HAVE_STRUCT_STATFS_F_TYPE) || defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) + /* common fs-detection logic for any modern POSIX-compliant environment, + * with the one wrinkle that some platforms (Darwin, BSD) give us a file + * system as a string, not an identifier */ + struct statfs fsbuf; +#endif +#if defined (HAVE_STRUCT_STAT_ST_FSTYPE) + struct stat sbuf; +#endif + + *file_id = UNKNOWN_SUPER_MAGIC; + +#ifdef HAVE_STRUCT_STATVFS_WITH_F_BASETYPE + err = statvfs(filename, &vfsbuf); + if (err == 0) + *file_id = vfsbuf.f_basetype; +#endif + +/* remember above how I said 'statfs with f_type' was the common linux-y way to + * report file system type? Darwin (and probably the BSDs) *also* uses f_type + * but it is "reserved" and does not give us anything meaningful. Fine. If + * configure detects f_type we'll use it here and on those "reserved" platforms + * we'll ignore that result and check the f_fstypename field */ +#ifdef HAVE_STRUCT_STATFS_F_TYPE + err = statfs(filename, &fsbuf); + if (err == 0) + *file_id = fsbuf.f_type; +#endif + + +#if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) || defined(HAVE_STRUCT_STAT_ST_FSTYPE) + /* these stat routines store the file system type in a string */ + char *fstype; +#ifdef HAVE_STRUCT_STATFS_F_FSTYPENAME + err = statfs(filename, &fsbuf); + fstype = fsbuf.f_fstypename; +#else + err = stat(filename, &sbuf); + fstype = sbuf.st_fstype; +#endif + if (err == 0) { + int i = 0; + /* any file system type not explicitly in the fstype table (ffs, hfs) + * will be "unknown" which ROMIO will service with ADIO_UFS */ + while (fstypes[i].fileops) { + /* '-1' to ignore the trailing colon */ + if (!strncasecmp(fstypes[i].prefix, fstype, strlen(fstypes[i].prefix) - 1)) { + *file_id = fstypes[i].magic; + } + i++; + } + } +#endif + + return err; + +} + /* ADIO_FileSysType_fncall - determines the file system type for a given file using a system-dependent function call @@ -291,32 +375,20 @@ Output Parameters: */ static void ADIO_FileSysType_fncall(const char *filename, int *fstype, int *error_code) { -#if defined (ROMIO_HAVE_STRUCT_STATVFS_WITH_F_BASETYPE) || defined (HAVE_STRUCT_STATFS) || defined (ROMIO_HAVE_STRUCT_STAT_WITH_ST_FSTYPE) int err; -#endif - -#ifdef ROMIO_HAVE_STRUCT_STATVFS_WITH_F_BASETYPE - struct statvfs vfsbuf; -#endif -#ifdef HAVE_STRUCT_STATFS - struct statfs fsbuf; -#endif -#ifdef ROMIO_HAVE_STRUCT_STAT_WITH_ST_FSTYPE - struct stat sbuf; -#endif + int64_t file_id; static char myname[] = "ADIO_RESOLVEFILETYPE_FNCALL"; + /* NFS can get stuck and end up returning ESTALE "forever" */ #define MAX_ESTALE_RETRY 10000 int retry_cnt; *error_code = MPI_SUCCESS; -#ifdef ROMIO_HAVE_STRUCT_STATVFS_WITH_F_BASETYPE - /* rare: old solaris machines */ retry_cnt = 0; do { - err = statvfs(filename, &vfsbuf); + err = romio_statfs(filename, &file_id); } while (err && (errno == ESTALE) && retry_cnt++ < MAX_ESTALE_RETRY); if (err) { @@ -329,60 +401,8 @@ static void ADIO_FileSysType_fncall(const char *filename, int *fstype, int *erro if (errno == ENOENT) { char *dir; ADIO_FileSysType_parentdir(filename, &dir); - err = statvfs(dir, &vfsbuf); - - ADIOI_Free(dir); - } else { - *error_code = ADIOI_Err_create_code(myname, filename, errno); - if (*error_code != MPI_SUCCESS) - return; - } - } - - /* --BEGIN ERROR HANDLING-- */ - if (err) { - *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, - myname, __LINE__, MPI_ERR_NO_SUCH_FILE, - "**filename", "**filename %s", filename); - return; - } - /* --END ERROR HANDLING-- */ - - /* FPRINTF(stderr, "%s\n", vfsbuf.f_basetype); */ - if (!strncmp(vfsbuf.f_basetype, "nfs", 3)) { - *fstype = ADIO_NFS; - return; - } - if (!strncmp(vfsbuf.f_basetype, "xfs", 3)) { - *fstype = ADIO_XFS; - return; - } -#ifdef ROMIO_UFS - /* if UFS support is enabled, default to that */ - *fstype = ADIO_UFS; - return; -#endif + err = romio_statfs(dir, &file_id); - /* --BEGIN ERROR HANDLING-- */ - *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, - myname, __LINE__, MPI_ERR_NO_SUCH_FILE, - "**filename", "**filename %s", filename); - /* --END ERROR HANDLING-- */ -#endif /* STATVFS APPROACH */ - -#if defined(HAVE_STRUCT_STATFS) && defined(HAVE_STATFS) - /* common automagic fs-detection logic for any modern POSX-compliant - * environment */ - retry_cnt = 0; - do { - err = statfs(filename, &fsbuf); - } while (err && (errno == ESTALE) && retry_cnt++ < MAX_ESTALE_RETRY); - - if (err) { - if (errno == ENOENT) { - char *dir; - ADIO_FileSysType_parentdir(filename, &dir); - err = statfs(dir, &fsbuf); ADIOI_Free(dir); } else { *error_code = ADIOI_Err_create_code(myname, filename, errno); @@ -400,163 +420,42 @@ static void ADIO_FileSysType_fncall(const char *filename, int *fstype, int *erro } /* --END ERROR HANDLING-- */ -#ifdef ROMIO_HAVE_STRUCT_STATFS_WITH_F_FSTYPENAME - /* less common: Darwin and OpenBSD */ - if (!strncmp("nfs", fsbuf.f_fstypename, 3)) { - *fstype = ADIO_NFS; - return; - } -#endif - - -#ifdef ROMIO_HAVE_STRUCT_STATFS_WITH_F_TYPE - -#ifdef ROMIO_GPFS - if (fsbuf.f_type == GPFS_SUPER_MAGIC) { - *fstype = ADIO_GPFS; - return; - } -#endif - - /* FPRINTF(stderr, "%d\n", fsbuf.f_type); */ -#ifdef NFS_SUPER_MAGIC - if (fsbuf.f_type == NFS_SUPER_MAGIC) { - *fstype = ADIO_NFS; - return; - } -#endif - -#ifdef ROMIO_LUSTRE -#ifndef LL_SUPER_MAGIC -#define LL_SUPER_MAGIC 0x0BD00BD0 -#endif - if (fsbuf.f_type == LL_SUPER_MAGIC) { - *fstype = ADIO_LUSTRE; - return; - } -#endif - -#ifdef DAOS_SUPER_MAGIC - if (fsbuf.f_type == DAOS_SUPER_MAGIC) { - *fstype = ADIO_DAOS; - return; - } -#endif - -#ifdef PAN_KERNEL_FS_CLIENT_SUPER_MAGIC - if (fsbuf.f_type == PAN_KERNEL_FS_CLIENT_SUPER_MAGIC) { - *fstype = ADIO_PANFS; - return; - } -#endif - -#ifdef MOUNT_NFS - if (fsbuf.f_type == MOUNT_NFS) { - *fstype = ADIO_NFS; - return; - } -#endif - -#ifdef MOUNT_PFS - if (fsbuf.f_type == MOUNT_PFS) { - *fstype = ADIO_PFS; - return; - } -#endif - -#ifdef PVFS_SUPER_MAGIC - if (fsbuf.f_type == PVFS_SUPER_MAGIC) { - *fstype = ADIO_PVFS; - return; - } -#endif - -#ifdef PVFS2_SUPER_MAGIC - if (fsbuf.f_type == PVFS2_SUPER_MAGIC) { - *fstype = ADIO_PVFS2; - return; - } -#endif - -#ifdef XFS_SUPER_MAGIC - if (fsbuf.f_type == XFS_SUPER_MAGIC || fsbuf.f_type == EXFS_SUPER_MAGIC) { - *fstype = ADIO_XFS; - return; - } -#endif - -#endif /*ROMIO_HAVE_STRUCT_STATFS_WITH_F_TYPE */ - -#ifdef ROMIO_UFS - /* if UFS support is enabled, default to that */ - *fstype = ADIO_UFS; - return; -#endif - /* --BEGIN ERROR HANDLING-- */ - *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, - myname, __LINE__, MPI_ERR_NO_SUCH_FILE, - "**filename", "**filename %s", filename); - /* --END ERROR HANDLING-- */ -#endif /* STATFS APPROACH */ - -#ifdef ROMIO_HAVE_STRUCT_STAT_WITH_ST_FSTYPE - /* rare: maybe old NEC SX or SGI IRIX machines */ - retry_cnt = 0; - do { - err = stat(filename, &sbuf); - } while (err && (errno == ESTALE) && retry_cnt++ < MAX_ESTALE_RETRY); - - if (err) { - if (errno == ENOENT) { - char *dir; - ADIO_FileSysType_parentdir(filename, &dir); - err = stat(dir, &sbuf); - ADIOI_Free(dir); - } else { - *error_code = ADIOI_Err_create_code(myname, filename, errno); - if (*error_code != MPI_SUCCESS) - return; - } - } - - if (err) { - /* --BEGIN ERROR HANDLING-- */ - *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, - myname, __LINE__, MPI_ERR_NO_SUCH_FILE, - "**filename", "**filename %s", filename); - /* --END ERROR HANDLING-- */ - return; - } else { - if (!strcmp(sbuf.st_fstype, "nfs")) + switch (file_id) { + case NFS_SUPER_MAGIC: *fstype = ADIO_NFS; - else - *fstype = ADIO_SFS; /* assuming SX4 for now */ + return; + case XFS_SUPER_MAGIC: + case EXFS_SUPER_MAGIC: + *fstype = ADIO_XFS; + return; + case GPFS_SUPER_MAGIC: + *fstype = ADIO_GPFS; + return; + case LL_SUPER_MAGIC: + *fstype = ADIO_LUSTRE; + return; + case DAOS_SUPER_MAGIC: + *fstype = ADIO_DAOS; + return; + case PAN_KERNEL_FS_CLIENT_SUPER_MAGIC: + *fstype = ADIO_PANFS; + return; + case PVFS2_SUPER_MAGIC: + *fstype = ADIO_PVFS2; + return; + default: + /* UFS support if we don't know what else to use */ + *fstype = ADIO_UFS; + return; } -#endif /* STAT APPROACH */ - -#ifdef ROMIO_NTFS - MPL_UNREFERENCED_ARG(filename); - MPL_UNREFERENCED_ARG(error_code); - *fstype = ADIO_NTFS; /* only supported FS on Windows */ -#elif defined(ROMIO_NFS) - *fstype = ADIO_NFS; -#elif defined(ROMIO_UFS) - *fstype = ADIO_UFS; -#else - /* --BEGIN ERROR HANDLING-- */ - *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, - myname, __LINE__, MPI_ERR_NO_SUCH_FILE, - "**filename", "**filename %s", filename); - /* --END ERROR HANDLING-- */ -#endif } /* all proceeses opening, creating, or deleting a file end up invoking several * stat system calls (unless a fs prefix is given). Cary out this file system * detection in a more scalable way by having rank 0 stat the file and broadcast the result (fs type and error code) to the other mpi processes */ -static void ADIO_FileSysType_fncall_scalable(MPI_Comm comm, const char *filename, int *file_system, - int *error_code) +static void ADIO_FileSysType_fncall_scalable(MPI_Comm comm, const char *filename, + int *file_system, int *error_code) { int rank; int buf[2]; diff --git a/src/mpi/romio/configure.ac b/src/mpi/romio/configure.ac index 1202458c479..6d1a887490b 100644 --- a/src/mpi/romio/configure.ac +++ b/src/mpi/romio/configure.ac @@ -1225,149 +1225,44 @@ AS_CASE([$host_os], # # Check for statfs (many) and specifically f_fstypename field (BSD) # -AC_CHECK_HEADERS(sys/vfs.h sys/param.h sys/mount.h sys/statvfs.h) -AC_CHECK_FUNCS([statfs]) -AC_MSG_CHECKING([whether struct statfs properly defined]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #ifdef HAVE_SYS_VFS_H - #include - #endif - #ifdef HAVE_SYS_STATVFS_H - #include - #endif - #ifdef HAVE_SYS_PARAM_H - #include - #endif - #ifdef HAVE_SYS_MOUNT_H - #include - #endif - ]],[[ - struct statfs f; - ]])], - pac_cv_have_statfs=yes,pac_cv_have_statfs=no -) -AC_MSG_RESULT($pac_cv_have_statfs) -# At this point, we could check for whether defining -# __SWORD_TYPE as sizet_t or int/long (size of pointer) -# would help. FIXME - -if test "$pac_cv_have_statfs" = yes ; then - AC_DEFINE(HAVE_STRUCT_STATFS,1,[Define if struct statfs can be compiled]) -fi -AC_MSG_CHECKING([for f_type member of statfs structure]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #ifdef HAVE_SYS_VFS_H - #include - #endif - #ifdef HAVE_SYS_STATVFS_H - #include - #endif - #ifdef HAVE_SYS_PARAM_H - #include - #endif - #ifdef HAVE_SYS_MOUNT_H - #include - #endif - #ifdef HAVE_STRING_H - #include - #endif - ]],[[ - struct statfs f; - memset(&f, 0, sizeof(f)); - f.f_type = 0; - ]])], - pac_cv_have_statfs_f_type=yes, - pac_cv_have_statfs_f_type=no -) -AC_MSG_RESULT($pac_cv_have_statfs_f_type) -if test $pac_cv_have_statfs_f_type = yes ; then - AC_DEFINE(ROMIO_HAVE_STRUCT_STATFS_WITH_F_TYPE, 1,[Define if statfs has f_type]) -fi - - -AC_MSG_CHECKING([for f_fstypename member of statfs structure]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #ifdef HAVE_SYS_VFS_H - #include - #endif - #ifdef HAVE_SYS_STATVFS_H - #include - #endif - #ifdef HAVE_SYS_PARAM_H - #include - #endif - #ifdef HAVE_SYS_MOUNT_H - #include - #endif - #ifdef HAVE_STRING_H - #include - #endif - ]],[[ - struct statfs f; - memset(&f, 0, sizeof(f)); - strncmp("nfs", f.f_fstypename, 3); - ]])], - pac_cv_have_statfs_f_fstypename=yes, - pac_cv_have_statfs_f_fstypename=no -) -AC_MSG_RESULT($pac_cv_have_statfs_f_fstypename) -if test $pac_cv_have_statfs_f_fstypename = yes ; then - AC_DEFINE(ROMIO_HAVE_STRUCT_STATFS_WITH_F_FSTYPENAME, 1,[Define if statfs has f_fstypename]) -fi - -# -# Check for stat and st_fstype field (NEC SX4) -# -AC_CHECK_HEADERS(sys/stat.h sys/types.h unistd.h) -AC_CHECK_FUNCS(stat, - AC_DEFINE(HAVE_STAT, 1, Define if stat function is present) - AC_MSG_CHECKING([for st_fstype member of stat structure]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #ifdef HAVE_SYS_TYPES_H - #include - #endif - #ifdef HAVE_SYS_STAT_H - #include - #endif - #ifdef HAVE_UNISTD_H - #include - #endif - ]],[[ - struct stat s; - s.st_fstype = NULL; - ]])], - AC_MSG_RESULT(yes) - AC_DEFINE(ROMIO_HAVE_STRUCT_STAT_WITH_ST_FSTYPE, 1, Define if struct stat has a st_fstype member), - AC_MSG_RESULT(no) - ) -) - -# -# Check for statvfs and f_basetype field (Solaris, Irix, AIX, etc.) -# -AC_CHECK_HEADERS(sys/types.h sys/statvfs.h sys/vfs.h) -AC_CHECK_FUNCS(statvfs, - AC_DEFINE(HAVE_STATVFS, 1, Define if statvfs function is present) - AC_MSG_CHECKING([for f_basetype member of statvfs structure]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #ifdef HAVE_SYS_TYPES_H - #include - #endif - #ifdef HAVE_SYS_VFS_H - #include - #endif - #ifdef HAVE_SYS_STATVFS_H - #include - #endif - ]], [[ - struct statvfs foo; - foo.f_basetype[0] = 'a'; - ]])], - AC_MSG_RESULT(yes) - AC_DEFINE(ROMIO_HAVE_STRUCT_STATVFS_WITH_F_BASETYPE, 1, defined if struct statvfs has a f_basetype member), - AC_MSG_RESULT(no) - ) -) +AC_CHECK_HEADERS(sys/vfs.h sys/param.h sys/mount.h sys/statvfs.h sys/stat.h sys/type.h unistd.h) +AC_CHECK_FUNCS([statvfs statfs stat]) +# Who would imagine so many different ways to determine "what kind of file system is this?" +# on old systems we used to check for statfs.f_fsid, but while it can be a file +# system type identifier it is more commonly used to generate a unique "fsid,inode" tuple +# struct statvfs.f_basetype -- Solaris, Irix, AIX +# struct statfs.f_fstypename -- BSD, NetBSD-3.0+, Darwin +# struct statfs.f_type -- Linux +# struct stat.st_fstype -- NEC SX4 (!!) + + +AC_CHECK_MEMBERS([struct statvfs.f_basetype, + struct statfs.f_fstypename, + struct statfs.f_type, + struct stat.st_fstype],[],[], + AC_INCLUDES_DEFAULT + [#ifdef HAVE_SYS_VFS_H + #include + #endif + #ifdef HAVE_SYS_PARAM_H + #include + #endif + #ifdef HAVE_SYS_MOUNT_H + #include + #endif + #ifdef HAVE_SYS_STATFS_H + #include + #endif + #ifdef HAVE_SYS_STAT_H + #include + #endif + #ifdef HAVE_SYS_TYPE_H + #include + #endif + #ifdef HAVE_UNISTD_H + #include + #endif + ]) AC_CHECK_TYPE([blksize_t],[],[AC_DEFINE_UNQUOTED([blksize_t],[__blksize_t],[Provide blksize_t if not available]) ], [[ #ifdef HAVE_SYS_TYPES_H