summaryrefslogtreecommitdiff
blob: 1f4c7cf06157c40e2a02e832a41da7a687bcc402 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
From 221a94a66c4d2f6e4f2dc938ee8a63a6ca739477 Mon Sep 17 00:00:00 2001
From: Ahmad Samir <a.samirh78@gmail.com>
Date: Wed, 20 Oct 2021 20:01:40 +0200
Subject: [PATCH] KMountPoint: revert to parsing /dev/disk/by-{uuid,label}/
 manually

Apparently libblkid is causing some performance issues when resolving
UUID/LABEL tags from fstab when the device that has that UUID/LABEL isn't
present.

Parsing /dev/disk/by-* is more basic, since it's a simple check resolving
some symlinks.

Thanks to the users in the bug report for the investigative work, because
personally I couldn't reproduce the problem on my machine no matter what I
tried.

BUG: 442106
FIXED-IN: 5.88
---
 CMakeLists.txt                      |  3 +--
 src/core/CMakeLists.txt             |  5 ++---
 src/core/config-kmountpoint.h.cmake |  2 +-
 src/core/kmountpoint.cpp            | 18 ++++--------------
 4 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ca374a4cb..f1bb1a59b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -130,8 +130,7 @@ set_package_properties(ACL PROPERTIES DESCRIPTION "LibACL"
 # Used by KMountPoint
 if (CMAKE_SYSTEM_NAME MATCHES "Linux")
     find_package(LibMount REQUIRED)
-    find_package(Blkid REQUIRED)
-    set(HAVE_LIBS_MOUNT_AND_BLKID ${LibMount_FOUND} AND ${Blkid_FOUND})
+    set(HAVE_LIB_MOUNT ${LibMount_FOUND})
 endif()
 
 if (ANDROID)
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index be19e9b62..67a1b1cf7 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -236,9 +236,8 @@ if(ACL_FOUND)
   target_link_libraries(KF5KIOCore PRIVATE ${ACL_LIBS})
 endif()
 
-if(HAVE_LIBS_MOUNT_AND_BLKID)
-  # libmount links against blkid anyway
-  target_link_libraries(KF5KIOCore PRIVATE LibMount::LibMount Blkid::Blkid)
+if(HAVE_LIB_MOUNT)
+  target_link_libraries(KF5KIOCore PRIVATE LibMount::LibMount)
 endif()
 
 # this should be done by cmake, see bug 371721
diff --git a/src/core/config-kmountpoint.h.cmake b/src/core/config-kmountpoint.h.cmake
index f824d4042..3673eb141 100644
--- a/src/core/config-kmountpoint.h.cmake
+++ b/src/core/config-kmountpoint.h.cmake
@@ -1,7 +1,7 @@
 #cmakedefine01 HAVE_GETMNTINFO
 #cmakedefine01 GETMNTINFO_USES_STATVFS
 
-#cmakedefine01 HAVE_LIBS_MOUNT_AND_BLKID
+#cmakedefine01 HAVE_LIB_MOUNT
 
 #cmakedefine01 HAVE_SYS_MOUNT_H
 #cmakedefine01 HAVE_FSTAB_H
diff --git a/src/core/kmountpoint.cpp b/src/core/kmountpoint.cpp
index e2d32055c..f41cff5ee 100644
--- a/src/core/kmountpoint.cpp
+++ b/src/core/kmountpoint.cpp
@@ -44,7 +44,7 @@ static const Qt::CaseSensitivity cs = Qt::CaseSensitive;
 #endif
 
 // Linux
-#if HAVE_LIBS_MOUNT_AND_BLKID
+#if HAVE_LIB_MOUNT
 #include <libmount/libmount.h>
 #include <blkid/blkid.h>
 #endif
@@ -176,7 +176,7 @@ KMountPoint::List KMountPoint::possibleMountPoints(DetailsNeededFlags infoNeeded
 #ifdef Q_OS_WIN
     result = KMountPoint::currentMountPoints(infoNeeded);
 
-#elif HAVE_LIBS_MOUNT_AND_BLKID
+#elif HAVE_LIB_MOUNT
     if (struct libmnt_table *table = mnt_new_table()) {
         // By default parses "/etc/fstab"
         if (mnt_table_parse_fstab(table, nullptr) == 0) {
@@ -202,23 +202,13 @@ KMountPoint::List KMountPoint::possibleMountPoints(DetailsNeededFlags infoNeeded
                 // or some network mount
                 if (const char *source = mnt_fs_get_source(fs)) {
                     mp->d->m_mountedFrom = QFile::decodeName(source);
-                    if (mp->d->m_mountedFrom.startsWith(QLatin1String("UUID")) || mp->d->m_mountedFrom.startsWith(QLatin1String("LABEL"))) {
-                        // Use blkid to resolve UUID/LABEL to the device file
-                        if (char *blkSource = blkid_evaluate_spec(source, nullptr)) {
-                            mp->d->m_mountedFrom = QFile::decodeName(blkSource);
-                            free(blkSource);
-                            if ((infoNeeded & KMountPoint::NeedRealDeviceName) //
-                                && mp->d->m_mountedFrom.startsWith(QLatin1String("/dev/"))) {
-                                mp->d->m_device = mp->d->m_mountedFrom;
-                            }
-                        }
-                    }
                 }
 
                 if (infoNeeded & NeedMountOptions) {
                     mp->d->m_mountOptions = QFile::decodeName(mnt_fs_get_options(fs)).split(QLatin1Char(','));
                 }
 
+                mp->d->finalizePossibleMountPoint(infoNeeded);
                 result.append(mp);
             }
             mnt_free_iter(itr);
@@ -351,7 +341,7 @@ KMountPoint::List KMountPoint::currentMountPoints(DetailsNeededFlags infoNeeded)
         }
     }
 
-#elif HAVE_LIBS_MOUNT_AND_BLKID
+#elif HAVE_LIB_MOUNT
     if (struct libmnt_table *table = mnt_new_table()) {
         // By default, parses "/proc/self/mountinfo"
         if (mnt_table_parse_mtab(table, nullptr) == 0) {
-- 
GitLab