From 976030c70bb95dd2be1c22846d4a80b5b0c2ec98 Mon Sep 17 00:00:00 2001 From: Gregor Beck Date: Fri, 11 Oct 2013 10:53:45 +0200 Subject: [PATCH] s3:libsmb: add function cli_qpathinfo3() This is a reimplemantation of cli_qpathinfo2 without the use of info level SMB_QFILEINFO_ALL_INFO which leads to broken responses from NetApp. Signed-off-by: Gregor Beck Reviewed-by: Stefan Metzmacher Reviewed-by: Jeremy Allison --- source3/libsmb/clirap.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ source3/libsmb/clirap.h | 7 +++++++ 2 files changed, 61 insertions(+) diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 1ca45c0a4bd..cedd6a65cdd 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -1412,3 +1412,57 @@ NTSTATUS cli_qpathinfo_standard(struct cli_state *cli, const char *fname, return NT_STATUS_OK; } + + +/* like cli_qpathinfo2 but do not use SMB_QUERY_FILE_ALL_INFO */ +NTSTATUS cli_qpathinfo3(struct cli_state *cli, const char *fname, + struct timespec *create_time, + struct timespec *access_time, + struct timespec *write_time, + struct timespec *change_time, + off_t *size, uint16 *mode, + SMB_INO_T *ino) +{ + NTSTATUS status = NT_STATUS_OK; + SMB_STRUCT_STAT st; + uint32_t attr; + uint64_t pos; + + if (create_time || access_time || write_time || change_time || mode) { + status = cli_qpathinfo_basic(cli, fname, &st, &attr); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + } + + if (size) { + status = cli_qpathinfo_standard(cli, fname, + NULL, &pos, NULL, NULL, NULL); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + *size = pos; + } + + if (create_time) { + *create_time = st.st_ex_btime; + } + if (access_time) { + *access_time = st.st_ex_atime; + } + if (write_time) { + *write_time = st.st_ex_mtime; + } + if (change_time) { + *change_time = st.st_ex_ctime; + } + if (mode) { + *mode = attr; + } + if (ino) { + *ino = 0; + } + + return NT_STATUS_OK; +} diff --git a/source3/libsmb/clirap.h b/source3/libsmb/clirap.h index 432642068a3..54f06b4e76c 100644 --- a/source3/libsmb/clirap.h +++ b/source3/libsmb/clirap.h @@ -82,6 +82,13 @@ NTSTATUS cli_qpathinfo2(struct cli_state *cli, const char *fname, struct timespec *change_time, off_t *size, uint16 *mode, SMB_INO_T *ino); +NTSTATUS cli_qpathinfo3(struct cli_state *cli, const char *fname, + struct timespec *create_time, + struct timespec *access_time, + struct timespec *write_time, + struct timespec *change_time, + off_t *size, uint16 *mode, + SMB_INO_T *ino); struct tevent_req *cli_qpathinfo_streams_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, -- 2.11.4.GIT