From 25c14ef0928ed46131dd4599fed37ec74bbc74e5 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 11 Jun 2014 09:32:56 +0000 Subject: smbd: Use full_path_tos() where appropriate Recently I've got reports that SMB2_FIND is slower than trans2 findfirst, so this tries to use recent performance-sensitive APIs right from the start :-) Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/smbd/smb2_find.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/source3/smbd/smb2_find.c b/source3/smbd/smb2_find.c index e9e0542bc26..481dcb9826c 100644 --- a/source3/smbd/smb2_find.c +++ b/source3/smbd/smb2_find.c @@ -330,17 +330,23 @@ static struct tevent_req *smbd_smb2_find_send(TALLOC_CTX *mem_ctx, if (!wcard_has_wild) { struct smb_filename *smb_fname = NULL; const char *fullpath; + char tmpbuf[PATH_MAX]; + char *to_free = NULL; if (ISDOT(fsp->fsp_name->base_name)) { fullpath = in_file_name; } else { - fullpath = talloc_asprintf(state, - "%s/%s", - fsp->fsp_name->base_name, - in_file_name); - } - if (tevent_req_nomem(fullpath, req)) { - return tevent_req_post(req, ev); + size_t len; + char *tmp; + + len = full_path_tos( + fsp->fsp_name->base_name, in_file_name, + tmpbuf, sizeof(tmpbuf), &tmp, &to_free); + if (len == -1) { + tevent_req_oom(req); + return tevent_req_post(req, ev); + } + fullpath = tmp; } status = filename_convert(state, conn, @@ -350,6 +356,8 @@ static struct tevent_req *smbd_smb2_find_send(TALLOC_CTX *mem_ctx, &wcard_has_wild, &smb_fname); + TALLOC_FREE(to_free); + if (!NT_STATUS_IS_OK(status)) { tevent_req_nterror(req, status); return tevent_req_post(req, ev); -- cgit