/**************************************************************************** Calculate the recommended write buffer size ****************************************************************************/ static size_t cli_write_max_bufsize(struct cli_state *cli, uint16_t write_mode) { if (write_mode == 0 && !client_is_signing_on(cli) && !cli_encryption_on(cli) && (cli->posix_capabilities & CIFS_UNIX_LARGE_WRITE_CAP) && (cli->capabilities & CAP_LARGE_FILES)) { /* Only do massive writes if we can do them direct * with no signing or encrypting - not on a pipe. */ return CLI_SAMBA_MAX_POSIX_LARGE_WRITEX_SIZE; } if (cli->is_samba) { return CLI_SAMBA_MAX_LARGE_WRITEX_SIZE; } if (((cli->capabilities & CAP_LARGE_WRITEX) == 0) || client_is_signing_on(cli) || strequal(cli->dev, "LPT1:")) { /* * Printer devices are restricted to max_xmit writesize in * Vista and XPSP3 as are signing connections. */ return (cli->max_xmit - (smb_size+32)) & ~1023; } return CLI_WINDOWS_MAX_LARGE_WRITEX_SIZE; }
/**************************************************************************** Calculate the recommended read buffer size ****************************************************************************/ static size_t cli_read_max_bufsize(struct cli_state *cli) { if (!client_is_signing_on(cli) && !cli_encryption_on(cli) && (cli->posix_capabilities & CIFS_UNIX_LARGE_READ_CAP)) { return CLI_SAMBA_MAX_POSIX_LARGE_READX_SIZE; } if (cli->capabilities & CAP_LARGE_READX) { return cli->is_samba ? CLI_SAMBA_MAX_LARGE_READX_SIZE : CLI_WINDOWS_MAX_LARGE_READX_SIZE; } return (cli->max_xmit - (smb_size+32)) & ~1023; }
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 ([email protected]) */ 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; }