]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbstatus: add machine readable time info to locked files
authorJule Anger <janger@samba.org>
Mon, 9 May 2022 08:00:22 +0000 (10:00 +0200)
committerJule Anger <janger@samba.org>
Mon, 8 Aug 2022 12:56:29 +0000 (12:56 +0000)
Time has the format "2022-03-31T12:23:30+0200".

Signed-off-by: Jule Anger <janger@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/utils/status_json.c

index 6e2e5e7ba3933ee58b32fa5c687ddd29ca93c05d..d100b10443916d857d33214760e632839ff3ce6e 100644 (file)
@@ -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);