From 2e7df84576d26bc37eb87b7e3c79fcb3fb358d68 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 15 Mar 2006 17:28:46 +0000 Subject: r14456: don't access the smbsrv_tcon inside the ntvfs modules metze (This used to be commit 5709c1c4e1a561dd9af98cfefbbbdac9b18765b7) --- source4/ntvfs/cifs/vfs_cifs.c | 37 +++++++++-------- source4/ntvfs/ipc/vfs_ipc.c | 9 ++--- source4/ntvfs/ntvfs.h | 27 ++++++++++++- source4/ntvfs/ntvfs_base.c | 26 ++++++------ source4/ntvfs/ntvfs_interface.c | 81 +++++++++++++++++++++++--------------- source4/ntvfs/posix/pvfs_dirlist.c | 2 +- source4/ntvfs/posix/pvfs_fsinfo.c | 2 +- source4/ntvfs/posix/pvfs_search.c | 2 +- source4/ntvfs/posix/pvfs_wait.c | 4 +- source4/ntvfs/posix/vfs_posix.c | 27 ++++++------- source4/ntvfs/posix/vfs_posix.h | 2 +- source4/ntvfs/print/vfs_print.c | 14 +++---- source4/ntvfs/simple/vfs_simple.c | 28 +++++++------ 13 files changed, 158 insertions(+), 103 deletions(-) (limited to 'source4/ntvfs') diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c index 9f3af57016..806585f8e9 100644 --- a/source4/ntvfs/cifs/vfs_cifs.c +++ b/source4/ntvfs/cifs/vfs_cifs.c @@ -38,7 +38,7 @@ struct cvfs_private { struct smbcli_tree *tree; struct smbcli_transport *transport; - struct smbsrv_tcon *tcon; + struct ntvfs_module_context *ntvfs; struct async_info *pending; BOOL map_generic; }; @@ -62,9 +62,12 @@ struct async_info { 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; - + NTSTATUS status; + DEBUG(5,("vfs_cifs: sending oplock break level %d for fnum %d\n", level, fnum)); - return req_send_oplock_break(private->tcon, fnum, level); + status = ntvfs_send_oplock_break(private->ntvfs, fnum, level); + if (!NT_STATUS_IS_OK(status)) return False; + return True; } /* @@ -73,12 +76,12 @@ static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uin static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { - struct smbsrv_tcon *tcon = req->tcon; NTSTATUS status; struct cvfs_private *private; const char *host, *user, *pass, *domain, *remote_share; struct smb_composite_connect io; struct composite_context *creq; + int snum = ntvfs->ctx->config.snum; struct cli_credentials *credentials; BOOL machine_account; @@ -87,16 +90,16 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, * For now we use parametric options, type cifs. * Later we will use security=server and auth_server.c. */ - 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"); + host = lp_parm_string(snum, "cifs", "server"); + user = lp_parm_string(snum, "cifs", "user"); + pass = lp_parm_string(snum, "cifs", "password"); + domain = lp_parm_string(snum, "cifs", "domain"); + remote_share = lp_parm_string(snum, "cifs", "share"); if (!remote_share) { remote_share = sharename; } - machine_account = lp_parm_bool(req->tcon->service, "cifs", "use_machine_account", False); + machine_account = lp_parm_bool(snum, "cifs", "use_machine_account", False); private = talloc_zero(ntvfs, struct cvfs_private); if (!private) { @@ -151,7 +154,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, io.in.service = remote_share; io.in.service_type = "?????"; - creq = smb_composite_connect_send(&io, private, tcon->smb_conn->connection->event.ctx); + creq = smb_composite_connect_send(&io, private, ntvfs->ctx->event_ctx); status = smb_composite_connect_recv(creq, private); NT_STATUS_NOT_OK_RETURN(status); @@ -159,15 +162,17 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, private->transport = private->tree->session->transport; SETUP_PID; - private->tcon = req->tcon; + private->ntvfs = ntvfs; + + ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); + ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); - tcon->fs_type = talloc_strdup(tcon, "NTFS"); - tcon->dev_type = talloc_strdup(tcon, "A:"); - /* we need to receive oplock break requests from the server */ smbcli_oplock_handler(private->transport, oplock_handler, private); - private->map_generic = lp_parm_bool(req->tcon->service, + private->map_generic = lp_parm_bool(ntvfs->ctx->config.snum, "cifs", "mapgeneric", False); return NT_STATUS_OK; diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index ad5c9594d5..7a572268d4 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -79,14 +79,13 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { NTSTATUS status; - struct smbsrv_tcon *tcon = req->tcon; struct ipc_private *private; - tcon->fs_type = talloc_strdup(tcon, "IPC"); - NT_STATUS_HAVE_NO_MEMORY(tcon->fs_type); + ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "IPC"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); - tcon->dev_type = talloc_strdup(tcon, "IPC"); - NT_STATUS_HAVE_NO_MEMORY(tcon->dev_type); + ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "IPC"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); /* prepare the private state for this connection */ private = talloc(ntvfs, struct ipc_private); diff --git a/source4/ntvfs/ntvfs.h b/source4/ntvfs/ntvfs.h index 0e15ee1542..2f43f5df20 100644 --- a/source4/ntvfs/ntvfs.h +++ b/source4/ntvfs/ntvfs.h @@ -158,17 +158,40 @@ struct ntvfs_ops { struct ntvfs_module_context { struct ntvfs_module_context *prev, *next; - void *private_data; - const struct ntvfs_ops *ops; + struct ntvfs_context *ctx; int depth; + const struct ntvfs_ops *ops; + void *private_data; }; struct ntvfs_context { enum ntvfs_type type; + + /* the reported filesystem type */ + char *fs_type; + + /* the reported device type */ + char *dev_type; + + enum protocol_types protocol; + /* * linked list of module contexts */ struct ntvfs_module_context *modules; + + struct { + int snum; + } config; + + uint32_t server_id; + struct event_context *event_ctx; + struct messaging_context *msg_ctx; + + struct { + void *private_data; + NTSTATUS (*handler)(void *private_data, uint16_t fnum, uint8_t level); + } oplock; }; diff --git a/source4/ntvfs/ntvfs_base.c b/source4/ntvfs/ntvfs_base.c index 7351d6b2a6..5abf449b8c 100644 --- a/source4/ntvfs/ntvfs_base.c +++ b/source4/ntvfs/ntvfs_base.c @@ -118,9 +118,12 @@ _PUBLIC_ const struct ntvfs_critical_sizes *ntvfs_interface_version(void) /* initialise a connection structure to point at a NTVFS backend */ -NTSTATUS ntvfs_init_connection(struct ntvfs_request *req, enum ntvfs_type type) +NTSTATUS ntvfs_init_connection(TALLOC_CTX *mem_ctx, int snum, enum ntvfs_type type, + enum protocol_types protocol, + struct event_context *ev, struct messaging_context *msg, + uint32_t server_id, struct ntvfs_context **_ctx) { - const char **handlers = lp_ntvfs_handler(req->tcon->service); + const char **handlers = lp_ntvfs_handler(snum); int i; struct ntvfs_context *ctx; @@ -128,19 +131,21 @@ NTSTATUS ntvfs_init_connection(struct ntvfs_request *req, enum ntvfs_type type) return NT_STATUS_INTERNAL_ERROR; } - ctx = talloc(req->tcon, struct ntvfs_context); + ctx = talloc_zero(mem_ctx, struct ntvfs_context); NT_STATUS_HAVE_NO_MEMORY(ctx); - ctx->type = type; - ctx->modules = NULL; + ctx->protocol = protocol; + ctx->type = type; + ctx->config.snum = snum; + ctx->event_ctx = ev; + ctx->msg_ctx = msg; + ctx->server_id = server_id; for (i=0; handlers[i]; i++) { struct ntvfs_module_context *ntvfs; - ntvfs = talloc(ctx, struct ntvfs_module_context); + ntvfs = talloc_zero(ctx, struct ntvfs_module_context); NT_STATUS_HAVE_NO_MEMORY(ntvfs); - - ntvfs->private_data = NULL; - + ntvfs->ctx = ctx; ntvfs->ops = ntvfs_backend_byname(handlers[i], ctx->type); if (!ntvfs->ops) { DEBUG(1,("ntvfs_init_connection: failed to find backend=%s, type=%d\n", @@ -155,8 +160,7 @@ NTSTATUS ntvfs_init_connection(struct ntvfs_request *req, enum ntvfs_type type) return NT_STATUS_INTERNAL_ERROR; } - req->tcon->ntvfs_ctx = ctx; - + *_ctx = ctx; return NT_STATUS_OK; } diff --git a/source4/ntvfs/ntvfs_interface.c b/source4/ntvfs/ntvfs_interface.c index 68166e5132..0888991877 100644 --- a/source4/ntvfs/ntvfs_interface.c +++ b/source4/ntvfs/ntvfs_interface.c @@ -26,7 +26,7 @@ /* connect/disconnect */ _PUBLIC_ NTSTATUS ntvfs_connect(struct ntvfs_request *req, const char *sharename) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->connect) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -50,7 +50,7 @@ _PUBLIC_ NTSTATUS ntvfs_disconnect(struct ntvfs_context *ntvfs_ctx) a async request */ _PUBLIC_ NTSTATUS ntvfs_async_setup(struct ntvfs_request *req, void *private) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->async_setup) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -60,7 +60,7 @@ _PUBLIC_ NTSTATUS ntvfs_async_setup(struct ntvfs_request *req, void *private) /* filesystem operations */ _PUBLIC_ NTSTATUS ntvfs_fsinfo(struct ntvfs_request *req, union smb_fsinfo *fs) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->fsinfo) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -70,7 +70,7 @@ _PUBLIC_ NTSTATUS ntvfs_fsinfo(struct ntvfs_request *req, union smb_fsinfo *fs) /* path operations */ _PUBLIC_ NTSTATUS ntvfs_unlink(struct ntvfs_request *req, union smb_unlink *unl) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->unlink) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -79,7 +79,7 @@ _PUBLIC_ NTSTATUS ntvfs_unlink(struct ntvfs_request *req, union smb_unlink *unl) _PUBLIC_ NTSTATUS ntvfs_chkpath(struct ntvfs_request *req, union smb_chkpath *cp) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->chkpath) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -88,7 +88,7 @@ _PUBLIC_ NTSTATUS ntvfs_chkpath(struct ntvfs_request *req, union smb_chkpath *cp _PUBLIC_ NTSTATUS ntvfs_qpathinfo(struct ntvfs_request *req, union smb_fileinfo *st) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->qpathinfo) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -97,7 +97,7 @@ _PUBLIC_ NTSTATUS ntvfs_qpathinfo(struct ntvfs_request *req, union smb_fileinfo _PUBLIC_ NTSTATUS ntvfs_setpathinfo(struct ntvfs_request *req, union smb_setfileinfo *st) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->setpathinfo) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -106,7 +106,7 @@ _PUBLIC_ NTSTATUS ntvfs_setpathinfo(struct ntvfs_request *req, union smb_setfile _PUBLIC_ NTSTATUS ntvfs_open(struct ntvfs_request *req, union smb_open *oi) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->open) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -115,7 +115,7 @@ _PUBLIC_ NTSTATUS ntvfs_open(struct ntvfs_request *req, union smb_open *oi) _PUBLIC_ NTSTATUS ntvfs_mkdir(struct ntvfs_request *req, union smb_mkdir *md) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->mkdir) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -124,7 +124,7 @@ _PUBLIC_ NTSTATUS ntvfs_mkdir(struct ntvfs_request *req, union smb_mkdir *md) _PUBLIC_ NTSTATUS ntvfs_rmdir(struct ntvfs_request *req, struct smb_rmdir *rd) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->rmdir) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -133,7 +133,7 @@ _PUBLIC_ NTSTATUS ntvfs_rmdir(struct ntvfs_request *req, struct smb_rmdir *rd) _PUBLIC_ NTSTATUS ntvfs_rename(struct ntvfs_request *req, union smb_rename *ren) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->rename) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -142,7 +142,7 @@ _PUBLIC_ NTSTATUS ntvfs_rename(struct ntvfs_request *req, union smb_rename *ren) _PUBLIC_ NTSTATUS ntvfs_copy(struct ntvfs_request *req, struct smb_copy *cp) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->copy) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -153,7 +153,7 @@ _PUBLIC_ NTSTATUS ntvfs_copy(struct ntvfs_request *req, struct smb_copy *cp) _PUBLIC_ NTSTATUS ntvfs_search_first(struct ntvfs_request *req, union smb_search_first *io, void *private, BOOL ntvfs_callback(void *private, union smb_search_data *file)) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->search_first) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -163,7 +163,7 @@ _PUBLIC_ NTSTATUS ntvfs_search_first(struct ntvfs_request *req, union smb_search _PUBLIC_ NTSTATUS ntvfs_search_next(struct ntvfs_request *req, union smb_search_next *io, void *private, BOOL ntvfs_callback(void *private, union smb_search_data *file)) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->search_next) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -172,7 +172,7 @@ _PUBLIC_ NTSTATUS ntvfs_search_next(struct ntvfs_request *req, union smb_search_ _PUBLIC_ NTSTATUS ntvfs_search_close(struct ntvfs_request *req, union smb_search_close *io) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->search_close) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -182,7 +182,7 @@ _PUBLIC_ NTSTATUS ntvfs_search_close(struct ntvfs_request *req, union smb_search /* operations on open files */ _PUBLIC_ NTSTATUS ntvfs_ioctl(struct ntvfs_request *req, union smb_ioctl *io) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->ioctl) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -191,7 +191,7 @@ _PUBLIC_ NTSTATUS ntvfs_ioctl(struct ntvfs_request *req, union smb_ioctl *io) _PUBLIC_ NTSTATUS ntvfs_read(struct ntvfs_request *req, union smb_read *io) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->read) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -200,7 +200,7 @@ _PUBLIC_ NTSTATUS ntvfs_read(struct ntvfs_request *req, union smb_read *io) _PUBLIC_ NTSTATUS ntvfs_write(struct ntvfs_request *req, union smb_write *io) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->write) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -209,7 +209,7 @@ _PUBLIC_ NTSTATUS ntvfs_write(struct ntvfs_request *req, union smb_write *io) _PUBLIC_ NTSTATUS ntvfs_seek(struct ntvfs_request *req, union smb_seek *io) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->seek) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -219,7 +219,7 @@ _PUBLIC_ NTSTATUS ntvfs_seek(struct ntvfs_request *req, union smb_seek *io) _PUBLIC_ NTSTATUS ntvfs_flush(struct ntvfs_request *req, union smb_flush *flush) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->flush) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -228,7 +228,7 @@ _PUBLIC_ NTSTATUS ntvfs_flush(struct ntvfs_request *req, _PUBLIC_ NTSTATUS ntvfs_lock(struct ntvfs_request *req, union smb_lock *lck) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->lock) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -237,7 +237,7 @@ _PUBLIC_ NTSTATUS ntvfs_lock(struct ntvfs_request *req, union smb_lock *lck) _PUBLIC_ NTSTATUS ntvfs_qfileinfo(struct ntvfs_request *req, union smb_fileinfo *info) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->qfileinfo) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -246,7 +246,7 @@ _PUBLIC_ NTSTATUS ntvfs_qfileinfo(struct ntvfs_request *req, union smb_fileinfo _PUBLIC_ NTSTATUS ntvfs_setfileinfo(struct ntvfs_request *req, union smb_setfileinfo *info) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->setfileinfo) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -255,7 +255,7 @@ _PUBLIC_ NTSTATUS ntvfs_setfileinfo(struct ntvfs_request *req, union smb_setfile _PUBLIC_ NTSTATUS ntvfs_close(struct ntvfs_request *req, union smb_close *io) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->close) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -265,7 +265,7 @@ _PUBLIC_ NTSTATUS ntvfs_close(struct ntvfs_request *req, union smb_close *io) /* trans interface - used by IPC backend for pipes and RAP calls */ _PUBLIC_ NTSTATUS ntvfs_trans(struct ntvfs_request *req, struct smb_trans2 *trans) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->trans) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -275,7 +275,7 @@ _PUBLIC_ NTSTATUS ntvfs_trans(struct ntvfs_request *req, struct smb_trans2 *tran /* trans2 interface - only used by CIFS backend to prover complete passthru for testing */ _PUBLIC_ NTSTATUS ntvfs_trans2(struct ntvfs_request *req, struct smb_trans2 *trans2) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->trans2) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -285,7 +285,7 @@ _PUBLIC_ NTSTATUS ntvfs_trans2(struct ntvfs_request *req, struct smb_trans2 *tra /* printing specific operations */ _PUBLIC_ NTSTATUS ntvfs_lpq(struct ntvfs_request *req, union smb_lpq *lpq) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->lpq) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -295,7 +295,7 @@ _PUBLIC_ NTSTATUS ntvfs_lpq(struct ntvfs_request *req, union smb_lpq *lpq) /* logoff - called when a vuid is closed */ _PUBLIC_ NTSTATUS ntvfs_logoff(struct ntvfs_request *req) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->logoff) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -304,7 +304,7 @@ _PUBLIC_ NTSTATUS ntvfs_logoff(struct ntvfs_request *req) _PUBLIC_ NTSTATUS ntvfs_exit(struct ntvfs_request *req) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->exit) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -316,7 +316,7 @@ _PUBLIC_ NTSTATUS ntvfs_exit(struct ntvfs_request *req) */ _PUBLIC_ NTSTATUS ntvfs_notify(struct ntvfs_request *req, union smb_notify *info) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->notify) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -328,7 +328,7 @@ _PUBLIC_ NTSTATUS ntvfs_notify(struct ntvfs_request *req, union smb_notify *info */ _PUBLIC_ NTSTATUS ntvfs_cancel(struct ntvfs_request *req) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->cancel) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -666,3 +666,22 @@ _PUBLIC_ NTSTATUS ntvfs_next_exit(struct ntvfs_module_context *ntvfs, } return ntvfs->next->ops->exit(ntvfs->next, req); } + +_PUBLIC_ NTSTATUS ntvfs_set_oplock_handler(struct ntvfs_context *ntvfs, + NTSTATUS (*handler)(void *private_data, uint16_t fnum, uint8_t level), + void *private_data) +{ + ntvfs->oplock.handler = handler; + ntvfs->oplock.private_data = private_data; + return NT_STATUS_OK; +} + +_PUBLIC_ NTSTATUS ntvfs_send_oplock_break(struct ntvfs_module_context *ntvfs, + uint16_t fnum, uint8_t level) +{ + if (!ntvfs->ctx->oplock.handler) { + return NT_STATUS_OK; + } + + return ntvfs->ctx->oplock.handler(ntvfs->ctx->oplock.private_data, fnum, level); +} diff --git a/source4/ntvfs/posix/pvfs_dirlist.c b/source4/ntvfs/posix/pvfs_dirlist.c index 9838072080..a61fc458b3 100644 --- a/source4/ntvfs/posix/pvfs_dirlist.c +++ b/source4/ntvfs/posix/pvfs_dirlist.c @@ -177,7 +177,7 @@ static void dcache_add(struct pvfs_dir *dir, const char *name) const char *pvfs_list_next(struct pvfs_dir *dir, uint_t *ofs) { struct dirent *de; - enum protocol_types protocol = dir->pvfs->tcon->smb_conn->negotiate.protocol; + enum protocol_types protocol = dir->pvfs->ntvfs->ctx->protocol; /* non-wildcard searches are easy */ if (dir->no_wildcard) { diff --git a/source4/ntvfs/posix/pvfs_fsinfo.c b/source4/ntvfs/posix/pvfs_fsinfo.c index 6b8f0504f2..553681a3d4 100644 --- a/source4/ntvfs/posix/pvfs_fsinfo.c +++ b/source4/ntvfs/posix/pvfs_fsinfo.c @@ -169,7 +169,7 @@ NTSTATUS pvfs_fsinfo(struct ntvfs_module_context *ntvfs, case RAW_QFS_ATTRIBUTE_INFORMATION: fs->attribute_info.out.fs_attr = pvfs->fs_attribs; fs->attribute_info.out.max_file_component_length = 255; - fs->attribute_info.out.fs_type.s = req->tcon->fs_type; + fs->attribute_info.out.fs_type.s = ntvfs->ctx->fs_type; return NT_STATUS_OK; case RAW_QFS_QUOTA_INFORMATION: diff --git a/source4/ntvfs/posix/pvfs_search.c b/source4/ntvfs/posix/pvfs_search.c index 6aa9163f1e..c74bac5a3d 100644 --- a/source4/ntvfs/posix/pvfs_search.c +++ b/source4/ntvfs/posix/pvfs_search.c @@ -72,7 +72,7 @@ static void pvfs_search_timer(struct event_context *ev, struct timed_event *te, */ static void pvfs_search_setup_timer(struct pvfs_search_state *search) { - struct event_context *ev = search->pvfs->tcon->smb_conn->connection->event.ctx; + struct event_context *ev = search->pvfs->ntvfs->ctx->event_ctx; talloc_free(search->te); search->te = event_add_timed(ev, search, timeval_current_ofs(search->pvfs->search_inactivity_time, 0), diff --git a/source4/ntvfs/posix/pvfs_wait.c b/source4/ntvfs/posix/pvfs_wait.c index 241382ba0b..9b2f478633 100644 --- a/source4/ntvfs/posix/pvfs_wait.c +++ b/source4/ntvfs/posix/pvfs_wait.c @@ -134,8 +134,8 @@ void *pvfs_wait_message(struct pvfs_state *pvfs, pwait->private = private; pwait->handler = fn; - pwait->msg_ctx = pvfs->tcon->smb_conn->connection->msg_ctx; - pwait->ev = req->tcon->smb_conn->connection->event.ctx; + pwait->msg_ctx = pvfs->ntvfs->ctx->msg_ctx; + pwait->ev = pvfs->ntvfs->ctx->event_ctx; pwait->msg_type = msg_type; pwait->req = talloc_reference(pwait, req); pwait->pvfs = pvfs; diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c index ba53dc65e0..31588fdf78 100644 --- a/source4/ntvfs/posix/vfs_posix.c +++ b/source4/ntvfs/posix/vfs_posix.c @@ -38,7 +38,7 @@ */ static void pvfs_setup_options(struct pvfs_state *pvfs) { - int snum = pvfs->tcon->service; + int snum = pvfs->ntvfs->ctx->config.snum; const char *eadb; if (lp_map_hidden(snum)) pvfs->flags |= PVFS_FLAG_MAP_HIDDEN; @@ -114,23 +114,22 @@ static void pvfs_setup_options(struct pvfs_state *pvfs) static NTSTATUS pvfs_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { - struct smbsrv_tcon *tcon = req->tcon; struct pvfs_state *pvfs; struct stat st; char *base_directory; NTSTATUS status; - pvfs = talloc_zero(tcon, struct pvfs_state); + pvfs = talloc_zero(ntvfs, struct pvfs_state); NT_STATUS_HAVE_NO_MEMORY(pvfs); /* for simplicity of path construction, remove any trailing slash now */ - base_directory = talloc_strdup(pvfs, lp_pathname(tcon->service)); + base_directory = talloc_strdup(pvfs, lp_pathname(ntvfs->ctx->config.snum)); NT_STATUS_HAVE_NO_MEMORY(base_directory); if (strcmp(base_directory, "/") != 0) { trim_string(base_directory, NULL, "/"); } - pvfs->tcon = tcon; + pvfs->ntvfs = ntvfs; pvfs->base_directory = base_directory; /* the directory must exist. Note that we deliberately don't @@ -141,25 +140,25 @@ static NTSTATUS pvfs_connect(struct ntvfs_module_context *ntvfs, return NT_STATUS_BAD_NETWORK_NAME; } - tcon->fs_type = talloc_strdup(tcon, "NTFS"); - NT_STATUS_HAVE_NO_MEMORY(tcon->fs_type); + ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); - tcon->dev_type = talloc_strdup(tcon, "A:"); - NT_STATUS_HAVE_NO_MEMORY(tcon->dev_type); + ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); ntvfs->private_data = pvfs; pvfs->brl_context = brl_init(pvfs, - pvfs->tcon->smb_conn->connection->server_id, - pvfs->tcon->service, - pvfs->tcon->smb_conn->connection->msg_ctx); + pvfs->ntvfs->ctx->server_id, + pvfs->ntvfs->ctx->config.snum, + pvfs->ntvfs->ctx->msg_ctx); if (pvfs->brl_context == NULL) { return NT_STATUS_INTERNAL_DB_CORRUPTION; } pvfs->odb_context = odb_init(pvfs, - pvfs->tcon->smb_conn->connection->server_id, - pvfs->tcon->smb_conn->connection->msg_ctx); + pvfs->ntvfs->ctx->server_id, + pvfs->ntvfs->ctx->msg_ctx); if (pvfs->odb_context == NULL) { return NT_STATUS_INTERNAL_DB_CORRUPTION; } diff --git a/source4/ntvfs/posix/vfs_posix.h b/source4/ntvfs/posix/vfs_posix.h index a22b55198c..84828fb3ce 100644 --- a/source4/ntvfs/posix/vfs_posix.h +++ b/source4/ntvfs/posix/vfs_posix.h @@ -31,7 +31,7 @@ /* this is the private structure for the posix vfs backend. It is used to hold per-connection (per tree connect) state information */ struct pvfs_state { - struct smbsrv_tcon *tcon; + struct ntvfs_module_context *ntvfs; const char *base_directory; struct GUID *base_fs_uuid; diff --git a/source4/ntvfs/print/vfs_print.c b/source4/ntvfs/print/vfs_print.c index eb17ef9c63..bd1615d603 100644 --- a/source4/ntvfs/print/vfs_print.c +++ b/source4/ntvfs/print/vfs_print.c @@ -35,13 +35,11 @@ static NTSTATUS print_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { - struct smbsrv_tcon *tcon = req->tcon; + ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); - tcon->fs_type = talloc_strdup(tcon, "NTFS"); - NT_STATUS_HAVE_NO_MEMORY(tcon->fs_type); - - tcon->dev_type = talloc_strdup(tcon, "LPT1:"); - NT_STATUS_HAVE_NO_MEMORY(tcon->dev_type); + ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "LPT1:"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); return NT_STATUS_OK; } @@ -78,6 +76,8 @@ static NTSTATUS print_ioctl(struct ntvfs_module_context *ntvfs, } if (io->ioctl.in.request == IOCTL_QUERY_JOB_INFO) { + int snum = ntvfs->ctx->config.snum; + /* a request for the print job id of an open print job */ io->ioctl.out.blob = data_blob_talloc(req, NULL, 32); @@ -86,7 +86,7 @@ static NTSTATUS print_ioctl(struct ntvfs_module_context *ntvfs, p = (char *)io->ioctl.out.blob.data; SSVAL(p,0, 1 /* REWRITE: fsp->rap_print_jobid */); push_string(p+2, lp_netbios_name(), 15, STR_TERMINATE|STR_ASCII); - push_string(p+18, lp_servicename(req->tcon->service), 13, STR_TERMINATE|STR_ASCII); + push_string(p+18, lp_servicename(snum), 13, STR_TERMINATE|STR_ASCII); return NT_STATUS_OK; } diff --git a/source4/ntvfs/simple/vfs_simple.c b/source4/ntvfs/simple/vfs_simple.c index fe43776dcc..2f5a8af8f5 100644 --- a/source4/ntvfs/simple/vfs_simple.c +++ b/source4/ntvfs/simple/vfs_simple.c @@ -40,7 +40,7 @@ #define O_DIRECTORY 0 #endif -#define CHECK_READ_ONLY(req) do { if (lp_readonly(req->tcon->service)) return NT_STATUS_ACCESS_DENIED; } while (0) +#define CHECK_READ_ONLY(req) do { if (lp_readonly(ntvfs->ctx->config.snum)) return NT_STATUS_ACCESS_DENIED; } while (0) /* connect to a share - used when a tree_connect operation comes @@ -52,13 +52,13 @@ static NTSTATUS svfs_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { struct stat st; - struct smbsrv_tcon *tcon = req->tcon; struct svfs_private *private; + int snum = ntvfs->ctx->config.snum; private = talloc(ntvfs, struct svfs_private); private->next_search_handle = 0; - private->connectpath = talloc_strdup(private, lp_pathname(tcon->service)); + private->connectpath = talloc_strdup(private, lp_pathname(snum)); private->open_files = NULL; private->search = NULL; @@ -69,8 +69,10 @@ static NTSTATUS svfs_connect(struct ntvfs_module_context *ntvfs, return NT_STATUS_BAD_NETWORK_NAME; } - tcon->fs_type = talloc_strdup(tcon, "NTFS"); - tcon->dev_type = talloc_strdup(tcon, "A:"); + ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); + ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); ntvfs->private_data = private; @@ -306,12 +308,14 @@ static NTSTATUS svfs_open(struct ntvfs_module_context *ntvfs, int fd, flags; struct svfs_file *f; int create_flags, rdwr_flags; + BOOL readonly; if (io->generic.level != RAW_OPEN_GENERIC) { return ntvfs_map_open(ntvfs, req, io); } - if (lp_readonly(req->tcon->service)) { + readonly = lp_readonly(ntvfs->ctx->config.snum); + if (readonly) { create_flags = 0; rdwr_flags = O_RDONLY; } else { @@ -345,7 +349,7 @@ static NTSTATUS svfs_open(struct ntvfs_module_context *ntvfs, if (io->generic.in.create_options & NTCREATEX_OPTIONS_DIRECTORY) { flags = O_RDONLY | O_DIRECTORY; - if (lp_readonly(req->tcon->service)) { + if (readonly) { goto do_open; } switch (io->generic.in.open_disposition) { @@ -376,9 +380,11 @@ do_open: return map_nt_error_from_unix(errno); } - f = talloc(req->tcon, struct svfs_file); + f = talloc(ntvfs, struct svfs_file); + NT_STATUS_HAVE_NO_MEMORY(f); f->fd = fd; - f->name = talloc_strdup(req->tcon, unix_path); + f->name = talloc_strdup(f, unix_path); + NT_STATUS_HAVE_NO_MEMORY(f->name); DLIST_ADD(private->open_files, f); @@ -719,8 +725,8 @@ static NTSTATUS svfs_fsinfo(struct ntvfs_module_context *ntvfs, fs->generic.out.quota_soft = 0; fs->generic.out.quota_hard = 0; fs->generic.out.quota_flags = 0; - fs->generic.out.volume_name = talloc_strdup(req, lp_servicename(req->tcon->service)); - fs->generic.out.fs_type = req->tcon->fs_type; + fs->generic.out.volume_name = talloc_strdup(req, lp_servicename(ntvfs->ctx->config.snum)); + fs->generic.out.fs_type = ntvfs->ctx->fs_type; return NT_STATUS_OK; } -- cgit