Skip to content

Commit e13fed7

Browse files
yosemite4: fix the console log file does not rotate
Summary: Description: - The file descriptor is lost after a sled cycle. The BMC will set the file size to 0 when it boots up. - If the log recorded after each sled cycle does not exceed 256K, the log file will grow indefinitely. - Set the end of the file as the file size. Motivation: As title. X-link: facebookexternal/openbmc.wiwynn#3150 Test Plan: - Build code : pass - Sled cycle and check the log size Gerrit link: - https://gerrit.openbmc.org/c/openbmc/obmc-console/+/73689 # Description Please include a summary of the change and which issue is fixed. # Motivation Please include an explanation of why you these changes are necessary Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Reviewed By: williamspatrick Differential Revision: D61717249 fbshipit-source-id: e89493cbd4e7d8659897fb80e5794a3a4d046e64
1 parent d74a01b commit e13fed7

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
From b750a1acd68c7139276a11c205a2d06791719530 Mon Sep 17 00:00:00 2001
2+
From: Marshall Zhan <marshall.zhan.wiwynn@gmail.com>
3+
Date: Thu, 22 Aug 2024 16:43:59 +0800
4+
Subject: [PATCH] Fix the console log file does not rotate
5+
6+
- The file descriptor might be reset after the system power cycle.
7+
- Set the end of the file as the file size.
8+
---
9+
log-handler.c | 2 +-
10+
1 file changed, 1 insertion(+), 1 deletion(-)
11+
12+
diff --git a/log-handler.c b/log-handler.c
13+
index 79b0f99..994d8a8 100644
14+
--- a/log-handler.c
15+
+++ b/log-handler.c
16+
@@ -136,7 +136,7 @@ static int log_create(struct log_handler *lh)
17+
warn("Can't open log buffer file %s", lh->log_filename);
18+
return -1;
19+
}
20+
- pos = lseek(lh->fd, 0, SEEK_CUR);
21+
+ pos = lseek(lh->fd, 0, SEEK_END);
22+
if (pos < 0) {
23+
warn("Can't query log position for file %s", lh->log_filename);
24+
close(lh->fd);
25+
--
26+
2.25.1
27+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
2+
3+
SRC_URI += " \
4+
file://0001-Fix-the-console-log-file-does-not-rotate.patch \
5+
"

0 commit comments

Comments
 (0)