From: Jule Anger Date: Mon, 9 May 2022 08:00:22 +0000 (+0200) Subject: smbstatus: add machine readable time info to locked files X-Git-Tag: samba-4.17.0rc1~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fb809a11712375a1583bc6a94bad0986ec7aad06;p=thirdparty%2Fsamba.git smbstatus: add machine readable time info to locked files Time has the format "2022-03-31T12:23:30+0200". Signed-off-by: Jule Anger Reviewed-by: Ralph Boehme --- diff --git a/source3/utils/status_json.c b/source3/utils/status_json.c index 6e2e5e7ba39..d100b104439 100644 --- a/source3/utils/status_json.c +++ b/source3/utils/status_json.c @@ -757,7 +757,9 @@ static int add_open_to_json(struct json_object *parent_json, { struct json_object sub_json; struct json_object opens_json; + struct timeval_buf tv_buf; int result = 0; + char *timestr; bool add_lease = false; char *key = NULL; char *share_file_id = NULL; @@ -820,6 +822,15 @@ static int add_open_to_json(struct json_object *parent_json, goto failure; } + timestr = timeval_str_buf(&e->time, true, true, &tv_buf); + if (timestr == NULL) { + goto failure; + } + result = json_add_string(&sub_json, "opened_at", timestr); + if (result < 0) { + goto failure; + } + pid = server_id_str_buf(e->pid, &tmp); key = talloc_asprintf(tmp_ctx, "%s/%lu", pid, e->share_file_id); result = json_add_object(&opens_json, key, &sub_json);