summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/clientgen.c45
-rw-r--r--source3/libsmb/clireadwrite.c158
2 files changed, 0 insertions, 203 deletions
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 7eb10c4f1d..cec645b4a6 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -380,51 +380,6 @@ bool cli_send_smb(struct cli_state *cli)
}
/****************************************************************************
- Send a "direct" writeX smb to a fd.
-****************************************************************************/
-
-bool cli_send_smb_direct_writeX(struct cli_state *cli,
- const char *p,
- size_t extradata)
-{
- /* First length to send is the offset to the data. */
- size_t len = SVAL(cli->outbuf,smb_vwv11) + 4;
- size_t nwritten=0;
- struct iovec iov[2];
-
- /* fd == -1 causes segfaults -- Tom (tom@ninja.nl) */
- if (cli->fd == -1) {
- return false;
- }
-
- if (client_is_signing_on(cli)) {
- DEBUG(0,("cli_send_smb_large: cannot send signed packet.\n"));
- return false;
- }
-
- iov[0].iov_base = (void *)cli->outbuf;
- iov[0].iov_len = len;
- iov[1].iov_base = CONST_DISCARD(void *, p);
- iov[1].iov_len = extradata;
-
- nwritten = write_data_iov(cli->fd, iov, 2);
- if (nwritten < (len + extradata)) {
- close(cli->fd);
- cli->fd = -1;
- cli->smb_rw_error = SMB_WRITE_ERROR;
- DEBUG(0,("Error writing %d bytes to client. (%s)\n",
- (int)(len+extradata), strerror(errno)));
- return false;
- }
-
- /* Increment the mid so we can tell between responses. */
- cli->mid++;
- if (!cli->mid)
- cli->mid++;
- return true;
-}
-
-/****************************************************************************
Setup basics in a outgoing packet.
****************************************************************************/
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index 6482a335e1..d36b280843 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -693,164 +693,6 @@ ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
}
/****************************************************************************
- Issue a single SMBwrite and don't wait for a reply.
-****************************************************************************/
-
-static bool cli_issue_write(struct cli_state *cli,
- uint16_t fnum,
- off_t offset,
- uint16 mode,
- const char *buf,
- size_t size)
-{
- char *p;
- bool large_writex = false;
- /* We can only do direct writes if not signing and not encrypting. */
- bool direct_writes = !client_is_signing_on(cli) && !cli_encryption_on(cli);
-
- if (!direct_writes && size + 1 > cli->bufsize) {
- cli->outbuf = (char *)SMB_REALLOC(cli->outbuf, size + 1024);
- if (!cli->outbuf) {
- return False;
- }
- cli->inbuf = (char *)SMB_REALLOC(cli->inbuf, size + 1024);
- if (cli->inbuf == NULL) {
- SAFE_FREE(cli->outbuf);
- return False;
- }
- cli->bufsize = size + 1024;
- }
-
- memset(cli->outbuf,'\0',smb_size);
- memset(cli->inbuf,'\0',smb_size);
-
- if (cli->capabilities & CAP_LARGE_FILES) {
- large_writex = True;
- }
-
- if (large_writex) {
- cli_set_message(cli->outbuf,14,0,True);
- } else {
- cli_set_message(cli->outbuf,12,0,True);
- }
-
- SCVAL(cli->outbuf,smb_com,SMBwriteX);
- SSVAL(cli->outbuf,smb_tid,cli->cnum);
- cli_setup_packet(cli);
-
- SCVAL(cli->outbuf,smb_vwv0,0xFF);
- SSVAL(cli->outbuf,smb_vwv2,fnum);
-
- SIVAL(cli->outbuf,smb_vwv3,offset);
- SIVAL(cli->outbuf,smb_vwv5,0);
- SSVAL(cli->outbuf,smb_vwv7,mode);
-
- SSVAL(cli->outbuf,smb_vwv8,(mode & 0x0008) ? size : 0);
- /*
- * According to CIFS-TR-1p00, this following field should only
- * be set if CAP_LARGE_WRITEX is set. We should check this
- * locally. However, this check might already have been
- * done by our callers.
- */
- SSVAL(cli->outbuf,smb_vwv9,(size>>16));
- SSVAL(cli->outbuf,smb_vwv10,size);
- /* +1 is pad byte. */
- SSVAL(cli->outbuf,smb_vwv11,
- smb_buf(cli->outbuf) - smb_base(cli->outbuf) + 1);
-
- if (large_writex) {
- SIVAL(cli->outbuf,smb_vwv12,(((uint64_t)offset)>>32) & 0xffffffff);
- }
-
- p = smb_base(cli->outbuf) + SVAL(cli->outbuf,smb_vwv11) -1;
- *p++ = '\0'; /* pad byte. */
- if (!direct_writes) {
- memcpy(p, buf, size);
- }
- if (size > 0x1FFFF) {
- /* This is a POSIX 14 word large write. */
- set_message_bcc(cli->outbuf, 0); /* Set bcc to zero. */
- _smb_setlen_large(cli->outbuf,smb_size + 28 + 1 /* pad */ + size - 4);
- } else {
- cli_setup_bcc(cli, p+size);
- }
-
- show_msg(cli->outbuf);
- if (direct_writes) {
- /* For direct writes we now need to write the data
- * directly out of buf. */
- return cli_send_smb_direct_writeX(cli, buf, size);
- } else {
- return cli_send_smb(cli);
- }
-}
-
-/****************************************************************************
- write to a file
- write_mode: 0x0001 disallow write cacheing
- 0x0002 return bytes remaining
- 0x0004 use raw named pipe protocol
- 0x0008 start of message mode named pipe protocol
-****************************************************************************/
-
-ssize_t cli_write(struct cli_state *cli,
- uint16_t fnum, uint16 write_mode,
- const char *buf, off_t offset, size_t size)
-{
- ssize_t bwritten = 0;
- unsigned int issued = 0;
- unsigned int received = 0;
- int mpx = 1;
- size_t writesize;
- int blocks;
-
- if(cli->max_mux > 1) {
- mpx = cli->max_mux-1;
- } else {
- mpx = 1;
- }
-
- writesize = cli_write_max_bufsize(cli, write_mode);
-
- blocks = (size + (writesize-1)) / writesize;
-
- while (received < blocks) {
-
- while ((issued - received < mpx) && (issued < blocks)) {
- ssize_t bsent = issued * writesize;
- ssize_t size1 = MIN(writesize, size - bsent);
-
- if (!cli_issue_write(cli, fnum, offset + bsent,
- write_mode,
- buf + bsent,
- size1))
- return -1;
- issued++;
- }
-
- if (!cli_receive_smb(cli)) {
- return bwritten;
- }
-
- received++;
-
- if (cli_is_error(cli))
- break;
-
- bwritten += SVAL(cli->inbuf, smb_vwv2);
- if (writesize > 0xFFFF) {
- bwritten += (((int)(SVAL(cli->inbuf, smb_vwv4)))<<16);
- }
- }
-
- while (received < issued && cli_receive_smb(cli)) {
- received++;
- }
-
- return bwritten;
-}
-
-/****************************************************************************
write to a file using a SMBwrite and not bypassing 0 byte writes
****************************************************************************/