Exemplo n.º 1
0
/*
  a handler for async write replies
 */
static void async_write(struct smbcli_request *c_req)
{
	struct async_info *async = c_req->async.private_data;
	struct ntvfs_request *req = async->req;
	req->async_states->status = smb_raw_write_recv(c_req, async->parms);
	talloc_free(async);
	req->async_states->send_fn(req);
}
Exemplo n.º 2
0
/*
  test a write that hits a byte range lock and send the close after the write
*/
static bool test_mux_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
	union smb_write io;
	NTSTATUS status;
	int fnum;
	bool ret = true;
	struct smbcli_request *req;

	printf("Testing multiplexed lock/write/close\n");

	fnum = smbcli_open(cli->tree, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE);
	if (fnum == -1) {
		printf("open failed in mux_write - %s\n", smbcli_errstr(cli->tree));
		ret = false;
		goto done;
	}

	cli->session->pid = 1;

	/* lock a range */
	if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 0, 4, 0, WRITE_LOCK))) {
		printf("lock failed in mux_write - %s\n", smbcli_errstr(cli->tree));
		ret = false;
		goto done;
	}

	cli->session->pid = 2;

	/* send an async write */
	io.generic.level = RAW_WRITE_WRITEX;
	io.writex.in.file.fnum = fnum;
	io.writex.in.offset = 0;
	io.writex.in.wmode = 0;
	io.writex.in.remaining = 0;
	io.writex.in.count = 4;
	io.writex.in.data = (const uint8_t *)&fnum;	
	req = smb_raw_write_send(cli->tree, &io);

	/* unlock the range */
	cli->session->pid = 1;
	smbcli_unlock(cli->tree, fnum, 0, 4);

	/* and recv the async write reply */
	status = smb_raw_write_recv(req, &io);
	CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);

	smbcli_close(cli->tree, fnum);

done:
	return ret;
}
Exemplo n.º 3
0
static void async_write_recv(struct smbcli_request *req)
{
	struct async_context *c = req->async.private;
	NTSTATUS status;

	status = smb_raw_write_recv(req, c->io_write);
	c->wreq = NULL;
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(1,
		      ("ERROR: smb_raw_write_recv - %s\n",
		       nt_errstr(status)));
		talloc_free(c->io_write);
		c->io_write = 0;
		if (c->cb_error)
			c->cb_error(c->cb_ctx, ASYNC_WRITE_RECV, status);
		return;
	}
	if (c->wq.begin) {
		async_write(c, c->wq.begin->data, c->wq.begin->size);
		list_dequeue(&c->wq);
	}
}
Exemplo n.º 4
0
/****************************************************************************
 raw write interface (sync interface)
****************************************************************************/
_PUBLIC_ NTSTATUS smb_raw_write(struct smbcli_tree *tree, union smb_write *parms)
{
	struct smbcli_request *req = smb_raw_write_send(tree, parms);
	return smb_raw_write_recv(req, parms);
}