s3: Make cli_setpathinfo_basic use cli_setpathinfo
authorVolker Lendecke <vl@samba.org>
Sun, 16 Jan 2011 11:56:09 +0000 (12:56 +0100)
committerVolker Lendecke <vl@samba.org>
Mon, 17 Jan 2011 07:03:42 +0000 (08:03 +0100)
source3/include/proto.h
source3/libsmb/clirap.c
source3/libsmb/libsmb_file.c

index b710d713b023612985715b89f290c2284e7b2b9f..a0297021687d2957fde2a93e779b3846be08c36f 100644 (file)
@@ -2301,12 +2301,12 @@ NTSTATUS cli_qpathinfo1(struct cli_state *cli,
                        time_t *write_time,
                        SMB_OFF_T *size,
                        uint16 *mode);
-bool cli_setpathinfo_basic(struct cli_state *cli, const char *fname,
-                          time_t create_time,
-                          time_t access_time,
-                          time_t write_time,
-                          time_t change_time,
-                          uint16 mode);
+NTSTATUS cli_setpathinfo_basic(struct cli_state *cli, const char *fname,
+                              time_t create_time,
+                              time_t access_time,
+                              time_t write_time,
+                              time_t change_time,
+                              uint16 mode);
 struct tevent_req *cli_qpathinfo2_send(TALLOC_CTX *mem_ctx,
                                       struct event_context *ev,
                                       struct cli_state *cli,
index 80d93d32d8b0df55a125f938512205222d0f9f0d..0955d1e3bb3f90068511b61e44c47c485d7218c7 100644 (file)
@@ -656,44 +656,16 @@ NTSTATUS cli_qpathinfo1(struct cli_state *cli,
  Send a setpathinfo call.
 ****************************************************************************/
 
-bool cli_setpathinfo_basic(struct cli_state *cli, const char *fname,
-                          time_t create_time,
-                          time_t access_time,
-                          time_t write_time,
-                          time_t change_time,
-                          uint16 mode)
+NTSTATUS cli_setpathinfo_basic(struct cli_state *cli, const char *fname,
+                              time_t create_time,
+                              time_t access_time,
+                              time_t write_time,
+                              time_t change_time,
+                              uint16 mode)
 {
        unsigned int data_len = 0;
-       unsigned int param_len = 0;
-       unsigned int rparam_len, rdata_len;
-       uint16 setup = TRANSACT2_SETPATHINFO;
-       char *param;
        char data[40];
-       char *rparam=NULL, *rdata=NULL;
-       int count=8;
-       bool ret;
        char *p;
-       size_t nlen = 2*(strlen(fname)+1);
-
-       param = SMB_MALLOC_ARRAY(char, 6+nlen+2);
-       if (!param) {
-               return false;
-       }
-       memset(param, '\0', 6);
-       memset(data, 0, sizeof(data));
-
-        p = param;
-
-        /* Add the information level */
-       SSVAL(p, 0, SMB_FILE_BASIC_INFORMATION);
-
-        /* Skip reserved */
-       p += 6;
-
-        /* Add the file name */
-       p += clistr_push(cli, p, fname, nlen, STR_TERMINATE);
-
-       param_len = PTR_DIFF(p, param);
 
         p = data;
 
@@ -722,37 +694,8 @@ bool cli_setpathinfo_basic(struct cli_state *cli, const char *fname,
 
         data_len = PTR_DIFF(p, data);
 
-       do {
-               ret = (cli_send_trans(cli, SMBtrans2,
-                                     NULL,           /* Name */
-                                     -1, 0,          /* fid, flags */
-                                     &setup, 1, 0,   /* setup, length, max */
-                                     param, param_len, 10, /* param, length, max */
-                                     data, data_len, cli->max_xmit /* data, length, max */
-                                     ) &&
-                      cli_receive_trans(cli, SMBtrans2,
-                                        &rparam, &rparam_len,
-                                        &rdata, &rdata_len));
-               if (!cli_is_dos_error(cli)) break;
-               if (!ret) {
-                       /* we need to work around a Win95 bug - sometimes
-                          it gives ERRSRV/ERRerror temprarily */
-                       uint8 eclass;
-                       uint32 ecode;
-                       cli_dos_error(cli, &eclass, &ecode);
-                       if (eclass != ERRSRV || ecode != ERRerror) break;
-                       smb_msleep(100);
-               }
-       } while (count-- && ret==False);
-
-       SAFE_FREE(param);
-       if (!ret) {
-               return False;
-       }
-
-       SAFE_FREE(rdata);
-       SAFE_FREE(rparam);
-       return True;
+       return cli_setpathinfo(cli, SMB_FILE_BASIC_INFORMATION, fname,
+                              (uint8_t *)data, data_len);
 }
 
 /****************************************************************************
index 6216c38bb17dc2d9e833dfa1819d2bd1fe9d5257..58403dfbb3681c6a0a8831f923b16c8cbe5a036c 100644 (file)
@@ -603,12 +603,12 @@ SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path,
          * attributes manipulated.
          */
         if (srv->no_pathinfo ||
-            ! cli_setpathinfo_basic(srv->cli, path,
-                                   create_time,
-                                   access_time,
-                                   write_time,
-                                   change_time,
-                                   mode)) {
+            !NT_STATUS_IS_OK(cli_setpathinfo_basic(srv->cli, path,
+                                                  create_time,
+                                                  access_time,
+                                                  write_time,
+                                                  change_time,
+                                                  mode))) {
 
                 /*
                  * setpathinfo is not supported; go to plan B.