lxc: Fix compilation with glibc 2.36
[feed/packages.git] / utils / lxc / patches / 012-tree-wide-use-struct-clone_args-directly.patch
1 From 63468abd3287ebd5cc4ed9205334217031049fb4 Mon Sep 17 00:00:00 2001
2 From: Christian Brauner <brauner@kernel.org>
3 Date: Wed, 10 Aug 2022 12:03:54 +0200
4 Subject: tree-wide: use struct clone_args directly
5
6 Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
7 ---
8 meson.build | 1 -
9 src/lxc/process_utils.c | 2 +-
10 src/lxc/process_utils.h | 7 ++++---
11 src/lxc/start.c | 2 +-
12 src/lxc/start.h | 1 -
13 src/tests/reboot.c | 2 --
14 6 files changed, 6 insertions(+), 9 deletions(-)
15
16 --- a/meson.build
17 +++ b/meson.build
18 @@ -582,7 +582,6 @@ decl_headers = '''
19 #include <linux/fs.h>
20 #include <linux/if_link.h>
21 #include <linux/openat2.h>
22 -#include <linux/sched.h>
23 #include <linux/types.h>
24 '''
25
26 --- a/src/lxc/process_utils.c
27 +++ b/src/lxc/process_utils.c
28 @@ -90,7 +90,7 @@ __returns_twice pid_t lxc_raw_legacy_clo
29 __returns_twice pid_t lxc_raw_clone(unsigned long flags, int *pidfd)
30 {
31 pid_t pid;
32 - struct lxc_clone_args args = {
33 + struct clone_args args = {
34 .flags = flags,
35 .pidfd = ptr_to_u64(pidfd),
36 };
37 --- a/src/lxc/process_utils.h
38 +++ b/src/lxc/process_utils.h
39 @@ -5,7 +5,6 @@
40
41 #include "config.h"
42
43 -#include <linux/sched.h>
44 #include <sched.h>
45 #include <signal.h>
46 #include <stdbool.h>
47 @@ -165,7 +164,8 @@
48 #define u64_to_ptr(x) ((void *)(uintptr_t)x)
49 #endif
50
51 -struct lxc_clone_args {
52 +#if !HAVE_STRUCT_CLONE_ARGS
53 +struct clone_args {
54 __aligned_u64 flags;
55 __aligned_u64 pidfd;
56 __aligned_u64 child_tid;
57 @@ -178,8 +178,9 @@ struct lxc_clone_args {
58 __aligned_u64 set_tid_size;
59 __aligned_u64 cgroup;
60 };
61 +#endif
62
63 -__returns_twice static inline pid_t lxc_clone3(struct lxc_clone_args *args, size_t size)
64 +__returns_twice static inline pid_t lxc_clone3(struct clone_args *args, size_t size)
65 {
66 return syscall(__NR_clone3, args, size);
67 }
68 --- a/src/lxc/start.c
69 +++ b/src/lxc/start.c
70 @@ -1673,7 +1673,7 @@ static int lxc_spawn(struct lxc_handler
71 } else {
72 int cgroup_fd = -EBADF;
73
74 - struct lxc_clone_args clone_args = {
75 + struct clone_args clone_args = {
76 .flags = handler->clone_flags,
77 .pidfd = ptr_to_u64(&handler->pidfd),
78 .exit_signal = SIGCHLD,
79 --- a/src/lxc/start.h
80 +++ b/src/lxc/start.h
81 @@ -5,7 +5,6 @@
82
83 #include "config.h"
84
85 -#include <linux/sched.h>
86 #include <sched.h>
87 #include <signal.h>
88 #include <stdbool.h>
89 --- a/src/tests/reboot.c
90 +++ b/src/tests/reboot.c
91 @@ -32,8 +32,6 @@
92
93 #include "namespace.h"
94
95 -#include <sched.h>
96 -#include <linux/sched.h>
97 #include <linux/reboot.h>
98
99 int clone(int (*fn)(void *), void *child_stack, int flags, void *arg, ...);