From: Volker Lendecke Date: Mon, 3 Apr 2023 16:31:01 +0000 (+0200) Subject: libsmb: Make cli_qpathinfo2_done() parse the results X-Git-Tag: talloc-2.4.1~899 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2446ea916d9e48b6b8420ddd2a124abc18f62e2e;p=thirdparty%2Fsamba.git libsmb: Make cli_qpathinfo2_done() parse the results Make it easier to do an async SMB2 version Signed-off-by: Volker Lendecke Reviewed-by: Andreas Schneider --- diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index b89c7e15591..24e6d7f7e27 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -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; }