From ac4b9a47cef7a17e27fb034b787089cf07f6c3d4 Mon Sep 17 00:00:00 2001 From: Philip Sequeira Date: Tue, 11 Mar 2014 15:27:50 -0400 Subject: stream_file: network file system detection for Linux Addresses issue #558 on Linux systems. Signed-off-by: wm4 --- old-configure | 1 + stream/stream_file.c | 28 ++++++++++++++++++++++++++++ wscript | 5 +++++ 3 files changed, 34 insertions(+) diff --git a/old-configure b/old-configure index b438f8b33e..42897f3c15 100755 --- a/old-configure +++ b/old-configure @@ -3400,6 +3400,7 @@ cat > $TMPH << EOF /* we didn't bother to add actual config checks for this */ #define HAVE_BSD_FSTATFS 0 +#define HAVE_LINUX_FSTATFS 0 /* system headers */ $def_mman_h diff --git a/stream/stream_file.c b/stream/stream_file.c index 9d22bd5539..c62249bf76 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -39,6 +39,10 @@ #include #endif +#if HAVE_LINUX_FSTATFS +#include +#endif + #ifdef __MINGW32__ #include #endif @@ -129,6 +133,30 @@ static bool check_stream_network(stream_t *stream) return true; return false; +} +#elif HAVE_LINUX_FSTATFS +static bool check_stream_network(stream_t *stream) +{ + struct statfs fs; + const uint32_t stypes[] = { + 0x5346414F /*AFS*/, 0x61756673 /*AUFS*/, 0x00C36400 /*CEPH*/, + 0xFF534D42 /*CIFS*/, 0x73757245 /*CODA*/, 0x19830326 /*FHGFS*/, + 0x65735546 /*FUSEBLK*/,0x65735543 /*FUSECTL*/,0x1161970 /*GFS*/, + 0x47504653 /*GPFS*/, 0x6B414653 /*KAFS*/, 0x0BD00BD0 /*LUSTRE*/, + 0x564C /*NCP*/, 0x6969 /*NFS*/, 0x6E667364 /*NFSD*/, + 0xAAD7AAEA /*PANFS*/, 0x50495045 /*PIPEFS*/, 0x517B /*SMB*/, + 0xBEEFDEAD /*SNFS*/, 0xBACBACBC /*VMHGFS*/, 0x7461636f /*OCFS2*/, + 0 + }; + struct priv *priv = stream->priv; + if (fstatfs(priv->fd, &fs) == 0) { + for (int i=0; stypes[i]; i++) { + if (stypes[i] == fs.f_type) + return true; + } + } + return false; + } #elif defined(__MINGW32__) static bool check_stream_network(stream_t *stream) diff --git a/wscript b/wscript index 85c0083989..59b8734e22 100644 --- a/wscript +++ b/wscript @@ -201,6 +201,11 @@ iconv support use --disable-iconv.", 'desc': "BSD's fstatfs()", 'func': check_statement(['sys/param.h', 'sys/mount.h'], 'struct statfs fs; fstatfs(0, &fs)') + }, { + 'name': 'linux-fstatfs', + 'desc': "Linux's fstatfs()", + 'func': check_statement('sys/vfs.h', + 'struct statfs fs; fstatfs(0, &fs); fs.f_namelen') }, { 'name': 'sys-sysinfo-h', 'desc': 'sys/sysinfo.h', -- cgit v1.2.3