1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

s3: Remove cli_write

Signed-off-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2011-04-02 16:44:40 +02:00 committed by Jeremy Allison
parent 0226428eb9
commit ca9ac7c4c7
3 changed files with 0 additions and 209 deletions

View File

@ -1191,9 +1191,6 @@ bool cli_state_seqnum_remove(struct cli_state *cli,
uint16_t mid);
bool cli_receive_smb(struct cli_state *cli);
bool cli_send_smb(struct cli_state *cli);
bool cli_send_smb_direct_writeX(struct cli_state *cli,
const char *p,
size_t extradata);
void cli_setup_packet_buf(struct cli_state *cli, char *buf);
void cli_setup_packet(struct cli_state *cli);
void cli_setup_bcc(struct cli_state *cli, void *p);
@ -1753,9 +1750,6 @@ NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum,
void *priv, SMB_OFF_T *received);
ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
off_t offset, size_t size);
ssize_t cli_write(struct cli_state *cli,
uint16_t fnum, uint16 write_mode,
const char *buf, off_t offset, size_t size);
NTSTATUS cli_smbwrite(struct cli_state *cli, uint16_t fnum, char *buf,
off_t offset, size_t size1, size_t *ptotal);
struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,

View File

@ -379,51 +379,6 @@ bool cli_send_smb(struct cli_state *cli)
return true;
}
/****************************************************************************
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.
****************************************************************************/

View File

@ -692,164 +692,6 @@ ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
return ret;
}
/****************************************************************************
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
****************************************************************************/