1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 15:27:54 +00:00

Add SMB2 magic number

Closes #9671.
This commit is contained in:
Chocobo1 2018-10-10 09:52:35 +08:00
parent b09e32ebc0
commit 25a0147f61
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C

View File

@ -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