similarity index 100%
rename from meta/recipes-core/systemd/systemd-boot-native_257.8.bb
rename to meta/recipes-core/systemd/systemd-boot-native_258.1.bb
similarity index 100%
rename from meta/recipes-core/systemd/systemd-boot_257.8.bb
rename to meta/recipes-core/systemd/systemd-boot_258.1.bb
similarity index 87%
rename from meta/recipes-core/systemd/systemd-systemctl-native_257.8.bb
rename to meta/recipes-core/systemd/systemd-systemctl-native_258.1.bb
@@ -6,14 +6,12 @@  require systemd.inc
 
 DEPENDS = "gperf-native libcap-native util-linux-native python3-jinja2-native"
 
-SRC_URI += "file://0001-systemctl-Call-systemd-sysv-install-without-path.patch"
-SRC_URI += "file://0002-implment-systemd-sysv-install-for-OE.patch"
-
 inherit pkgconfig meson native
 
 MESON_TARGET = "systemctl:executable"
 MESON_INSTALL_TAGS = "systemctl"
 EXTRA_OEMESON += "-Dlink-systemctl-shared=false"
+EXTRA_OEMESON += "-Dsysvinit-path= -Dsysvrcnd-path="
 
 # Systemctl is supposed to operate on target, but the target sysroot is not
 # determined at run-time, but rather set during configure
@@ -12,11 +12,11 @@  work as a drop-in replacement for sysvinit."
 
 LICENSE = "GPL-2.0-only & LGPL-2.1-or-later"
 LICENSE:libsystemd = "LGPL-2.1-or-later"
-LIC_FILES_CHKSUM = "file://LICENSE.GPL2;md5=751419260aa954499f7abaabaa882bbe \
-                    file://LICENSE.LGPL2.1;md5=4fbd65380cdd255951079008b364516c"
+LIC_FILES_CHKSUM = "file://LICENSE.GPL2;md5=c09786363500a9acc29b147e6e72d2c6 \
+                    file://LICENSE.LGPL2.1;md5=be0aaf4a380f73f7e00b420a007368f2"
 
-SRCREV = "5e38d199a623563698ab4a69acbbe3afa9135198"
-SRCBRANCH = "v257-stable"
+SRCREV = "67a1069b7269cc23c3d04a2fb0cf110abe7abf31"
+SRCBRANCH = "v258-stable"
 SRC_URI = "git://github.com/systemd/systemd.git;protocol=https;branch=${SRCBRANCH};tag=v${PV}"
 
 CVE_PRODUCT = "systemd"
@@ -1,7 +1,7 @@ 
-From e5fd143f215f072404c544f694cb026a4231503e Mon Sep 17 00:00:00 2001
+From b1ab58d3b4a8164e5978409706d6769f5cfde404 Mon Sep 17 00:00:00 2001
 From: Chen Qi <Qi.Chen@windriver.com>
 Date: Thu, 21 Feb 2019 16:23:24 +0800
-Subject: [PATCH 01/26] binfmt: Don't install dependency links at install time
+Subject: [PATCH 01/16] binfmt: Don't install dependency links at install time
  for the binfmt services
 
 use [Install] blocks so that they get created when the service is enabled
@@ -25,10 +25,10 @@  Signed-off-by: Scott Murray <scott.murray@konsulko.com>
  3 files changed, 7 insertions(+), 2 deletions(-)
 
 diff --git a/units/meson.build b/units/meson.build
-index 96f4852741..0a3a4fee67 100644
+index 4f47a3b2bd..237870025b 100644
 --- a/units/meson.build
 +++ b/units/meson.build
-@@ -156,7 +156,6 @@ units = [
+@@ -154,7 +154,6 @@ units = [
          {
            'file' : 'proc-sys-fs-binfmt_misc.automount',
            'conditions' : ['ENABLE_BINFMT'],
@@ -36,7 +36,7 @@  index 96f4852741..0a3a4fee67 100644
          },
          {
            'file' : 'proc-sys-fs-binfmt_misc.mount',
-@@ -258,7 +257,6 @@ units = [
+@@ -263,7 +262,6 @@ units = [
          {
            'file' : 'systemd-binfmt.service.in',
            'conditions' : ['ENABLE_BINFMT'],
deleted file mode 100644
@@ -1,37 +0,0 @@ 
-From 34c8551a8b16bf235a1ebe8d9cb1a3474a7c975e Mon Sep 17 00:00:00 2001
-From: Peter Kjellerstedt <pkj@axis.com>
-Date: Fri, 22 Aug 2025 18:07:28 +0200
-Subject: [PATCH] systemctl: Call systemd-sysv-install without path
-
-Expect to find systemd-sysv-install in $PATH instead of hardcoding the
-path to it, as the latter does not work when running systemctl from a
-recipe sysroot.
-
-Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
-Upstream-Status: Inappropriate [OE specific]
----
- src/systemctl/systemctl-sysv-compat.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/systemctl/systemctl-sysv-compat.c b/src/systemctl/systemctl-sysv-compat.c
-index cb9c43e3dc..e44ef9f64e 100644
---- a/src/systemctl/systemctl-sysv-compat.c
-+++ b/src/systemctl/systemctl-sysv-compat.c
-@@ -140,7 +140,7 @@ int enable_sysv_units(const char *verb, char **args) {
-         while (args[f]) {
- 
-                 const char *argv[] = {
--                        LIBEXECDIR "/systemd-sysv-install",
-+                        "systemd-sysv-install",
-                         NULL, /* --root= */
-                         NULL, /* verb */
-                         NULL, /* service */
-@@ -218,7 +218,7 @@ int enable_sysv_units(const char *verb, char **args) {
-                         return j;
-                 if (j == 0) {
-                         /* Child */
--                        execv(argv[0], (char**) argv);
-+                        execvp(argv[0], (char**) argv);
-                         log_error_errno(errno, "Failed to execute %s: %m", argv[0]);
-                         _exit(EXIT_FAILURE);
-                 }
@@ -1,7 +1,7 @@ 
-From 4a5602ede9881fd8e578a3c8bc40dd5df7c4d802 Mon Sep 17 00:00:00 2001
+From 08ab9f1eaa86ca2c6a0bb45219a0153495708acb Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Sat, 5 Sep 2015 06:31:47 +0000
-Subject: [PATCH] implement systemd-sysv-install for OE
+Subject: [PATCH 02/16] implment systemd-sysv-install for OE
 
 Use update-rc.d for enabling/disabling and status command
 to check the status of the sysv service
@@ -14,7 +14,7 @@  Signed-off-by: Khem Raj <raj.khem@gmail.com>
  1 file changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/src/systemctl/systemd-sysv-install.SKELETON b/src/systemctl/systemd-sysv-install.SKELETON
-index cb58d8243b..eff3f5f579 100755
+index cb58d8243b..000bdf6165 100755
 --- a/src/systemctl/systemd-sysv-install.SKELETON
 +++ b/src/systemctl/systemd-sysv-install.SKELETON
 @@ -34,17 +34,17 @@ case "$1" in
@@ -22,13 +22,13 @@  index cb58d8243b..eff3f5f579 100755
          # call the command to enable SysV init script $NAME here
          # (consider optional $ROOT)
 -        echo "IMPLEMENT ME: enabling SysV init.d script $NAME"
-+        update-rc.d ${ROOT:+-r $ROOT} -f $NAME defaults
++        update-rc.d -f $NAME defaults
          ;;
      disable)
          # call the command to disable SysV init script $NAME here
          # (consider optional $ROOT)
 -        echo "IMPLEMENT ME: disabling SysV init.d script $NAME"
-+        update-rc.d ${ROOT:+-r $ROOT} -f $NAME remove
++        update-rc.d -f $NAME remove
          ;;
      is-enabled)
          # exit with 0 if $NAME is enabled, non-zero if it is disabled
@@ -38,3 +38,6 @@  index cb58d8243b..eff3f5f579 100755
          ;;
      *)
          usage ;;
+-- 
+2.34.1
+
similarity index 84%
rename from meta/recipes-core/systemd/systemd/0001-Do-not-create-var-log-README.patch
rename to meta/recipes-core/systemd/systemd/0003-Do-not-create-var-log-README.patch
@@ -1,7 +1,7 @@ 
-From 425ad51e727058b48dd4580fd6afe7e51e96a28a Mon Sep 17 00:00:00 2001
+From a7f6a296707642d05463aec22ea3dfce7d06c989 Mon Sep 17 00:00:00 2001
 From: Peter Kjellerstedt <pkj@axis.com>
 Date: Tue, 21 Jan 2025 05:02:00 +0100
-Subject: [PATCH] Do not create /var/log/README
+Subject: [PATCH 03/16] Do not create /var/log/README
 
 /var/log/README is a link to /usr/share/doc/systemd/README.logs. The
 latter is packaged in systemd-doc and likely not installed, which leaves
@@ -15,7 +15,7 @@  Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
  1 file changed, 3 deletions(-)
 
 diff --git a/tmpfiles.d/legacy.conf.in b/tmpfiles.d/legacy.conf.in
-index b475500e58..650c91a8da 100644
+index cdef21fa9b..03798c953e 100644
 --- a/tmpfiles.d/legacy.conf.in
 +++ b/tmpfiles.d/legacy.conf.in
 @@ -13,9 +13,6 @@
@@ -28,3 +28,6 @@  index b475500e58..650c91a8da 100644
  
  {% if HAVE_SYSV_COMPAT %}
  # /run/lock/subsys is used for serializing SysV service execution, and
+-- 
+2.34.1
+
deleted file mode 100644
@@ -1,61 +0,0 @@ 
-From f99ef6c4407b56e8d15455fe27eb732ada87215b Mon Sep 17 00:00:00 2001
-From: Chen Qi <Qi.Chen@windriver.com>
-Date: Mon, 25 Feb 2019 13:55:12 +0800
-Subject: [PATCH 03/26] missing_type.h: add comparison_fn_t
-
-Make it work with musl where comparison_fn_t and is not provided.
-
-Upstream-Status: Inappropriate [musl specific]
-
-Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
-[Rebased for v244]
-Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
-[Rebased for v242]
-Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
-[Rebased for v250, Drop __compare_fn_t]
-Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
----
- src/basic/missing_type.h            | 4 ++++
- src/basic/sort-util.h               | 1 +
- src/libsystemd/sd-journal/catalog.c | 1 +
- 3 files changed, 6 insertions(+)
-
-diff --git a/src/basic/missing_type.h b/src/basic/missing_type.h
-index 1d17705c35..fc33b76ec1 100644
---- a/src/basic/missing_type.h
-+++ b/src/basic/missing_type.h
-@@ -10,3 +10,7 @@
- #if !HAVE_CHAR16_T
- #  define char16_t uint16_t
- #endif
-+
-+#ifndef __GLIBC__
-+typedef int (*comparison_fn_t)(const void *, const void *);
-+#endif
-diff --git a/src/basic/sort-util.h b/src/basic/sort-util.h
-index 9c818bd747..ef10c8be2c 100644
---- a/src/basic/sort-util.h
-+++ b/src/basic/sort-util.h
-@@ -4,6 +4,7 @@
- #include <stdlib.h>
- 
- #include "macro.h"
-+#include "missing_type.h"
- 
- /* This is the same as glibc's internal __compar_d_fn_t type. glibc exports a public comparison_fn_t, for the
-  * external type __compar_fn_t, but doesn't do anything similar for __compar_d_fn_t. Let's hence do that
-diff --git a/src/libsystemd/sd-journal/catalog.c b/src/libsystemd/sd-journal/catalog.c
-index 7dcc35d8d5..87b8d6aad6 100644
---- a/src/libsystemd/sd-journal/catalog.c
-+++ b/src/libsystemd/sd-journal/catalog.c
-@@ -29,6 +29,7 @@
- #include "string-util.h"
- #include "strv.h"
- #include "tmpfile-util.h"
-+#include "missing_type.h"
- 
- const char * const catalog_file_dirs[] = {
-         "/usr/local/lib/systemd/catalog/",
-2.34.1
-
new file mode 100644
@@ -0,0 +1,61 @@ 
+From ca53ef485929773cbb2e4b1d2dd3d15204409d70 Mon Sep 17 00:00:00 2001
+From: Chen Qi <Qi.Chen@windriver.com>
+Date: Mon, 29 Sep 2025 11:04:09 +0800
+Subject: [PATCH 04/16] musl.h: introduce header file and add __THROW
+
+1. Introduce musl.h in preparation to hold musl related header workarounds.
+2. Define __THROW as empty to avoid compilation error.
+
+Upstream-Status: Inappropriate [musl specific]
+
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+---
+ src/include/override/musl.h      | 8 ++++++++
+ src/include/override/net/if.h    | 2 ++
+ src/include/override/sys/mount.h | 2 ++
+ 3 files changed, 12 insertions(+)
+ create mode 100644 src/include/override/musl.h
+
+diff --git a/src/include/override/musl.h b/src/include/override/musl.h
+new file mode 100644
+index 0000000000..6d747c1005
+--- /dev/null
++++ b/src/include/override/musl.h
+@@ -0,0 +1,8 @@
++#ifndef _MUSL_H
++#define _MUSL_H    1
++
++#ifndef __THROW
++#define __THROW
++#endif
++
++#endif /* musl.h */
+diff --git a/src/include/override/net/if.h b/src/include/override/net/if.h
+index 1914b596e3..1606be0fef 100644
+--- a/src/include/override/net/if.h
++++ b/src/include/override/net/if.h
+@@ -4,6 +4,8 @@
+ #include <features.h>
+ #include <linux/if.h>   /* IWYU pragma: export */
+ 
++#include <musl.h>
++
+ #define IF_NAMESIZE       16
+ 
+ extern unsigned int if_nametoindex(const char *__ifname) __THROW;
+diff --git a/src/include/override/sys/mount.h b/src/include/override/sys/mount.h
+index 33a843b8f4..1b9d00ee60 100644
+--- a/src/include/override/sys/mount.h
++++ b/src/include/override/sys/mount.h
+@@ -9,6 +9,8 @@
+ #include <stdint.h>
+ #include <sys/ioctl.h>
+ 
++#include <musl.h>
++
+ /* Since glibc-2.37 (774058d72942249f71d74e7f2b639f77184160a6), sys/mount.h includes linux/mount.h, and
+  * we can safely include both headers in the same source file. However, we cannot do that with older glibc.
+  * To avoid conflicts, let's not use glibc's sys/mount.h, and provide our own minimal implementation.
+-- 
+2.34.1
+
similarity index 88%
rename from meta/recipes-core/systemd/systemd/0004-add-fallback-parse_printf_format-implementation.patch
rename to meta/recipes-core/systemd/systemd/0005-add-fallback-parse_printf_format-implementation.patch
@@ -1,7 +1,7 @@ 
-From 34fe809cf686c1a81db5f3f027e33fece350ba0b Mon Sep 17 00:00:00 2001
+From e826bec34abac24b6a595919d965b888227d1687 Mon Sep 17 00:00:00 2001
 From: Alexander Kanavin <alex.kanavin@gmail.com>
 Date: Sat, 22 May 2021 20:26:24 +0200
-Subject: [PATCH 04/26] add fallback parse_printf_format implementation
+Subject: [PATCH 05/16] add fallback parse_printf_format implementation
 
 Upstream-Status: Inappropriate [musl specific]
 
@@ -10,35 +10,36 @@  Signed-off-by: Khem Raj <raj.khem@gmail.com>
 Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
 [rebased for systemd 243]
 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
+[Rebased for systemd 258]
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
 ---
- meson.build                              |   1 +
- src/basic/meson.build                    |   5 +
- src/basic/parse-printf-format.c          | 273 +++++++++++++++++++++++
- src/basic/parse-printf-format.h          |  57 +++++
- src/basic/stdio-util.h                   |   2 +-
- src/libsystemd/sd-journal/journal-send.c |   2 +-
- 6 files changed, 338 insertions(+), 2 deletions(-)
+ meson.build                     |   1 +
+ src/basic/meson.build           |   5 +
+ src/basic/parse-printf-format.c | 273 ++++++++++++++++++++++++++++++++
+ src/basic/parse-printf-format.h |  55 +++++++
+ src/basic/stdio-util.h          |   2 +-
+ 5 files changed, 335 insertions(+), 1 deletion(-)
  create mode 100644 src/basic/parse-printf-format.c
  create mode 100644 src/basic/parse-printf-format.h
 
 diff --git a/meson.build b/meson.build
-index bffda86845..4146f4beef 100644
+index 238b935372..0df7ecbe67 100644
 --- a/meson.build
 +++ b/meson.build
-@@ -770,6 +770,7 @@ foreach header : ['crypt.h',
-                   'linux/ioprio.h',
-                   'linux/memfd.h',
-                   'linux/time_types.h',
-+                  'printf.h',
-                   'sys/auxv.h',
-                   'sys/sdt.h',
-                   'threads.h',
+@@ -697,6 +697,7 @@ foreach header : [
+ endforeach
+ 
+ foreach header : [
++        'printf.h',
+         'sys/sdt.h',
+         'threads.h',
+         'valgrind/memcheck.h',
 diff --git a/src/basic/meson.build b/src/basic/meson.build
-index e02f787c75..9435df895d 100644
+index 79af468381..a06d0b4745 100644
 --- a/src/basic/meson.build
 +++ b/src/basic/meson.build
-@@ -188,6 +188,11 @@ endforeach
- 
+@@ -166,6 +166,11 @@ endforeach
+ generated_sources += generated_gperf_headers
  basic_sources += generated_gperf_headers
  
 +if conf.get('HAVE_PRINTF_H') != 1
@@ -48,7 +49,7 @@  index e02f787c75..9435df895d 100644
 +
  ############################################################
  
- arch_list = [
+ filesystem_sets_py = files('filesystem-sets.py')
 diff --git a/src/basic/parse-printf-format.c b/src/basic/parse-printf-format.c
 new file mode 100644
 index 0000000000..49437e5445
@@ -330,10 +331,10 @@  index 0000000000..49437e5445
 +}
 diff --git a/src/basic/parse-printf-format.h b/src/basic/parse-printf-format.h
 new file mode 100644
-index 0000000000..47be7522d7
+index 0000000000..1d4e8ac914
 --- /dev/null
 +++ b/src/basic/parse-printf-format.h
-@@ -0,0 +1,57 @@
+@@ -0,0 +1,55 @@
 +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
 +
 +/***
@@ -360,8 +361,6 @@  index 0000000000..47be7522d7
 +
 +#pragma once
 +
-+#include "config.h"
-+
 +#if HAVE_PRINTF_H
 +#include <printf.h>
 +#else
@@ -392,43 +391,21 @@  index 0000000000..47be7522d7
 +
 +#endif /* HAVE_PRINTF_H */
 diff --git a/src/basic/stdio-util.h b/src/basic/stdio-util.h
-index 0a2239d022..43a765dacd 100644
+index 052087ce15..62a6b6b316 100644
 --- a/src/basic/stdio-util.h
 +++ b/src/basic/stdio-util.h
-@@ -1,12 +1,12 @@
+@@ -1,10 +1,10 @@
  /* SPDX-License-Identifier: LGPL-2.1-or-later */
  #pragma once
  
 -#include <printf.h>
- #include <stdarg.h>
  #include <stdio.h>
- #include <sys/types.h>
  
- #include "macro.h"
+ #include "forward.h"
 +#include "parse-printf-format.h"
  
  _printf_(3, 4)
  static inline char* snprintf_ok(char *buf, size_t len, const char *format, ...) {
-diff --git a/src/libsystemd/sd-journal/journal-send.c b/src/libsystemd/sd-journal/journal-send.c
-index 7d02b57d7b..75e8e08add 100644
---- a/src/libsystemd/sd-journal/journal-send.c
-+++ b/src/libsystemd/sd-journal/journal-send.c
-@@ -2,7 +2,6 @@
- 
- #include <errno.h>
- #include <fcntl.h>
--#include <printf.h>
- #include <stddef.h>
- #include <sys/un.h>
- #include <unistd.h>
-@@ -28,6 +27,7 @@
- #include "stdio-util.h"
- #include "string-util.h"
- #include "tmpfile-util.h"
-+#include "parse-printf-format.h"
- 
- #define SNDBUF_SIZE (8*1024*1024)
- 
 -- 
 2.34.1
 
deleted file mode 100644
@@ -1,156 +0,0 @@ 
-From d368a0317c747961f69a455a09a3de3fd13410a2 Mon Sep 17 00:00:00 2001
-From: Chen Qi <Qi.Chen@windriver.com>
-Date: Mon, 25 Feb 2019 14:56:21 +0800
-Subject: [PATCH 05/26] don't fail if GLOB_BRACE and GLOB_ALTDIRFUNC is not
- defined
-
-If the standard library doesn't provide brace
-expansion users just won't get it.
-
-Dont use GNU GLOB extentions on non-glibc systems
-
-Conditionalize use of GLOB_ALTDIRFUNC
-
-Upstream-Status: Inappropriate [musl specific]
-
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
-Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
-[rebased for systemd 243]
-Signed-off-by: Scott Murray <scott.murray@konsulko.com>
----
- src/basic/glob-util.c     | 12 ++++++++++++
- src/test/test-glob-util.c | 16 ++++++++++++++++
- src/tmpfiles/tmpfiles.c   | 10 ++++++++++
- 3 files changed, 38 insertions(+)
-
-diff --git a/src/basic/glob-util.c b/src/basic/glob-util.c
-index 802ca8c655..23818a67c6 100644
---- a/src/basic/glob-util.c
-+++ b/src/basic/glob-util.c
-@@ -12,6 +12,12 @@
- #include "path-util.h"
- #include "strv.h"
- 
-+/* Don't fail if the standard library
-+ * doesn't provide brace expansion */
-+#ifndef GLOB_BRACE
-+#define GLOB_BRACE 0
-+#endif
-+
- static void closedir_wrapper(void* v) {
-         (void) closedir(v);
- }
-@@ -19,6 +25,7 @@ static void closedir_wrapper(void* v) {
- int safe_glob(const char *path, int flags, glob_t *pglob) {
-         int k;
- 
-+#ifdef GLOB_ALTDIRFUNC
-         /* We want to set GLOB_ALTDIRFUNC ourselves, don't allow it to be set. */
-         assert(!(flags & GLOB_ALTDIRFUNC));
- 
-@@ -32,9 +39,14 @@ int safe_glob(const char *path, int flags, glob_t *pglob) {
-                 pglob->gl_lstat = lstat;
-         if (!pglob->gl_stat)
-                 pglob->gl_stat = stat;
-+#endif
- 
-         errno = 0;
-+#ifdef GLOB_ALTDIRFUNC
-         k = glob(path, flags | GLOB_ALTDIRFUNC, NULL, pglob);
-+#else
-+        k = glob(path, flags, NULL, pglob);
-+#endif
-         if (k == GLOB_NOMATCH)
-                 return -ENOENT;
-         if (k == GLOB_NOSPACE)
-diff --git a/src/test/test-glob-util.c b/src/test/test-glob-util.c
-index 49d71f15c7..0a49ebcc17 100644
---- a/src/test/test-glob-util.c
-+++ b/src/test/test-glob-util.c
-@@ -34,6 +34,12 @@ TEST(glob_first) {
-         ASSERT_NULL(first);
- }
- 
-+/* Don't fail if the standard library
-+ * doesn't provide brace expansion */
-+#ifndef GLOB_BRACE
-+#define GLOB_BRACE 0
-+#endif
-+
- TEST(glob_exists) {
-         char name[] = "/tmp/test-glob_exists.XXXXXX";
-         int fd = -EBADF;
-@@ -61,11 +67,13 @@ TEST(glob_no_dot) {
-         const char *fn;
- 
-         _cleanup_globfree_ glob_t g = {
-+#ifdef GLOB_ALTDIRFUNC
-                 .gl_closedir = closedir_wrapper,
-                 .gl_readdir = (struct dirent *(*)(void *)) readdir_no_dot,
-                 .gl_opendir = (void *(*)(const char *)) opendir,
-                 .gl_lstat = lstat,
-                 .gl_stat = stat,
-+#endif
-         };
- 
-         int r;
-@@ -73,11 +81,19 @@ TEST(glob_no_dot) {
-         assert_se(mkdtemp(template));
- 
-         fn = strjoina(template, "/*");
-+#ifdef GLOB_ALTDIRFUNC
-         r = glob(fn, GLOB_NOSORT|GLOB_BRACE|GLOB_ALTDIRFUNC, NULL, &g);
-+#else
-+        r = glob(fn, GLOB_NOSORT|GLOB_BRACE, NULL, &g);
-+#endif
-         assert_se(r == GLOB_NOMATCH);
- 
-         fn = strjoina(template, "/.*");
-+#ifdef GLOB_ALTDIRFUNC
-         r = glob(fn, GLOB_NOSORT|GLOB_BRACE|GLOB_ALTDIRFUNC, NULL, &g);
-+#else
-+        r = glob(fn, GLOB_NOSORT|GLOB_BRACE, NULL, &g);
-+#endif
-         assert_se(r == GLOB_NOMATCH);
- 
-         (void) rm_rf(template, REMOVE_ROOT|REMOVE_PHYSICAL);
-diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
-index 86bf16356d..da552dbaab 100644
---- a/src/tmpfiles/tmpfiles.c
-+++ b/src/tmpfiles/tmpfiles.c
-@@ -73,6 +73,12 @@
- #include "user-util.h"
- #include "virt.h"
- 
-+/* Don't fail if the standard library
-+ * doesn't provide brace expansion */
-+#ifndef GLOB_BRACE
-+#define GLOB_BRACE 0
-+#endif
-+
- /* This reads all files listed in /etc/tmpfiles.d/?*.conf and creates
-  * them in the file system. This is intended to be used to create
-  * properly owned directories beneath /tmp, /var/tmp, /run, which are
-@@ -2573,7 +2579,9 @@ finish:
- 
- static int glob_item(Context *c, Item *i, action_t action) {
-         _cleanup_globfree_ glob_t g = {
-+#ifdef GLOB_ALTDIRFUNC
-                 .gl_opendir = (void *(*)(const char *)) opendir_nomod,
-+#endif
-         };
-         int r;
- 
-@@ -2601,7 +2609,9 @@ static int glob_item_recursively(
-                 fdaction_t action) {
- 
-         _cleanup_globfree_ glob_t g = {
-+#ifdef GLOB_ALTDIRFUNC
-                 .gl_opendir = (void *(*)(const char *)) opendir_nomod,
-+#endif
-         };
-         int r;
- 
-2.34.1
-
new file mode 100644
@@ -0,0 +1,117 @@ 
+From ec5bda959aa2820acc4b6c72668cfb50a745de86 Mon Sep 17 00:00:00 2001
+From: Chen Qi <Qi.Chen@windriver.com>
+Date: Mon, 29 Sep 2025 12:52:35 +0800
+Subject: [PATCH 06/16] Make mallinfo related contents glibc specific
+
+musl does not define mallinfo related contents.
+And systemd has removed support for checking, and has assumed it
+always exists[1], so these contents need to made glibc specific.
+
+[1] https://github.com/systemd/systemd/commit/abb99d3168259136187f81e0f701cda712ffd78d
+
+Upstream-Status: Inappropriate [musl specific]
+
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+---
+ src/include/override/malloc.h      |  3 ++-
+ src/libsystemd/sd-event/sd-event.c | 14 ++++++++++----
+ src/shared/selinux-util.c          | 10 +++++++++-
+ 3 files changed, 21 insertions(+), 6 deletions(-)
+
+diff --git a/src/include/override/malloc.h b/src/include/override/malloc.h
+index d0080b6cbc..c129713831 100644
+--- a/src/include/override/malloc.h
++++ b/src/include/override/malloc.h
+@@ -2,7 +2,7 @@
+ #pragma once
+ 
+ #include_next <malloc.h>
+-
++#ifdef __GLIBC__
+ #if !HAVE_MALLINFO2
+ struct mallinfo2 {
+         size_t arena;    /* non-mmapped space allocated from system */
+@@ -37,3 +37,4 @@ static inline struct mallinfo2 mallinfo2(void) {
+         };
+ }
+ #endif
++#endif
+diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
+index 6cb496c541..79d574f5a9 100644
+--- a/src/libsystemd/sd-event/sd-event.c
++++ b/src/libsystemd/sd-event/sd-event.c
+@@ -1867,9 +1867,9 @@ _public_ int sd_event_trim_memory(void) {
+          * NULL callback parameter. */
+ 
+         log_debug("Memory pressure event, trimming malloc() memory.");
+-
++#ifdef __GLIBC__
+         struct mallinfo2 before_mallinfo = mallinfo2();
+-
++#endif
+         usec_t before_timestamp = now(CLOCK_MONOTONIC);
+         hashmap_trim_pools();
+         r = malloc_trim(0);
+@@ -1881,7 +1881,7 @@ _public_ int sd_event_trim_memory(void) {
+                 log_debug("Couldn't trim any memory.");
+ 
+         usec_t period = after_timestamp - before_timestamp;
+-
++#ifdef __GLIBC__
+         struct mallinfo2 after_mallinfo = mallinfo2();
+         size_t l = LESS_BY(before_mallinfo.hblkhd, after_mallinfo.hblkhd) +
+                 LESS_BY(before_mallinfo.arena, after_mallinfo.arena);
+@@ -1892,7 +1892,13 @@ _public_ int sd_event_trim_memory(void) {
+                    LOG_MESSAGE_ID(SD_MESSAGE_MEMORY_TRIM_STR),
+                    LOG_ITEM("TRIMMED_BYTES=%zu", l),
+                    LOG_ITEM("TRIMMED_USEC=" USEC_FMT, period));
+-
++#else
++        log_struct(LOG_DEBUG,
++                   LOG_MESSAGE("Memory trimming took %s",
++                               FORMAT_TIMESPAN(period, 0)),
++                   LOG_MESSAGE_ID(SD_MESSAGE_MEMORY_TRIM_STR),
++                   LOG_ITEM("TRIMMED_USEC=" USEC_FMT, period));
++#endif
+         return 0;
+ }
+ 
+diff --git a/src/shared/selinux-util.c b/src/shared/selinux-util.c
+index f7c4c7d2f8..b669475180 100644
+--- a/src/shared/selinux-util.c
++++ b/src/shared/selinux-util.c
+@@ -91,10 +91,13 @@ static int open_label_db(void) {
+         struct selabel_handle *hnd;
+         /* Avoid maybe-uninitialized false positives */
+         usec_t before_timestamp = USEC_INFINITY, after_timestamp = USEC_INFINITY;
++#ifdef __GLIBC__
+         struct mallinfo2 before_mallinfo = {};
+-
++#endif
+         if (DEBUG_LOGGING) {
++#ifdef __GLIBC__
+                 before_mallinfo = mallinfo2();
++#endif
+                 before_timestamp = now(CLOCK_MONOTONIC);
+         }
+ 
+@@ -104,11 +107,16 @@ static int open_label_db(void) {
+ 
+         if (DEBUG_LOGGING) {
+                 after_timestamp = now(CLOCK_MONOTONIC);
++#ifdef __GLIBC__
+                 struct mallinfo2 after_mallinfo = mallinfo2();
+                 size_t l = LESS_BY(after_mallinfo.uordblks, before_mallinfo.uordblks);
+                 log_debug("Successfully loaded SELinux database in %s, size on heap is %zuK.",
+                           FORMAT_TIMESPAN(after_timestamp - before_timestamp, 0),
+                           DIV_ROUND_UP(l, 1024));
++#else
++                log_debug("Successfully loaded SELinux database in %s",
++                          FORMAT_TIMESPAN(after_timestamp - before_timestamp, 0));
++#endif
+         }
+ 
+         /* release memory after measurement */
+-- 
+2.34.1
+
deleted file mode 100644
@@ -1,44 +0,0 @@ 
-From 54b6e10aea2b0fb52782c3a71f06654a89b46bff Mon Sep 17 00:00:00 2001
-From: Chen Qi <Qi.Chen@windriver.com>
-Date: Mon, 25 Feb 2019 15:00:06 +0800
-Subject: [PATCH 06/26] add missing FTW_ macros for musl
-
-This is to avoid build failures like below for musl.
-
-  locale-util.c:296:24: error: 'FTW_STOP' undeclared
-
-Upstream-Status: Inappropriate [musl specific]
-
-Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
----
- src/basic/missing_type.h    | 4 ++++
- src/test/test-recurse-dir.c | 1 +
- 2 files changed, 5 insertions(+)
-
-diff --git a/src/basic/missing_type.h b/src/basic/missing_type.h
-index fc33b76ec1..34a36d83f0 100644
---- a/src/basic/missing_type.h
-+++ b/src/basic/missing_type.h
-@@ -14,3 +14,7 @@
- #ifndef __GLIBC__
- typedef int (*comparison_fn_t)(const void *, const void *);
- #endif
-+
-+#ifndef FTW_CONTINUE
-+#define FTW_CONTINUE 0
-+#endif
-diff --git a/src/test/test-recurse-dir.c b/src/test/test-recurse-dir.c
-index 8684d064ec..70fc2b5376 100644
---- a/src/test/test-recurse-dir.c
-+++ b/src/test/test-recurse-dir.c
-@@ -8,6 +8,7 @@
- #include "recurse-dir.h"
- #include "strv.h"
- #include "tests.h"
-+#include "missing_type.h"
- 
- static char **list_nftw = NULL;
- 
-2.34.1
-
deleted file mode 100644
@@ -1,106 +0,0 @@ 
-From 85d8c4c27e855d54c1740902a836c8f2aea9bebc Mon Sep 17 00:00:00 2001
-From: Chen Qi <Qi.Chen@windriver.com>
-Date: Mon, 25 Feb 2019 15:12:41 +0800
-Subject: [PATCH 07/26] Use uintmax_t for handling rlim_t
-
-PRIu{32,64} is not right format to represent rlim_t type
-therefore use %ju and typecast the rlim_t variables to
-uintmax_t.
-
-Fixes portablility errors like
-
-execute.c:3446:36: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'rlim_t {aka long long unsigned int}' [-Werror=format=]
-|                          fprintf(f, "%s%s: " RLIM_FMT "\n",
-|                                     ^~~~~~~~
-|                                  prefix, rlimit_to_string(i), c->rlimit[i]->rlim_max);
-|                                                               ~~~~~~~~~~~~~~~~~~~~~~
-
-Upstream-Status: Denied [https://github.com/systemd/systemd/pull/7199]
-
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
-[Rebased for v241]
-Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
----
- src/basic/format-util.h |  8 +-------
- src/basic/rlimit-util.c | 12 ++++++------
- src/core/execute.c      |  4 ++--
- 3 files changed, 9 insertions(+), 15 deletions(-)
-
-diff --git a/src/basic/format-util.h b/src/basic/format-util.h
-index b528c005ca..41c4c095be 100644
---- a/src/basic/format-util.h
-+++ b/src/basic/format-util.h
-@@ -41,13 +41,7 @@ assert_cc(sizeof(gid_t) == sizeof(uint32_t));
- #  error Unknown timex member size
- #endif
- 
--#if SIZEOF_RLIM_T == 8
--#  define RLIM_FMT "%" PRIu64
--#elif SIZEOF_RLIM_T == 4
--#  define RLIM_FMT "%" PRIu32
--#else
--#  error Unknown rlim_t size
--#endif
-+#define RLIM_FMT "%ju"
- 
- #if SIZEOF_DEV_T == 8
- #  define DEV_FMT "%" PRIu64
-diff --git a/src/basic/rlimit-util.c b/src/basic/rlimit-util.c
-index a9f7b87f28..059c67731d 100644
---- a/src/basic/rlimit-util.c
-+++ b/src/basic/rlimit-util.c
-@@ -47,7 +47,7 @@ int setrlimit_closest(int resource, const struct rlimit *rlim) {
-             fixed.rlim_max == highest.rlim_max)
-                 return 0;
- 
--        log_debug("Failed at setting rlimit " RLIM_FMT " for resource RLIMIT_%s. Will attempt setting value " RLIM_FMT " instead.", rlim->rlim_max, rlimit_to_string(resource), fixed.rlim_max);
-+        log_debug("Failed at setting rlimit " RLIM_FMT " for resource RLIMIT_%s. Will attempt setting value " RLIM_FMT " instead.", (uintmax_t)rlim->rlim_max, rlimit_to_string(resource), (uintmax_t)fixed.rlim_max);
- 
-         return RET_NERRNO(setrlimit(resource, &fixed));
- }
-@@ -310,13 +310,13 @@ int rlimit_format(const struct rlimit *rl, char **ret) {
-         if (rl->rlim_cur >= RLIM_INFINITY && rl->rlim_max >= RLIM_INFINITY)
-                 r = free_and_strdup(&s, "infinity");
-         else if (rl->rlim_cur >= RLIM_INFINITY)
--                r = asprintf(&s, "infinity:" RLIM_FMT, rl->rlim_max);
-+                r = asprintf(&s, "infinity:" RLIM_FMT, (uintmax_t)rl->rlim_max);
-         else if (rl->rlim_max >= RLIM_INFINITY)
--                r = asprintf(&s, RLIM_FMT ":infinity", rl->rlim_cur);
-+                r = asprintf(&s, RLIM_FMT ":infinity", (uintmax_t)rl->rlim_cur);
-         else if (rl->rlim_cur == rl->rlim_max)
--                r = asprintf(&s, RLIM_FMT, rl->rlim_cur);
-+                r = asprintf(&s, RLIM_FMT, (uintmax_t)rl->rlim_cur);
-         else
--                r = asprintf(&s, RLIM_FMT ":" RLIM_FMT, rl->rlim_cur, rl->rlim_max);
-+                r = asprintf(&s, RLIM_FMT ":" RLIM_FMT, (uintmax_t)rl->rlim_cur, (uintmax_t)rl->rlim_max);
-         if (r < 0)
-                 return -ENOMEM;
- 
-@@ -425,7 +425,7 @@ int rlimit_nofile_safe(void) {
-         rl.rlim_max = MIN(rl.rlim_max, (rlim_t) read_nr_open());
-         rl.rlim_cur = MIN((rlim_t) FD_SETSIZE, rl.rlim_max);
-         if (setrlimit(RLIMIT_NOFILE, &rl) < 0)
--                return log_debug_errno(errno, "Failed to lower RLIMIT_NOFILE's soft limit to " RLIM_FMT ": %m", rl.rlim_cur);
-+                return log_debug_errno(errno, "Failed to lower RLIMIT_NOFILE's soft limit to " RLIM_FMT ": %m", (uintmax_t)rl.rlim_cur);
- 
-         return 1;
- }
-diff --git a/src/core/execute.c b/src/core/execute.c
-index 3d55b0b772..4824ff159e 100644
---- a/src/core/execute.c
-+++ b/src/core/execute.c
-@@ -1162,9 +1162,9 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) {
-         for (unsigned i = 0; i < RLIM_NLIMITS; i++)
-                 if (c->rlimit[i]) {
-                         fprintf(f, "%sLimit%s: " RLIM_FMT "\n",
--                                prefix, rlimit_to_string(i), c->rlimit[i]->rlim_max);
-+                                prefix, rlimit_to_string(i), (uintmax_t)c->rlimit[i]->rlim_max);
-                         fprintf(f, "%sLimit%sSoft: " RLIM_FMT "\n",
--                                prefix, rlimit_to_string(i), c->rlimit[i]->rlim_cur);
-+                                prefix, rlimit_to_string(i), (uintmax_t)c->rlimit[i]->rlim_cur);
-                 }
- 
-         if (c->ioprio_set) {
-2.34.1
-
new file mode 100644
@@ -0,0 +1,43 @@ 
+From 62d0b5c1689076468e95b5473bffd599b51f8d8e Mon Sep 17 00:00:00 2001
+From: Chen Qi <Qi.Chen@windriver.com>
+Date: Mon, 29 Sep 2025 14:14:44 +0800
+Subject: [PATCH 07/16] add src/include/override/sys/prctl.h to avoid
+ redefinition error
+
+The linux/prctl.h has all the needed macros, what we need is the
+prctl function definition. This avoids error of redefinition.
+
+Upstream-Status: Inappropriate [musl specific]
+
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+---
+ src/include/override/sys/prctl.h | 17 +++++++++++++++++
+ 1 file changed, 17 insertions(+)
+ create mode 100644 src/include/override/sys/prctl.h
+
+diff --git a/src/include/override/sys/prctl.h b/src/include/override/sys/prctl.h
+new file mode 100644
+index 0000000000..20468bd30f
+--- /dev/null
++++ b/src/include/override/sys/prctl.h
+@@ -0,0 +1,17 @@
++#ifndef _SYS_PRCTL_H
++#define _SYS_PRCTL_H
++
++#ifdef __cplusplus
++extern "C" {
++#endif
++
++#include <stdint.h>
++#include <linux/prctl.h>
++
++int prctl (int, ...);
++
++#ifdef __cplusplus
++}
++#endif
++
++#endif
+-- 
+2.34.1
+
deleted file mode 100644
@@ -1,34 +0,0 @@ 
-From f4cd939c7cc1ce0a59bab2693768f2c95d9ced00 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Sun, 27 May 2018 08:36:44 -0700
-Subject: [PATCH 08/26] Define glibc compatible basename() for non-glibc
- systems
-
-Fixes builds with musl, even though systemd is adamant about
-using non-posix basename implementation, we have a way out
-
-Upstream-Status: Inappropriate [musl specific]
-
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- src/basic/string-util.h | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/src/basic/string-util.h b/src/basic/string-util.h
-index cc6aa183c0..0b035125cd 100644
---- a/src/basic/string-util.h
-+++ b/src/basic/string-util.h
-@@ -27,6 +27,10 @@
- #define URI_UNRESERVED      ALPHANUMERICAL "-._~"       /* [RFC3986] */
- #define URI_VALID           URI_RESERVED URI_UNRESERVED /* [RFC3986] */
- 
-+#if !defined(__GLIBC__)
-+#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src)
-+#endif
-+
- static inline char* strstr_ptr(const char *haystack, const char *needle) {
-         if (!haystack || !needle)
-                 return NULL;
-2.34.1
-
similarity index 77%
rename from meta/recipes-core/systemd/systemd/0010-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch
rename to meta/recipes-core/systemd/systemd/0008-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch
@@ -1,10 +1,10 @@ 
-From b7f6c245b4ae72999f23eecc2bbb6d6fb8db667c Mon Sep 17 00:00:00 2001
+From bbe0096367618026fe5ebb81c266fd50084f113a Mon Sep 17 00:00:00 2001
 From: Chen Qi <Qi.Chen@windriver.com>
 Date: Tue, 10 Jul 2018 15:40:17 +0800
-Subject: [PATCH 10/26] distinguish XSI-compliant strerror_r from GNU-specifi
+Subject: [PATCH 08/16] distinguish XSI-compliant strerror_r from GNU-specific
  strerror_r
 
-XSI-compliant strerror_r and GNU-specifi strerror_r are different.
+XSI-compliant strerror_r and GNU-specific strerror_r are different.
 
        int strerror_r(int errnum, char *buf, size_t buflen);
                    /* XSI-compliant */
@@ -24,10 +24,10 @@  Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
  2 files changed, 15 insertions(+), 1 deletion(-)
 
 diff --git a/src/libsystemd/sd-bus/bus-error.c b/src/libsystemd/sd-bus/bus-error.c
-index 58c24d25c0..69a0d09d42 100644
+index bc0164c1b4..e69ffe4f75 100644
 --- a/src/libsystemd/sd-bus/bus-error.c
 +++ b/src/libsystemd/sd-bus/bus-error.c
-@@ -405,7 +405,12 @@ static void bus_error_strerror(sd_bus_error *e, int error) {
+@@ -400,7 +400,12 @@ static void bus_error_strerror(sd_bus_error *e, int error) {
                          return;
  
                  errno = 0;
@@ -40,25 +40,25 @@  index 58c24d25c0..69a0d09d42 100644
                  if (errno == ERANGE || strlen(x) >= k - 1) {
                          free(m);
                          k *= 2;
-@@ -590,8 +595,12 @@ const char* _bus_error_message(const sd_bus_error *e, int error, char buf[static
+@@ -585,8 +590,12 @@ const char* _bus_error_message(const sd_bus_error *e, int error, char buf[static
  
          if (e && e->message)
                  return e->message;
 -
 +#ifndef __GLIBC__
-+        strerror_r(abs(error), buf, ERRNO_BUF_LEN);
++        strerror_r(ABS(error), buf, ERRNO_BUF_LEN);
 +        return buf;
 +#else
-         return strerror_r(abs(error), buf, ERRNO_BUF_LEN);
+         return strerror_r(ABS(error), buf, ERRNO_BUF_LEN);
 +#endif
  }
  
  static bool map_ok(const sd_bus_error_map *map) {
 diff --git a/src/libsystemd/sd-journal/journal-send.c b/src/libsystemd/sd-journal/journal-send.c
-index 75e8e08add..41e5c7c2b8 100644
+index e838e7e0d7..28b6e014c0 100644
 --- a/src/libsystemd/sd-journal/journal-send.c
 +++ b/src/libsystemd/sd-journal/journal-send.c
-@@ -361,7 +361,12 @@ static int fill_iovec_perror_and_send(const char *message, int skip, struct iove
+@@ -338,7 +338,12 @@ static int fill_iovec_perror_and_send(const char *message, int skip, struct iove
                  char* j;
  
                  errno = 0;
deleted file mode 100644
@@ -1,41 +0,0 @@ 
-From 6959db351fdd551d46e22667deec6032552b2662 Mon Sep 17 00:00:00 2001
-From: Chen Qi <Qi.Chen@windriver.com>
-Date: Wed, 4 Jul 2018 15:00:44 +0800
-Subject: [PATCH 09/26] Do not disable buffering when writing to oom_score_adj
-
-On musl, disabling buffering when writing to oom_score_adj will
-cause the following error.
-
-  Failed to adjust OOM setting: Invalid argument
-
-This error appears for systemd-udevd.service and dbus.service.
-This is because kernel receives '-' instead of the whole '-900'
-if buffering is disabled.
-
-This is libc implementation specific, as glibc does not have this issue.
-
-Upstream-Status: Inappropriate [musl specific]
-
-Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
-[rebased for systemd 243]
-Signed-off-by: Scott Murray <scott.murray@konsulko.com>
----
- src/basic/process-util.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/basic/process-util.c b/src/basic/process-util.c
-index 3253a9c3fb..772c4082a1 100644
---- a/src/basic/process-util.c
-+++ b/src/basic/process-util.c
-@@ -1848,7 +1848,7 @@ int set_oom_score_adjust(int value) {
-         xsprintf(t, "%i", value);
- 
-         return write_string_file("/proc/self/oom_score_adj", t,
--                                 WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_DISABLE_BUFFER);
-+                                 WRITE_STRING_FILE_VERIFY_ON_FAILURE);
- }
- 
- int get_oom_score_adjust(int *ret) {
-2.34.1
-
similarity index 72%
rename from meta/recipes-core/systemd/systemd/0019-errno-util-Make-STRERROR-portable-for-musl.patch
rename to meta/recipes-core/systemd/systemd/0009-errno-util-Make-STRERROR-portable-for-musl.patch
@@ -1,7 +1,7 @@ 
-From 28fa1d5f56c6ddee9e336e6f2051c55e9f2f98b4 Mon Sep 17 00:00:00 2001
+From 7ce68a17deeda43c31a5de5956bad4c92481f1ca Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Mon, 23 Jan 2023 23:39:46 -0800
-Subject: [PATCH 19/26] errno-util: Make STRERROR portable for musl
+Subject: [PATCH 09/16] errno-util: Make STRERROR portable for musl
 
 Sadly, systemd has decided to use yet another GNU extention in a macro
 lets make this such that we can use XSI compliant strerror_r() for
@@ -10,27 +10,30 @@  non-glibc hosts
 Upstream-Status: Inappropriate [musl specific]
 
 Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+Rebased for v258
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
 ---
  src/basic/errno-util.h | 10 +++++++++-
  1 file changed, 9 insertions(+), 1 deletion(-)
 
 diff --git a/src/basic/errno-util.h b/src/basic/errno-util.h
-index 48b76e4bf7..6e7653e2d9 100644
+index 5fe337cfb1..dee34167cb 100644
 --- a/src/basic/errno-util.h
 +++ b/src/basic/errno-util.h
-@@ -15,8 +15,16 @@
+@@ -13,8 +13,16 @@
   * https://stackoverflow.com/questions/34880638/compound-literal-lifetime-and-if-blocks
   *
   * Note that we use the GNU variant of strerror_r() here. */
--#define STRERROR(errnum) strerror_r(abs(errnum), (char[ERRNO_BUF_LEN]){}, ERRNO_BUF_LEN)
+-#define STRERROR(errnum) strerror_r(ABS(errnum), (char[ERRNO_BUF_LEN]){}, ERRNO_BUF_LEN)
 +static inline const char * STRERROR(int errnum);
  
 +static inline const char * STRERROR(int errnum) {
 +#ifdef __GLIBC__
-+        return strerror_r(abs(errnum), (char[ERRNO_BUF_LEN]){}, ERRNO_BUF_LEN);
++        return strerror_r(ABS(errnum), (char[ERRNO_BUF_LEN]){}, ERRNO_BUF_LEN);
 +#else
 +        static __thread char buf[ERRNO_BUF_LEN];
-+        return strerror_r(abs(errnum), buf, ERRNO_BUF_LEN) ? "unknown error" : buf;
++        return strerror_r(ABS(errnum), buf, ERRNO_BUF_LEN) ? "unknown error" : buf;
 +#endif
 +}
  /* A helper to print an error message or message for functions that return 0 on EOF.
new file mode 100644
@@ -0,0 +1,40 @@ 
+From adf7bd6cf6305f5454cfb1ad4f1755880e831f7e Mon Sep 17 00:00:00 2001
+From: Chen Qi <Qi.Chen@windriver.com>
+Date: Mon, 29 Sep 2025 14:41:52 +0800
+Subject: [PATCH 10/16] src/basic/format-util.h: define RLIM_FMT to fit musl's
+ rlim_t definition
+
+musl always defines rlim_t to be "unsigned long long".
+
+Upstream-Status: Inappropriate [musl specific]
+
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+---
+ src/basic/format-util.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/basic/format-util.h b/src/basic/format-util.h
+index e42f788ce6..9275f9615d 100644
+--- a/src/basic/format-util.h
++++ b/src/basic/format-util.h
+@@ -39,6 +39,7 @@ assert_cc(sizeof(gid_t) == sizeof(uint32_t));
+ #  error Unknown timex member size
+ #endif
+ 
++#ifdef __GLIBC__
+ #if SIZEOF_RLIM_T == 8
+ #  define RLIM_FMT "%" PRIu64
+ #elif SIZEOF_RLIM_T == 4
+@@ -46,6 +47,9 @@ assert_cc(sizeof(gid_t) == sizeof(uint32_t));
+ #else
+ #  error Unknown rlim_t size
+ #endif
++#else
++#define RLIM_FMT "%llu"
++#endif
+ 
+ #if SIZEOF_DEV_T == 8
+ #  define DEV_FMT "%" PRIu64
+-- 
+2.34.1
+
deleted file mode 100644
@@ -1,32 +0,0 @@ 
-From 43b0269e850a2fbcb6ca615258aa8f8a9b4f6a9d Mon Sep 17 00:00:00 2001
-From: Chen Qi <Qi.Chen@windriver.com>
-Date: Mon, 25 Feb 2019 15:44:54 +0800
-Subject: [PATCH 11/26] avoid redefinition of prctl_mm_map structure
-
-Fix the following compile failure:
-error: redefinition of 'struct prctl_mm_map'
-
-Upstream-Status: Inappropriate [musl specific]
-
-Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
----
- src/basic/missing_prctl.h | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/src/basic/missing_prctl.h b/src/basic/missing_prctl.h
-index 2c9f9f6c50..65a984b564 100644
---- a/src/basic/missing_prctl.h
-+++ b/src/basic/missing_prctl.h
-@@ -1,7 +1,9 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- #pragma once
- 
-+#ifdef __GLIBC__
- #include <linux/prctl.h>
-+#endif
- 
- #include "macro.h"
- 
-2.34.1
-
new file mode 100644
@@ -0,0 +1,41 @@ 
+From 9173921022c74067f35078d0a4de686cc504e182 Mon Sep 17 00:00:00 2001
+From: Chen Qi <Qi.Chen@windriver.com>
+Date: Mon, 29 Sep 2025 14:49:13 +0800
+Subject: [PATCH 11/16] src/include/override/malloc.h: define dummy
+ malloc_trim/malloc_info for musl
+
+For malloc_trim:
+As we're not releasing any stack, just return 0 to match the
+malloc_trim's meaning in glibc.
+
+For malloc_info:
+There's no real malloc_info implementation in musl, define a dummy
+one which always return -1 to indicate error.
+
+Upstream-Status: Inappropriate [musl specific]
+
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+---
+ src/include/override/malloc.h | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/src/include/override/malloc.h b/src/include/override/malloc.h
+index c129713831..0b09bf6de6 100644
+--- a/src/include/override/malloc.h
++++ b/src/include/override/malloc.h
+@@ -37,4 +37,12 @@ static inline struct mallinfo2 mallinfo2(void) {
+         };
+ }
+ #endif
++#else
++#include <stdio.h>
++static inline int malloc_trim(size_t s) {
++        return 0;
++}
++static inline int malloc_info(int options, FILE *stream) {
++        return -1;
++}
+ #endif
+-- 
+2.34.1
+
deleted file mode 100644
@@ -1,530 +0,0 @@ 
-From eaf26fdad00448b8cd336eb5db51e0baa8d8e588 Mon Sep 17 00:00:00 2001
-From: Chen Qi <Qi.Chen@windriver.com>
-Date: Mon, 16 Dec 2024 14:37:25 +0800
-Subject: [PATCH 12/26] do not disable buffer in writing files
-
-Do not disable buffer in writing files, otherwise we get
-failure at boot for musl like below.
-
-  [!!!!!!] Failed to allocate manager object.
-
-And there will be other failures, critical or not critical.
-This is specific to musl.
-
-Upstream-Status: Inappropriate [musl]
-
-Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
-[Rebased for v242]
-Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
-[rebased for systemd 243]
-Signed-off-by: Scott Murray <scott.murray@konsulko.com>
-[rebased for systemd 254]
-Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
-[rebased for systemd 255.1]
----
- src/basic/cgroup-util.c              |  4 ++--
- src/basic/namespace-util.c           |  4 ++--
- src/basic/procfs-util.c              |  4 ++--
- src/basic/sysctl-util.c              |  2 +-
- src/binfmt/binfmt.c                  |  6 +++---
- src/core/cgroup.c                    |  2 +-
- src/core/ipe-setup.c                 |  2 +-
- src/core/main.c                      |  2 +-
- src/core/smack-setup.c               |  6 +++---
- src/home/homework.c                  |  2 +-
- src/libsystemd/sd-device/sd-device.c |  2 +-
- src/nspawn/nspawn-cgroup.c           |  2 +-
- src/nspawn/nspawn.c                  |  6 +++---
- src/shared/binfmt-util.c             |  2 +-
- src/shared/cgroup-setup.c            | 12 ++++++------
- src/shared/coredump-util.c           |  2 +-
- src/shared/hibernate-util.c          |  4 ++--
- src/shared/smack-util.c              |  2 +-
- src/sleep/sleep.c                    |  2 +-
- src/storagetm/storagetm.c            | 24 ++++++++++++------------
- src/vconsole/vconsole-setup.c        |  2 +-
- 21 files changed, 47 insertions(+), 47 deletions(-)
-
-diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
-index 309dccb45a..7aec5072a0 100644
---- a/src/basic/cgroup-util.c
-+++ b/src/basic/cgroup-util.c
-@@ -495,7 +495,7 @@ int cg_kill_kernel_sigkill(const char *path) {
-         if (r < 0)
-                 return r;
- 
--        r = write_string_file(killfile, "1", WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file(killfile, "1", 0);
-         if (r < 0)
-                 return log_debug_errno(r, "Failed to write to cgroup.kill for cgroup '%s': %m", path);
- 
-@@ -1721,7 +1721,7 @@ int cg_set_attribute(const char *controller, const char *path, const char *attri
-         if (r < 0)
-                 return r;
- 
--        return write_string_file(p, value, WRITE_STRING_FILE_DISABLE_BUFFER);
-+        return write_string_file(p, value, 0);
- }
- 
- int cg_get_attribute(const char *controller, const char *path, const char *attribute, char **ret) {
-diff --git a/src/basic/namespace-util.c b/src/basic/namespace-util.c
-index 332e8cdfd5..804498127d 100644
---- a/src/basic/namespace-util.c
-+++ b/src/basic/namespace-util.c
-@@ -359,12 +359,12 @@ int userns_acquire(const char *uid_map, const char *gid_map) {
-                 freeze();
- 
-         xsprintf(path, "/proc/" PID_FMT "/uid_map", pid);
--        r = write_string_file(path, uid_map, WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file(path, uid_map, 0);
-         if (r < 0)
-                 return log_debug_errno(r, "Failed to write UID map: %m");
- 
-         xsprintf(path, "/proc/" PID_FMT "/gid_map", pid);
--        r = write_string_file(path, gid_map, WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file(path, gid_map, 0);
-         if (r < 0)
-                 return log_debug_errno(r, "Failed to write GID map: %m");
- 
-diff --git a/src/basic/procfs-util.c b/src/basic/procfs-util.c
-index d7cfcd9105..58fb5918a3 100644
---- a/src/basic/procfs-util.c
-+++ b/src/basic/procfs-util.c
-@@ -63,13 +63,13 @@ int procfs_tasks_set_limit(uint64_t limit) {
-          * decrease it, as threads-max is the much more relevant sysctl. */
-         if (limit > pid_max-1) {
-                 sprintf(buffer, "%" PRIu64, limit+1); /* Add one, since PID 0 is not a valid PID */
--                r = write_string_file("/proc/sys/kernel/pid_max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER);
-+                r = write_string_file("/proc/sys/kernel/pid_max", buffer, 0);
-                 if (r < 0)
-                         return r;
-         }
- 
-         sprintf(buffer, "%" PRIu64, limit);
--        r = write_string_file("/proc/sys/kernel/threads-max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file("/proc/sys/kernel/threads-max", buffer, 0);
-         if (r < 0) {
-                 uint64_t threads_max;
- 
-diff --git a/src/basic/sysctl-util.c b/src/basic/sysctl-util.c
-index 2feb4917d7..4c74620a00 100644
---- a/src/basic/sysctl-util.c
-+++ b/src/basic/sysctl-util.c
-@@ -97,7 +97,7 @@ int sysctl_write_full(const char *property, const char *value, Hashmap **shadow)
-         if (r < 0)
-                 return r;
- 
--        return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_SUPPRESS_REDUNDANT_VIRTUAL);
-+        return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | 0 | WRITE_STRING_FILE_SUPPRESS_REDUNDANT_VIRTUAL);
- }
- 
- int sysctl_writef(const char *property, const char *format, ...) {
-diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c
-index d21f3f79ff..258607cc7e 100644
---- a/src/binfmt/binfmt.c
-+++ b/src/binfmt/binfmt.c
-@@ -30,7 +30,7 @@ static bool arg_unregister = false;
- 
- static int delete_rule(const char *rulename) {
-         const char *fn = strjoina("/proc/sys/fs/binfmt_misc/", rulename);
--        return write_string_file(fn, "-1", WRITE_STRING_FILE_DISABLE_BUFFER);
-+        return write_string_file(fn, "-1", 0);
- }
- 
- static int apply_rule(const char *filename, unsigned line, const char *rule) {
-@@ -58,7 +58,7 @@ static int apply_rule(const char *filename, unsigned line, const char *rule) {
-         if (r >= 0)
-                 log_debug("%s:%u: Rule '%s' deleted.", filename, line, rulename);
- 
--        r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, 0);
-         if (r < 0)
-                 return log_error_errno(r, "%s:%u: Failed to add binary format '%s': %m",
-                                        filename, line, rulename);
-@@ -248,7 +248,7 @@ static int run(int argc, char *argv[]) {
-                         return r;
- 
-                 /* Flush out all rules */
--                r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER);
-+                r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0);
-                 if (r < 0)
-                         log_warning_errno(r, "Failed to flush binfmt_misc rules, ignoring: %m");
-                 else
-diff --git a/src/core/cgroup.c b/src/core/cgroup.c
-index 6933aae54d..ab6fccc0e4 100644
---- a/src/core/cgroup.c
-+++ b/src/core/cgroup.c
-@@ -5175,7 +5175,7 @@ int unit_cgroup_freezer_action(Unit *u, FreezerAction action) {
-         if (r < 0)
-                 return r;
- 
--        r = write_string_file(path, one_zero(objective == FREEZER_FROZEN), WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file(path, one_zero(objective == FREEZER_FROZEN), 0);
-         if (r < 0)
-                 return r;
- 
-diff --git a/src/core/ipe-setup.c b/src/core/ipe-setup.c
-index 4648d43829..80d03d87d4 100644
---- a/src/core/ipe-setup.c
-+++ b/src/core/ipe-setup.c
-@@ -94,7 +94,7 @@ int ipe_setup(void) {
-                 if (!activate_path)
-                         return log_oom();
- 
--                r = write_string_file(activate_path, "1", WRITE_STRING_FILE_DISABLE_BUFFER);
-+                r = write_string_file(activate_path, "1", 0);
-                 if (r == -ESTALE) {
-                         log_debug_errno(r,
-                                         "IPE policy %s is already loaded with a version that is equal or higher, skipping.",
-diff --git a/src/core/main.c b/src/core/main.c
-index 172742c769..e68ce2a6d8 100644
---- a/src/core/main.c
-+++ b/src/core/main.c
-@@ -1826,7 +1826,7 @@ static void initialize_core_pattern(bool skip_setup) {
-         if (getpid_cached() != 1)
-                 return;
- 
--        r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, 0);
-         if (r < 0)
-                 log_warning_errno(r, "Failed to write '%s' to /proc/sys/kernel/core_pattern, ignoring: %m",
-                                   arg_early_core_pattern);
-diff --git a/src/core/smack-setup.c b/src/core/smack-setup.c
-index 7ea902b6f9..ee4cd56023 100644
---- a/src/core/smack-setup.c
-+++ b/src/core/smack-setup.c
-@@ -321,17 +321,17 @@ int mac_smack_setup(bool *loaded_policy) {
-         }
- 
- #if HAVE_SMACK_RUN_LABEL
--        r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, 0);
-         if (r < 0)
-                 log_warning_errno(r, "Failed to set SMACK label \"" SMACK_RUN_LABEL "\" on self: %m");
--        r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, 0);
-         if (r < 0)
-                 log_warning_errno(r, "Failed to set SMACK ambient label \"" SMACK_RUN_LABEL "\": %m");
-         r = write_string_file("/sys/fs/smackfs/netlabel",
-                               "0.0.0.0/0 " SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER);
-         if (r < 0)
-                 log_warning_errno(r, "Failed to set SMACK netlabel rule \"0.0.0.0/0 " SMACK_RUN_LABEL "\": %m");
--        r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", 0);
-         if (r < 0)
-                 log_warning_errno(r, "Failed to set SMACK netlabel rule \"127.0.0.1 -CIPSO\": %m");
- #endif
-diff --git a/src/home/homework.c b/src/home/homework.c
-index 00e74894b3..7457113efe 100644
---- a/src/home/homework.c
-+++ b/src/home/homework.c
-@@ -304,7 +304,7 @@ static void drop_caches_now(void) {
-          * for details. We write "3" into /proc/sys/vm/drop_caches to ensure dentries/inodes are flushed, but
-          * not more. */
- 
--        r = write_string_file("/proc/sys/vm/drop_caches", "3\n", WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file("/proc/sys/vm/drop_caches", "3\n", 0);
-         if (r < 0)
-                 log_warning_errno(r, "Failed to drop caches, ignoring: %m");
-         else
-diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
-index 01fa90b1ff..83ab655bf4 100644
---- a/src/libsystemd/sd-device/sd-device.c
-+++ b/src/libsystemd/sd-device/sd-device.c
-@@ -2564,7 +2564,7 @@ _public_ int sd_device_set_sysattr_value(sd_device *device, const char *sysattr,
-         if (!value)
-                 return -ENOMEM;
- 
--        r = write_string_file(path, value, WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_NOFOLLOW);
-+        r = write_string_file(path, value, 0 | WRITE_STRING_FILE_NOFOLLOW);
-         if (r < 0) {
-                 /* On failure, clear cache entry, as we do not know how it fails. */
-                 device_remove_cached_sysattr_value(device, sysattr);
-diff --git a/src/nspawn/nspawn-cgroup.c b/src/nspawn/nspawn-cgroup.c
-index 4f28b4a225..c899c218b2 100644
---- a/src/nspawn/nspawn-cgroup.c
-+++ b/src/nspawn/nspawn-cgroup.c
-@@ -93,7 +93,7 @@ int sync_cgroup(pid_t pid, CGroupUnified unified_requested, uid_t uid_shift) {
-         fn = strjoina(tree, cgroup, "/cgroup.procs");
- 
-         sprintf(pid_string, PID_FMT, pid);
--        r = write_string_file(fn, pid_string, WRITE_STRING_FILE_DISABLE_BUFFER|WRITE_STRING_FILE_MKDIR_0755);
-+        r = write_string_file(fn, pid_string, 0|WRITE_STRING_FILE_MKDIR_0755);
-         if (r < 0) {
-                 log_error_errno(r, "Failed to move process: %m");
-                 goto finish;
-diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
-index 500725d35f..745b6815db 100644
---- a/src/nspawn/nspawn.c
-+++ b/src/nspawn/nspawn.c
-@@ -2857,7 +2857,7 @@ static int reset_audit_loginuid(void) {
-         if (streq(p, "4294967295"))
-                 return 0;
- 
--        r = write_string_file("/proc/self/loginuid", "4294967295", WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file("/proc/self/loginuid", "4294967295", 0);
-         if (r < 0) {
-                 log_error_errno(r,
-                                 "Failed to reset audit login UID. This probably means that your kernel is too\n"
-@@ -4588,7 +4588,7 @@ static int setup_uid_map(
-                 return log_oom();
- 
-         xsprintf(uid_map, "/proc/" PID_FMT "/uid_map", pid);
--        r = write_string_file(uid_map, s, WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file(uid_map, s, 0);
-         if (r < 0)
-                 return log_error_errno(r, "Failed to write UID map: %m");
- 
-@@ -4598,7 +4598,7 @@ static int setup_uid_map(
-                 return log_oom();
- 
-         xsprintf(uid_map, "/proc/" PID_FMT "/gid_map", pid);
--        r = write_string_file(uid_map, s, WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file(uid_map, s, 0);
-         if (r < 0)
-                 return log_error_errno(r, "Failed to write GID map: %m");
- 
-diff --git a/src/shared/binfmt-util.c b/src/shared/binfmt-util.c
-index a26175474b..1413a9c72c 100644
---- a/src/shared/binfmt-util.c
-+++ b/src/shared/binfmt-util.c
-@@ -46,7 +46,7 @@ int disable_binfmt(void) {
-                 return 0;
-         }
- 
--        r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0);
-         if (r < 0)
-                 return log_warning_errno(r, "Failed to unregister binfmt_misc entries: %m");
- 
-diff --git a/src/shared/cgroup-setup.c b/src/shared/cgroup-setup.c
-index 49d40f60d8..0f4aa8512a 100644
---- a/src/shared/cgroup-setup.c
-+++ b/src/shared/cgroup-setup.c
-@@ -369,7 +369,7 @@ int cg_attach(const char *controller, const char *path, pid_t pid) {
- 
-         xsprintf(c, PID_FMT "\n", pid);
- 
--        r = write_string_file(fs, c, WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file(fs, c, 0);
-         if (r == -EOPNOTSUPP && cg_is_threaded(path) > 0)
-                 /* When the threaded mode is used, we cannot read/write the file. Let's return recognizable error. */
-                 return -EUCLEAN;
-@@ -399,7 +399,7 @@ int cg_fd_attach(int fd, pid_t pid) {
- 
-         xsprintf(c, PID_FMT "\n", pid);
- 
--        return write_string_file_at(fd, "cgroup.procs", c, WRITE_STRING_FILE_DISABLE_BUFFER);
-+        return write_string_file_at(fd, "cgroup.procs", c, 0);
- }
- 
- int cg_attach_fallback(const char *controller, const char *path, pid_t pid) {
-@@ -1049,7 +1049,7 @@ int cg_install_release_agent(const char *controller, const char *agent) {
- 
-         sc = strstrip(contents);
-         if (isempty(sc)) {
--                r = write_string_file(fs, agent, WRITE_STRING_FILE_DISABLE_BUFFER);
-+                r = write_string_file(fs, agent, 0);
-                 if (r < 0)
-                         return r;
-         } else if (!path_equal(sc, agent))
-@@ -1067,7 +1067,7 @@ int cg_install_release_agent(const char *controller, const char *agent) {
- 
-         sc = strstrip(contents);
-         if (streq(sc, "0")) {
--                r = write_string_file(fs, "1", WRITE_STRING_FILE_DISABLE_BUFFER);
-+                r = write_string_file(fs, "1", 0);
-                 if (r < 0)
-                         return r;
- 
-@@ -1094,7 +1094,7 @@ int cg_uninstall_release_agent(const char *controller) {
-         if (r < 0)
-                 return r;
- 
--        r = write_string_file(fs, "0", WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file(fs, "0", 0);
-         if (r < 0)
-                 return r;
- 
-@@ -1104,7 +1104,7 @@ int cg_uninstall_release_agent(const char *controller) {
-         if (r < 0)
-                 return r;
- 
--        r = write_string_file(fs, "", WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file(fs, "", 0);
-         if (r < 0)
-                 return r;
- 
-diff --git a/src/shared/coredump-util.c b/src/shared/coredump-util.c
-index 805503f366..3234a1d76e 100644
---- a/src/shared/coredump-util.c
-+++ b/src/shared/coredump-util.c
-@@ -180,7 +180,7 @@ void disable_coredumps(void) {
-         if (detect_container() > 0)
-                 return;
- 
--        r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", 0);
-         if (r < 0)
-                 log_debug_errno(r, "Failed to turn off coredumps, ignoring: %m");
- }
-diff --git a/src/shared/hibernate-util.c b/src/shared/hibernate-util.c
-index 1213fdc2c7..4c26e6a4ee 100644
---- a/src/shared/hibernate-util.c
-+++ b/src/shared/hibernate-util.c
-@@ -498,7 +498,7 @@ int write_resume_config(dev_t devno, uint64_t offset, const char *device) {
- 
-         /* We write the offset first since it's safer. Note that this file is only available in 4.17+, so
-          * fail gracefully if it doesn't exist and we're only overwriting it with 0. */
--        r = write_string_file("/sys/power/resume_offset", offset_str, WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file("/sys/power/resume_offset", offset_str, 0);
-         if (r == -ENOENT) {
-                 if (offset != 0)
-                         return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
-@@ -514,7 +514,7 @@ int write_resume_config(dev_t devno, uint64_t offset, const char *device) {
-                 log_debug("Wrote resume_offset=%s for device '%s' to /sys/power/resume_offset.",
-                           offset_str, device);
- 
--        r = write_string_file("/sys/power/resume", devno_str, WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file("/sys/power/resume", devno_str, 0);
-         if (r < 0)
-                 return log_error_errno(r,
-                                        "Failed to write device '%s' (%s) to /sys/power/resume: %m",
-diff --git a/src/shared/smack-util.c b/src/shared/smack-util.c
-index d0a79b2635..0c82d9943a 100644
---- a/src/shared/smack-util.c
-+++ b/src/shared/smack-util.c
-@@ -113,7 +113,7 @@ int mac_smack_apply_pid(pid_t pid, const char *label) {
-                 return 0;
- 
-         p = procfs_file_alloca(pid, "attr/current");
--        r = write_string_file(p, label, WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file(p, label, 0);
-         if (r < 0)
-                 return r;
- 
-diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
-index 181bb4ccef..2dbb3f4bc6 100644
---- a/src/sleep/sleep.c
-+++ b/src/sleep/sleep.c
-@@ -158,7 +158,7 @@ static int write_mode(const char *path, char * const *modes) {
-         assert(path);
- 
-         STRV_FOREACH(mode, modes) {
--                r = write_string_file(path, *mode, WRITE_STRING_FILE_DISABLE_BUFFER);
-+                r = write_string_file(path, *mode, 0);
-                 if (r >= 0) {
-                         log_debug("Using sleep mode '%s' for %s.", *mode, path);
-                         return 0;
-diff --git a/src/storagetm/storagetm.c b/src/storagetm/storagetm.c
-index ca8e886d37..5c27c54f09 100644
---- a/src/storagetm/storagetm.c
-+++ b/src/storagetm/storagetm.c
-@@ -197,7 +197,7 @@ static int nvme_subsystem_unlink(NvmeSubsystem *s) {
-                                         if (!enable_fn)
-                                                 return log_oom();
- 
--                                        r = write_string_file_at(namespaces_fd, enable_fn, "0", WRITE_STRING_FILE_DISABLE_BUFFER);
-+                                        r = write_string_file_at(namespaces_fd, enable_fn, "0", 0);
-                                         if (r < 0)
-                                                 log_warning_errno(r, "Failed to disable namespace '%s' of NVME subsystem '%s', ignoring: %m", e->d_name, s->name);
- 
-@@ -265,7 +265,7 @@ static int nvme_subsystem_write_metadata(int subsystem_fd, sd_device *device) {
-                 _cleanup_free_ char *truncated = strndup(w, 40); /* kernel refuses more than 40 chars (as per nvme spec) */
- 
-                 /* The default string stored in 'attr_model' is "Linux" btw. */
--                r = write_string_file_at(subsystem_fd, "attr_model", truncated, WRITE_STRING_FILE_DISABLE_BUFFER);
-+                r = write_string_file_at(subsystem_fd, "attr_model", truncated, 0);
-                 if (r < 0)
-                         log_warning_errno(r, "Failed to set model of subsystem to '%s', ignoring: %m", w);
-         }
-@@ -279,7 +279,7 @@ static int nvme_subsystem_write_metadata(int subsystem_fd, sd_device *device) {
-                         return log_oom();
- 
-                  /* The default string stored in 'attr_firmware' is `uname -r` btw, but truncated to 8 chars. */
--                r = write_string_file_at(subsystem_fd, "attr_firmware", truncated, WRITE_STRING_FILE_DISABLE_BUFFER);
-+                r = write_string_file_at(subsystem_fd, "attr_firmware", truncated, 0);
-                 if (r < 0)
-                         log_warning_errno(r, "Failed to set model of subsystem to '%s', ignoring: %m", truncated);
-         }
-@@ -306,7 +306,7 @@ static int nvme_subsystem_write_metadata(int subsystem_fd, sd_device *device) {
-                 if (!truncated)
-                         return log_oom();
- 
--                r = write_string_file_at(subsystem_fd, "attr_serial", truncated, WRITE_STRING_FILE_DISABLE_BUFFER);
-+                r = write_string_file_at(subsystem_fd, "attr_serial", truncated, 0);
-                 if (r < 0)
-                         log_warning_errno(r, "Failed to set serial of subsystem to '%s', ignoring: %m", truncated);
-         }
-@@ -356,7 +356,7 @@ static int nvme_namespace_write_metadata(int namespace_fd, sd_device *device, co
-                 id = id128_digest(j, l);
-         }
- 
--        r = write_string_file_at(namespace_fd, "device_uuid", SD_ID128_TO_UUID_STRING(id), WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file_at(namespace_fd, "device_uuid", SD_ID128_TO_UUID_STRING(id), 0);
-         if (r < 0)
-                 log_warning_errno(r, "Failed to set uuid of namespace to '%s', ignoring: %m", SD_ID128_TO_UUID_STRING(id));
- 
-@@ -419,7 +419,7 @@ static int nvme_subsystem_add(const char *node, int consumed_fd, sd_device *devi
-         if (subsystem_fd < 0)
-                 return log_error_errno(subsystem_fd, "Failed to create NVME subsystem '%s': %m", j);
- 
--        r = write_string_file_at(subsystem_fd, "attr_allow_any_host", "1", WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file_at(subsystem_fd, "attr_allow_any_host", "1", 0);
-         if (r < 0)
-                 return log_error_errno(r, "Failed to set 'attr_allow_any_host' flag: %m");
- 
-@@ -434,11 +434,11 @@ static int nvme_subsystem_add(const char *node, int consumed_fd, sd_device *devi
- 
-         /* We use /proc/$PID/fd/$FD rather than /proc/self/fd/$FD, because this string is visible to others
-          * via configfs, and by including the PID it's clear to who the stuff belongs. */
--        r = write_string_file_at(namespace_fd, "device_path", FORMAT_PROC_PID_FD_PATH(0, fd), WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file_at(namespace_fd, "device_path", FORMAT_PROC_PID_FD_PATH(0, fd), 0);
-         if (r < 0)
-                 return log_error_errno(r, "Failed to write 'device_path' attribute: %m");
- 
--        r = write_string_file_at(namespace_fd, "enable", "1", WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file_at(namespace_fd, "enable", "1", 0);
-         if (r < 0)
-                 return log_error_errno(r, "Failed to write 'enable' attribute: %m");
- 
-@@ -568,19 +568,19 @@ static int nvme_port_add_portnr(
-                 return 0;
-         }
- 
--        r = write_string_file_at(port_fd, "addr_adrfam", af_to_ipv4_ipv6(ip_family), WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file_at(port_fd, "addr_adrfam", af_to_ipv4_ipv6(ip_family), 0);
-         if (r < 0)
-                 return log_error_errno(r, "Failed to set address family on NVME port %" PRIu16 ": %m", portnr);
- 
--        r = write_string_file_at(port_fd, "addr_trtype", "tcp", WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file_at(port_fd, "addr_trtype", "tcp", 0);
-         if (r < 0)
-                 return log_error_errno(r, "Failed to set transport type on NVME port %" PRIu16 ": %m", portnr);
- 
--        r = write_string_file_at(port_fd, "addr_trsvcid", fname, WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file_at(port_fd, "addr_trsvcid", fname, 0);
-         if (r < 0)
-                 return log_error_errno(r, "Failed to set IP port on NVME port %" PRIu16 ": %m", portnr);
- 
--        r = write_string_file_at(port_fd, "addr_traddr", ip_family == AF_INET6 ? "::" : "0.0.0.0", WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file_at(port_fd, "addr_traddr", ip_family == AF_INET6 ? "::" : "0.0.0.0", 0);
-         if (r < 0)
-                 return log_error_errno(r, "Failed to set IP address on NVME port %" PRIu16 ": %m", portnr);
- 
-diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c
-index ba742dda69..6f20e81615 100644
---- a/src/vconsole/vconsole-setup.c
-+++ b/src/vconsole/vconsole-setup.c
-@@ -277,7 +277,7 @@ static int toggle_utf8_vc(const char *name, int fd, bool utf8) {
- static int toggle_utf8_sysfs(bool utf8) {
-         int r;
- 
--        r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), WRITE_STRING_FILE_DISABLE_BUFFER);
-+        r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), 0);
-         if (r < 0)
-                 return log_warning_errno(r, "Failed to %s sysfs UTF-8 flag: %m", enable_disable(utf8));
- 
-2.34.1
-
new file mode 100644
@@ -0,0 +1,47 @@ 
+From 3deaad26b98ce024a938aa61c1609cbd038da369 Mon Sep 17 00:00:00 2001
+From: Chen Qi <Qi.Chen@windriver.com>
+Date: Mon, 29 Sep 2025 14:59:27 +0800
+Subject: [PATCH 12/16] src/shared/condition.c: avoid using glibc
+ ConditionVersion
+
+The ConditionVersion on glibc is glibc specific.
+And musl does not export programming interface to get its version.
+So it cannot be extended to musl.
+
+Upstream-Status: Inappropriate [musl specific]
+
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+---
+ src/shared/condition.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/src/shared/condition.c b/src/shared/condition.c
+index b09eff1bfb..4899bd6c39 100644
+--- a/src/shared/condition.c
++++ b/src/shared/condition.c
+@@ -2,7 +2,9 @@
+ 
+ #include <fcntl.h>
+ #include <fnmatch.h>
++#ifdef __GLIBC__
+ #include <gnu/libc-version.h>
++#endif
+ #include <sys/stat.h>
+ #include <sys/utsname.h>
+ #include <time.h>
+@@ -254,10 +256,10 @@ static int condition_test_version(Condition *c, char **env) {
+ 
+         if (streq(word, "systemd"))
+                 return condition_test_version_cmp(p, STRINGIFY(PROJECT_VERSION));
+-
++#ifdef __GLIBC__
+         if (streq(word, "glibc"))
+                 return condition_test_version_cmp(p, gnu_get_libc_version());
+-
++#endif
+         /* if no predicate has been set, default to "kernel" and use the whole parameter as condition */
+         if (!streq(word, "kernel"))
+                 p = c->parameter;
+-- 
+2.34.1
+
deleted file mode 100644
@@ -1,60 +0,0 @@ 
-From ab4fda874b26542de96720db58cb0e8704a40108 Mon Sep 17 00:00:00 2001
-From: Scott Murray <scott.murray@konsulko.com>
-Date: Fri, 13 Sep 2019 19:26:27 -0400
-Subject: [PATCH 13/26] Handle __cpu_mask usage
-
-Fixes errors:
-
-src/test/test-cpu-set-util.c:18:54: error: '__cpu_mask' undeclared (first use in this function)
-src/test/test-sizeof.c:73:14: error: '__cpu_mask' undeclared (first use in this function)
-
-__cpu_mask is an internal type of glibc's cpu_set implementation, not
-part of the POSIX definition, which is problematic when building with
-musl, which does not define a matching type.  From inspection of musl's
-sched.h, however, it is clear that the corresponding type would be
-unsigned long, which does match glibc's actual __CPU_MASK_TYPE.  So,
-add a typedef to cpu-set-util.h defining __cpu_mask appropriately.
-
-Upstream-Status: Inappropriate [musl specific]
-
-Signed-off-by: Scott Murray <scott.murray@konsulko.com>
----
- src/shared/cpu-set-util.h | 2 ++
- src/test/test-sizeof.c    | 2 +-
- 2 files changed, 3 insertions(+), 1 deletion(-)
-
-diff --git a/src/shared/cpu-set-util.h b/src/shared/cpu-set-util.h
-index 2c477d8a01..c026ce77a6 100644
---- a/src/shared/cpu-set-util.h
-+++ b/src/shared/cpu-set-util.h
-@@ -6,6 +6,8 @@
- #include "macro.h"
- #include "missing_syscall.h"
- 
-+typedef unsigned long __cpu_mask;
-+
- /* This wraps the libc interface with a variable to keep the allocated size. */
- typedef struct CPUSet {
-         cpu_set_t *set;
-diff --git a/src/test/test-sizeof.c b/src/test/test-sizeof.c
-index ea0c58770e..b65c0bd370 100644
---- a/src/test/test-sizeof.c
-+++ b/src/test/test-sizeof.c
-@@ -1,6 +1,5 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
--#include <sched.h>
- #include <stdio.h>
- #include <string.h>
- #include <sys/resource.h>
-@@ -12,6 +11,7 @@
- #include <float.h>
- 
- #include "time-util.h"
-+#include "cpu-set-util.h"
- 
- /* Print information about various types. Useful when diagnosing
-  * gcc diagnostics on an unfamiliar architecture. */
-2.34.1
-
similarity index 77%
rename from meta/recipes-core/systemd/systemd/0026-build-path.c-avoid-boot-time-segfault-for-musl.patch
rename to meta/recipes-core/systemd/systemd/0013-build-path.c-avoid-boot-time-segfault-for-musl.patch
@@ -1,7 +1,7 @@ 
-From f2a7cf1d2a2bc2516a180809efd85c828cd9c7f4 Mon Sep 17 00:00:00 2001
+From a4b921b8d408e0f1c9d035a3ec93c3da3fe42352 Mon Sep 17 00:00:00 2001
 From: Chen Qi <Qi.Chen@windriver.com>
 Date: Wed, 3 Jul 2024 07:18:42 -0700
-Subject: [PATCH 26/26] build-path.c: avoid boot time segfault for musl
+Subject: [PATCH 13/16] build-path.c: avoid boot time segfault for musl
 
 This function, at runtime, should return -ENOEXEC. For musl, it
 somehow segfaults. I think it's related to getauxval, but it's
@@ -15,10 +15,10 @@  Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
  1 file changed, 1 insertion(+)
 
 diff --git a/src/basic/build-path.c b/src/basic/build-path.c
-index b5972658df..4ef551034e 100644
+index 577ff72bce..3a7876798c 100644
 --- a/src/basic/build-path.c
 +++ b/src/basic/build-path.c
-@@ -151,6 +151,7 @@ int get_build_exec_dir(char **ret) {
+@@ -152,6 +152,7 @@ int get_build_exec_dir(char **ret) {
           */
  
          static int runpath_cached = -ERRNO_MAX-1;
similarity index 71%
rename from meta/recipes-core/systemd/systemd/0014-Handle-missing-gshadow.patch
rename to meta/recipes-core/systemd/systemd/0014-Handle-missing-gshadow-for-musl.patch
@@ -1,7 +1,7 @@ 
-From c5165f6adf8a9cfe8c0784c598b87d7d7e8b7d1a Mon Sep 17 00:00:00 2001
+From 6018d55f5fcab127fef9acbd250cdc185983ba59 Mon Sep 17 00:00:00 2001
 From: Alex Kiernan <alex.kiernan@gmail.com>
 Date: Tue, 10 Mar 2020 11:05:20 +0000
-Subject: [PATCH 14/26] Handle missing gshadow
+Subject: [PATCH 14/16] Handle missing gshadow for musl
 
 gshadow usage is now present in the userdb code. Mask all uses of it to
 allow compilation on musl
@@ -10,17 +10,36 @@  Upstream-Status: Inappropriate [musl specific]
 Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
 [Rebased for v247]
 Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
+[Rebased for v258]
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
 ---
- src/shared/user-record-nss.c | 20 ++++++++++++++++++++
- src/shared/user-record-nss.h |  4 ++++
- src/shared/userdb.c          |  7 ++++++-
- 3 files changed, 30 insertions(+), 1 deletion(-)
+ src/include/override/gshadow.h | 10 ++++++++++
+ src/shared/user-record-nss.c   | 20 ++++++++++++++++++++
+ src/shared/userdb.c            |  7 ++++++-
+ 3 files changed, 36 insertions(+), 1 deletion(-)
+ create mode 100644 src/include/override/gshadow.h
 
+diff --git a/src/include/override/gshadow.h b/src/include/override/gshadow.h
+new file mode 100644
+index 0000000000..568a9bb2d9
+--- /dev/null
++++ b/src/include/override/gshadow.h
+@@ -0,0 +1,10 @@
++#ifndef _GSHADOW_H
++#define _GSHADOW_H    1
++
++#if ENABLE_GSHADOW
++#include_next <gshadow.h>
++#else
++struct sgrp;
++#endif
++
++#endif /* gshadow.h */
 diff --git a/src/shared/user-record-nss.c b/src/shared/user-record-nss.c
-index 9223a2e6ca..f9eb1a5b64 100644
+index 10a5a75e9f..24db7c953d 100644
 --- a/src/shared/user-record-nss.c
 +++ b/src/shared/user-record-nss.c
-@@ -286,8 +286,10 @@ int nss_group_to_group_record(
+@@ -296,8 +296,10 @@ int nss_group_to_group_record(
          if (isempty(grp->gr_name))
                  return -EINVAL;
  
@@ -31,7 +50,7 @@  index 9223a2e6ca..f9eb1a5b64 100644
  
          g = group_record_new();
          if (!g)
-@@ -303,6 +305,7 @@ int nss_group_to_group_record(
+@@ -313,6 +315,7 @@ int nss_group_to_group_record(
  
          g->gid = grp->gr_gid;
  
@@ -39,7 +58,7 @@  index 9223a2e6ca..f9eb1a5b64 100644
          if (sgrp) {
                  if (looks_like_hashed_password(utf8_only(sgrp->sg_passwd))) {
                          g->hashed_password = strv_new(sgrp->sg_passwd);
-@@ -318,6 +321,7 @@ int nss_group_to_group_record(
+@@ -328,6 +331,7 @@ int nss_group_to_group_record(
                  if (r < 0)
                          return r;
          }
@@ -47,15 +66,15 @@  index 9223a2e6ca..f9eb1a5b64 100644
  
          r = sd_json_buildo(
                          &g->json,
-@@ -345,6 +349,7 @@ int nss_sgrp_for_group(const struct group *grp, struct sgrp *ret_sgrp, char **re
+@@ -355,6 +359,7 @@ int nss_sgrp_for_group(const struct group *grp, struct sgrp *ret_sgrp, char **re
          assert(ret_sgrp);
          assert(ret_buffer);
  
 +#if ENABLE_GSHADOW
          for (;;) {
                  _cleanup_free_ char *buf = NULL;
-                 struct sgrp sgrp, *result;
-@@ -373,6 +378,9 @@ int nss_sgrp_for_group(const struct group *grp, struct sgrp *ret_sgrp, char **re
+                 struct sgrp sgrp = {}, *result = NULL;
+@@ -383,6 +388,9 @@ int nss_sgrp_for_group(const struct group *grp, struct sgrp *ret_sgrp, char **re
                  buflen *= 2;
                  buf = mfree(buf);
          }
@@ -65,7 +84,7 @@  index 9223a2e6ca..f9eb1a5b64 100644
  }
  
  int nss_group_record_by_name(
-@@ -383,7 +391,9 @@ int nss_group_record_by_name(
+@@ -393,7 +401,9 @@ int nss_group_record_by_name(
          _cleanup_free_ char *sbuf = NULL;
          _cleanup_free_ struct group *result = NULL;
          bool incomplete = false;
@@ -75,7 +94,7 @@  index 9223a2e6ca..f9eb1a5b64 100644
          int r;
  
          assert(name);
-@@ -392,6 +402,7 @@ int nss_group_record_by_name(
+@@ -402,6 +412,7 @@ int nss_group_record_by_name(
          if (r < 0)
                  return r;
  
@@ -83,7 +102,7 @@  index 9223a2e6ca..f9eb1a5b64 100644
          if (with_shadow) {
                  r = nss_sgrp_for_group(result, &sgrp, &sbuf);
                  if (r < 0) {
-@@ -403,6 +414,9 @@ int nss_group_record_by_name(
+@@ -413,6 +424,9 @@ int nss_group_record_by_name(
                  incomplete = true;
  
          r = nss_group_to_group_record(result, sresult, ret);
@@ -93,7 +112,7 @@  index 9223a2e6ca..f9eb1a5b64 100644
          if (r < 0)
                  return r;
  
-@@ -419,13 +433,16 @@ int nss_group_record_by_gid(
+@@ -429,13 +443,16 @@ int nss_group_record_by_gid(
          _cleanup_free_ char *sbuf = NULL;
          _cleanup_free_ struct group *result = NULL;
          bool incomplete = false;
@@ -110,7 +129,7 @@  index 9223a2e6ca..f9eb1a5b64 100644
          if (with_shadow) {
                  r = nss_sgrp_for_group(result, &sgrp, &sbuf);
                  if (r < 0) {
-@@ -437,6 +454,9 @@ int nss_group_record_by_gid(
+@@ -447,6 +464,9 @@ int nss_group_record_by_gid(
                  incomplete = true;
  
          r = nss_group_to_group_record(result, sresult, ret);
@@ -120,27 +139,11 @@  index 9223a2e6ca..f9eb1a5b64 100644
          if (r < 0)
                  return r;
  
-diff --git a/src/shared/user-record-nss.h b/src/shared/user-record-nss.h
-index 22ab04d6ee..4e52e7a911 100644
---- a/src/shared/user-record-nss.h
-+++ b/src/shared/user-record-nss.h
-@@ -2,7 +2,11 @@
- #pragma once
- 
- #include <grp.h>
-+#if ENABLE_GSHADOW
- #include <gshadow.h>
-+#else
-+struct sgrp;
-+#endif
- #include <pwd.h>
- #include <shadow.h>
- 
 diff --git a/src/shared/userdb.c b/src/shared/userdb.c
-index ff83d4bf90..54d36cc706 100644
+index 49850ff216..f4217c0971 100644
 --- a/src/shared/userdb.c
 +++ b/src/shared/userdb.c
-@@ -1042,13 +1042,15 @@ int groupdb_iterator_get(UserDBIterator *iterator, GroupRecord **ret) {
+@@ -1551,13 +1551,15 @@ static int groupdb_iterator_get_one(UserDBIterator *iterator, GroupRecord **ret)
                  if (gr) {
                          _cleanup_free_ char *buffer = NULL;
                          bool incomplete = false;
@@ -157,7 +160,7 @@  index ff83d4bf90..54d36cc706 100644
                          if (!FLAGS_SET(iterator->flags, USERDB_SUPPRESS_SHADOW)) {
                                  r = nss_sgrp_for_group(gr, &sgrp, &buffer);
                                  if (r < 0) {
-@@ -1061,6 +1063,9 @@ int groupdb_iterator_get(UserDBIterator *iterator, GroupRecord **ret) {
+@@ -1570,6 +1572,9 @@ static int groupdb_iterator_get_one(UserDBIterator *iterator, GroupRecord **ret)
                          }
  
                          r = nss_group_to_group_record(gr, r >= 0 ? &sgrp : NULL, ret);
new file mode 100644
@@ -0,0 +1,35 @@ 
+From 5dbeaee2085d3edcf20983fce4208eb174e46422 Mon Sep 17 00:00:00 2001
+From: Chen Qi <Qi.Chen@windriver.com>
+Date: Thu, 9 Oct 2025 15:19:09 +0800
+Subject: [PATCH 15/16] Avoid sequence-point error
+
+See https://www.openwall.com/lists/musl/2025/09/30/4
+
+Upstream-Status: Inappropriate [musl specific]
+
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+---
+ src/shared/cpu-set-util.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/src/shared/cpu-set-util.c b/src/shared/cpu-set-util.c
+index 7a155c12d4..a9c57fc31c 100644
+--- a/src/shared/cpu-set-util.c
++++ b/src/shared/cpu-set-util.c
+@@ -97,9 +97,11 @@ char* cpu_set_to_mask_string(const CPUSet *c) {
+         for (size_t i = c->allocated * 8; i > 0; ) {
+                 uint32_t m = 0;
+ 
+-                for (int j = (i % 32 ?: 32) - 1; j >= 0; j--)
+-                        if (CPU_ISSET_S(--i, c->allocated, c->set))
++                for (int j = (i % 32 ?: 32) - 1; j >= 0; j--) {
++                        --i;
++                        if (CPU_ISSET_S(i, c->allocated, c->set))
+                                 SET_BIT(m, j);
++                }
+ 
+                 if (!found_nonzero) {
+                         if (m == 0)
+-- 
+2.34.1
+
deleted file mode 100644
@@ -1,42 +0,0 @@ 
-From ef9ad83759f78de983d2d7c4f95bc48b83bb8f66 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Mon, 12 Apr 2021 23:44:53 -0700
-Subject: [PATCH 15/26] missing_syscall.h: Define MIPS ABI defines for musl
-
-musl does not define _MIPS_SIM_ABI32, _MIPS_SIM_NABI32, _MIPS_SIM_ABI64
-unlike glibc where these are provided by libc headers, therefore define
-them here in case they are undefined
-
-Upstream-Status: Pending
-
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- src/basic/missing_syscall.h  | 6 ++++++
- src/shared/base-filesystem.c | 1 +
- 2 files changed, 7 insertions(+)
-
---- a/src/basic/missing_syscall.h
-+++ b/src/basic/missing_syscall.h
-@@ -20,6 +20,12 @@
- #include <asm/sgidefs.h>
- #endif
- 
-+#ifndef _MIPS_SIM_ABI32
-+#define _MIPS_SIM_ABI32	1
-+#define _MIPS_SIM_NABI32 2
-+#define _MIPS_SIM_ABI64	3
-+#endif
-+
- #include "macro.h"
- #include "missing_keyctl.h"
- #include "missing_sched.h"
---- a/src/shared/base-filesystem.c
-+++ b/src/shared/base-filesystem.c
-@@ -20,6 +20,7 @@
- #include "string-util.h"
- #include "umask-util.h"
- #include "user-util.h"
-+#include "missing_syscall.h"
- 
- typedef enum BaseFilesystemFlags {
-         BASE_FILESYSTEM_IGNORE_ON_FAILURE = 1 << 0,
new file mode 100644
@@ -0,0 +1,409 @@ 
+From bedd0563f4b142aa6376a2ad1e2884d2c0dc3e45 Mon Sep 17 00:00:00 2001
+From: Chen Qi <Qi.Chen@windriver.com>
+Date: Mon, 13 Oct 2025 17:07:57 +0800
+Subject: [PATCH 16/16] Fix the segfault for glob related codes and define
+ dummy macros
+
+systemd switches to use its own free function to free gl_pathv
+located by glob() function. This causes segfault error for musl.
+
+The backtrace is like below:
+get_meta (p=p@entry=0x7ffff7b39fa8 "/proc/sys/net/ipv4/conf/all/rp_filter")
+    at /usr/src/debug/musl/1.2.5+git/src/malloc/mallocng/meta.h:131
+    131             assert(!((uintptr_t)p & 15));
+
+Why so? Because it's expected that people use globfree to do the memory
+freeing work. Invoking free on gl_pathv[*] is not freeing the correct
+memory address.
+
+The key line in musl's globfree is as below:
+  free(g->gl_pathv[g->gl_offs + i] - offsetof(struct match, name));
+
+So we can see the addree is not gl_pathv[*], it's
+gl_pathv[*] - offsetof(struct match, name).
+
+To address this issue, revert the following codes:
+1. Revert "glob-util: rework safe_glob()"
+   This reverts commit 2a5f950e5643a74bef70b1c3c46ec33ad0e3fd41.
+2. Revert "glob-util: drop unused _cleanup_globfree_"
+   This reverts commit f117272f6645fc2fe9751898770603ed07d15cea.
+
+There is no functional change.
+
+Also, define dummy macros to make things compile for musl.
+
+Note:
+If systemd later adopts some dramatic change for glob, we might
+need to adopt other methods instead of doing the revert. In this
+version, reverting is prefered because there is NO functional change.
+
+Upstream-Status: Inappropriate [musl specific]
+
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+---
+ src/basic/glob-util.c       | 96 ++++++++++++++++++-------------------
+ src/basic/glob-util.h       | 12 ++---
+ src/core/exec-credential.c  |  6 +--
+ src/core/execute.c          |  8 ++--
+ src/include/override/glob.h |  6 +++
+ src/test/test-glob-util.c   | 27 ++++++-----
+ src/tmpfiles/tmpfiles.c     | 20 +++++---
+ 7 files changed, 95 insertions(+), 80 deletions(-)
+ create mode 100644 src/include/override/glob.h
+
+diff --git a/src/basic/glob-util.c b/src/basic/glob-util.c
+index 5843ef088f..a9c62151af 100644
+--- a/src/basic/glob-util.c
++++ b/src/basic/glob-util.c
+@@ -6,83 +6,81 @@
+ #include "dirent-util.h"
+ #include "errno-util.h"
+ #include "glob-util.h"
++#include "log.h"
+ #include "string-util.h"
+ #include "strv.h"
+ 
+-DEFINE_TRIVIAL_DESTRUCTOR(closedir_wrapper, void, closedir);
+-
+-int safe_glob_full(const char *path, int flags, opendir_t opendir_func, char ***ret) {
+-        _cleanup_(globfree) glob_t g = {
+-                .gl_closedir = closedir_wrapper,
+-                .gl_readdir = (struct dirent* (*)(void *)) readdir_no_dot,
+-                .gl_opendir = (void* (*)(const char *)) (opendir_func ?: opendir),
+-                .gl_lstat = lstat,
+-                .gl_stat = stat,
+-        };
+-        int r;
+-
+-        assert(path);
++static void closedir_wrapper(void* v) {
++        (void) closedir(v);
++}
+ 
++int safe_glob(const char *path, int flags, glob_t *pglob) {
++        int k;
++
++        /* We want to set GLOB_ALTDIRFUNC ourselves, don't allow it to be set. */
++        assert(!(flags & GLOB_ALTDIRFUNC));
++#ifdef __GLIBC__
++        if (!pglob->gl_closedir)
++                pglob->gl_closedir = closedir_wrapper;
++        if (!pglob->gl_readdir)
++                pglob->gl_readdir = (struct dirent *(*)(void *)) readdir_no_dot;
++        if (!pglob->gl_opendir)
++                pglob->gl_opendir = (void *(*)(const char *)) opendir;
++        if (!pglob->gl_lstat)
++                pglob->gl_lstat = lstat;
++        if (!pglob->gl_stat)
++                pglob->gl_stat = stat;
++#endif
+         errno = 0;
+-        r = glob(path, flags | GLOB_ALTDIRFUNC, NULL, &g);
+-        if (r == GLOB_NOMATCH)
++        k = glob(path, flags | GLOB_ALTDIRFUNC, NULL, pglob);
++        if (k == GLOB_NOMATCH)
+                 return -ENOENT;
+-        if (r == GLOB_NOSPACE)
++        if (k == GLOB_NOSPACE)
+                 return -ENOMEM;
+-        if (r != 0)
++        if (k != 0)
+                 return errno_or_else(EIO);
+-
+-        if (strv_isempty(g.gl_pathv))
++        if (strv_isempty(pglob->gl_pathv))
+                 return -ENOENT;
+ 
+-        if (ret) {
+-                *ret = g.gl_pathv;
+-                TAKE_STRUCT(g); /* To avoid the result being freed. */
+-        }
+-
+         return 0;
+ }
+ 
+-int glob_first(const char *path, char **ret) {
+-        _cleanup_strv_free_ char **v = NULL;
+-        int r;
++int glob_first(const char *path, char **ret_first) {
++        _cleanup_globfree_ glob_t g = {};
++        int k;
+ 
+         assert(path);
+ 
+-        r = safe_glob(path, GLOB_NOSORT|GLOB_BRACE, &v);
+-        if (r == -ENOENT) {
+-                if (ret)
+-                        *ret = NULL;
++        k = safe_glob(path, GLOB_NOSORT|GLOB_BRACE, &g);
++        if (k == -ENOENT) {
++                if (ret_first)
++                        *ret_first = NULL;
+                 return false;
+         }
+-        if (r < 0)
+-                return r;
+-
+-        assert(!strv_isempty(v));
++        if (k < 0)
++                return k;
+ 
+-        if (ret) {
+-                /* Free all results except for the first one. */
+-                STRV_FOREACH(p, strv_skip(v, 1))
+-                        *p = mfree(*p);
++        if (ret_first) {
++                assert(g.gl_pathv && g.gl_pathv[0]);
+ 
+-                /* Then, take the first result. */
+-                *ret = TAKE_PTR(*v);
++                char *first = strdup(g.gl_pathv[0]);
++                if (!first)
++                        return log_oom_debug();
++                *ret_first = first;
+         }
+ 
+         return true;
+ }
+ 
+ int glob_extend(char ***strv, const char *path, int flags) {
+-        char **v;
+-        int r;
+-
+-        assert(path);
++        _cleanup_globfree_ glob_t g = {};
++        int k;
+ 
+-        r = safe_glob(path, GLOB_NOSORT|GLOB_BRACE|flags, &v);
+-        if (r < 0)
+-                return r;
++        k = safe_glob(path, GLOB_NOSORT|GLOB_BRACE|flags, &g);
++        if (k < 0)
++                return k;
+ 
+-        return strv_extend_strv_consume(strv, v, /* filter_duplicates = */ false);
++        return strv_extend_strv(strv, g.gl_pathv, false);
+ }
+ 
+ int glob_non_glob_prefix(const char *path, char **ret) {
+diff --git a/src/basic/glob-util.h b/src/basic/glob-util.h
+index ea3e869319..4fa23f5048 100644
+--- a/src/basic/glob-util.h
++++ b/src/basic/glob-util.h
+@@ -5,18 +5,16 @@
+ 
+ #include "forward.h"
+ 
+-typedef DIR* (*opendir_t)(const char *);
+-
+-int safe_glob_full(const char *path, int flags, opendir_t opendir_func, char ***ret);
+-static inline int safe_glob(const char *path, int flags, char ***ret) {
+-        return safe_glob_full(path, flags, NULL, ret);
+-}
++/* Note: this function modifies pglob to set various functions. */
++int safe_glob(const char *path, int flags, glob_t *pglob);
+ 
+ /* Note: which match is returned depends on the implementation/system and not guaranteed to be stable */
+-int glob_first(const char *path, char **ret);
++int glob_first(const char *path, char **ret_first);
+ #define glob_exists(path) glob_first(path, NULL)
+ int glob_extend(char ***strv, const char *path, int flags);
+ 
+ int glob_non_glob_prefix(const char *path, char **ret);
+ 
++#define _cleanup_globfree_ _cleanup_(globfree)
++
+ bool string_is_glob(const char *p) _pure_;
+diff --git a/src/core/exec-credential.c b/src/core/exec-credential.c
+index 5e2bc8edd9..32cbb4d4d0 100644
+--- a/src/core/exec-credential.c
++++ b/src/core/exec-credential.c
+@@ -556,20 +556,20 @@ static int load_credential_glob(
+         assert(search_path);
+ 
+         STRV_FOREACH(d, search_path) {
+-                _cleanup_strv_free_ char **paths = NULL;
++                _cleanup_globfree_ glob_t pglob = {};
+                 _cleanup_free_ char *j = NULL;
+ 
+                 j = path_join(*d, ic->glob);
+                 if (!j)
+                         return -ENOMEM;
+ 
+-                r = safe_glob(j, /* flags = */ 0, &paths);
++                r = safe_glob(j, 0, &pglob);
+                 if (r == -ENOENT)
+                         continue;
+                 if (r < 0)
+                         return r;
+ 
+-                STRV_FOREACH(p, paths) {
++                FOREACH_ARRAY(p, pglob.gl_pathv, pglob.gl_pathc) {
+                         _cleanup_free_ char *fn = NULL;
+                         _cleanup_(erase_and_freep) char *data = NULL;
+                         size_t size;
+diff --git a/src/core/execute.c b/src/core/execute.c
+index c384e9dd63..3d6546c037 100644
+--- a/src/core/execute.c
++++ b/src/core/execute.c
+@@ -897,7 +897,7 @@ static int exec_context_load_environment(const Unit *unit, const ExecContext *c,
+         assert(ret);
+ 
+         STRV_FOREACH(i, c->environment_files) {
+-                _cleanup_strv_free_ char **paths = NULL;
++                _cleanup_globfree_ glob_t pglob = {};
+                 bool ignore = false;
+                 char *fn = *i;
+ 
+@@ -913,7 +913,7 @@ static int exec_context_load_environment(const Unit *unit, const ExecContext *c,
+                 }
+ 
+                 /* Filename supports globbing, take all matching files */
+-                r = safe_glob(fn, /* flags = */ 0, &paths);
++                r = safe_glob(fn, 0, &pglob);
+                 if (r < 0) {
+                         if (ignore)
+                                 continue;
+@@ -921,9 +921,9 @@ static int exec_context_load_environment(const Unit *unit, const ExecContext *c,
+                 }
+ 
+                 /* When we don't match anything, -ENOENT should be returned */
+-                assert(!strv_isempty(paths));
++                assert(pglob.gl_pathc > 0);
+ 
+-                STRV_FOREACH(path, paths) {
++                FOREACH_ARRAY(path, pglob.gl_pathv, pglob.gl_pathc) {
+                         _cleanup_strv_free_ char **p = NULL;
+ 
+                         r = load_env_file(NULL, *path, &p);
+diff --git a/src/include/override/glob.h b/src/include/override/glob.h
+new file mode 100644
+index 0000000000..a8f1829766
+--- /dev/null
++++ b/src/include/override/glob.h
+@@ -0,0 +1,6 @@
++#pragma once
++
++#include_next <glob.h>
++
++#define GLOB_BRACE 0
++#define GLOB_ALTDIRFUNC 0
+diff --git a/src/test/test-glob-util.c b/src/test/test-glob-util.c
+index a9880f15c8..754dc77447 100644
+--- a/src/test/test-glob-util.c
++++ b/src/test/test-glob-util.c
+@@ -9,7 +9,6 @@
+ #include "fs-util.h"
+ #include "glob-util.h"
+ #include "rm-rf.h"
+-#include "strv.h"
+ #include "tests.h"
+ #include "tmpfile-util.h"
+ 
+@@ -55,25 +54,31 @@ TEST(glob_exists) {
+ TEST(safe_glob) {
+         char template[] = "/tmp/test-glob-util.XXXXXXX";
+         const char *fn, *fn2, *fname;
+-        _cleanup_strv_free_ char **v = NULL;
+ 
+-        ASSERT_NOT_NULL(mkdtemp(template));
++        _cleanup_globfree_ glob_t g = {};
++        int r;
++
++        assert_se(mkdtemp(template));
+ 
+         fn = strjoina(template, "/*");
+-        ASSERT_ERROR(safe_glob(fn, /* flags = */ 0, &v), ENOENT);
++        r = safe_glob(fn, 0, &g);
++        assert_se(r == -ENOENT);
+ 
+         fn2 = strjoina(template, "/.*");
+-        ASSERT_ERROR(safe_glob(fn2, GLOB_NOSORT|GLOB_BRACE, &v), ENOENT);
++        r = safe_glob(fn2, GLOB_NOSORT|GLOB_BRACE, &g);
++        assert_se(r == -ENOENT);
+ 
+         fname = strjoina(template, "/.foobar");
+-        ASSERT_OK(touch(fname));
++        assert_se(touch(fname) == 0);
+ 
+-        ASSERT_ERROR(safe_glob(fn, /* flags = */ 0, &v), ENOENT);
++        r = safe_glob(fn, 0, &g);
++        assert_se(r == -ENOENT);
+ 
+-        ASSERT_OK(safe_glob(fn2, GLOB_NOSORT|GLOB_BRACE, &v));
+-        ASSERT_EQ(strv_length(v), 1u);
+-        ASSERT_STREQ(v[0], fname);
+-        ASSERT_NULL(v[1]);
++        r = safe_glob(fn2, GLOB_NOSORT|GLOB_BRACE, &g);
++        assert_se(r == 0);
++        assert_se(g.gl_pathc == 1);
++        ASSERT_STREQ(g.gl_pathv[0], fname);
++        ASSERT_NULL(g.gl_pathv[1]);
+ 
+         (void) rm_rf(template, REMOVE_ROOT|REMOVE_PHYSICAL);
+ }
+diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
+index 4342ed70ab..2e1fd87f54 100644
+--- a/src/tmpfiles/tmpfiles.c
++++ b/src/tmpfiles/tmpfiles.c
+@@ -2575,21 +2575,25 @@ finish:
+ }
+ 
+ static int glob_item(Context *c, Item *i, action_t action) {
+-        _cleanup_strv_free_ char **paths = NULL;
++        _cleanup_globfree_ glob_t g = {
++#ifdef __GLIBC__
++                .gl_opendir = (void *(*)(const char *)) opendir_nomod,
++#endif
++        };
+         int r;
+ 
+         assert(c);
+         assert(i);
+         assert(action);
+ 
+-        r = safe_glob_full(i->path, GLOB_NOSORT|GLOB_BRACE, opendir_nomod, &paths);
++        r = safe_glob(i->path, GLOB_NOSORT|GLOB_BRACE, &g);
+         if (r == -ENOENT)
+                 return 0;
+         if (r < 0)
+                 return log_error_errno(r, "Failed to glob '%s': %m", i->path);
+ 
+         r = 0;
+-        STRV_FOREACH(fn, paths)
++        STRV_FOREACH(fn, g.gl_pathv)
+                 /* We pass CREATION_EXISTING here, since if we are globbing for it, it always has to exist */
+                 RET_GATHER(r, action(c, i, *fn, CREATION_EXISTING));
+ 
+@@ -2601,21 +2605,25 @@ static int glob_item_recursively(
+                 Item *i,
+                 fdaction_t action) {
+ 
+-        _cleanup_strv_free_ char **paths = NULL;
++        _cleanup_globfree_ glob_t g = {
++#ifdef __GLIBC__
++                .gl_opendir = (void *(*)(const char *)) opendir_nomod,
++#endif
++        };
+         int r;
+ 
+         assert(c);
+         assert(i);
+         assert(action);
+ 
+-        r = safe_glob_full(i->path, GLOB_NOSORT|GLOB_BRACE, opendir_nomod, &paths);
++        r = safe_glob(i->path, GLOB_NOSORT|GLOB_BRACE, &g);
+         if (r == -ENOENT)
+                 return 0;
+         if (r < 0)
+                 return log_error_errno(r, "Failed to glob '%s': %m", i->path);
+ 
+         r = 0;
+-        STRV_FOREACH(fn, paths) {
++        STRV_FOREACH(fn, g.gl_pathv) {
+                 _cleanup_close_ int fd = -EBADF;
+ 
+                 /* Make sure we won't trigger/follow file object (such as device nodes, automounts, ...)
+-- 
+2.34.1
+
deleted file mode 100644
@@ -1,37 +0,0 @@ 
-From 9079b158779a9c395c24f882f72a1c734795045d Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Fri, 21 Jan 2022 15:15:11 -0800
-Subject: [PATCH 16/26] pass correct parameters to getdents64
-
-Fixes
-../git/src/basic/recurse-dir.c:57:40: error: incompatible pointer types passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'struct dirent *' [-Werror,-Wincompatible-pointer-types]
-                n = getdents64(dir_fd, (uint8_t*) de->buffer + de->buffer_size, bs - de->buffer_size);
-                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-../git/src/basic/stat-util.c:102:28: error: incompatible pointer types passing 'union (unnamed union at ../git/src/basic/stat-util.c:78:9) *' to parameter of type 'struct dirent *' [-Werror,-Wincompatible-pointer-types]
-        n = getdents64(fd, &buffer, sizeof(buffer));
-                           ^~~~~~~
-
-Upstream-Status: Inappropriate [musl specific]
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
-Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
----
- src/basic/recurse-dir.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/basic/recurse-dir.c b/src/basic/recurse-dir.c
-index 378fd92b06..5b567b457d 100644
---- a/src/basic/recurse-dir.c
-+++ b/src/basic/recurse-dir.c
-@@ -56,7 +56,7 @@ int readdir_all(int dir_fd,
-                 bs = MIN(MALLOC_SIZEOF_SAFE(de) - offsetof(DirectoryEntries, buffer), (size_t) SSIZE_MAX);
-                 assert(bs > de->buffer_size);
- 
--                n = getdents64(dir_fd, (uint8_t*) de->buffer + de->buffer_size, bs - de->buffer_size);
-+                n = getdents64(dir_fd, (struct dirent*)((uint8_t*) de->buffer + de->buffer_size), bs - de->buffer_size);
-                 if (n < 0)
-                         return -errno;
-                 if (n == 0)
-2.34.1
-
deleted file mode 100644
@@ -1,526 +0,0 @@ 
-From be9d8f221ab9d31c0df8b2b3e66172bb9bc0f71f Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Fri, 21 Jan 2022 22:19:37 -0800
-Subject: [PATCH 17/26] Adjust for musl headers
-
-Upstream-Status: Inappropriate [musl specific]
-
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
-
-[Rebased for v255.1]
-Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
----
- src/basic/linux/ethtool.h                     | 3 ++-
- src/libsystemd-network/sd-dhcp6-client.c      | 2 +-
- src/network/netdev/bareudp.c                  | 2 +-
- src/network/netdev/batadv.c                   | 2 +-
- src/network/netdev/bond.c                     | 2 +-
- src/network/netdev/bridge.c                   | 3 ++-
- src/network/netdev/dummy.c                    | 2 +-
- src/network/netdev/geneve.c                   | 2 +-
- src/network/netdev/ifb.c                      | 2 +-
- src/network/netdev/ipoib.c                    | 2 +-
- src/network/netdev/ipvlan.c                   | 2 +-
- src/network/netdev/macsec.c                   | 2 +-
- src/network/netdev/macvlan.c                  | 2 +-
- src/network/netdev/netdev.c                   | 2 +-
- src/network/netdev/netdevsim.c                | 2 +-
- src/network/netdev/nlmon.c                    | 2 +-
- src/network/netdev/tunnel.c                   | 2 +-
- src/network/netdev/vcan.c                     | 2 +-
- src/network/netdev/veth.c                     | 2 +-
- src/network/netdev/vlan.c                     | 2 +-
- src/network/netdev/vrf.c                      | 2 +-
- src/network/netdev/vxcan.c                    | 2 +-
- src/network/netdev/vxlan.c                    | 2 +-
- src/network/netdev/wireguard.c                | 2 +-
- src/network/netdev/xfrm.c                     | 2 +-
- src/network/networkd-dhcp-common.c            | 3 ++-
- src/network/networkd-dhcp-prefix-delegation.c | 3 ++-
- src/network/networkd-dhcp-server.c            | 2 +-
- src/network/networkd-dhcp4.c                  | 2 +-
- src/network/networkd-ipv6ll.c                 | 2 +-
- src/network/networkd-link.c                   | 2 +-
- src/network/networkd-ndisc.c                  | 2 +-
- src/network/networkd-setlink.c                | 2 +-
- src/network/networkd-sysctl.c                 | 2 +-
- src/shared/netif-util.c                       | 2 +-
- src/udev/udev-builtin-net_id.c                | 2 +-
- 36 files changed, 40 insertions(+), 36 deletions(-)
-
-diff --git a/src/basic/linux/ethtool.h b/src/basic/linux/ethtool.h
-index a32293ba20..2aad67e9c0 100644
---- a/src/basic/linux/ethtool.h
-+++ b/src/basic/linux/ethtool.h
-@@ -16,7 +16,8 @@
- 
- #include <linux/const.h>
- #include <linux/types.h>
--#include <linux/if_ether.h>
-+#include <netinet/if_ether.h>
-+//#include <linux/if_ether.h>
- 
- #include <limits.h> /* for INT_MAX */
- 
-diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
-index 3e992d7cad..c7e1ff4dbf 100644
---- a/src/libsystemd-network/sd-dhcp6-client.c
-+++ b/src/libsystemd-network/sd-dhcp6-client.c
-@@ -5,7 +5,7 @@
- 
- #include <errno.h>
- #include <sys/ioctl.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- #include <linux/if_infiniband.h>
- 
- #include "sd-dhcp6-client.h"
-diff --git a/src/network/netdev/bareudp.c b/src/network/netdev/bareudp.c
-index e122abd97f..c120c2969b 100644
---- a/src/network/netdev/bareudp.c
-+++ b/src/network/netdev/bareudp.c
-@@ -2,7 +2,7 @@
-  * Copyright © 2020 VMware, Inc. */
- 
- #include <netinet/in.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "bareudp.h"
- #include "netlink-util.h"
-diff --git a/src/network/netdev/batadv.c b/src/network/netdev/batadv.c
-index 9806d8eb7c..19c3d881c2 100644
---- a/src/network/netdev/batadv.c
-+++ b/src/network/netdev/batadv.c
-@@ -3,7 +3,7 @@
- #include <inttypes.h>
- #include <netinet/in.h>
- #include <linux/genetlink.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "batadv.h"
- #include "fileio.h"
-diff --git a/src/network/netdev/bond.c b/src/network/netdev/bond.c
-index b866940b7a..a0eaf0a866 100644
---- a/src/network/netdev/bond.c
-+++ b/src/network/netdev/bond.c
-@@ -1,7 +1,7 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
- #include <netinet/in.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "alloc-util.h"
- #include "bond.h"
-diff --git a/src/network/netdev/bridge.c b/src/network/netdev/bridge.c
-index d3ba4989d9..4f7301c4f1 100644
---- a/src/network/netdev/bridge.c
-+++ b/src/network/netdev/bridge.c
-@@ -2,7 +2,8 @@
- 
- /* Make sure the net/if.h header is included before any linux/ one */
- #include <net/if.h>
--#include <linux/if_arp.h>
-+#include <netinet/in.h>
-+//#include <linux/if_arp.h>
- #include <linux/if_bridge.h>
- #include <netinet/in.h>
- 
-diff --git a/src/network/netdev/dummy.c b/src/network/netdev/dummy.c
-index 8b2893d5b4..412123f036 100644
---- a/src/network/netdev/dummy.c
-+++ b/src/network/netdev/dummy.c
-@@ -1,6 +1,6 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "dummy.h"
- 
-diff --git a/src/network/netdev/geneve.c b/src/network/netdev/geneve.c
-index 1d68be9bc8..539151c49e 100644
---- a/src/network/netdev/geneve.c
-+++ b/src/network/netdev/geneve.c
-@@ -2,7 +2,7 @@
- 
- /* Make sure the net/if.h header is included before any linux/ one */
- #include <net/if.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- #include <netinet/in.h>
- 
- #include "alloc-util.h"
-diff --git a/src/network/netdev/ifb.c b/src/network/netdev/ifb.c
-index d7ff44cb9e..e037629ae4 100644
---- a/src/network/netdev/ifb.c
-+++ b/src/network/netdev/ifb.c
-@@ -1,7 +1,7 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later
-  * Copyright © 2019 VMware, Inc. */
- 
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "ifb.h"
- 
-diff --git a/src/network/netdev/ipoib.c b/src/network/netdev/ipoib.c
-index 6932c62e2a..fc458da9e8 100644
---- a/src/network/netdev/ipoib.c
-+++ b/src/network/netdev/ipoib.c
-@@ -1,6 +1,6 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- #include <linux/if_link.h>
- 
- #include "ipoib.h"
-diff --git a/src/network/netdev/ipvlan.c b/src/network/netdev/ipvlan.c
-index 6e50f72aaa..49acfee25e 100644
---- a/src/network/netdev/ipvlan.c
-+++ b/src/network/netdev/ipvlan.c
-@@ -3,7 +3,7 @@
- /* Make sure the net/if.h header is included before any linux/ one */
- #include <net/if.h>
- #include <netinet/in.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "conf-parser.h"
- #include "ipvlan.h"
-diff --git a/src/network/netdev/macsec.c b/src/network/netdev/macsec.c
-index 6dd434f803..f9fbe9f51a 100644
---- a/src/network/netdev/macsec.c
-+++ b/src/network/netdev/macsec.c
-@@ -1,7 +1,7 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
- #include <netinet/in.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- #include <linux/if_ether.h>
- #include <linux/if_macsec.h>
- #include <linux/genetlink.h>
-diff --git a/src/network/netdev/macvlan.c b/src/network/netdev/macvlan.c
-index fd112b58e1..b038740bda 100644
---- a/src/network/netdev/macvlan.c
-+++ b/src/network/netdev/macvlan.c
-@@ -3,7 +3,7 @@
- /* Make sure the net/if.h header is included before any linux/ one */
- #include <net/if.h>
- #include <netinet/in.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "conf-parser.h"
- #include "macvlan.h"
-diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c
-index c2986aafb5..147f1c95d0 100644
---- a/src/network/netdev/netdev.c
-+++ b/src/network/netdev/netdev.c
-@@ -3,7 +3,7 @@
- /* Make sure the net/if.h header is included before any linux/ one */
- #include <net/if.h>
- #include <netinet/in.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- #include <unistd.h>
- 
- #include "alloc-util.h"
-diff --git a/src/network/netdev/netdevsim.c b/src/network/netdev/netdevsim.c
-index 59958c3bbe..61169016b0 100644
---- a/src/network/netdev/netdevsim.c
-+++ b/src/network/netdev/netdevsim.c
-@@ -1,6 +1,6 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "netdevsim.h"
- 
-diff --git a/src/network/netdev/nlmon.c b/src/network/netdev/nlmon.c
-index ff372092e6..eef66811f4 100644
---- a/src/network/netdev/nlmon.c
-+++ b/src/network/netdev/nlmon.c
-@@ -1,6 +1,6 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "nlmon.h"
- 
-diff --git a/src/network/netdev/tunnel.c b/src/network/netdev/tunnel.c
-index af05cfda81..f659bed3a6 100644
---- a/src/network/netdev/tunnel.c
-+++ b/src/network/netdev/tunnel.c
-@@ -2,7 +2,7 @@
- 
- #include <netinet/in.h>
- #include <linux/fou.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- #include <linux/if_tunnel.h>
- #include <linux/ip.h>
- #include <linux/ip6_tunnel.h>
-diff --git a/src/network/netdev/vcan.c b/src/network/netdev/vcan.c
-index 380547ee1e..137c1adf8a 100644
---- a/src/network/netdev/vcan.c
-+++ b/src/network/netdev/vcan.c
-@@ -1,6 +1,6 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "vcan.h"
- 
-diff --git a/src/network/netdev/veth.c b/src/network/netdev/veth.c
-index 54d3b59734..f3f75e22b5 100644
---- a/src/network/netdev/veth.c
-+++ b/src/network/netdev/veth.c
-@@ -3,7 +3,7 @@
- /* Make sure the net/if.h header is included before any linux/ one */
- #include <net/if.h>
- #include <errno.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- #include <linux/veth.h>
- #include <netinet/in.h>
- 
-diff --git a/src/network/netdev/vlan.c b/src/network/netdev/vlan.c
-index 60e49a5b8a..266fd58813 100644
---- a/src/network/netdev/vlan.c
-+++ b/src/network/netdev/vlan.c
-@@ -3,7 +3,7 @@
- /* Make sure the net/if.h header is included before any linux/ one */
- #include <net/if.h>
- #include <errno.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- #include <linux/if_vlan.h>
- 
- #include "parse-util.h"
-diff --git a/src/network/netdev/vrf.c b/src/network/netdev/vrf.c
-index c35419f859..4d1d3ef141 100644
---- a/src/network/netdev/vrf.c
-+++ b/src/network/netdev/vrf.c
-@@ -2,8 +2,8 @@
- 
- /* Make sure the net/if.h header is included before any linux/ one */
- #include <net/if.h>
--#include <linux/if_arp.h>
- #include <netinet/in.h>
-+//#include <linux/if_arp.h>
- 
- #include "vrf.h"
- 
-diff --git a/src/network/netdev/vxcan.c b/src/network/netdev/vxcan.c
-index 2de89b8e24..ce1b8f9b69 100644
---- a/src/network/netdev/vxcan.c
-+++ b/src/network/netdev/vxcan.c
-@@ -1,7 +1,7 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
- #include <linux/can/vxcan.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "vxcan.h"
- 
-diff --git a/src/network/netdev/vxlan.c b/src/network/netdev/vxlan.c
-index d8a066370d..8f94eeb763 100644
---- a/src/network/netdev/vxlan.c
-+++ b/src/network/netdev/vxlan.c
-@@ -3,7 +3,7 @@
- /* Make sure the net/if.h header is included before any linux/ one */
- #include <net/if.h>
- #include <netinet/in.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "conf-parser.h"
- #include "alloc-util.h"
-diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c
-index 8d1dddf828..5182783f45 100644
---- a/src/network/netdev/wireguard.c
-+++ b/src/network/netdev/wireguard.c
-@@ -5,7 +5,7 @@
- 
- /* Make sure the net/if.h header is included before any linux/ one */
- #include <net/if.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- #include <linux/ipv6_route.h>
- #include <netinet/in.h>
- #include <sys/ioctl.h>
-diff --git a/src/network/netdev/xfrm.c b/src/network/netdev/xfrm.c
-index 905bfc0bdf..39e34dbb3b 100644
---- a/src/network/netdev/xfrm.c
-+++ b/src/network/netdev/xfrm.c
-@@ -1,6 +1,6 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "missing_network.h"
- #include "xfrm.h"
-diff --git a/src/network/networkd-dhcp-common.c b/src/network/networkd-dhcp-common.c
-index 8b64dfe8f0..caa2885728 100644
---- a/src/network/networkd-dhcp-common.c
-+++ b/src/network/networkd-dhcp-common.c
-@@ -1,7 +1,8 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
- #include <netinet/in.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
-+#include <net/if.h>
- 
- #include "bus-error.h"
- #include "bus-locator.h"
-diff --git a/src/network/networkd-dhcp-prefix-delegation.c b/src/network/networkd-dhcp-prefix-delegation.c
-index 16426de981..3d8efc05f1 100644
---- a/src/network/networkd-dhcp-prefix-delegation.c
-+++ b/src/network/networkd-dhcp-prefix-delegation.c
-@@ -1,6 +1,5 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
--#include <linux/ipv6_route.h>
- 
- #include "dhcp6-lease-internal.h"
- #include "hashmap.h"
-@@ -21,6 +20,8 @@
- #include "strv.h"
- #include "tunnel.h"
- 
-+#include <linux/ipv6_route.h>
-+
- bool link_dhcp_pd_is_enabled(Link *link) {
-         assert(link);
- 
-diff --git a/src/network/networkd-dhcp-server.c b/src/network/networkd-dhcp-server.c
-index c35102af74..3be469ae16 100644
---- a/src/network/networkd-dhcp-server.c
-+++ b/src/network/networkd-dhcp-server.c
-@@ -1,7 +1,7 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
- #include <netinet/in.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- #include <linux/if.h>
- 
- #include "sd-dhcp-server.h"
-diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
-index d94ac1a213..b8fe82cb6a 100644
---- a/src/network/networkd-dhcp4.c
-+++ b/src/network/networkd-dhcp4.c
-@@ -3,7 +3,7 @@
- #include <netinet/in.h>
- #include <netinet/ip.h>
- #include <linux/if.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "alloc-util.h"
- #include "device-private.h"
-diff --git a/src/network/networkd-ipv6ll.c b/src/network/networkd-ipv6ll.c
-index 04f51ab530..c4580754f7 100644
---- a/src/network/networkd-ipv6ll.c
-+++ b/src/network/networkd-ipv6ll.c
-@@ -1,7 +1,7 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
- #include <linux/if.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "in-addr-util.h"
- #include "networkd-address.h"
-diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
-index 3c042e6c18..05fe2cb900 100644
---- a/src/network/networkd-link.c
-+++ b/src/network/networkd-link.c
-@@ -4,7 +4,7 @@
- #include <net/if.h>
- #include <netinet/in.h>
- #include <linux/if.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- #include <linux/if_link.h>
- #include <linux/netdevice.h>
- #include <sys/socket.h>
-diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c
-index 33e86fb04e..51292871fc 100644
---- a/src/network/networkd-ndisc.c
-+++ b/src/network/networkd-ndisc.c
-@@ -6,7 +6,7 @@
- #include <arpa/inet.h>
- #include <netinet/icmp6.h>
- #include <linux/if.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "sd-ndisc.h"
- 
-diff --git a/src/network/networkd-setlink.c b/src/network/networkd-setlink.c
-index 8519e6e7a0..7aca2bbecc 100644
---- a/src/network/networkd-setlink.c
-+++ b/src/network/networkd-setlink.c
-@@ -2,7 +2,7 @@
- 
- #include <netinet/in.h>
- #include <linux/if.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- #include <linux/if_bridge.h>
- #include <linux/ipv6.h>
- 
-diff --git a/src/network/networkd-sysctl.c b/src/network/networkd-sysctl.c
-index 10a35bc44b..84c6b68ee4 100644
---- a/src/network/networkd-sysctl.c
-+++ b/src/network/networkd-sysctl.c
-@@ -2,7 +2,7 @@
- 
- #include <netinet/in.h>
- #include <linux/if.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "sd-messages.h"
- 
-diff --git a/src/shared/netif-util.c b/src/shared/netif-util.c
-index 978ce42341..899b5f613f 100644
---- a/src/shared/netif-util.c
-+++ b/src/shared/netif-util.c
-@@ -1,7 +1,7 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
- #include <linux/if.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- 
- #include "arphrd-util.h"
- #include "device-util.h"
-diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
-index 09c04b9a7f..4686897dbf 100644
---- a/src/udev/udev-builtin-net_id.c
-+++ b/src/udev/udev-builtin-net_id.c
-@@ -19,7 +19,7 @@
- #include <stdarg.h>
- #include <unistd.h>
- #include <linux/if.h>
--#include <linux/if_arp.h>
-+//#include <linux/if_arp.h>
- #include <linux/netdevice.h>
- #include <linux/pci_regs.h>
- 
-2.34.1
-
new file mode 100644
@@ -0,0 +1,40 @@ 
+From 675460e529f7373d042db581da3fdc3c9c25bf63 Mon Sep 17 00:00:00 2001
+From: Chen Qi <Qi.Chen@windriver.com>
+Date: Wed, 15 Oct 2025 15:48:09 +0800
+Subject: [PATCH 17/17] Always include netinet/if_ether.h first
+
+When compiling systemd with musl, we get many ethhdr redinition
+errors. This is because netinet/if_ether.h in musl does not check
+__UAPI_DEF_ETHHDR and expects programs to include it before other
+kernel headers.
+See https://www.openwall.com/lists/musl/2025/10/14/2
+
+To avoid this redefinition error, and to avoid resolving conflicts
+every time we upgrade systemd, use '-include netinet/if_ether.h' to
+make sure this file header is included first.
+
+The major consideration behind such method is maintenance.
+
+Upstream-Status: Inappropriate [musl specific]
+
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+---
+ meson.build | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/meson.build b/meson.build
+index 0df7ecbe67..842f058f04 100644
+--- a/meson.build
++++ b/meson.build
+@@ -2006,7 +2006,7 @@ config_h = configure_file(
+         output : 'config.h',
+         configuration : conf)
+ 
+-userspace_c_args += ['-include', 'config.h']
++userspace_c_args += ['-include', 'config.h', '-include', 'netinet/if_ether.h']
+ 
+ jinja2_cmdline = [meson_render_jinja2, config_h]
+ 
+-- 
+2.34.1
+
deleted file mode 100644
@@ -1,52 +0,0 @@ 
-From 349f9a0f9ecfc6575a3d9eeaffe89536e6a43914 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Tue, 8 Nov 2022 13:31:34 -0800
-Subject: [PATCH 18/26] test-bus-error: strerror() is assumed to be GNU
- specific version mark it so
-
-Upstream-Status: Inappropriate [Upstream systemd only supports glibc]
-
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- src/libsystemd/sd-bus/test-bus-error.c | 2 ++
- src/test/test-errno-util.c             | 3 ++-
- 2 files changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/libsystemd/sd-bus/test-bus-error.c b/src/libsystemd/sd-bus/test-bus-error.c
-index 91045c06c2..a06b9bac0c 100644
---- a/src/libsystemd/sd-bus/test-bus-error.c
-+++ b/src/libsystemd/sd-bus/test-bus-error.c
-@@ -99,7 +99,9 @@ TEST(error) {
-         assert_se(!sd_bus_error_is_set(&error));
-         assert_se(sd_bus_error_set_errno(&error, EBUSY) == -EBUSY);
-         assert_se(streq(error.name, "System.Error.EBUSY"));
-+#ifdef __GLIBC__
-         assert_se(streq(error.message, STRERROR(EBUSY)));
-+#endif
-         assert_se(sd_bus_error_has_name(&error, "System.Error.EBUSY"));
-         assert_se(sd_bus_error_get_errno(&error) == EBUSY);
-         assert_se(sd_bus_error_is_set(&error));
-diff --git a/src/test/test-errno-util.c b/src/test/test-errno-util.c
-index ab463bd1b3..e2ebcaaf33 100644
---- a/src/test/test-errno-util.c
-+++ b/src/test/test-errno-util.c
-@@ -4,7 +4,7 @@
- #include "stdio-util.h"
- #include "string-util.h"
- #include "tests.h"
--
-+#ifdef __GLIBC__
- TEST(strerror_not_threadsafe) {
-         /* Just check that strerror really is not thread-safe. */
-         log_info("strerror(%d) → %s", 200, strerror(200));
-@@ -46,6 +46,7 @@ TEST(STRERROR_OR_ELSE) {
-         log_info("STRERROR_OR_ELSE(EPERM, \"EOF\") → %s", STRERROR_OR_EOF(EPERM));
-         log_info("STRERROR_OR_ELSE(-EPERM, \"EOF\") → %s", STRERROR_OR_EOF(-EPERM));
- }
-+#endif /* __GLIBC__ */
- 
- TEST(PROTECT_ERRNO) {
-         errno = 12;
-2.34.1
-
deleted file mode 100644
@@ -1,39 +0,0 @@ 
-From 66de8a53849f76f5596327c38ae5f002b9f534cd Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Wed, 2 Aug 2023 12:06:27 -0700
-Subject: [PATCH 20/26] sd-event: Make malloc_trim() conditional on glibc
-
-musl does not have this API
-
-Upstream-Status: Inappropriate [musl-specific]
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- src/libsystemd/sd-event/sd-event.c | 4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
-
-diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
-index 7aea7d2581..d3f4001f53 100644
---- a/src/libsystemd/sd-event/sd-event.c
-+++ b/src/libsystemd/sd-event/sd-event.c
-@@ -1881,7 +1881,7 @@ _public_ int sd_event_add_exit(
- }
- 
- _public_ int sd_event_trim_memory(void) {
--        int r;
-+        int r = 0;
- 
-         /* A default implementation of a memory pressure callback. Simply releases our own allocation caches
-          * and glibc's. This is automatically used when people call sd_event_add_memory_pressure() with a
-@@ -1895,7 +1895,9 @@ _public_ int sd_event_trim_memory(void) {
- 
-         usec_t before_timestamp = now(CLOCK_MONOTONIC);
-         hashmap_trim_pools();
-+#ifdef __GLIBC__
-         r = malloc_trim(0);
-+#endif
-         usec_t after_timestamp = now(CLOCK_MONOTONIC);
- 
-         if (r > 0)
-2.34.1
-
deleted file mode 100644
@@ -1,57 +0,0 @@ 
-From 93d13363c605fb2de484f38f3726f8fbad1c3540 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Wed, 2 Aug 2023 12:20:40 -0700
-Subject: [PATCH 21/26] shared: Do not use malloc_info on musl
-
-Upstream-Status: Inappropriate [musl-specific]
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- src/shared/bus-util.c      | 5 +++--
- src/shared/common-signal.c | 4 ++--
- 2 files changed, 5 insertions(+), 4 deletions(-)
-
-diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
-index ff80e580fc..a628a29d0c 100644
---- a/src/shared/bus-util.c
-+++ b/src/shared/bus-util.c
-@@ -787,15 +787,16 @@ static int method_dump_memory_state_by_fd(sd_bus_message *message, void *userdat
-         _cleanup_close_ int fd = -EBADF;
-         size_t dump_size;
-         FILE *f;
--        int r;
-+        int r = 0;
- 
-         assert(message);
- 
-         f = memstream_init(&m);
-         if (!f)
-                 return -ENOMEM;
--
-+#ifdef __GLIBC__
-         r = RET_NERRNO(malloc_info(/* options= */ 0, f));
-+#endif
-         if (r < 0)
-                 return r;
- 
-diff --git a/src/shared/common-signal.c b/src/shared/common-signal.c
-index 8e70e365dd..9e782caec9 100644
---- a/src/shared/common-signal.c
-+++ b/src/shared/common-signal.c
-@@ -65,12 +65,12 @@ int sigrtmin18_handler(sd_event_source *s, const struct signalfd_siginfo *si, vo
-                         log_oom();
-                         break;
-                 }
--
-+#ifdef __GLIBC__
-                 if (malloc_info(0, f) < 0) {
-                         log_error_errno(errno, "Failed to invoke malloc_info(): %m");
-                         break;
-                 }
--
-+#endif
-                 (void) memstream_dump(LOG_INFO, &m);
-                 break;
-         }
-2.34.1
-
deleted file mode 100644
@@ -1,56 +0,0 @@ 
-From 5b8df64993b68a5a4af0f214d8cae77f4e716593 Mon Sep 17 00:00:00 2001
-From: Chen Qi <Qi.Chen@windriver.com>
-Date: Tue, 2 Jan 2024 11:03:27 +0800
-Subject: [PATCH 22/26] avoid missing LOCK_EX declaration
-
-This only happens on MUSL. Include sys/file.h to avoid compilation
-error about missing LOCK_EX declaration.
-
-Upstream-Status: Inappropriate [musl specific]
-
-Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
----
- src/basic/fd-util.h    | 1 +
- src/core/exec-invoke.c | 1 +
- src/shared/dev-setup.h | 1 +
- 3 files changed, 3 insertions(+)
-
-diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h
-index 93b254c680..5f0b1a816d 100644
---- a/src/basic/fd-util.h
-+++ b/src/basic/fd-util.h
-@@ -6,6 +6,7 @@
- #include <stdbool.h>
- #include <stdio.h>
- #include <sys/socket.h>
-+#include <sys/file.h>
- 
- #include "macro.h"
- #include "missing_fcntl.h"
-diff --git a/src/core/exec-invoke.c b/src/core/exec-invoke.c
-index 9d636f5529..6be43caa57 100644
---- a/src/core/exec-invoke.c
-+++ b/src/core/exec-invoke.c
-@@ -5,6 +5,7 @@
- #include <sys/ioctl.h>
- #include <sys/mount.h>
- #include <sys/prctl.h>
-+#include <sys/file.h>
- 
- #if HAVE_PAM
- #include <security/pam_appl.h>
-diff --git a/src/shared/dev-setup.h b/src/shared/dev-setup.h
-index 92ba6cf764..ba01a0ae55 100644
---- a/src/shared/dev-setup.h
-+++ b/src/shared/dev-setup.h
-@@ -2,6 +2,7 @@
- #pragma once
- 
- #include <sys/types.h>
-+#include <sys/file.h>
- 
- int dev_setup(const char *prefix, uid_t uid, gid_t gid);
- 
-2.34.1
-
deleted file mode 100644
@@ -1,27 +0,0 @@ 
-From e39afec7e5a2f3a9de7202affab4d0340ba879d7 Mon Sep 17 00:00:00 2001
-From: Chen Qi <Qi.Chen@windriver.com>
-Date: Tue, 2 Jul 2024 22:18:47 -0700
-Subject: [PATCH 23/26] include signal.h to avoid the 'undeclared' error
-
-Upstream-Status: Inappropriate [musl specific]
-
-Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
----
- src/basic/pidref.h | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/src/basic/pidref.h b/src/basic/pidref.h
-index 42ddf4e50b..b9cf53680f 100644
---- a/src/basic/pidref.h
-+++ b/src/basic/pidref.h
-@@ -3,6 +3,7 @@
- 
- typedef struct PidRef PidRef;
- 
-+#include <signal.h>
- #include "macro.h"
- #include "process-util.h"
- 
-2.34.1
-
deleted file mode 100644
@@ -1,48 +0,0 @@ 
-From 5a4334fde21b896cd75b2d1a56e06a4f365e9c4d Mon Sep 17 00:00:00 2001
-From: Chen Qi <Qi.Chen@windriver.com>
-Date: Tue, 2 Jul 2024 22:44:31 -0700
-Subject: [PATCH 24/26] undef stdin for references using stdin as a struct
- member
-
-In musl stdio.h, we have:
-include/stdio.h:#define stdin  (stdin)
-
-This causes error when a struct member is also named stdin. undef it.
-
-Upstream-Status: Inappropriate [musl specific]
-
-Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
----
- src/shared/edit-util.c         | 2 ++
- src/systemctl/systemctl-edit.c | 2 ++
- 2 files changed, 4 insertions(+)
-
-diff --git a/src/shared/edit-util.c b/src/shared/edit-util.c
-index e37609c2e1..1b212ae7b4 100644
---- a/src/shared/edit-util.c
-+++ b/src/shared/edit-util.c
-@@ -3,6 +3,8 @@
- #include <errno.h>
- #include <stdio.h>
- 
-+#undef stdin
-+
- #include "alloc-util.h"
- #include "copy.h"
- #include "edit-util.h"
-diff --git a/src/systemctl/systemctl-edit.c b/src/systemctl/systemctl-edit.c
-index c42a31153d..7695ceeead 100644
---- a/src/systemctl/systemctl-edit.c
-+++ b/src/systemctl/systemctl-edit.c
-@@ -13,6 +13,8 @@
- #include "systemctl.h"
- #include "terminal-util.h"
- 
-+#undef stdin
-+
- int verb_cat(int argc, char *argv[], void *userdata) {
-         _cleanup_hashmap_free_ Hashmap *cached_id_map = NULL, *cached_name_map = NULL;
-         _cleanup_(lookup_paths_done) LookupPaths lp = {};
-2.34.1
-
deleted file mode 100644
@@ -1,288 +0,0 @@ 
-From a90044320eecda424ed678d283ef60806c70fcda Mon Sep 17 00:00:00 2001
-From: Chen Qi <Qi.Chen@windriver.com>
-Date: Tue, 2 Jul 2024 23:23:57 -0700
-Subject: [PATCH 25/26] adjust header inclusion order to avoid redeclaration
-
-Upstream-Status: Inappropriate [musl specific]
-
-Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
----
- src/basic/parse-util.c                | 3 ++-
- src/libsystemd-network/ndisc-option.c | 6 +++---
- src/libsystemd-network/sd-radv.c      | 5 +++--
- src/network/netdev/l2tp-tunnel.c      | 9 ++++-----
- src/network/netdev/l2tp-tunnel.h      | 6 +++---
- src/network/netdev/wireguard.c        | 2 +-
- src/network/networkctl-link-info.c    | 4 ++--
- src/network/networkd-bridge-mdb.c     | 3 ++-
- src/network/networkd-route.c          | 8 ++++----
- src/resolve/resolved-dns-stream.c     | 5 +++--
- src/resolve/resolved-manager.c        | 5 +++--
- src/shared/conf-parser.c              | 3 ++-
- 12 files changed, 32 insertions(+), 27 deletions(-)
-
-diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c
-index faa5344921..0fc9d12c89 100644
---- a/src/basic/parse-util.c
-+++ b/src/basic/parse-util.c
-@@ -2,7 +2,6 @@
- 
- #include <errno.h>
- #include <inttypes.h>
--#include <linux/ipv6.h>
- #include <net/if.h>
- #include <stdio.h>
- #include <stdlib.h>
-@@ -20,6 +19,8 @@
- #include "string-util.h"
- #include "strv.h"
- 
-+#include <linux/ipv6.h>
-+
- int parse_boolean(const char *v) {
-         if (!v)
-                 return -EINVAL;
-diff --git a/src/libsystemd-network/ndisc-option.c b/src/libsystemd-network/ndisc-option.c
-index 3aab51f51b..feeb4c78e5 100644
---- a/src/libsystemd-network/ndisc-option.c
-+++ b/src/libsystemd-network/ndisc-option.c
-@@ -1,8 +1,5 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
--#include <linux/ipv6.h>
--#include <netinet/icmp6.h>
--
- #include "dns-resolver-internal.h"
- #include "dns-domain.h"
- #include "ether-addr-util.h"
-@@ -16,6 +13,9 @@
- #include "strv.h"
- #include "unaligned.h"
- 
-+#include <linux/ipv6.h>
-+#include <netinet/icmp6.h>
-+
- /* RFC does not say anything about the maximum number of options, but let's limit the number of options for
-  * safety. Typically, the number of options in an ICMPv6 message should be only a few. */
- #define MAX_OPTIONS 128
-diff --git a/src/libsystemd-network/sd-radv.c b/src/libsystemd-network/sd-radv.c
-index f241929ad5..7cef3c3f71 100644
---- a/src/libsystemd-network/sd-radv.c
-+++ b/src/libsystemd-network/sd-radv.c
-@@ -3,8 +3,6 @@
-   Copyright © 2017 Intel Corporation. All rights reserved.
- ***/
- 
--#include <linux/ipv6.h>
--#include <netinet/icmp6.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- 
-@@ -29,6 +27,9 @@
- #include "strv.h"
- #include "unaligned.h"
- 
-+#include <linux/ipv6.h>
-+#include <netinet/icmp6.h>
-+
- int sd_radv_new(sd_radv **ret) {
-         _cleanup_(sd_radv_unrefp) sd_radv *ra = NULL;
- 
-diff --git a/src/network/netdev/l2tp-tunnel.c b/src/network/netdev/l2tp-tunnel.c
-index c87e44797b..437b40c114 100644
---- a/src/network/netdev/l2tp-tunnel.c
-+++ b/src/network/netdev/l2tp-tunnel.c
-@@ -1,10 +1,5 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
--#include <netinet/in.h>
--#include <linux/if_arp.h>
--#include <linux/l2tp.h>
--#include <linux/genetlink.h>
--
- #include "conf-parser.h"
- #include "hashmap.h"
- #include "l2tp-tunnel.h"
-@@ -17,6 +12,10 @@
- #include "string-table.h"
- #include "string-util.h"
- 
-+#include <netinet/in.h>
-+#include <linux/l2tp.h>
-+#include <linux/genetlink.h>
-+
- static const char* const l2tp_l2spec_type_table[_NETDEV_L2TP_L2SPECTYPE_MAX] = {
-         [NETDEV_L2TP_L2SPECTYPE_NONE]    = "none",
-         [NETDEV_L2TP_L2SPECTYPE_DEFAULT] = "default",
-diff --git a/src/network/netdev/l2tp-tunnel.h b/src/network/netdev/l2tp-tunnel.h
-index c558ed49de..8419ef34c5 100644
---- a/src/network/netdev/l2tp-tunnel.h
-+++ b/src/network/netdev/l2tp-tunnel.h
-@@ -1,13 +1,13 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- #pragma once
- 
--#include <netinet/in.h>
--#include <linux/l2tp.h>
--
- #include "in-addr-util.h"
- #include "netdev.h"
- #include "networkd-util.h"
- 
-+#include <netinet/in.h>
-+#include <linux/l2tp.h>
-+
- typedef enum L2tpL2specType {
-         NETDEV_L2TP_L2SPECTYPE_NONE = L2TP_L2SPECTYPE_NONE,
-         NETDEV_L2TP_L2SPECTYPE_DEFAULT = L2TP_L2SPECTYPE_DEFAULT,
-diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c
-index 5182783f45..79b21cb4ba 100644
---- a/src/network/netdev/wireguard.c
-+++ b/src/network/netdev/wireguard.c
-@@ -5,9 +5,9 @@
- 
- /* Make sure the net/if.h header is included before any linux/ one */
- #include <net/if.h>
-+#include <netinet/in.h>
- //#include <linux/if_arp.h>
- #include <linux/ipv6_route.h>
--#include <netinet/in.h>
- #include <sys/ioctl.h>
- 
- #include "sd-resolve.h"
-diff --git a/src/network/networkctl-link-info.c b/src/network/networkctl-link-info.c
-index f356d3c231..216c442de1 100644
---- a/src/network/networkctl-link-info.c
-+++ b/src/network/networkctl-link-info.c
-@@ -1,7 +1,5 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
--#include <linux/if_tunnel.h>
--
- #include "bus-common-errors.h"
- #include "bus-error.h"
- #include "bus-util.h"
-@@ -16,6 +14,8 @@
- #include "strxcpyx.h"
- #include "wifi-util.h"
- 
-+#include <linux/if_tunnel.h>
-+
- /* use 128 kB for receive socket kernel queue, we shouldn't need more here */
- #define RCVBUF_SIZE    (128*1024)
- 
-diff --git a/src/network/networkd-bridge-mdb.c b/src/network/networkd-bridge-mdb.c
-index 358ca4d294..fe87f7c093 100644
---- a/src/network/networkd-bridge-mdb.c
-+++ b/src/network/networkd-bridge-mdb.c
-@@ -2,7 +2,6 @@
- 
- /* Make sure the net/if.h header is included before any linux/ one */
- #include <net/if.h>
--#include <linux/if_bridge.h>
- 
- #include "netlink-util.h"
- #include "networkd-bridge-mdb.h"
-@@ -13,6 +12,8 @@
- #include "string-util.h"
- #include "vlan-util.h"
- 
-+#include <linux/if_bridge.h>
-+
- #define STATIC_BRIDGE_MDB_ENTRIES_PER_NETWORK_MAX 1024U
- 
- /* remove MDB entry. */
-diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
-index 0f3f79ec4f..325743bebf 100644
---- a/src/network/networkd-route.c
-+++ b/src/network/networkd-route.c
-@@ -1,9 +1,5 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
--#include <linux/if.h>
--#include <linux/ipv6_route.h>
--#include <linux/nexthop.h>
--
- #include "alloc-util.h"
- #include "event-util.h"
- #include "netlink-util.h"
-@@ -21,6 +17,10 @@
- #include "vrf.h"
- #include "wireguard.h"
- 
-+#include <linux/if.h>
-+#include <linux/ipv6_route.h>
-+#include <linux/nexthop.h>
-+
- static Route* route_detach_impl(Route *route) {
-         assert(route);
-         assert(!!route->network + !!route->manager + !!route->wireguard <= 1);
-diff --git a/src/resolve/resolved-dns-stream.c b/src/resolve/resolved-dns-stream.c
-index e57af66221..f66d8f0606 100644
---- a/src/resolve/resolved-dns-stream.c
-+++ b/src/resolve/resolved-dns-stream.c
-@@ -1,7 +1,5 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
--#include <linux/if_arp.h>
--#include <netinet/tcp.h>
- #include <unistd.h>
- 
- #include "alloc-util.h"
-@@ -12,6 +10,9 @@
- #include "resolved-dns-stream.h"
- #include "resolved-manager.h"
- 
-+//#include <linux/if_arp.h>
-+#include <netinet/tcp.h>
-+
- #define DNS_STREAMS_MAX 128
- 
- #define DNS_QUERIES_PER_STREAM 32
-diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
-index dbaad81734..b988e75851 100644
---- a/src/resolve/resolved-manager.c
-+++ b/src/resolve/resolved-manager.c
-@@ -1,8 +1,6 @@
- /* SPDX-License-Identifier: LGPL-2.1-or-later */
- 
- #include <fcntl.h>
--#include <linux/ipv6.h>
--#include <netinet/in.h>
- #include <poll.h>
- #include <sys/ioctl.h>
- #include <sys/stat.h>
-@@ -46,6 +44,9 @@
- #include "utf8.h"
- #include "varlink-util.h"
- 
-+#include <linux/ipv6.h>
-+#include <netinet/in.h>
-+
- #define SEND_TIMEOUT_USEC (200 * USEC_PER_MSEC)
- 
- static int manager_process_link(sd_netlink *rtnl, sd_netlink_message *mm, void *userdata) {
-diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
-index eaa8a5f11c..03379e7474 100644
---- a/src/shared/conf-parser.c
-+++ b/src/shared/conf-parser.c
-@@ -2,7 +2,6 @@
- 
- #include <errno.h>
- #include <limits.h>
--#include <linux/ipv6.h>
- #include <stdint.h>
- #include <stdio.h>
- #include <stdlib.h>
-@@ -47,6 +46,8 @@
- #include "time-util.h"
- #include "utf8.h"
- 
-+#include <linux/ipv6.h>
-+
- DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(config_file_hash_ops_fclose,
-                                               char, path_hash_func, path_compare,
-                                               FILE, safe_fclose);
-2.34.1
-
similarity index 92%
rename from meta/recipes-core/systemd/systemd_257.8.bb
rename to meta/recipes-core/systemd/systemd_258.1.bb
@@ -28,36 +28,26 @@  SRC_URI += " \
            file://systemd-pager.sh \
            file://0001-binfmt-Don-t-install-dependency-links-at-install-tim.patch \
            file://0002-implment-systemd-sysv-install-for-OE.patch \
-           file://0001-Do-not-create-var-log-README.patch \
+           file://0003-Do-not-create-var-log-README.patch \
            "
 
 # patches needed by musl
 SRC_URI:append:libc-musl = " ${SRC_URI_MUSL}"
 SRC_URI_MUSL = "\
-               file://0003-missing_type.h-add-comparison_fn_t.patch \
-               file://0004-add-fallback-parse_printf_format-implementation.patch \
-               file://0005-don-t-fail-if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not-.patch \
-               file://0006-add-missing-FTW_-macros-for-musl.patch \
-               file://0007-Use-uintmax_t-for-handling-rlim_t.patch \
-               file://0008-Define-glibc-compatible-basename-for-non-glibc-syste.patch \
-               file://0009-Do-not-disable-buffering-when-writing-to-oom_score_a.patch \
-               file://0010-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch \
-               file://0011-avoid-redefinition-of-prctl_mm_map-structure.patch \
-               file://0012-do-not-disable-buffer-in-writing-files.patch \
-               file://0013-Handle-__cpu_mask-usage.patch \
-               file://0014-Handle-missing-gshadow.patch \
-               file://0015-missing_syscall.h-Define-MIPS-ABI-defines-for-musl.patch \
-               file://0016-pass-correct-parameters-to-getdents64.patch \
-               file://0017-Adjust-for-musl-headers.patch \
-               file://0018-test-bus-error-strerror-is-assumed-to-be-GNU-specifi.patch \
-               file://0019-errno-util-Make-STRERROR-portable-for-musl.patch \
-               file://0020-sd-event-Make-malloc_trim-conditional-on-glibc.patch \
-               file://0021-shared-Do-not-use-malloc_info-on-musl.patch \
-               file://0022-avoid-missing-LOCK_EX-declaration.patch \
-               file://0023-include-signal.h-to-avoid-the-undeclared-error.patch \
-               file://0024-undef-stdin-for-references-using-stdin-as-a-struct-m.patch \
-               file://0025-adjust-header-inclusion-order-to-avoid-redeclaration.patch \
-               file://0026-build-path.c-avoid-boot-time-segfault-for-musl.patch \
+               file://0004-musl.h-introduce-header-file-and-add-__THROW.patch \
+               file://0005-add-fallback-parse_printf_format-implementation.patch \
+               file://0006-Make-mallinfo-related-contents-glibc-specific.patch \
+               file://0007-add-src-include-override-sys-prctl.h-to-avoid-redefi.patch \
+               file://0008-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch \
+               file://0009-errno-util-Make-STRERROR-portable-for-musl.patch \
+               file://0010-src-basic-format-util.h-define-RLIM_FMT-to-fit-musl-.patch \
+               file://0011-src-include-override-malloc.h-define-dummy-malloc_tr.patch \
+               file://0012-src-shared-condition.c-avoid-using-glibc-ConditionVe.patch \
+               file://0013-build-path.c-avoid-boot-time-segfault-for-musl.patch \
+               file://0014-Handle-missing-gshadow-for-musl.patch \
+               file://0015-Avoid-sequence-point-error.patch \
+               file://0016-Fix-the-segfault-for-glob-related-codes-and-define-d.patch \
+               file://0017-Always-include-netinet-if_ether.h-first.patch \
                "
 
 PAM_PLUGINS = " \
@@ -154,8 +144,6 @@  PACKAGECONFIG[firstboot] = "-Dfirstboot=true,-Dfirstboot=false"
 PACKAGECONFIG[repart] = "-Drepart=enabled,-Drepart=disabled"
 PACKAGECONFIG[homed] = "-Dhomed=enabled,-Dhomed=disabled"
 # Sign the journal for anti-tampering
-PACKAGECONFIG[gcrypt] = "-Dgcrypt=enabled,-Dgcrypt=disabled,libgcrypt"
-PACKAGECONFIG[gnutls] = "-Dgnutls=enabled,-Dgnutls=disabled,gnutls"
 PACKAGECONFIG[gshadow] = "-Dgshadow=true,-Dgshadow=false"
 PACKAGECONFIG[hibernate] = "-Dhibernate=true,-Dhibernate=false"
 PACKAGECONFIG[hostnamed] = "-Dhostnamed=true,-Dhostnamed=false"
@@ -252,6 +240,7 @@  EXTRA_OEMESON += "-Dnobody-user=nobody \
                   -Dtranslations=${@'false' if d.getVar('USE_NLS') == 'no' else 'true'} \
                   ${@bb.utils.contains('DISTRO_FEATURES', 'zeroconf', '-Ddefault-mdns=no -Ddefault-llmnr=no', '', d)} \
                   -Ddbus=disabled \
+                  -Dtests=false \
                   "
 
 # Hardcode target binary paths to avoid using paths from sysroot or worse
@@ -341,15 +330,6 @@  do_install() {
 	install -d ${D}${systemd_system_unitdir}/reboot.target.wants
 	install -d ${D}${systemd_system_unitdir}/rescue.target.wants
 
-	# Create symlinks for systemd-update-utmp-runlevel.service
-	if ${@bb.utils.contains('PACKAGECONFIG', 'utmp', 'true', 'false', d)} && ${@bb.utils.contains('PACKAGECONFIG', 'sysvinit', 'true', 'false', d)}; then
-		ln -sf ../systemd-update-utmp-runlevel.service ${D}${systemd_system_unitdir}/graphical.target.wants/systemd-update-utmp-runlevel.service
-		ln -sf ../systemd-update-utmp-runlevel.service ${D}${systemd_system_unitdir}/multi-user.target.wants/systemd-update-utmp-runlevel.service
-		ln -sf ../systemd-update-utmp-runlevel.service ${D}${systemd_system_unitdir}/poweroff.target.wants/systemd-update-utmp-runlevel.service
-		ln -sf ../systemd-update-utmp-runlevel.service ${D}${systemd_system_unitdir}/reboot.target.wants/systemd-update-utmp-runlevel.service
-		ln -sf ../systemd-update-utmp-runlevel.service ${D}${systemd_system_unitdir}/rescue.target.wants/systemd-update-utmp-runlevel.service
-	fi
-
 	# this file is needed to exist if networkd is disabled but timesyncd is still in use since timesyncd checks it
 	# for existence else it fails
 	if [ -s ${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf ] &&
@@ -552,6 +532,7 @@  FILES:${PN}-container = "${sysconfdir}/dbus-1/system.d/org.freedesktop.import1.c
                          ${systemd_system_unitdir}/org.freedesktop.machine1.busname \
                          ${systemd_system_unitdir}/systemd-importd.service \
                          ${systemd_system_unitdir}/systemd-machined.service \
+                         ${systemd_system_unitdir}/systemd-machined.socket \
                          ${systemd_system_unitdir}/dbus-org.freedesktop.machine1.service \
                          ${systemd_system_unitdir}/var-lib-machines.mount \
                          ${nonarch_libdir}/systemd/systemd-import \
@@ -614,10 +595,6 @@  FILES:${PN}-extra-utils = "\
                         ${systemd_system_unitdir}/systemd-pcrphase-sysinit.service \
                         ${systemd_system_unitdir}/systemd-suspend.service \
                         ${systemd_system_unitdir}/sleep.target \
-                        ${nonarch_libdir}/systemd/systemd-initctl \
-                        ${systemd_system_unitdir}/systemd-initctl.service \
-                        ${systemd_system_unitdir}/systemd-initctl.socket \
-                        ${systemd_system_unitdir}/sockets.target.wants/systemd-initctl.socket \
                         ${nonarch_libdir}/systemd/system-generators/systemd-gpt-auto-generator \
                         ${nonarch_libdir}/systemd/systemd-cgroups-agent \
 "
@@ -668,8 +645,6 @@  FILES:${PN} = " ${base_bindir}/* \
                 ${base_sbindir}/shutdown \
                 ${base_sbindir}/halt \
                 ${base_sbindir}/poweroff \
-                ${base_sbindir}/runlevel \
-                ${base_sbindir}/telinit \
                 ${base_sbindir}/resolvconf \
                 ${base_sbindir}/reboot \
                 ${base_sbindir}/init \
@@ -790,6 +765,7 @@  FILES:udev += "${base_sbindir}/udevd \
                ${nonarch_libdir}/udev/rules.d/60-infiniband.rules \
                ${nonarch_libdir}/udev/rules.d/60-input-id.rules \
                ${nonarch_libdir}/udev/rules.d/60-persistent-alsa.rules \
+               ${nonarch_libdir}/udev/rules.d/60-persistent-hidraw.rules \
                ${nonarch_libdir}/udev/rules.d/60-persistent-input.rules \
                ${nonarch_libdir}/udev/rules.d/60-persistent-storage.rules \
                ${nonarch_libdir}/udev/rules.d/60-persistent-storage-mtd.rules \
@@ -810,7 +786,9 @@  FILES:udev += "${base_sbindir}/udevd \
                ${nonarch_libdir}/udev/rules.d/78-sound-card.rules \
                ${nonarch_libdir}/udev/rules.d/80-drivers.rules \
                ${nonarch_libdir}/udev/rules.d/80-net-setup-link.rules \
+               ${nonarch_libdir}/udev/rules.d/81-net-bridge.rules \
                ${nonarch_libdir}/udev/rules.d/81-net-dhcp.rules \
+               ${nonarch_libdir}/udev/rules.d/90-image-dissect.rules \
                ${nonarch_libdir}/udev/rules.d/90-vconsole.rules \
                ${nonarch_libdir}/udev/rules.d/90-iocost.rules \
                ${nonarch_libdir}/udev/rules.d/README \
@@ -855,7 +833,6 @@  python do_warn_musl() {
 addtask warn_musl before do_configure
 
 ALTERNATIVE:${PN} = "halt reboot shutdown poweroff \
-                     ${@bb.utils.contains('PACKAGECONFIG', 'sysvinit', 'runlevel', '', d)} \
                      ${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'resolv-conf', '', d)}"
 
 ALTERNATIVE_TARGET[resolv-conf] = "${sysconfdir}/resolv-conf.systemd"
@@ -878,10 +855,6 @@  ALTERNATIVE_TARGET[poweroff] = "${base_bindir}/systemctl"
 ALTERNATIVE_LINK_NAME[poweroff] = "${base_sbindir}/poweroff"
 ALTERNATIVE_PRIORITY[poweroff] ?= "300"
 
-ALTERNATIVE_TARGET[runlevel] = "${base_bindir}/systemctl"
-ALTERNATIVE_LINK_NAME[runlevel] = "${base_sbindir}/runlevel"
-ALTERNATIVE_PRIORITY[runlevel] ?= "300"
-
 pkg_postinst:${PN}:append () {
 	if ${@bb.utils.contains('PACKAGECONFIG', 'set-time-epoch', 'true', 'false', d)}; then
 		touch $D${nonarch_libdir}/clock-epoch