Fix CIFS and NFS detection on Mac

This commit is contained in:
Christophe Dumez 2011-01-07 19:42:34 +00:00
parent a5ff654baf
commit 57ad73c4e9

View file

@ -15,6 +15,7 @@
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
#include <sys/param.h> #include <sys/param.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <string.h>
#else #else
#include <sys/vfs.h> #include <sys/vfs.h>
#endif #endif
@ -30,6 +31,10 @@
#define NFS_SUPER_MAGIC 0x6969 #define NFS_SUPER_MAGIC 0x6969
#endif #endif
#ifndef SMB_SUPER_MAGIC
#define SMB_SUPER_MAGIC 0x517B
#endif
const int WATCH_INTERVAL = 10000; // 10 sec const int WATCH_INTERVAL = 10000; // 10 sec
const int MAX_PARTIAL_RETRIES = 5; const int MAX_PARTIAL_RETRIES = 5;
@ -59,7 +64,12 @@ private:
file += "."; file += ".";
struct statfs buf; struct statfs buf;
if(!statfs(file.toLocal8Bit().constData(), &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 { } else {
std::cerr << "Error: statfs() call failed for " << qPrintable(file) << ". Supposing it is a local folder..." << std::endl; std::cerr << "Error: statfs() call failed for " << qPrintable(file) << ". Supposing it is a local folder..." << std::endl;
switch(errno) { switch(errno) {