From 93cadc9d631415b3e3948fdc93336edea28714eb Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 28 Oct 2025 12:01:38 +0100 Subject: [PATCH] Truncate nrL1_stats.log before writing Without this, the remainder of the file remains in place, and this can be confusing if the total file size reduces. --- executables/nr-gnb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 2be0ee80ad..aa1a496559 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -314,13 +314,16 @@ void *nrL1_stats_thread(void *param) { reset_meas(&gNB->dlsch_precoding_stats); while (!oai_exit) { sleep(1); + if (ftruncate(fileno(fd), 0) != 0 || fseek(fd, 0, SEEK_SET) != 0) { + LOG_E(NR_MAC, "error while writing nrL1_stats.log: %d, %s\n", errno, strerror(errno)); + break; + } dump_nr_I0_stats(fd,gNB); dump_pdsch_stats(fd,gNB); dump_pusch_stats(fd,gNB); dump_L1_meas_stats(gNB, ru, output, L1STATSSTRLEN); fprintf(fd,"%s\n",output); fflush(fd); - fseek(fd,0,SEEK_SET); } fclose(fd); return(NULL);