]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
samples/landlock: Fix building on musl libc
authorBrahmajit Das <listout@listout.xyz>
Mon, 30 Jun 2025 20:32:48 +0000 (02:02 +0530)
committerMickaël Salaün <mic@digikod.net>
Tue, 1 Jul 2025 19:42:39 +0000 (21:42 +0200)
Building with make allyesconfig on musl results in the following

In file included from samples/landlock/sandboxer.c:22:
/usr/include/sys/prctl.h:88:8: error: redefinition of 'struct prctl_mm_map'
   88 | struct prctl_mm_map {
      |        ^~~~~~~~~~~~
In file included from samples/landlock/sandboxer.c:16:
usr/include/linux/prctl.h:134:8: note: originally defined here
  134 | struct prctl_mm_map {
      |        ^~~~~~~~~~~~

This is mainly due to difference in the sys/prctl.h between glibc and
musl. The struct prctl_mm_map is defined in sys/prctl.h in musl.

Signed-off-by: Brahmajit Das <listout@listout.xyz>
[mic: Move down the if/include/endif block]
Link: https://lore.kernel.org/r/20250630203248.16273-1-listout@listout.xyz
Signed-off-by: Mickaël Salaün <mic@digikod.net>
samples/landlock/sandboxer.c

index 4e2854c6f9a3eb2f0fb1beb892772ac6d472a3cc..e7af02f98208baa9f6f889b8a5cf794829cb7824 100644 (file)
@@ -13,7 +13,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <linux/landlock.h>
-#include <linux/prctl.h>
 #include <linux/socket.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <stdbool.h>
 
+#if defined(__GLIBC__)
+#include <linux/prctl.h>
+#endif
+
 #ifndef landlock_create_ruleset
 static inline int
 landlock_create_ruleset(const struct landlock_ruleset_attr *const attr,