From f57d8f1341587e6b2aa84b8404aa218432584206 Mon Sep 17 00:00:00 2001
From: Alex Trotsenko <alex1973tr@gmail.com>
Date: Sat, 5 Mar 2016 19:32:02 +0200
Subject: [PATCH] QFileSystemMetaData: do not treat block devices as sequential
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This patch allows handling of special block devices in random-access
mode that restores a Qt4 behavior.

Can not be tested because requires root privileges in the system.

Task-number: QTBUG-51666
Change-Id: Iaa56355f1be343c0d05b292e3c7d2e1c88724529
Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com>
Reviewed-by: Andrius Å tikonas <andrius@stikonas.eu>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
---
 src/corelib/io/qfilesystemengine.cpp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp
index a49d69d4478..02aa2ff4b72 100644
--- a/src/corelib/io/qfilesystemengine.cpp
+++ b/src/corelib/io/qfilesystemengine.cpp
@@ -258,7 +258,7 @@ void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer)
         entryFlags |= QFileSystemMetaData::FileType;
     else if ((statBuffer.st_mode & S_IFMT) == S_IFDIR)
         entryFlags |= QFileSystemMetaData::DirectoryType;
-    else
+    else if ((statBuffer.st_mode & S_IFMT) != S_IFBLK)
         entryFlags |= QFileSystemMetaData::SequentialType;
 
     // Attributes
@@ -341,6 +341,18 @@ void QFileSystemMetaData::fillFromDirEnt(const QT_DIRENT &entry)
         break;
 
     case DT_BLK:
+        knownFlagsMask = QFileSystemMetaData::LinkType
+            | QFileSystemMetaData::FileType
+            | QFileSystemMetaData::DirectoryType
+            | QFileSystemMetaData::BundleType
+            | QFileSystemMetaData::AliasType
+            | QFileSystemMetaData::SequentialType
+            | QFileSystemMetaData::ExistsAttribute;
+
+        entryFlags = QFileSystemMetaData::ExistsAttribute;
+
+        break;
+
     case DT_CHR:
     case DT_FIFO:
     case DT_SOCK:
-- 
GitLab