kernel: fix gen_init_cpio build on macOS hosts
Kernel ae18b94099b0 (2025-08-20, in 6.18) introduced a dependency on the Linux-specific O_LARGEFILE, and kernel 97169cd6d95b (2025-08-20, in 6.18) introduced a dependency on the Linux-specific copy_file_range. Both of these commits were a part of the https://lore.kernel.org/all/20250819032607.28727-1-ddiss@suse.de/ series. These new dependencies may not be available on non-Linux systems, although it is possible to cross-build Linux on non-Linux build hosts, and it is appropriate to run tools like gen_init_cpio on such build hosts. It is straightforward to avoid these Linux-specific features when not building on Linux. This fixes: HOSTCC usr/gen_init_cpio usr/gen_init_cpio.c:460:16: error: call to undeclared function 'copy_file_range'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 460 | this_read = copy_file_range(file, NULL, outfd, N... | ^ usr/gen_init_cpio.c:677:31: error: use of undeclared identifier 'O_LARGEFILE' 677 | O_WRONLY | O_CREAT | O_LARGEFILE | O_TRUNC, | ^~~~~~~~~~~ 2 errors generated. gmake[7]: *** [scripts/Makefile.host:114: usr/gen_init_cpio] Error 1 Signed-off-by: Mark Mentovai <mark@mentovai.com> Link: https://github.com/openwrt/openwrt/pull/23612 Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
parent
b0d2cee3ea
commit
f5c5ccd236
@ -0,0 +1,52 @@
|
|||||||
|
From 60e044199e773df4863405dba0f7abe16a43282d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Mentovai <mark@mentovai.com>
|
||||||
|
Date: Fri, 29 May 2026 12:48:31 -0400
|
||||||
|
Subject: [PATCH] gen_init_cpio: fix build on macOS hosts
|
||||||
|
|
||||||
|
ae18b94099b0 (2025-08-20, in 6.18) introduced a dependency on the
|
||||||
|
Linux-specific O_LARGEFILE, and 97169cd6d95b (2025-08-20, in 6.18)
|
||||||
|
introduced a dependency on the Linux-specific copy_file_range. Both of
|
||||||
|
these commits were a part of the
|
||||||
|
https://lore.kernel.org/all/20250819032607.28727-1-ddiss@suse.de/
|
||||||
|
series. These new dependencies may not be available on non-Linux
|
||||||
|
systems, although it is possible to cross-build Linux on non-Linux build
|
||||||
|
hosts, and it is appropriate to run tools like gen_init_cpio on such
|
||||||
|
build hosts. It is straightforward to avoid these Linux-specific
|
||||||
|
features when not building on Linux.
|
||||||
|
|
||||||
|
Signed-off-by: Mark Mentovai <mark@mentovai.com>
|
||||||
|
---
|
||||||
|
usr/gen_init_cpio.c | 8 +++++++-
|
||||||
|
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
--- a/usr/gen_init_cpio.c
|
||||||
|
+++ b/usr/gen_init_cpio.c
|
||||||
|
@@ -456,6 +456,7 @@ static int cpio_mkfile(const char *name,
|
||||||
|
push_pad(namepadlen ? namepadlen : padlen(offset, 4)) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
+#ifdef __linux__
|
||||||
|
if (size) {
|
||||||
|
this_read = copy_file_range(file, NULL, outfd, NULL, size, 0);
|
||||||
|
if (this_read > 0) {
|
||||||
|
@@ -466,6 +467,7 @@ static int cpio_mkfile(const char *name,
|
||||||
|
}
|
||||||
|
/* short or failed copy falls back to read/write... */
|
||||||
|
}
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
while (size) {
|
||||||
|
unsigned char filebuf[65536];
|
||||||
|
@@ -674,7 +676,11 @@ int main (int argc, char *argv[])
|
||||||
|
break;
|
||||||
|
case 'o':
|
||||||
|
outfd = open(optarg,
|
||||||
|
- O_WRONLY | O_CREAT | O_LARGEFILE | O_TRUNC,
|
||||||
|
+ O_WRONLY | O_CREAT | O_TRUNC
|
||||||
|
+#ifdef O_LARGEFILE
|
||||||
|
+ | O_LARGEFILE
|
||||||
|
+#endif
|
||||||
|
+ ,
|
||||||
|
0600);
|
||||||
|
if (outfd < 0) {
|
||||||
|
fprintf(stderr, "failed to open %s\n", optarg);
|
||||||
Loading…
Reference in New Issue
Block a user