diff options
author | Leah Rowe <leah@libreboot.org> | 2024-07-28 16:09:35 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2024-07-28 16:09:35 +0100 |
commit | a78eaac88336922e38f33f51d7ee5d2262abdf10 (patch) | |
tree | 8d03af2911e3f4fe1748943e0bb8f938518c3c89 | |
parent | 59894ed555ecccf0346a7942e208171a21412d9b (diff) |
uefitool: Add patch working around musl libc issue
musl libc is very conservative in what it implements,
preferring a very "pure" libc implementation. this means
that it lacks many of the niceties found in others like
the GNU C Library; the latter implements many BSD libc
extensions, for example.
ACCESSPERMS is a #define in BSD libc that does:
S_IRWXU | S_IRWXG | S_IRWXO
Essentially, it provides a bitwise OR providing chmod 0777,
which can be used as shorthand in calls to functions such
as mkdir() available in all libc implementations.
In the case of uefitool, this define is indeed used on mkdir.
Conditionally re-define ACCESSPERMS, if undefined, so that musl
libc can be used when building uefitool.
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r-- | config/uefitool/patches/0001-common-filesystem-define-ACCESSPERMS-if-undefined.patch | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/config/uefitool/patches/0001-common-filesystem-define-ACCESSPERMS-if-undefined.patch b/config/uefitool/patches/0001-common-filesystem-define-ACCESSPERMS-if-undefined.patch new file mode 100644 index 00000000..56ba0cb6 --- /dev/null +++ b/config/uefitool/patches/0001-common-filesystem-define-ACCESSPERMS-if-undefined.patch @@ -0,0 +1,54 @@ +From 35f5bbf5aa7dc32f0140147737af73fd3866f455 Mon Sep 17 00:00:00 2001 +From: Leah Rowe <info@minifree.org> +Date: Sun, 28 Jul 2024 16:04:30 +0100 +Subject: [PATCH 1/1] common/filesystem: define ACCESSPERMS if undefined + +normally defined in sys/stat.h on various libc implementations, +but musl libc doesn't seem to have it, leading to this build +issue: + +common/filesystem.cpp:86:38: error: 'ACCESSPERMS' was not declared in this scope + 86 | return (mkdir(dir.toLocal8Bit(), ACCESSPERMS) == 0); + +ACCESSPERMS is typically defined as the result of bitwise OR: +S_IRWXU | S_IRWXG | S_IRWXO + +This creates the chmod permission 0777, used on the mkdir() call. + +ACCESSPERMS is supported on GNU C Library, for compatibility with +BSD libc implementations; the latter also implements ALLPERMS +and DEFFILEMODE, which don't seem to be used by uefitool regardless. + +Signed-off-by: Leah Rowe <info@minifree.org> +--- + common/filesystem.cpp | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/common/filesystem.cpp b/common/filesystem.cpp +index b2b8d65..9672e07 100644 +--- a/common/filesystem.cpp ++++ b/common/filesystem.cpp +@@ -15,6 +15,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + #include <sys/stat.h> + #include <fstream> + ++/* musl libc does not define ACCESSPERMS, seen on glibc and many bsd libc. ++ * let's do alpine linux users a massive favour, so that the code compiles. ++ */ ++#ifndef ACCESSPERMS ++#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* chmod permission: 0777 */ ++#endif ++ + bool readFileIntoBuffer(const UString& inPath, UByteArray& buf) + { + if (!isExistOnFs(inPath)) +@@ -103,4 +110,4 @@ UString getAbsPath(const UString & path) { + return UString(abs); + return path; + } +-#endif +\ No newline at end of file ++#endif +-- +2.39.2 + |