From 8930a9c52008c7c9a755b213f857dfa2247f6823 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 7 Feb 2010 14:07:17 +0100 Subject: s3: Convert cli_qpathinfo_basic to use cli_trans() --- source3/client/client.c | 8 ++++-- source3/include/proto.h | 4 +-- source3/libsmb/clidfs.c | 4 ++- source3/libsmb/clirap.c | 65 ++++++++++++++++++++----------------------------- 4 files changed, 37 insertions(+), 44 deletions(-) (limited to 'source3') diff --git a/source3/client/client.c b/source3/client/client.c index 1ceb3ab639..24fae3901b 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -408,8 +408,12 @@ static int do_cd(const char *new_dir) Except Win9x doesn't support the qpathinfo_basic() call..... */ if (targetcli->protocol > PROTOCOL_LANMAN2 && !targetcli->win95) { - if (!cli_qpathinfo_basic( targetcli, targetpath, &sbuf, &attributes ) ) { - d_printf("cd %s: %s\n", new_cd, cli_errstr(targetcli)); + NTSTATUS status; + + status = cli_qpathinfo_basic(targetcli, targetpath, &sbuf, + &attributes); + if (!NT_STATUS_IS_OK(status)) { + d_printf("cd %s: %s\n", new_cd, nt_errstr(status)); client_set_cur_dir(saved_dir); goto out; } diff --git a/source3/include/proto.h b/source3/include/proto.h index b120cb1a92..63270e14fa 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2846,8 +2846,8 @@ bool cli_qfileinfo(struct cli_state *cli, uint16_t fnum, struct timespec *write_time, struct timespec *change_time, SMB_INO_T *ino); -bool cli_qpathinfo_basic( struct cli_state *cli, const char *name, - SMB_STRUCT_STAT *sbuf, uint32 *attributes ); +NTSTATUS cli_qpathinfo_basic(struct cli_state *cli, const char *name, + SMB_STRUCT_STAT *sbuf, uint32 *attributes); bool cli_qfileinfo_test(struct cli_state *cli, uint16_t fnum, int level, char **poutdata, uint32 *poutlen); NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstring alt_name); diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c index d9e2b87d10..d5ae11ff8d 100644 --- a/source3/libsmb/clidfs.c +++ b/source3/libsmb/clidfs.c @@ -772,6 +772,7 @@ bool cli_resolve_path(TALLOC_CTX *ctx, char *ppath = NULL; SMB_STRUCT_STAT sbuf; uint32 attributes; + NTSTATUS status; if ( !rootcli || !path || !targetcli ) { return false; @@ -802,7 +803,8 @@ bool cli_resolve_path(TALLOC_CTX *ctx, return false; } - if (cli_qpathinfo_basic( rootcli, dfs_path, &sbuf, &attributes)) { + status = cli_qpathinfo_basic( rootcli, dfs_path, &sbuf, &attributes); + if (NT_STATUS_IS_OK(status)) { /* This is an ordinary path, just return it. */ *targetcli = rootcli; *pp_targetpath = talloc_strdup(ctx, path); diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 990b8063ca..55a783efd0 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -1047,24 +1047,24 @@ bool cli_qfileinfo(struct cli_state *cli, uint16_t fnum, Send a qpathinfo BASIC_INFO call. ****************************************************************************/ -bool cli_qpathinfo_basic( struct cli_state *cli, const char *name, - SMB_STRUCT_STAT *sbuf, uint32 *attributes ) +NTSTATUS cli_qpathinfo_basic(struct cli_state *cli, const char *name, + SMB_STRUCT_STAT *sbuf, uint32 *attributes) { unsigned int param_len = 0; - unsigned int data_len = 0; - uint16 setup = TRANSACT2_QPATHINFO; - char *param; - char *rparam=NULL, *rdata=NULL; - char *p; + uint32_t rdata_len; + uint16_t setup[1]; + uint8_t *param, *rdata; + uint8_t *p; char *path; int len; size_t nlen; TALLOC_CTX *frame = talloc_stackframe(); + NTSTATUS status; path = talloc_strdup(frame, name); if (!path) { TALLOC_FREE(frame); - return false; + return NT_STATUS_NO_MEMORY; } /* cleanup */ @@ -1074,54 +1074,41 @@ bool cli_qpathinfo_basic( struct cli_state *cli, const char *name, } nlen = 2*(strlen(path)+1); - param = TALLOC_ARRAY(frame,char,6+nlen+2); + param = TALLOC_ARRAY(frame, uint8_t, 6+nlen+2); if (!param) { - return false; + TALLOC_FREE(frame); + return NT_STATUS_NO_MEMORY; } p = param; memset(param, '\0', 6); + SSVAL(setup, 0, TRANSACT2_QPATHINFO); SSVAL(p, 0, SMB_QUERY_FILE_BASIC_INFO); p += 6; p += clistr_push(cli, p, path, nlen, STR_TERMINATE); param_len = PTR_DIFF(p, param); - - if (!cli_send_trans(cli, SMBtrans2, - NULL, /* name */ - -1, 0, /* fid, flags */ - &setup, 1, 0, /* setup, length, max */ - param, param_len, 2, /* param, length, max */ - NULL, 0, cli->max_xmit /* data, length, max */ - )) { + status = cli_trans(talloc_tos(), cli, SMBtrans2, NULL, -1, 0, 0, + setup, 1, 0, + param, param_len, 2, + NULL, 0, cli->max_xmit, + NULL, 0, NULL, + NULL, 0, NULL, + &rdata, 36, &rdata_len); + if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(frame); - return False; + return status; } - TALLOC_FREE(frame); - - if (!cli_receive_trans(cli, SMBtrans2, - &rparam, ¶m_len, - &rdata, &data_len)) { - return False; - } - - if (data_len < 36) { - SAFE_FREE(rdata); - SAFE_FREE(rparam); - return False; - } - - sbuf->st_ex_atime = interpret_long_date( rdata+8 ); /* Access time. */ - sbuf->st_ex_mtime = interpret_long_date( rdata+16 ); /* Write time. */ - sbuf->st_ex_ctime = interpret_long_date( rdata+24 ); /* Change time. */ + sbuf->st_ex_atime = interpret_long_date((char *)rdata+8); + sbuf->st_ex_mtime = interpret_long_date((char *)rdata+16); + sbuf->st_ex_ctime = interpret_long_date((char *)rdata+24); *attributes = IVAL( rdata, 32 ); - SAFE_FREE(rparam); - SAFE_FREE(rdata); + TALLOC_FREE(rdata); - return True; + return NT_STATUS_OK; } /**************************************************************************** -- cgit