[Skiboot] [PATCH] external/opal-prd: Split HBRT puts() into separate log file

Jack Miller jack at codezen.org
Wed Jan 25 06:56:49 AEDT 2017


Simple patch to keep excessive hostboot noise out of syslog.

Signed-off-by: Jack Miller <jack at codezen.org>
---
 external/opal-prd/opal-prd.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/external/opal-prd/opal-prd.c b/external/opal-prd/opal-prd.c
index 1723924..26efa22 100644
--- a/external/opal-prd/opal-prd.c
+++ b/external/opal-prd/opal-prd.c
@@ -78,6 +78,7 @@ struct opal_prd_ctx {
 	bool			debug;
 	struct pnor		pnor;
 	char			*hbrt_file_name;
+	int			hbrt_log_fd;
 	bool			use_syslog;
 	bool			expert_mode;
 	void			(*vlog)(int, const char *, va_list);
@@ -117,6 +118,8 @@ static const int ipmi_timeout_ms = 5000;
 static const char *devicetree_base =
 		"/sys/firmware/devicetree/base";
 
+static const char *hbrt_log_path = "/var/log/hbrt.log";
+
 /* Memory error handling */
 static const char *mem_offline_soft =
 		"/sys/devices/system/memory/soft_offline_page";
@@ -259,7 +262,21 @@ extern int call_run_command(int argc, const char **argv, char **o_outString);
 
 void hservice_puts(const char *str)
 {
-	pr_log(LOG_INFO, "HBRT: %s", str);
+	int len, rc;
+
+	if (ctx->hbrt_log_fd < 0) {
+		pr_log(LOG_INFO, "HBRT: %s", str);
+		return;
+	}
+
+	len = strlen(str);
+	rc = write(ctx->hbrt_log_fd, str, len);
+
+	if (len != rc)
+		pr_log(LOG_WARNING, "Failed to write to HBRT log: %s\n", strerror(errno));
+
+	write(ctx->hbrt_log_fd, "\n", 1);
+	fsync(ctx->hbrt_log_fd);
 }
 
 void hservice_assert(void)
@@ -1588,6 +1605,7 @@ static int run_prd_daemon(struct opal_prd_ctx *ctx)
 
 	ctx->fd = -1;
 	ctx->socket = -1;
+	ctx->hbrt_log_fd = -1;
 
 	i2c_init();
 
@@ -1618,7 +1636,6 @@ static int run_prd_daemon(struct opal_prd_ctx *ctx)
 		goto out_close;
 	}
 
-
 	if (ctx->hbrt_file_name) {
 		rc = map_hbrt_file(ctx, ctx->hbrt_file_name);
 		if (rc) {
@@ -1639,6 +1656,10 @@ static int run_prd_daemon(struct opal_prd_ctx *ctx)
 	pr_debug("IMAGE: hbrt map at %p, size 0x%zx",
 			ctx->code_addr, ctx->code_size);
 
+	ctx->hbrt_log_fd = open(hbrt_log_path, O_WRONLY | O_CREAT | O_APPEND);
+	if (ctx->hbrt_log_fd < 0)
+		pr_log(LOG_WARNING, "Failed to open HBRT log file: %s\n", strerror(errno));
+
 	fixup_hinterface_table();
 
 	rc = pnor_init(&ctx->pnor);
@@ -1676,6 +1697,8 @@ out_close:
 		close(ctx->fd);
 	if (ctx->socket != -1)
 		close(ctx->socket);
+	if (ctx->hbrt_log_fd != -1)
+		close(ctx->hbrt_log_fd);
 	return rc;
 }
 
-- 
2.7.4



More information about the Skiboot mailing list