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
|
From ca2c6c4a0a90ed467af9c4c73b918dd4bf720f2a Mon Sep 17 00:00:00 2001
From: Stefan Hundhammer <Stefan.Hundhammer@gmx.de>
Date: Wed, 9 Feb 2022 11:05:31 +0100
Subject: [PATCH] Fixed GitHub issue #187: ALLPERMS not defined in libc-musl
---
src/BrokenLibc.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
src/FileInfo.cpp | 1 +
src/FormatUtil.cpp | 1 +
src/src.pro | 3 ++-
4 files changed, 49 insertions(+), 1 deletion(-)
create mode 100644 src/BrokenLibc.h
diff --git a/src/BrokenLibc.h b/src/BrokenLibc.h
new file mode 100644
index 00000000..8bdf2a84
--- /dev/null
+++ b/src/BrokenLibc.h
@@ -0,0 +1,45 @@
+/*
+ * File name: BrokenLibc.h
+ * Summary: Substitutes for common system-level defines
+ * License: GPL V2 - See file LICENSE for details.
+ *
+ * Author: Stefan Hundhammer <Stefan.Hundhammer@gmx.de>
+ */
+
+#ifndef BrokenLibc_h
+#define BrokenLibc_h
+
+// This contains common #defines that are present on modern systems, but
+// sometimes not on systems that insist to exchange known working subsystems
+// such as glibc with their own version, commonly because of the "not invented
+// here" syndrome.
+
+
+// Make sure the original defines are available regardless of include order
+
+#include <sys/stat.h> // ALLPERMS
+
+
+#ifndef ALLPERMS
+# define ALLPERMS 07777
+
+// Uncomment for debugging:
+// # warning "Using ALLPERMS replacement"
+
+// Not available in musl-libc used on Gentoo:
+//
+// https://github.com/shundhammer/qdirstat/issues/187
+//
+// Original from Linux / glibc /usr/include/x86_64-linux-gnu/sys/stat.h :
+//
+// #define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)/* 07777 */
+//
+// But that might induce more complaints because any of S_IRWXU, S_IRWXG
+// etc. may also not be defined on such a system. So let's keep it simple.
+// If they also use a different bit pattern for those permissions, that's their
+// problem.
+#endif
+
+
+
+#endif // BrokenLibc_h
diff --git a/src/FileInfo.cpp b/src/FileInfo.cpp
index 6be13a8d..d8195819 100644
--- a/src/FileInfo.cpp
+++ b/src/FileInfo.cpp
@@ -26,6 +26,7 @@
#include "SysUtil.h"
#include "Logger.h"
#include "Exception.h"
+#include "BrokenLibc.h" // ALLPERMS
// Some filesystems (NTFS seems to be among them) may handle block fragments
// well. Don't report files as "sparse" files if the block size is only a few
diff --git a/src/FormatUtil.cpp b/src/FormatUtil.cpp
index 6c755d79..43ca9ec4 100644
--- a/src/FormatUtil.cpp
+++ b/src/FormatUtil.cpp
@@ -11,6 +11,7 @@
#include <QTextStream>
#include "FormatUtil.h"
+#include "BrokenLibc.h" // ALLPERMS
using namespace QDirStat;
diff --git a/src/src.pro b/src/src.pro
index c9616462..50b51ca4 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -157,7 +157,8 @@ HEADERS = \
ActionManager.h \
AdaptiveTimer.h \
Attic.h \
- BreadcrumbNavigator.h \
+ BreadcrumbNavigator.h \
+ BrokenLibc.h \
BucketsTableModel.h \
BusyPopup.h \
Cleanup.h \
|