Skip to content

Commit 970f8a1

Browse files
listoutl0kod
authored andcommitted
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>
1 parent e0a69cf commit 970f8a1

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

samples/landlock/sandboxer.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <errno.h>
1414
#include <fcntl.h>
1515
#include <linux/landlock.h>
16-
#include <linux/prctl.h>
1716
#include <linux/socket.h>
1817
#include <stddef.h>
1918
#include <stdio.h>
@@ -25,6 +24,10 @@
2524
#include <unistd.h>
2625
#include <stdbool.h>
2726

27+
#if defined(__GLIBC__)
28+
#include <linux/prctl.h>
29+
#endif
30+
2831
#ifndef landlock_create_ruleset
2932
static inline int
3033
landlock_create_ruleset(const struct landlock_ruleset_attr *const attr,

0 commit comments

Comments
 (0)