|
|
bf143f |
From ebf6be5ba316ffda354af5eb1f1241ad6543b3cd Mon Sep 17 00:00:00 2001
|
|
|
bf143f |
From: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
|
|
|
bf143f |
Date: Thu, 18 Aug 2022 14:46:19 -0400
|
|
|
bf143f |
Subject: [PATCH 3/3] virtiofsd: use g_date_time_get_microsecond to get
|
|
|
bf143f |
subsecond
|
|
|
bf143f |
MIME-Version: 1.0
|
|
|
bf143f |
Content-Type: text/plain; charset=UTF-8
|
|
|
bf143f |
Content-Transfer-Encoding: 8bit
|
|
|
bf143f |
|
|
|
bf143f |
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
bf143f |
RH-MergeRequest: 222: virtiofsd: use g_date_time_get_microsecond to get subsecond
|
|
|
bf143f |
RH-Bugzilla: 2018885
|
|
|
bf143f |
RH-Acked-by: Vivek Goyal <None>
|
|
|
bf143f |
RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
bf143f |
RH-Acked-by: Sergio Lopez <slp@redhat.com>
|
|
|
bf143f |
RH-Commit: [1/1] da8795576acc7029044a801ef42676d66471a577
|
|
|
bf143f |
|
|
|
bf143f |
The "%f" specifier in g_date_time_format() is only available in glib
|
|
|
bf143f |
2.65.2 or later. If combined with older glib, the function returns null
|
|
|
bf143f |
and the timestamp displayed as "(null)".
|
|
|
bf143f |
|
|
|
bf143f |
For backward compatibility, g_date_time_get_microsecond should be used
|
|
|
bf143f |
to retrieve subsecond.
|
|
|
bf143f |
|
|
|
bf143f |
In this patch the g_date_time_format() leaves subsecond field as "%06d"
|
|
|
bf143f |
and let next snprintf to format with g_date_time_get_microsecond.
|
|
|
bf143f |
|
|
|
bf143f |
Signed-off-by: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
|
|
|
bf143f |
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
bf143f |
Message-id: 20220818184618.2205172-1-yokada.996@gmail.com
|
|
|
bf143f |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
bf143f |
(cherry picked from commit f16d15c9276bd8f501f861c39cbd4adc812d0c1d)
|
|
|
bf143f |
---
|
|
|
bf143f |
tools/virtiofsd/passthrough_ll.c | 7 +++++--
|
|
|
bf143f |
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
|
bf143f |
|
|
|
bf143f |
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
|
|
|
bf143f |
index b3d0674f6d..523d8fbe1e 100644
|
|
|
bf143f |
--- a/tools/virtiofsd/passthrough_ll.c
|
|
|
bf143f |
+++ b/tools/virtiofsd/passthrough_ll.c
|
|
|
bf143f |
@@ -3791,6 +3791,7 @@ static void setup_nofile_rlimit(unsigned long rlimit_nofile)
|
|
|
bf143f |
static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
|
|
|
bf143f |
{
|
|
|
bf143f |
g_autofree char *localfmt = NULL;
|
|
|
bf143f |
+ char buf[64];
|
|
|
bf143f |
|
|
|
bf143f |
if (current_log_level < level) {
|
|
|
bf143f |
return;
|
|
|
bf143f |
@@ -3803,9 +3804,11 @@ static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
|
|
|
bf143f |
fmt);
|
|
|
bf143f |
} else {
|
|
|
bf143f |
g_autoptr(GDateTime) now = g_date_time_new_now_utc();
|
|
|
bf143f |
- g_autofree char *nowstr = g_date_time_format(now, "%Y-%m-%d %H:%M:%S.%f%z");
|
|
|
bf143f |
+ g_autofree char *nowstr = g_date_time_format(now,
|
|
|
bf143f |
+ "%Y-%m-%d %H:%M:%S.%%06d%z");
|
|
|
bf143f |
+ snprintf(buf, 64, nowstr, g_date_time_get_microsecond(now));
|
|
|
bf143f |
localfmt = g_strdup_printf("[%s] [ID: %08ld] %s",
|
|
|
bf143f |
- nowstr, syscall(__NR_gettid), fmt);
|
|
|
bf143f |
+ buf, syscall(__NR_gettid), fmt);
|
|
|
bf143f |
}
|
|
|
bf143f |
fmt = localfmt;
|
|
|
bf143f |
}
|
|
|
bf143f |
--
|
|
|
bf143f |
2.35.3
|
|
|
bf143f |
|