diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/client/clitar.c | 8 | ||||
-rw-r--r-- | source3/client/smbspool.c | 17 | ||||
-rw-r--r-- | source3/libsmb/libsmb_file.c | 14 | ||||
-rw-r--r-- | source3/torture/denytest.c | 14 | ||||
-rw-r--r-- | source3/torture/nbio.c | 10 | ||||
-rw-r--r-- | source3/torture/test_posix_append.c | 15 | ||||
-rw-r--r-- | source3/torture/torture.c | 180 | ||||
-rw-r--r-- | source3/torture/utable.c | 3 | ||||
-rw-r--r-- | source3/utils/net_rpc_printer.c | 11 |
9 files changed, 169 insertions, 103 deletions
diff --git a/source3/client/clitar.c b/source3/client/clitar.c index b46115becf..645899a9ff 100644 --- a/source3/client/clitar.c +++ b/source3/client/clitar.c @@ -1045,8 +1045,12 @@ static int get_file(file_info2 finfo) dsize = MIN(dsize, rsize); /* Should be only what is left */ DEBUG(5, ("writing %i bytes, bpos = %i ...\n", dsize, bpos)); - if (cli_write(cli, fnum, 0, buffer_p + bpos, pos, dsize) != dsize) { - DEBUG(0, ("Error writing remote file\n")); + status = cli_writeall(cli, fnum, 0, + (uint8_t *)(buffer_p + bpos), pos, + dsize, NULL); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("Error writing remote file: %s\n", + nt_errstr(status))); return 0; } diff --git a/source3/client/smbspool.c b/source3/client/smbspool.c index 98c350d7dd..5a736c4930 100644 --- a/source3/client/smbspool.c +++ b/source3/client/smbspool.c @@ -595,14 +595,19 @@ smb_print(struct cli_state * cli, /* I - SMB connection */ tbytes = 0; while ((nbytes = fread(buffer, 1, sizeof(buffer), fp)) > 0) { - if (cli_write(cli, fnum, 0, buffer, tbytes, nbytes) != nbytes) { - int status = get_exit_code(cli, cli_nt_error(cli)); - - fprintf(stderr, "ERROR: Error writing spool: %s\n", cli_errstr(cli)); - fprintf(stderr, "DEBUG: Returning status %d...\n", status); + NTSTATUS status; + + status = cli_writeall(cli, fnum, 0, (uint8_t *)buffer, + tbytes, nbytes, NULL); + if (!NT_STATUS_IS_OK(status)) { + int ret = get_exit_code(cli, status); + fprintf(stderr, "ERROR: Error writing spool: %s\n", + nt_errstr(status)); + fprintf(stderr, "DEBUG: Returning status %d...\n", + ret); cli_close(cli, fnum); - return (status); + return (ret); } tbytes += nbytes; } diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c index 58403dfbb3..4ab6cd22e5 100644 --- a/source3/libsmb/libsmb_file.c +++ b/source3/libsmb/libsmb_file.c @@ -318,13 +318,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 +377,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, (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 ... */ } /* diff --git a/source3/torture/denytest.c b/source3/torture/denytest.c index 1f60734fa7..63448d44f3 100644 --- a/source3/torture/denytest.c +++ b/source3/torture/denytest.c @@ -1423,7 +1423,8 @@ bool torture_denytest1(int dummy) for (i=0;i<2;i++) { cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN); cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE, &fnum1); - cli_write(cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i])); + cli_writeall(cli1, fnum1, 0, (uint8_t *)fnames[i], 0, + strlen(fnames[i]), NULL); cli_close(cli1, fnum1); } @@ -1452,7 +1453,9 @@ bool torture_denytest1(int dummy) if (cli_read(cli1, fnum2, (char *)&x, 0, 1) == 1) { res += A_R; } - if (cli_write(cli1, fnum2, 0, (char *)&x, 0, 1) == 1) { + if (NT_STATUS_IS_OK(cli_writeall(cli1, fnum2, 0, + (uint8_t *)&x, 0, 1, + NULL))) { res += A_W; } } @@ -1514,7 +1517,8 @@ bool torture_denytest2(int dummy) for (i=0;i<2;i++) { cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN); cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE, &fnum1); - cli_write(cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i])); + cli_writeall(cli1, fnum1, 0, (uint8_t *)fnames[i], 0, + strlen(fnames[i]), NULL); cli_close(cli1, fnum1); } @@ -1541,7 +1545,9 @@ bool torture_denytest2(int dummy) if (cli_read(cli2, fnum2, (char *)&x, 0, 1) == 1) { res += A_R; } - if (cli_write(cli2, fnum2, 0, (char *)&x, 0, 1) == 1) { + if (NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, + (uint8_t *)&x, 0, 1, + NULL))) { res += A_W; } } diff --git a/source3/torture/nbio.c b/source3/torture/nbio.c index 664943b681..49ac4b5cec 100644 --- a/source3/torture/nbio.c +++ b/source3/torture/nbio.c @@ -189,13 +189,17 @@ void nb_createx(const char *fname, void nb_writex(int handle, int offset, int size, int ret_size) { int i; + NTSTATUS status; if (buf[0] == 0) memset(buf, 1, sizeof(buf)); i = find_handle(handle); - if (cli_write(c, ftable[i].fd, 0, buf, offset, size) != ret_size) { - printf("(%d) ERROR: write failed on handle %d, fd %d \ -errno %d (%s)\n", line_count, handle, ftable[i].fd, errno, strerror(errno)); + status = cli_writeall(c, ftable[i].fd, 0, (uint8_t *)buf, offset, size, + NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("(%d) ERROR: write failed on handle %d, fd %d " + "error %s\n", line_count, handle, ftable[i].fd, + nt_errstr(status)); exit(1); } diff --git a/source3/torture/test_posix_append.c b/source3/torture/test_posix_append.c index 6c8317e5aa..e18a1c1421 100644 --- a/source3/torture/test_posix_append.c +++ b/source3/torture/test_posix_append.c @@ -32,9 +32,8 @@ bool run_posix_append(int dummy) const char *fname = "append"; NTSTATUS status; uint16_t fnum; - ssize_t written; SMB_OFF_T size; - char c = '\0'; + uint8_t c = '\0'; bool ret = false; printf("Starting POSIX_APPEND\n"); @@ -69,14 +68,14 @@ bool run_posix_append(int dummy) * with a file of 2 byte length. */ - written = cli_write(cli, fnum, 0, &c, 0, sizeof(c)); - if (written != sizeof(c)) { - printf("cli_write failed\n"); + status = cli_writeall(cli, fnum, 0, &c, 0, sizeof(c), NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("cli_write failed: %s\n", nt_errstr(status)); goto fail; } - written = cli_write(cli, fnum, 0, &c, 0, sizeof(c)); - if (written != sizeof(c)) { - printf("cli_write failed\n"); + status = cli_writeall(cli, fnum, 0, &c, 0, sizeof(c), NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("cli_write failed: %s\n", nt_errstr(status)); goto fail; } diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 6319d6194d..9fcf582724 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -578,6 +578,7 @@ static bool rw_torture(struct cli_state *c) for (i=0;i<torture_numops;i++) { unsigned n = (unsigned)sys_random()%10; + if (i % 10 == 0) { printf("%d\r", i); fflush(stdout); } @@ -593,16 +594,20 @@ static bool rw_torture(struct cli_state *c) break; } - if (cli_write(c, fnum, 0, (char *)&pid, 0, sizeof(pid)) != sizeof(pid)) { - printf("write failed (%s)\n", cli_errstr(c)); + status = cli_writeall(c, fnum, 0, (uint8_t *)&pid, 0, + sizeof(pid), NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("write failed (%s)\n", nt_errstr(status)); correct = False; } for (j=0;j<50;j++) { - if (cli_write(c, fnum, 0, (char *)buf, - sizeof(pid)+(j*sizeof(buf)), - sizeof(buf)) != sizeof(buf)) { - printf("write failed (%s)\n", cli_errstr(c)); + status = cli_writeall(c, fnum, 0, (uint8_t *)buf, + sizeof(pid)+(j*sizeof(buf)), + sizeof(buf), NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("write failed (%s)\n", + nt_errstr(status)); correct = False; } } @@ -728,8 +733,11 @@ static bool rw_torture3(struct cli_state *c, char *lockfname) sent = sizeof(buf) - count; } - if (cli_write(c, fnum, 0, buf+count, count, (size_t)sent) != sent) { - printf("write failed (%s)\n", cli_errstr(c)); + status = cli_writeall(c, fnum, 0, (uint8_t *)buf+count, + count, (size_t)sent, NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("write failed (%s)\n", + nt_errstr(status)); correct = False; } } @@ -798,6 +806,7 @@ static bool rw_torture2(struct cli_state *c1, struct cli_state *c2) for (i=0;i<torture_numops;i++) { + NTSTATUS status; size_t buf_size = ((unsigned)sys_random()%(sizeof(buf)-1))+ 1; if (i % 10 == 0) { printf("%d\r", i); fflush(stdout); @@ -805,8 +814,10 @@ static bool rw_torture2(struct cli_state *c1, struct cli_state *c2) generate_random_buffer((unsigned char *)buf, buf_size); - if (cli_write(c1, fnum1, 0, buf, 0, buf_size) != buf_size) { - printf("write failed (%s)\n", cli_errstr(c1)); + status = cli_writeall(c1, fnum1, 0, (uint8_t *)buf, 0, + buf_size, NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("write failed (%s)\n", nt_errstr(status)); correct = False; break; } @@ -929,7 +940,7 @@ static bool run_readwritelarge_internal(int max_xmit_k) return False; } - cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf)); + cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, sizeof(buf), NULL); if (!NT_STATUS_IS_OK(cli_qfileinfo_basic( cli1, fnum1, NULL, &fsize, NULL, NULL, @@ -1293,8 +1304,9 @@ static bool run_tcon_test(int dummy) cnum1 = cli->cnum; vuid1 = cli->vuid; - if (cli_write(cli, fnum1, 0, buf, 130, 4) != 4) { - printf("initial write failed (%s)", cli_errstr(cli)); + status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("initial write failed (%s)", nt_errstr(status)); return False; } @@ -1314,33 +1326,39 @@ static bool run_tcon_test(int dummy) /* try a write with the wrong tid */ cli->cnum = cnum2; - if (cli_write(cli, fnum1, 0, buf, 130, 4) == 4) { + status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL); + if (NT_STATUS_IS_OK(status)) { printf("* server allows write with wrong TID\n"); ret = False; } else { - printf("server fails write with wrong TID : %s\n", cli_errstr(cli)); + printf("server fails write with wrong TID : %s\n", + nt_errstr(status)); } /* try a write with an invalid tid */ cli->cnum = cnum3; - if (cli_write(cli, fnum1, 0, buf, 130, 4) == 4) { + status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL); + if (NT_STATUS_IS_OK(status)) { printf("* server allows write with invalid TID\n"); ret = False; } else { - printf("server fails write with invalid TID : %s\n", cli_errstr(cli)); + printf("server fails write with invalid TID : %s\n", + nt_errstr(status)); } /* try a write with an invalid vuid */ cli->vuid = vuid2; cli->cnum = cnum1; - if (cli_write(cli, fnum1, 0, buf, 130, 4) == 4) { + status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL); + if (NT_STATUS_IS_OK(status)) { printf("* server allows write with invalid VUID\n"); ret = False; } else { - printf("server fails write with invalid VUID : %s\n", cli_errstr(cli)); + printf("server fails write with invalid VUID : %s\n", + nt_errstr(status)); } cli->cnum = cnum1; @@ -1793,6 +1811,7 @@ static bool run_locktest4(int dummy) bool ret; char buf[1000]; bool correct = True; + NTSTATUS status; if (!torture_open_connection(&cli1, 0) || !torture_open_connection(&cli2, 1)) { return False; @@ -1810,8 +1829,10 @@ static bool run_locktest4(int dummy) memset(buf, 0, sizeof(buf)); - if (cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) { - printf("Failed to create file\n"); + status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, sizeof(buf), + NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("Failed to create file: %s\n", nt_errstr(status)); correct = False; goto fail; } @@ -1883,8 +1904,12 @@ static bool run_locktest4(int dummy) EXPECTED(ret, False); printf("this server %s strict write locking\n", ret?"doesn't do":"does"); - ret = cli_lock(cli1, fnum1, 130, 4, 0, READ_LOCK) && - (cli_write(cli2, fnum2, 0, buf, 130, 4) == 4); + ret = cli_lock(cli1, fnum1, 130, 4, 0, READ_LOCK); + if (ret) { + status = cli_writeall(cli2, fnum2, 0, (uint8_t *)buf, 130, 4, + NULL); + ret = NT_STATUS_IS_OK(status); + } EXPECTED(ret, False); printf("this server %s strict read locking\n", ret?"doesn't do":"does"); @@ -1901,21 +1926,24 @@ static bool run_locktest4(int dummy) cli_lock(cli1, fnum1, 150, 4, 0, READ_LOCK) && NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 150, 4)) && (cli_read(cli2, fnum2, buf, 150, 4) == 4) && - !(cli_write(cli2, fnum2, 0, buf, 150, 4) == 4) && + !(NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, (uint8_t *)buf, + 150, 4, NULL))) && NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 150, 4)); EXPECTED(ret, True); printf("this server %s do recursive lock overlays\n", ret?"does":"doesn't"); ret = cli_lock(cli1, fnum1, 160, 4, 0, READ_LOCK) && NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 160, 4)) && - (cli_write(cli2, fnum2, 0, buf, 160, 4) == 4) && + NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, (uint8_t *)buf, + 160, 4, NULL)) && (cli_read(cli2, fnum2, buf, 160, 4) == 4); EXPECTED(ret, True); printf("the same process %s remove a read lock using write locking\n", ret?"can":"cannot"); ret = cli_lock(cli1, fnum1, 170, 4, 0, WRITE_LOCK) && NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 170, 4)) && - (cli_write(cli2, fnum2, 0, buf, 170, 4) == 4) && + NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, (uint8_t *)buf, + 170, 4, NULL)) && (cli_read(cli2, fnum2, buf, 170, 4) == 4); EXPECTED(ret, True); printf("the same process %s remove a write lock using read locking\n", ret?"can":"cannot"); @@ -1923,7 +1951,8 @@ static bool run_locktest4(int dummy) ret = cli_lock(cli1, fnum1, 190, 4, 0, WRITE_LOCK) && cli_lock(cli1, fnum1, 190, 4, 0, READ_LOCK) && NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 190, 4)) && - !(cli_write(cli2, fnum2, 0, buf, 190, 4) == 4) && + !NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, (uint8_t *)buf, + 190, 4, NULL)) && (cli_read(cli2, fnum2, buf, 190, 4) == 4); EXPECTED(ret, True); printf("the same process %s remove the first lock first\n", ret?"does":"doesn't"); @@ -1964,6 +1993,7 @@ static bool run_locktest5(int dummy) bool ret; char buf[1000]; bool correct = True; + NTSTATUS status; if (!torture_open_connection(&cli1, 0) || !torture_open_connection(&cli2, 1)) { return False; @@ -1982,8 +2012,10 @@ static bool run_locktest5(int dummy) memset(buf, 0, sizeof(buf)); - if (cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) { - printf("Failed to create file\n"); + status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, sizeof(buf), + NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("Failed to create file: %s\n", nt_errstr(status)); correct = False; goto fail; } @@ -2127,6 +2159,7 @@ static bool run_locktest7(int dummy) uint16_t fnum1; char buf[200]; bool correct = False; + NTSTATUS status; if (!torture_open_connection(&cli1, 0)) { return False; @@ -2142,8 +2175,10 @@ static bool run_locktest7(int dummy) memset(buf, 0, sizeof(buf)); - if (cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) { - printf("Failed to create file\n"); + status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, sizeof(buf), + NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("Failed to create file: %s\n", nt_errstr(status)); goto fail; } @@ -2163,9 +2198,11 @@ static bool run_locktest7(int dummy) printf("pid1 successfully read the range 130:4\n"); } - if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) { - printf("pid1 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1)); - if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) { + status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 130, 4, NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("pid1 unable to write to the range 130:4, error was " + "%s\n", nt_errstr(status)); + if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) { printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n"); goto fail; } @@ -2182,9 +2219,11 @@ static bool run_locktest7(int dummy) printf("pid2 successfully read the range 130:4\n"); } - if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) { - printf("pid2 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1)); - if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) { + status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 130, 4, NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("pid2 unable to write to the range 130:4, error was " + "%s\n", nt_errstr(status)); + if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) { printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n"); goto fail; } @@ -2210,8 +2249,10 @@ static bool run_locktest7(int dummy) printf("pid1 successfully read the range 130:4\n"); } - if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) { - printf("pid1 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1)); + status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 130, 4, NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("pid1 unable to write to the range 130:4, error was " + "%s\n", nt_errstr(status)); goto fail; } else { printf("pid1 successfully wrote to the range 130:4\n"); @@ -2230,9 +2271,11 @@ static bool run_locktest7(int dummy) goto fail; } - if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) { - printf("pid2 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1)); - if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) { + status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 130, 4, NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("pid2 unable to write to the range 130:4, error was " + "%s\n", nt_errstr(status)); + if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) { printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n"); goto fail; } @@ -2540,6 +2583,7 @@ static bool run_fdpasstest(int dummy) const char *fname = "\\fdpass.tst"; uint16_t fnum1; char buf[1024]; + NTSTATUS status; if (!torture_open_connection(&cli1, 0) || !torture_open_connection(&cli2, 1)) { return False; @@ -2556,8 +2600,10 @@ static bool run_fdpasstest(int dummy) return False; } - if (cli_write(cli1, fnum1, 0, "hello world\n", 0, 13) != 13) { - printf("write failed (%s)\n", cli_errstr(cli1)); + status = cli_writeall(cli1, fnum1, 0, (uint8_t *)"hello world\n", 0, + 13, NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("write failed (%s)\n", nt_errstr(status)); return False; } @@ -2594,6 +2640,7 @@ static bool run_fdsesstest(int dummy) uint16_t fnum2; char buf[1024]; bool ret = True; + NTSTATUS status; if (!torture_open_connection(&cli, 0)) return False; @@ -2618,8 +2665,10 @@ static bool run_fdsesstest(int dummy) return False; } - if (cli_write(cli, fnum1, 0, "hello world\n", 0, 13) != 13) { - printf("write failed (%s)\n", cli_errstr(cli)); + status = cli_writeall(cli, fnum1, 0, (uint8_t *)"hello world\n", 0, 13, + NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("write failed (%s)\n", nt_errstr(status)); return False; } @@ -3121,7 +3170,7 @@ static bool run_trans2test(int dummy) cli_open(cli, fname2, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum); - cli_write(cli, fnum, 0, (char *)&fnum, 0, sizeof(fnum)); + cli_writeall(cli, fnum, 0, (uint8_t *)&fnum, 0, sizeof(fnum), NULL); cli_close(cli, fnum); status = cli_qpathinfo2(cli, "\\trans2\\", &c_time_ts, &a_time_ts, &w_time_ts, &m_time2_ts, &size, NULL, NULL); @@ -3356,13 +3405,6 @@ static bool run_oplock2(int dummy) cli_read(cli1, fnum1, buf, 0, 4); -#if 0 - if (cli_write(cli1, fnum1, 0, buf, 0, 4) != 4) { - printf("write on fnum1 failed (%s)\n", cli_errstr(cli1)); - correct = False; - } -#endif - if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) { printf("close1 failed (%s)\n", cli_errstr(cli1)); correct = False; @@ -3421,7 +3463,7 @@ static bool run_oplock3(int dummy) sleep(2); /* try to trigger a oplock break in parent */ cli_open(cli, fname, O_RDWR, DENY_NONE, &fnum); - cli_write(cli, fnum, 0, buf, 0, 4); + cli_writeall(cli, fnum, 0, (uint8_t *)buf, 0, 4, NULL); exit(0); } @@ -3433,7 +3475,7 @@ static bool run_oplock3(int dummy) } cli_oplock_handler(cli, oplock3_handler); cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE, &fnum); - cli_write(cli, fnum, 0, buf, 0, 4); + cli_writeall(cli, fnum, 0, (uint8_t *)buf, 0, 4, NULL); cli_close(cli, fnum); cli_open(cli, fname, O_RDWR, DENY_NONE, &fnum); cli->timeout = 20000; @@ -4548,8 +4590,9 @@ static bool run_opentest(int dummy) memset(buf, '\0', 20); - if (cli_write(cli1, fnum1, 0, buf, 0, 20) != 20) { - printf("write failed (%s)\n", cli_errstr(cli1)); + status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, 20, NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("write failed (%s)\n", nt_errstr(status)); correct = False; } @@ -4817,8 +4860,10 @@ static bool run_opentest(int dummy) } /* Write to ensure we have to update the file time. */ - if (cli_write(cli1, fnum1, 0, "TEST DATA\n", 0, 10) != 10) { - printf("TEST #8 cli_write failed: %s\n", cli_errstr(cli1)); + status = cli_writeall(cli1, fnum1, 0, (uint8_t *)"TEST DATA\n", 0, 10, + NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("TEST #8 cli_write failed: %s\n", nt_errstr(status)); correct = false; goto out; } @@ -4990,8 +5035,10 @@ static bool run_simple_posix_open_test(int dummy) } /* Write some data into it. */ - if (cli_write(cli1, fnum1, 0, "TEST DATA\n", 0, 10) != 10) { - printf("cli_write failed: %s\n", cli_errstr(cli1)); + status = cli_writeall(cli1, fnum1, 0, (uint8_t *)"TEST DATA\n", 0, 10, + NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("cli_write failed: %s\n", nt_errstr(status)); goto out; } @@ -6510,14 +6557,15 @@ static bool run_windows_write(int dummy) start_time = timeval_current(); for (i=0; i<torture_numops; i++) { - char c = 0; + uint8_t c = 0; off_t start = i * torture_blocksize; NTSTATUS status; size_t to_pull = torture_blocksize - 1; - if (cli_write(cli1, fnum, 0, &c, - start + torture_blocksize - 1, 1) != 1) { - printf("cli_write failed: %s\n", cli_errstr(cli1)); + status = cli_writeall(cli1, fnum, 0, &c, + start + torture_blocksize - 1, 1, NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("cli_write failed: %s\n", nt_errstr(status)); goto fail; } diff --git a/source3/torture/utable.c b/source3/torture/utable.c index e7ee00a8a3..d4d5117bd1 100644 --- a/source3/torture/utable.c +++ b/source3/torture/utable.c @@ -198,7 +198,8 @@ bool torture_casetable(int dummy) fflush(stdout); } - cli_write(cli, fnum, 0, (char *)&c, size, sizeof(c)); + cli_writeall(cli, fnum, 0, (uint8_t *)&c, size, sizeof(c), + NULL); cli_close(cli, fnum); } diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c index 7a22587174..06023649ec 100644 --- a/source3/utils/net_rpc_printer.c +++ b/source3/utils/net_rpc_printer.c @@ -387,20 +387,19 @@ NTSTATUS net_copy_file(struct net_context *c, while (is_file) { /* copying file */ - int n, ret; + int n; n = cli_read(cli_share_src, fnum_src, data, nread, read_size); if (n <= 0) break; - ret = cli_write(cli_share_dst, fnum_dst, 0, data, - nread, n); + nt_status = cli_writeall(cli_share_dst, fnum_dst, 0, + (uint8_t *)data, nread, n, NULL); - if (n != ret) { + if (!NT_STATUS_IS_OK(nt_status)) { d_fprintf(stderr, _("Error writing file: %s\n"), - cli_errstr(cli_share_dst)); - nt_status = cli_nt_error(cli_share_dst); + nt_errstr(nt_status)); goto out; } |