Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

samples/landlock: Fix building on musl libc

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>

authored by

Brahmajit Das and committed by
Mickaël Salaün
970f8a17 e0a69cf2

+4 -1
+4 -1
samples/landlock/sandboxer.c
··· 13 13 #include <errno.h> 14 14 #include <fcntl.h> 15 15 #include <linux/landlock.h> 16 - #include <linux/prctl.h> 17 16 #include <linux/socket.h> 18 17 #include <stddef.h> 19 18 #include <stdio.h> ··· 23 24 #include <sys/syscall.h> 24 25 #include <unistd.h> 25 26 #include <stdbool.h> 27 + 28 + #if defined(__GLIBC__) 29 + #include <linux/prctl.h> 30 + #endif 26 31 27 32 #ifndef landlock_create_ruleset 28 33 static inline int