QStorageInfo: update the detection of pseudo filesystems
Allow tmpfs filesystems to be reported, as they're often usable by the user, mounted in /tmp and in /run (the fs for $XDG_RUNTIME_DIR). But disallow anything whose device is not a pathname. This catches most of everything else that wasn't specifically tested for before, like virtual fuse filesystems, like GVFS. Change-Id: I3e15a26e0e424169ac2bffff1417b7cee0f8ec97 Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
b168c6c824
commit
d9f6b6d1f8
@ -160,12 +160,15 @@ static bool isPseudoFs(const QStorageIterator &it)
|
|||||||
|
|
||||||
QByteArray type = it.fileSystemType();
|
QByteArray type = it.fileSystemType();
|
||||||
if (type == "tmpfs")
|
if (type == "tmpfs")
|
||||||
return true;
|
return false;
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
if (type == "rootfs" || type == "rpc_pipefs")
|
if (type == "rootfs" || type == "rpc_pipefs")
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!it.device().startsWith('/'))
|
||||||
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,10 +66,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
printf("Filesystem (Type) Size Available BSize Label Mounted on\n");
|
printf("Filesystem (Type) Size Available BSize Label Mounted on\n");
|
||||||
foreach (const QStorageInfo &info, volumes) {
|
foreach (const QStorageInfo &info, volumes) {
|
||||||
const QString fsAndType = info.device() + QLatin1String(" (") +
|
QByteArray fsAndType = info.device();
|
||||||
info.fileSystemType() + QLatin1Char(')');
|
if (info.fileSystemType() != fsAndType)
|
||||||
|
fsAndType += " (" + info.fileSystemType() + ')';
|
||||||
|
|
||||||
printf("%-19s R%c ", qPrintable(fsAndType), info.isReadOnly() ? 'O' : 'W');
|
printf("%-19s R%c ", fsAndType.constData(), info.isReadOnly() ? 'O' : 'W');
|
||||||
if (fsAndType.size() > 19)
|
if (fsAndType.size() > 19)
|
||||||
printf("\n%23s", "");
|
printf("\n%23s", "");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user