From 8228c3c68c8d5b6e5e4ec2f4ec6e4a9c99e35f48 Mon Sep 17 00:00:00 2001 From: Gregor Beck Date: Fri, 11 Oct 2013 10:52:21 +0200 Subject: [PATCH] s3:libsmb: add function cli_qpathinfo_standard() Signed-off-by: Gregor Beck Reviewed-by: Stefan Metzmacher Reviewed-by: Jeremy Allison --- source3/libsmb/clirap.c | 49 +++++++++++++++++++++++++++++++++++++++++ source3/libsmb/clirap.h | 4 ++++ 2 files changed, 53 insertions(+) diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index e01e1399be..1ca45c0a4b 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -1363,3 +1363,52 @@ NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstrin return NT_STATUS_OK; } + +/**************************************************************************** + Send a qpathinfo SMB_QUERY_FILE_STADNDARD_INFO call. +****************************************************************************/ + +NTSTATUS cli_qpathinfo_standard(struct cli_state *cli, const char *fname, + uint64_t *allocated, uint64_t *size, + uint32_t *nlinks, + bool *is_del_pending, bool *is_dir) +{ + uint8_t *rdata; + uint32_t num_rdata; + NTSTATUS status; + + if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) { + return NT_STATUS_NOT_IMPLEMENTED; + } + + status = cli_qpathinfo(talloc_tos(), cli, fname, + SMB_QUERY_FILE_STANDARD_INFO, + 24, CLI_BUFFER_SIZE, &rdata, &num_rdata); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (allocated) { + *allocated = BVAL(rdata, 0); + } + + if (size) { + *size = BVAL(rdata, 8); + } + + if (nlinks) { + *nlinks = IVAL(rdata, 16); + } + + if (is_del_pending) { + *is_del_pending = CVAL(rdata, 20); + } + + if (is_dir) { + *is_dir = CVAL(rdata, 20); + } + + TALLOC_FREE(rdata); + + return NT_STATUS_OK; +} diff --git a/source3/libsmb/clirap.h b/source3/libsmb/clirap.h index e105182f09..432642068a 100644 --- a/source3/libsmb/clirap.h +++ b/source3/libsmb/clirap.h @@ -115,6 +115,10 @@ NTSTATUS cli_qpathinfo_basic_recv(struct tevent_req *req, SMB_STRUCT_STAT *sbuf, uint32 *attributes); NTSTATUS cli_qpathinfo_basic(struct cli_state *cli, const char *name, SMB_STRUCT_STAT *sbuf, uint32 *attributes); +NTSTATUS cli_qpathinfo_standard(struct cli_state *cli, const char *fname, + uint64_t *allocated, uint64_t *size, + uint32_t *nlinks, + bool *is_del_pending, bool *is_dir); NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstring alt_name); struct tevent_req *cli_qpathinfo_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, -- 2.34.1