*/
#include "includes.h"
+#include "events.h"
+#include "libcli/raw/libcliraw.h"
+#include "smb_server/smb_server.h"
/* this is stored in ntvfs_private */
struct cvfs_private {
- struct cli_tree *tree;
- struct cli_transport *transport;
- struct tcon_context *conn;
- const char *map_calls;
+ struct smbcli_tree *tree;
+ struct smbcli_transport *transport;
+ struct smbsrv_tcon *tcon;
+ BOOL map_generic;
};
/* a structure used to pass information to an async handler */
struct async_info {
- struct request_context *req;
+ struct smbsrv_request *req;
void *parms;
};
+#define SETUP_PID private->tree->session->pid = SVAL(req->in.hdr, HDR_PID)
+
/*
an idle function to cope with messages from the smbd client while
waiting for a reply from the server
this function won't be needed once all of the cifs backend
and the core of smbd is converted to use async calls
*/
-static void idle_func(struct cli_transport *transport, void *p_private)
+static void idle_func(struct smbcli_transport *transport, void *p_private)
{
struct cvfs_private *private = p_private;
- if (socket_pending(private->conn->smb->socket.fd)) {
- smbd_process_async(private->conn->smb);
+ int fd = socket_get_fd(private->tcon->smb_conn->connection->socket);
+
+ if (socket_pending(fd)) {
+ smbd_process_async(private->tcon->smb_conn);
}
}
a handler for oplock break events from the server - these need to be passed
along to the client
*/
-static BOOL oplock_handler(struct cli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *p_private)
+static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *p_private)
{
struct cvfs_private *private = p_private;
DEBUG(5,("vfs_cifs: sending oplock break level %d for fnum %d\n", level, fnum));
- return req_send_oplock_break(private->conn, fnum, level);
+ return req_send_oplock_break(private->tcon, fnum, level);
}
-/*
+ /*
a handler for read events on a connection to a backend server
*/
-static void cifs_socket_handler(struct event_context *ev, struct fd_event *fde, time_t t, uint16_t flags)
+static void cifs_socket_handler(struct event_context *ev, struct fd_event *fde,
+ struct timeval t, uint16_t flags)
{
struct cvfs_private *private = fde->private;
- struct tcon_context *conn = private->conn;
-
+ struct smbsrv_tcon *tcon = private->tcon;
+
DEBUG(5,("cifs_socket_handler event on fd %d\n", fde->fd));
-
- if (!cli_request_receive_next(private->transport)) {
+
+ if (!smbcli_transport_process(private->transport)) {
/* the connection to our server is dead */
- close_cnum(conn);
+ talloc_free(tcon);
}
}
/*
connect to a share - used when a tree_connect operation comes in.
*/
-static NTSTATUS cvfs_connect(struct request_context *req, const char *sharename)
+static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, const char *sharename)
{
- struct tcon_context *conn = req->conn;
+ struct smbsrv_tcon *tcon = req->tcon;
NTSTATUS status;
struct cvfs_private *private;
- const char *map_calls;
- struct fd_event fde;
const char *host, *user, *pass, *domain, *remote_share;
/* Here we need to determine which server to connect to.
* For now we use parametric options, type cifs.
* Later we will use security=server and auth_server.c.
*/
- host = lp_parm_string(req->conn->service, "cifs", "server");
- user = lp_parm_string(req->conn->service, "cifs", "user");
- pass = lp_parm_string(req->conn->service, "cifs", "password");
- domain = lp_parm_string(req->conn->service, "cifs", "domain");
- remote_share = lp_parm_string(req->conn->service, "cifs", "share");
+ host = lp_parm_string(req->tcon->service, "cifs", "server");
+ user = lp_parm_string(req->tcon->service, "cifs", "user");
+ pass = lp_parm_string(req->tcon->service, "cifs", "password");
+ domain = lp_parm_string(req->tcon->service, "cifs", "domain");
+ remote_share = lp_parm_string(req->tcon->service, "cifs", "share");
if (!remote_share) {
remote_share = sharename;
}
return NT_STATUS_INVALID_PARAMETER;
}
- private = talloc(req->conn->mem_ctx, sizeof(struct cvfs_private));
+ private = talloc_p(req->tcon, struct cvfs_private);
if (!private) {
return NT_STATUS_NO_MEMORY;
}
ZERO_STRUCTP(private);
- req->conn->ntvfs_private = (void *)private;
+ ntvfs->private_data = private;
- status = cli_tree_full_connection(&private->tree,
- "vfs_cifs",
- host,
- 0,
- remote_share, "?????",
- user, domain,
- pass);
+ status = smbcli_tree_full_connection(private,
+ &private->tree,
+ "vfs_cifs",
+ host,
+ 0,
+ remote_share, "?????",
+ user, domain,
+ pass);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
private->transport = private->tree->session->transport;
- private->tree->session->pid = SVAL(req->in.hdr, HDR_PID);
- private->conn = req->conn;
+ SETUP_PID;
+ private->tcon = req->tcon;
- conn->fs_type = talloc_strdup(conn->mem_ctx, "NTFS");
- conn->dev_type = talloc_strdup(conn->mem_ctx, "A:");
+ tcon->fs_type = talloc_strdup(tcon, "NTFS");
+ tcon->dev_type = talloc_strdup(tcon, "A:");
- map_calls = lp_parm_string(req->conn->service, "cifs", "map calls");
- if (map_calls) {
- private->map_calls = talloc_strdup(conn->mem_ctx, map_calls);
- }
-
- /* if we are mapping trans2, then we need to give a trans2
- pointer in the operations structure */
- if (private->map_calls && in_list("trans2", private->map_calls, True)) {
- struct ntvfs_ops *ops = talloc_memdup(conn->mem_ctx,conn->ntvfs_ops,sizeof(*ops));
- static NTSTATUS cvfs_trans2(struct request_context *,struct smb_trans2 *);
- if (!ops) {
- return NT_STATUS_NO_MEMORY;
- }
- ops->trans2 = cvfs_trans2;
- conn->ntvfs_ops = ops;
- }
-
- /* we need to tell the event loop that we wish to receive read events
- on our SMB connection to the server */
- fde.fd = private->transport->socket->fd;
- fde.flags = EVENT_FD_READ;
- fde.private = private;
- fde.handler = cifs_socket_handler;
-
- event_add_fd(conn->smb->events, &fde);
-
/* we need to receive oplock break requests from the server */
- cli_oplock_handler(private->transport, oplock_handler, private);
- cli_transport_idle_handler(private->transport, idle_func, 100, private);
+ smbcli_oplock_handler(private->transport, oplock_handler, private);
+ smbcli_transport_idle_handler(private->transport, idle_func, 50000, private);
+
+ private->transport->socket->event.fde->handler = cifs_socket_handler;
+ private->transport->socket->event.fde->private = private;
+
+ private->transport->socket->event.ctx = event_context_merge(tcon->smb_conn->connection->event.ctx,
+ private->transport->socket->event.ctx);
+ talloc_reference(private, private->transport->socket->event.ctx);
+ private->map_generic = lp_parm_bool(req->tcon->service,
+ "cifs", "mapgeneric", False);
return NT_STATUS_OK;
}
/*
disconnect from a share
*/
-static NTSTATUS cvfs_disconnect(struct tcon_context *conn)
+static NTSTATUS cvfs_disconnect(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_tcon *tcon)
{
- struct cvfs_private *private = conn->ntvfs_private;
+ struct cvfs_private *private = ntvfs->private_data;
- event_remove_fd_all(conn->smb->events, private->transport->socket->fd);
- smb_tree_disconnect(private->tree);
- cli_tree_close(private->tree);
+ talloc_free(private);
return NT_STATUS_OK;
}
this handler can only be used for functions that don't return any
parameters (those that just return a status code)
*/
-static void async_simple(struct cli_request *c_req)
+static void async_simple(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
- struct request_context *req = async->req;
- req->async.status = cli_request_simple_recv(c_req);
- req->async.send_fn(req);
+ struct smbsrv_request *req = async->req;
+ req->async_states->status = smbcli_request_simple_recv(c_req);
+ req->async_states->send_fn(req);
}
if (!c_req) return NT_STATUS_UNSUCCESSFUL; \
{ \
struct async_info *async; \
- async = talloc(req->mem_ctx, sizeof(*async)); \
+ async = talloc_p(req, struct async_info); \
if (!async) return NT_STATUS_NO_MEMORY; \
async->parms = io; \
async->req = req; \
c_req->async.private = async; \
} \
c_req->async.fn = async_fn; \
- req->control_flags |= REQ_CONTROL_ASYNC; \
+ req->async_states->state |= NTVFS_ASYNC_STATE_ASYNC; \
return NT_STATUS_OK; \
} while (0)
delete a file - the dirtype specifies the file types to include in the search.
The name can contain CIFS wildcards, but rarely does (except with OS/2 clients)
*/
-static NTSTATUS cvfs_unlink(struct request_context *req, struct smb_unlink *unl)
+static NTSTATUS cvfs_unlink(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, struct smb_unlink *unl)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
- struct cli_request *c_req;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
+
+ SETUP_PID;
/* see if the front end will allow us to perform this
function asynchronously. */
- if (!req->async.send_fn) {
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
return smb_raw_unlink(private->tree, unl);
}
/*
a handler for async ioctl replies
*/
-static void async_ioctl(struct cli_request *c_req)
+static void async_ioctl(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
- struct request_context *req = async->req;
- req->async.status = smb_raw_ioctl_recv(c_req, req->mem_ctx, async->parms);
- req->async.send_fn(req);
+ struct smbsrv_request *req = async->req;
+ req->async_states->status = smb_raw_ioctl_recv(c_req, req, async->parms);
+ req->async_states->send_fn(req);
}
/*
ioctl interface
*/
-static NTSTATUS cvfs_ioctl(struct request_context *req, union smb_ioctl *io)
+static NTSTATUS cvfs_ioctl(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_ioctl *io)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
- struct cli_request *c_req;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
+
+ SETUP_PID;
/* see if the front end will allow us to perform this
function asynchronously. */
- if (!req->async.send_fn) {
- return smb_raw_ioctl(private->tree, req->mem_ctx, io);
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
+ return smb_raw_ioctl(private->tree, req, io);
}
c_req = smb_raw_ioctl_send(private->tree, io);
/*
check if a directory exists
*/
-static NTSTATUS cvfs_chkpath(struct request_context *req, struct smb_chkpath *cp)
+static NTSTATUS cvfs_chkpath(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, struct smb_chkpath *cp)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
- struct cli_request *c_req;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
+
+ SETUP_PID;
- if (!req->async.send_fn) {
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
return smb_raw_chkpath(private->tree, cp);
}
/*
a handler for async qpathinfo replies
*/
-static void async_qpathinfo(struct cli_request *c_req)
+static void async_qpathinfo(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
- struct request_context *req = async->req;
- req->async.status = smb_raw_pathinfo_recv(c_req, req->mem_ctx, async->parms);
- req->async.send_fn(req);
+ struct smbsrv_request *req = async->req;
+ req->async_states->status = smb_raw_pathinfo_recv(c_req, req, async->parms);
+ req->async_states->send_fn(req);
}
/*
return info on a pathname
*/
-static NTSTATUS cvfs_qpathinfo(struct request_context *req, union smb_fileinfo *info)
+static NTSTATUS cvfs_qpathinfo(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_fileinfo *info)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
- struct cli_request *c_req;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
- if (!req->async.send_fn) {
- return smb_raw_pathinfo(private->tree, req->mem_ctx, info);
+ SETUP_PID;
+
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
+ return smb_raw_pathinfo(private->tree, req, info);
}
c_req = smb_raw_pathinfo_send(private->tree, info);
/*
a handler for async qfileinfo replies
*/
-static void async_qfileinfo(struct cli_request *c_req)
+static void async_qfileinfo(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
- struct request_context *req = async->req;
- req->async.status = smb_raw_fileinfo_recv(c_req, req->mem_ctx, async->parms);
- req->async.send_fn(req);
+ struct smbsrv_request *req = async->req;
+ req->async_states->status = smb_raw_fileinfo_recv(c_req, req, async->parms);
+ req->async_states->send_fn(req);
}
/*
query info on a open file
*/
-static NTSTATUS cvfs_qfileinfo(struct request_context *req, union smb_fileinfo *info)
+static NTSTATUS cvfs_qfileinfo(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_fileinfo *info)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
- struct cli_request *c_req;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
+
+ SETUP_PID;
- if (!req->async.send_fn) {
- return smb_raw_fileinfo(private->tree, req->mem_ctx, info);
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
+ return smb_raw_fileinfo(private->tree, req, info);
}
c_req = smb_raw_fileinfo_send(private->tree, info);
/*
set info on a pathname
*/
-static NTSTATUS cvfs_setpathinfo(struct request_context *req, union smb_setfileinfo *st)
+static NTSTATUS cvfs_setpathinfo(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_setfileinfo *st)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
- struct cli_request *c_req;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
- if (!req->async.send_fn) {
+ SETUP_PID;
+
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
return smb_raw_setpathinfo(private->tree, st);
}
/*
a handler for async open replies
*/
-static void async_open(struct cli_request *c_req)
+static void async_open(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
- struct request_context *req = async->req;
- req->async.status = smb_raw_open_recv(c_req, req->mem_ctx, async->parms);
- req->async.send_fn(req);
+ struct smbsrv_request *req = async->req;
+ req->async_states->status = smb_raw_open_recv(c_req, req, async->parms);
+ req->async_states->send_fn(req);
}
/*
open a file
*/
-static NTSTATUS cvfs_open(struct request_context *req, union smb_open *io)
+static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_open *io)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
- struct cli_request *c_req;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
+
+ SETUP_PID;
- if (private->map_calls && in_list("open", private->map_calls, True) &&
- io->generic.level != RAW_OPEN_GENERIC) {
- return ntvfs_map_open(req, io);
+ if (io->generic.level != RAW_OPEN_GENERIC &&
+ private->map_generic) {
+ return ntvfs_map_open(req, io, ntvfs);
}
- if (!req->async.send_fn) {
- return smb_raw_open(private->tree, req->mem_ctx, io);
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
+ return smb_raw_open(private->tree, req, io);
}
c_req = smb_raw_open_send(private->tree, io);
/*
create a directory
*/
-static NTSTATUS cvfs_mkdir(struct request_context *req, union smb_mkdir *md)
+static NTSTATUS cvfs_mkdir(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_mkdir *md)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
- struct cli_request *c_req;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
+
+ SETUP_PID;
- if (!req->async.send_fn) {
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
return smb_raw_mkdir(private->tree, md);
}
/*
remove a directory
*/
-static NTSTATUS cvfs_rmdir(struct request_context *req, struct smb_rmdir *rd)
+static NTSTATUS cvfs_rmdir(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, struct smb_rmdir *rd)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
- struct cli_request *c_req;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
- if (!req->async.send_fn) {
+ SETUP_PID;
+
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
return smb_raw_rmdir(private->tree, rd);
}
c_req = smb_raw_rmdir_send(private->tree, rd);
/*
rename a set of files
*/
-static NTSTATUS cvfs_rename(struct request_context *req, union smb_rename *ren)
+static NTSTATUS cvfs_rename(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_rename *ren)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
- struct cli_request *c_req;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
+
+ SETUP_PID;
- if (!req->async.send_fn) {
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
return smb_raw_rename(private->tree, ren);
}
/*
copy a set of files
*/
-static NTSTATUS cvfs_copy(struct request_context *req, struct smb_copy *cp)
+static NTSTATUS cvfs_copy(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, struct smb_copy *cp)
{
return NT_STATUS_NOT_SUPPORTED;
}
/*
a handler for async read replies
*/
-static void async_read(struct cli_request *c_req)
+static void async_read(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
- struct request_context *req = async->req;
- req->async.status = smb_raw_read_recv(c_req, async->parms);
- req->async.send_fn(req);
+ struct smbsrv_request *req = async->req;
+ req->async_states->status = smb_raw_read_recv(c_req, async->parms);
+ req->async_states->send_fn(req);
}
/*
read from a file
*/
-static NTSTATUS cvfs_read(struct request_context *req, union smb_read *rd)
+static NTSTATUS cvfs_read(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_read *rd)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
- struct cli_request *c_req;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
- if (!req->async.send_fn) {
+ SETUP_PID;
+
+ if (rd->generic.level != RAW_READ_GENERIC &&
+ private->map_generic) {
+ return ntvfs_map_read(req, rd, ntvfs);
+ }
+
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
return smb_raw_read(private->tree, rd);
}
/*
a handler for async write replies
*/
-static void async_write(struct cli_request *c_req)
+static void async_write(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
- struct request_context *req = async->req;
- req->async.status = smb_raw_write_recv(c_req, async->parms);
- req->async.send_fn(req);
+ struct smbsrv_request *req = async->req;
+ req->async_states->status = smb_raw_write_recv(c_req, async->parms);
+ req->async_states->send_fn(req);
}
/*
write to a file
*/
-static NTSTATUS cvfs_write(struct request_context *req, union smb_write *wr)
+static NTSTATUS cvfs_write(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_write *wr)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
- struct cli_request *c_req;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
+
+ SETUP_PID;
+
+ if (wr->generic.level != RAW_WRITE_GENERIC &&
+ private->map_generic) {
+ return ntvfs_map_write(req, wr, ntvfs);
+ }
- if (!req->async.send_fn) {
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
return smb_raw_write(private->tree, wr);
}
/*
seek in a file
*/
-static NTSTATUS cvfs_seek(struct request_context *req, struct smb_seek *io)
+static NTSTATUS cvfs_seek(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, struct smb_seek *io)
{
- return NT_STATUS_NOT_SUPPORTED;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
+
+ SETUP_PID;
+
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
+ return smb_raw_seek(private->tree, io);
+ }
+
+ c_req = smb_raw_seek_send(private->tree, io);
+
+ SIMPLE_ASYNC_TAIL;
}
/*
flush a file
*/
-static NTSTATUS cvfs_flush(struct request_context *req, struct smb_flush *io)
+static NTSTATUS cvfs_flush(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, struct smb_flush *io)
{
- return NT_STATUS_OK;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
+
+ SETUP_PID;
+
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
+ return smb_raw_flush(private->tree, io);
+ }
+
+ c_req = smb_raw_flush_send(private->tree, io);
+
+ SIMPLE_ASYNC_TAIL;
}
/*
close a file
*/
-static NTSTATUS cvfs_close(struct request_context *req, union smb_close *io)
+static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_close *io)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
- struct cli_request *c_req;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
+
+ SETUP_PID;
- if (!req->async.send_fn) {
+ if (io->generic.level != RAW_CLOSE_GENERIC &&
+ private->map_generic) {
+ return ntvfs_map_close(req, io, ntvfs);
+ }
+
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
return smb_raw_close(private->tree, io);
}
}
/*
- exit - closing files?
+ exit - closing files open by the pid
*/
-static NTSTATUS cvfs_exit(struct request_context *req)
+static NTSTATUS cvfs_exit(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req)
{
- return NT_STATUS_NOT_SUPPORTED;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
+
+ SETUP_PID;
+
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
+ return smb_raw_exit(private->tree->session);
+ }
+
+ c_req = smb_raw_exit_send(private->tree->session);
+
+ SIMPLE_ASYNC_TAIL;
+}
+
+/*
+ logoff - closing files open by the user
+*/
+static NTSTATUS cvfs_logoff(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req)
+{
+ /* we can't do this right in the cifs backend .... */
+ return NT_STATUS_OK;
+}
+
+/*
+ setup for an async call - nothing to do yet
+*/
+static NTSTATUS cvfs_async_setup(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req,
+ void *private)
+{
+ return NT_STATUS_OK;
+}
+
+/*
+ cancel an async call
+*/
+static NTSTATUS cvfs_cancel(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
}
/*
lock a byte range
*/
-static NTSTATUS cvfs_lock(struct request_context *req, union smb_lock *lck)
+static NTSTATUS cvfs_lock(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_lock *lck)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
- struct cli_request *c_req;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
+
+ SETUP_PID;
- if (!req->async.send_fn) {
+ if (lck->generic.level != RAW_LOCK_GENERIC &&
+ private->map_generic) {
+ return ntvfs_map_lock(req, lck, ntvfs);
+ }
+
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
return smb_raw_lock(private->tree, lck);
}
/*
set info on a open file
*/
-static NTSTATUS cvfs_setfileinfo(struct request_context *req,
+static NTSTATUS cvfs_setfileinfo(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req,
union smb_setfileinfo *info)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
- struct cli_request *c_req;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
+
+ SETUP_PID;
- if (!req->async.send_fn) {
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
return smb_raw_setfileinfo(private->tree, info);
}
c_req = smb_raw_setfileinfo_send(private->tree, info);
/*
a handler for async fsinfo replies
*/
-static void async_fsinfo(struct cli_request *c_req)
+static void async_fsinfo(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
- struct request_context *req = async->req;
- req->async.status = smb_raw_fsinfo_recv(c_req, req->mem_ctx, async->parms);
- req->async.send_fn(req);
+ struct smbsrv_request *req = async->req;
+ req->async_states->status = smb_raw_fsinfo_recv(c_req, req, async->parms);
+ req->async_states->send_fn(req);
}
/*
return filesystem space info
*/
-static NTSTATUS cvfs_fsinfo(struct request_context *req, union smb_fsinfo *fs)
+static NTSTATUS cvfs_fsinfo(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_fsinfo *fs)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
- struct cli_request *c_req;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
- if (!req->async.send_fn) {
- return smb_raw_fsinfo(private->tree, req->mem_ctx, fs);
+ SETUP_PID;
+
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
+ return smb_raw_fsinfo(private->tree, req, fs);
}
- c_req = smb_raw_fsinfo_send(private->tree, req->mem_ctx, fs);
+ c_req = smb_raw_fsinfo_send(private->tree, req, fs);
ASYNC_RECV_TAIL(fs, async_fsinfo);
}
/*
return print queue info
*/
-static NTSTATUS cvfs_lpq(struct request_context *req, union smb_lpq *lpq)
+static NTSTATUS cvfs_lpq(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_lpq *lpq)
{
return NT_STATUS_NOT_SUPPORTED;
}
/*
list files in a directory matching a wildcard pattern
*/
-static NTSTATUS cvfs_search_first(struct request_context *req, union smb_search_first *io,
+static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_search_first *io,
void *search_private,
BOOL (*callback)(void *, union smb_search_data *))
{
- struct cvfs_private *private = req->conn->ntvfs_private;
+ struct cvfs_private *private = ntvfs->private_data;
+
+ SETUP_PID;
- return smb_raw_search_first(private->tree, req->mem_ctx, io, search_private, callback);
+ return smb_raw_search_first(private->tree, req, io, search_private, callback);
}
/* continue a search */
-static NTSTATUS cvfs_search_next(struct request_context *req, union smb_search_next *io,
+static NTSTATUS cvfs_search_next(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_search_next *io,
void *search_private,
BOOL (*callback)(void *, union smb_search_data *))
{
- struct cvfs_private *private = req->conn->ntvfs_private;
+ struct cvfs_private *private = ntvfs->private_data;
- return smb_raw_search_next(private->tree, req->mem_ctx, io, search_private, callback);
+ SETUP_PID;
+
+ return smb_raw_search_next(private->tree, req, io, search_private, callback);
}
/* close a search */
-static NTSTATUS cvfs_search_close(struct request_context *req, union smb_search_close *io)
+static NTSTATUS cvfs_search_close(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_search_close *io)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
+ struct cvfs_private *private = ntvfs->private_data;
+
+ SETUP_PID;
return smb_raw_search_close(private->tree, io);
}
/*
a handler for async trans2 replies
*/
-static void async_trans2(struct cli_request *c_req)
+static void async_trans2(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
- struct request_context *req = async->req;
- req->async.status = smb_raw_trans2_recv(c_req, req->mem_ctx, async->parms);
- req->async.send_fn(req);
+ struct smbsrv_request *req = async->req;
+ req->async_states->status = smb_raw_trans2_recv(c_req, req, async->parms);
+ req->async_states->send_fn(req);
}
/* raw trans2 */
-static NTSTATUS cvfs_trans2(struct request_context *req, struct smb_trans2 *trans2)
+static NTSTATUS cvfs_trans2(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, struct smb_trans2 *trans2)
{
- struct cvfs_private *private = req->conn->ntvfs_private;
- struct cli_request *c_req;
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smbcli_request *c_req;
- if (!req->async.send_fn) {
- return smb_raw_trans2(private->tree, req->mem_ctx, trans2);
+ SETUP_PID;
+
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
+ return smb_raw_trans2(private->tree, req, trans2);
}
c_req = smb_raw_trans2_send(private->tree, trans2);
/* SMBtrans - not used on file shares */
-static NTSTATUS cvfs_trans(struct request_context *req, struct smb_trans2 *trans2)
+static NTSTATUS cvfs_trans(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, struct smb_trans2 *trans2)
{
return NT_STATUS_ACCESS_DENIED;
}
ops.chkpath = cvfs_chkpath;
ops.qpathinfo = cvfs_qpathinfo;
ops.setpathinfo = cvfs_setpathinfo;
- ops.open = cvfs_open;
+ ops.openfile = cvfs_open;
ops.mkdir = cvfs_mkdir;
ops.rmdir = cvfs_rmdir;
ops.rename = cvfs_rename;
ops.search_next = cvfs_search_next;
ops.search_close = cvfs_search_close;
ops.trans = cvfs_trans;
+ ops.logoff = cvfs_logoff;
+ ops.async_setup = cvfs_async_setup;
+ ops.cancel = cvfs_cancel;
- /* only define this one for trans2 testing */
- ops.trans2 = NULL;
+ if (lp_parm_bool(-1, "cifs", "maptrans2", False)) {
+ ops.trans2 = cvfs_trans2;
+ }
/* register ourselves with the NTVFS subsystem. We register
under the name 'cifs'. */
- ret = register_backend("ntvfs", &ops);
+ ret = ntvfs_register(&ops);
if (!NT_STATUS_IS_OK(ret)) {
DEBUG(0,("Failed to register CIFS backend!\n"));