From edba446b58f96db6d01968db0fc398be46188b72 Mon Sep 17 00:00:00 2001
From: zhangyao <zhangyao108@huawei.com>
Date: Mon, 23 Dec 2024 16:14:37 +0800
Subject: [PATCH] systemd-fstab-generator print logs only to kmsg

---
 src/fstab-generator/fstab-generator.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 016f3ba..54b84c0 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -1631,6 +1631,13 @@ static int run(int argc, char **argv) {
         } else {
                 /* Run in generator mode */
                 log_setup_generator();
+                /*
+                 * Writing logs to the journal may cause sendmsg to time out,
+                 * which leads to systemd startup failure. Therefore, we need
+                 * to print logs only to kmsg.
+                 */
+                log_set_target(LOG_TARGET_KMSG);
+                log_open();
 
                 if (!IN_SET(strv_length(argv), 2, 4))
                         return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
-- 
2.33.0

