0001-common-filesystem-define-ACCESSPERMS-if-undefined.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. From 75437e2253fc70f4e3368c9d030415ce4ae52fa6 Mon Sep 17 00:00:00 2001
  2. From: Leah Rowe <info@minifree.org>
  3. Date: Sun, 28 Jul 2024 16:04:30 +0100
  4. Subject: [PATCH 1/1] common/filesystem: define ACCESSPERMS if undefined
  5. Normally defined in sys/stat.h on various libc implementations,
  6. but musl libc doesn't seem to have it, leading to this build
  7. issue:
  8. common/filesystem.cpp:86:38: error: 'ACCESSPERMS' was not declared in this scope
  9. 86 | return (mkdir(dir.toLocal8Bit(), ACCESSPERMS) == 0);
  10. ACCESSPERMS is typically defined as the result of bitwise OR:
  11. S_IRWXU | S_IRWXG | S_IRWXO
  12. This creates the chmod permission 0777, used on the mkdir() call.
  13. ACCESSPERMS is supported on GNU C Library, for compatibility with
  14. BSD libc implementations; the latter also implements ALLPERMS
  15. and DEFFILEMODE, which don't seem to be used by uefitool regardless.
  16. Do not define it on the Windows builds; only do it for the others,
  17. such as Linux.
  18. Signed-off-by: Leah Rowe <info@minifree.org>
  19. ---
  20. common/filesystem.cpp | 8 +++++++-
  21. 1 file changed, 7 insertions(+), 1 deletion(-)
  22. diff --git a/common/filesystem.cpp b/common/filesystem.cpp
  23. index b2b8d65..af5e537 100644
  24. --- a/common/filesystem.cpp
  25. +++ b/common/filesystem.cpp
  26. @@ -75,6 +75,12 @@ UString getAbsPath(const UString & path)
  27. #else
  28. #include <unistd.h>
  29. #include <stdlib.h>
  30. +
  31. +/* musl libc does not define ACCESSPERMS */
  32. +#ifndef ACCESSPERMS
  33. +#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* chmod permission: 0777 */
  34. +#endif
  35. +
  36. bool isExistOnFs(const UString & path)
  37. {
  38. struct stat buf;
  39. @@ -103,4 +109,4 @@ UString getAbsPath(const UString & path) {
  40. return UString(abs);
  41. return path;
  42. }
  43. -#endif
  44. \ No newline at end of file
  45. +#endif
  46. --
  47. 2.39.2