s3: Convert cli_qpathinfo_basic to use cli_trans()
authorVolker Lendecke <vl@samba.org>
Sun, 7 Feb 2010 13:07:17 +0000 (14:07 +0100)
committerVolker Lendecke <vl@samba.org>
Sat, 20 Feb 2010 17:59:30 +0000 (18:59 +0100)
source3/client/client.c
source3/include/proto.h
source3/libsmb/clidfs.c
source3/libsmb/clirap.c

index 1ceb3ab6396d6611b30a1d436ffa0bb8939889f3..24fae3901b87c4beaa38f9c95f6913a8bd44fb18 100644 (file)
@@ -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;
                }
index b120cb1a92b74b0a6fa37bbb21af475593312a25..63270e14fa48bad6b742c564247a2db20b8cfb04 100644 (file)
@@ -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);
 
index d9e2b87d10c39898cd310ab2c5566c5c5c53cbe7..d5ae11ff8da7f606c3293094f1025630313eba48 100644 (file)
@@ -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);
index 990b8063ca9cd30ce7eb366c6a1f48092928ab0a..55a783efd004208d6de2a004efb601a98d9dbb95 100644 (file)
@@ -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, &param_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;
 }
 
 /****************************************************************************