]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmb: Make cli_qpathinfo2_done() parse the results
authorVolker Lendecke <vl@samba.org>
Mon, 3 Apr 2023 16:31:01 +0000 (18:31 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 18 Apr 2023 14:58:36 +0000 (14:58 +0000)
Make it easier to do an async SMB2 version

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/libsmb/clirap.c

index b89c7e15591852a429e8e421e940e72719022c55..24e6d7f7e274449c6f7cc97febe34bf77d0d9332 100644 (file)
@@ -908,8 +908,13 @@ NTSTATUS cli_setfileinfo_ext(
 ****************************************************************************/
 
 struct cli_qpathinfo2_state {
-       uint32_t num_data;
-       uint8_t *data;
+       struct timespec create_time;
+       struct timespec access_time;
+       struct timespec write_time;
+       struct timespec change_time;
+       off_t size;
+       uint32_t attr;
+       SMB_INO_T ino;
 };
 
 static void cli_qpathinfo2_done(struct tevent_req *subreq);
@@ -942,15 +947,35 @@ static void cli_qpathinfo2_done(struct tevent_req *subreq)
                subreq, struct tevent_req);
        struct cli_qpathinfo2_state *state = tevent_req_data(
                req, struct cli_qpathinfo2_state);
+       uint8_t *data = NULL;
+       uint32_t num_data;
        NTSTATUS status;
 
-       status = cli_qpathinfo_recv(subreq, state, &state->data,
-                                   &state->num_data);
+       status = cli_qpathinfo_recv(subreq, state, &data, &num_data);
        TALLOC_FREE(subreq);
        if (!NT_STATUS_IS_OK(status)) {
                tevent_req_nterror(req, status);
                return;
        }
+
+       state->create_time = interpret_long_date((char *)data + 0);
+       state->access_time = interpret_long_date((char *)data + 8);
+       state->write_time = interpret_long_date((char *)data + 16);
+       state->change_time = interpret_long_date((char *)data + 24);
+       state->attr = PULL_LE_U32(data, 32);
+       state->size = PULL_LE_U64(data, 48);
+
+       /*
+        * SMB1 qpathinfo2 uses SMB_QUERY_FILE_ALL_INFO which doesn't
+        * return an inode number (fileid).  We can't change this to
+        * one of the FILE_ID info levels as only Win2003 and above
+        * support these [MS-SMB: 2.2.2.3.1] and the SMB1 code needs
+        * to support older servers.
+        */
+       state->ino = 0;
+
+       TALLOC_FREE(data);
+
        tevent_req_done(req);
 }
 
@@ -971,34 +996,25 @@ NTSTATUS cli_qpathinfo2_recv(struct tevent_req *req,
        }
 
        if (create_time) {
-                *create_time = interpret_long_date((char *)state->data+0);
+               *create_time = state->create_time;
        }
        if (access_time) {
-               *access_time = interpret_long_date((char *)state->data+8);
+               *access_time = state->access_time;
        }
        if (write_time) {
-               *write_time = interpret_long_date((char *)state->data+16);
+               *write_time = state->write_time;
        }
        if (change_time) {
-               *change_time = interpret_long_date((char *)state->data+24);
+               *change_time = state->change_time;
        }
        if (pattr) {
-               /* SMB_QUERY_FILE_ALL_INFO returns 32-bit attributes. */
-               *pattr = IVAL(state->data, 32);
+               *pattr = state->attr;
        }
        if (size) {
-                *size = IVAL2_TO_SMB_BIG_UINT(state->data,48);
+               *size = state->size;
        }
        if (ino) {
-               /*
-                * SMB1 qpathinfo2 uses SMB_QUERY_FILE_ALL_INFO
-                * which doesn't return an inode number (fileid).
-                * We can't change this to one of the FILE_ID
-                * info levels as only Win2003 and above support
-                * these [MS-SMB: 2.2.2.3.1] and the SMB1 code
-                * needs to support older servers.
-                */
-               *ino = 0;
+               *ino = state->ino;
        }
        return NT_STATUS_OK;
 }