smb_share_modes: don't use tdb_jenkins_hash.
[bbaumbach/samba-autobuild/.git] / source3 / libsmb / libsmb_file.c
index 1a44f0e9af39be50eea86c5eafa6860c33ca482b..c822eab79850dfe43ee73124cd666686613571b5 100644 (file)
@@ -23,6 +23,7 @@
 */
 
 #include "includes.h"
+#include "libsmb/libsmb.h"
 #include "libsmbclient.h"
 #include "libsmb_internal.h"
 
@@ -318,13 +319,13 @@ SMBC_write_ctx(SMBCCTX *context,
                const void *buf,
                size_t count)
 {
-       int ret;
         off_t offset;
        char *server = NULL, *share = NULL, *user = NULL, *password = NULL;
        char *path = NULL;
        char *targetpath = NULL;
        struct cli_state *targetcli = NULL;
        TALLOC_CTX *frame = talloc_stackframe();
+       NTSTATUS status;
 
        /* First check all pointers before dereferencing them */
 
@@ -377,18 +378,18 @@ SMBC_write_ctx(SMBCCTX *context,
        }
        /*d_printf(">>>write: resolved path as %s\n", targetpath);*/
 
-       ret = cli_write(targetcli, file->cli_fd,
-                        0, (char *)buf, offset, count);
-       if (ret <= 0) {
-               errno = SMBC_errno(context, targetcli);
+       status = cli_writeall(targetcli, file->cli_fd,
+                             0, (const uint8_t *)buf, offset, count, NULL);
+       if (!NT_STATUS_IS_OK(status)) {
+               errno = map_errno_from_nt_status(status);
                TALLOC_FREE(frame);
                return -1;
        }
 
-       file->offset += ret;
+       file->offset += count;
 
        TALLOC_FREE(frame);
-       return ret;  /* Success, 0 bytes of data ... */
+       return count;  /* Success, 0 bytes of data ... */
 }
 
 /*
@@ -480,7 +481,7 @@ SMBC_close_ctx(SMBCCTX *context,
 bool
 SMBC_getatr(SMBCCTX * context,
             SMBCSRV *srv,
-            char *path,
+            const char *path,
             uint16 *mode,
             SMB_OFF_T *size,
             struct timespec *create_time_ts,
@@ -603,12 +604,12 @@ SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path,
          * attributes manipulated.
          */
         if (srv->no_pathinfo ||
-            ! cli_setpathinfo(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. 
@@ -730,9 +731,10 @@ SMBC_lseek_ctx(SMBCCTX *context,
                }
 
                /*d_printf(">>>lseek: resolved path as %s\n", targetpath);*/
-               if (!cli_qfileinfo_basic(targetcli, file->cli_fd, NULL,
-                                        &size, NULL, NULL, NULL, NULL, NULL))
-               {
+               if (!NT_STATUS_IS_OK(cli_qfileinfo_basic(
+                                            targetcli, file->cli_fd, NULL,
+                                            &size, NULL, NULL, NULL, NULL,
+                                            NULL))) {
                         SMB_OFF_T b_size = size;
                        if (!NT_STATUS_IS_OK(cli_getattrE(targetcli, file->cli_fd,
                                           NULL, &b_size, NULL, NULL, NULL))) {