From 57ad73c4e91e8fbf7c7a0b0843c7a71760cbfa49 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Fri, 7 Jan 2011 19:42:34 +0000 Subject: [PATCH] Fix CIFS and NFS detection on Mac --- src/filesystemwatcher.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/filesystemwatcher.h b/src/filesystemwatcher.h index 874418019..aeb82c5c4 100644 --- a/src/filesystemwatcher.h +++ b/src/filesystemwatcher.h @@ -15,6 +15,7 @@ #ifdef Q_WS_MAC #include #include +#include #else #include #endif @@ -30,6 +31,10 @@ #define NFS_SUPER_MAGIC 0x6969 #endif +#ifndef SMB_SUPER_MAGIC +#define SMB_SUPER_MAGIC 0x517B +#endif + const int WATCH_INTERVAL = 10000; // 10 sec const int MAX_PARTIAL_RETRIES = 5; @@ -59,7 +64,12 @@ private: file += "."; struct statfs buf; if(!statfs(file.toLocal8Bit().constData(), &buf)) { - return (buf.f_type == (long)CIFS_MAGIC_NUMBER || buf.f_type == (long)NFS_SUPER_MAGIC); +#ifdef Q_WS_MAC + // XXX: should we make sure HAVE_STRUCT_FSSTAT_F_FSTYPENAME is defined? + return (strcmp(buf.f_fstypename, "nfs") == 0 || strcmp(buf.f_fstypename, "cifs") == 0 || strcmp(buf.f_fstypename, "smbfs") == 0); +#else + return (buf.f_type == (long)CIFS_MAGIC_NUMBER || buf.f_type == (long)NFS_SUPER_MAGIC || buf.f_type == (long)SMB_SUPER_MAGIC); +#endif } else { std::cerr << "Error: statfs() call failed for " << qPrintable(file) << ". Supposing it is a local folder..." << std::endl; switch(errno) {