Browse Source

Add SMB2 magic number

Closes #9671.
adaptive-webui-19844
Chocobo1 6 years ago
parent
commit
25a0147f61
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 24
      src/base/utils/fs.cpp

24
src/base/utils/fs.cpp

@ -315,18 +315,22 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path) @@ -315,18 +315,22 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path)
#if defined(Q_OS_MAC) || defined(Q_OS_OPENBSD)
// XXX: should we make sure HAVE_STRUCT_FSSTAT_F_FSTYPENAME is defined?
return ((strncmp(buf.f_fstypename, "nfs", sizeof(buf.f_fstypename)) == 0)
|| (strncmp(buf.f_fstypename, "cifs", sizeof(buf.f_fstypename)) == 0)
return ((strncmp(buf.f_fstypename, "cifs", sizeof(buf.f_fstypename)) == 0)
|| (strncmp(buf.f_fstypename, "nfs", sizeof(buf.f_fstypename)) == 0)
|| (strncmp(buf.f_fstypename, "smbfs", sizeof(buf.f_fstypename)) == 0));
#else
// usually defined in /usr/include/linux/magic.h
const unsigned long CIFS_MAGIC_NUMBER = 0xFF534D42;
const unsigned long NFS_SUPER_MAGIC = 0x6969;
const unsigned long SMB_SUPER_MAGIC = 0x517B;
return ((buf.f_type == CIFS_MAGIC_NUMBER)
|| (buf.f_type == NFS_SUPER_MAGIC)
|| (buf.f_type == SMB_SUPER_MAGIC));
// Magic number references:
// 1. /usr/include/linux/magic.h
// 2. https://github.com/coreutils/coreutils/blob/master/src/stat.c
switch (buf.f_type) {
case 0xFF534D42: // CIFS_MAGIC_NUMBER
case 0x6969: // NFS_SUPER_MAGIC
case 0x517B: // SMB_SUPER_MAGIC
case 0xFE534D42: // S_MAGIC_SMB2
return true;
default:
return false;
}
#endif
}
#endif

Loading…
Cancel
Save