r14456: don't access the smbsrv_tcon inside the ntvfs modules
authorStefan Metzmacher <metze@samba.org>
Wed, 15 Mar 2006 17:28:46 +0000 (17:28 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:57:26 +0000 (13:57 -0500)
metze
(This used to be commit 5709c1c4e1a561dd9af98cfefbbbdac9b18765b7)

19 files changed:
source4/ntvfs/cifs/vfs_cifs.c
source4/ntvfs/ipc/vfs_ipc.c
source4/ntvfs/ntvfs.h
source4/ntvfs/ntvfs_base.c
source4/ntvfs/ntvfs_interface.c
source4/ntvfs/posix/pvfs_dirlist.c
source4/ntvfs/posix/pvfs_fsinfo.c
source4/ntvfs/posix/pvfs_search.c
source4/ntvfs/posix/pvfs_wait.c
source4/ntvfs/posix/vfs_posix.c
source4/ntvfs/posix/vfs_posix.h
source4/ntvfs/print/vfs_print.c
source4/ntvfs/simple/vfs_simple.c
source4/smb_server/management.c
source4/smb_server/smb/receive.c
source4/smb_server/smb/service.c
source4/smb_server/smb2/tcon.c
source4/smb_server/smb_server.h
source4/smb_server/tcon.c

index 9f3af5701659b330edb4b4bad25f28349e465259..806585f8e9d4f9061f877fa13200003f69d1a319 100644 (file)
@@ -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;
index ad5c9594d522f7d3eca87dd9e526a02fe6e2449a..7a572268d417fc23a1f57d1c74d5e849f6238dde 100644 (file)
@@ -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);
index 0e15ee154229602482dca1336e20f0f62721cfd1..2f43f5df208109d397d89ba9df4eb7897f166593 100644 (file)
@@ -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;
 };
 
 
index 7351d6b2a669a6a60f1bf75a829d90e4fb8237fc..5abf449b8c779450eadf106870eec7d8e6617cbe 100644 (file)
@@ -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;
 }
 
index 68166e51329e8e0c83beefd7a2bd5b56521de554..0888991877271cc9c3aba5f4cad892aaf30e7f0e 100644 (file)
@@ -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);
+}
index 9838072080c892c51bb3009492e1333a2ad2c43c..a61fc458b3a19248edc83392344b839e8597da89 100644 (file)
@@ -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) {
index 6b8f0504f2289c6c0e7c4569319fecdc100ca832..553681a3d4cfe352ec8692bbf5ea80bbc07965d4 100644 (file)
@@ -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:
index 6aa9163f1e176be13ccdafe900c77dcaac20fbc7..c74bac5a3d6132e2664763936d934b20f34ab655 100644 (file)
@@ -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), 
index 241382ba0bcde9568b6a50d6c081d8f5323420cf..9b2f4786333c01649787ca78b10ceb68607621ca 100644 (file)
@@ -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;
index ba53dc65e0b31851115fa1bed942219c95409515..31588fdf782ceb02576849c7b6d20d4f2a81f7e5 100644 (file)
@@ -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;
        }
index a22b55198ced9d4b541975ad7a507dcf5102d7ea..84828fb3ceeb47a0c616fa16d4babdd620c4383d 100644 (file)
@@ -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;
 
index eb17ef9c63bc4294638c0b76a454f8d5f1cab470..bd1615d603e3f36d0d64ee135be931e4d04a0333 100644 (file)
 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;
        }
 
index fe43776dcc129208f6f90e05b9b5de17b23ea17e..2f5a8af8f5cac510eded2759a4f69bb616879ac1 100644 (file)
@@ -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;
 }
index bb153d3c5e414c1f6a48373e43e8a94a62e00d62..b55a9f7d574cea11986111c30f5fcbd83f66df79 100644 (file)
@@ -100,7 +100,7 @@ static NTSTATUS smbsrv_tcon_information(struct irpc_message *msg,
                }
 
                info->tid          = tcon->tid;
-               info->share_name   = lp_servicename(tcon->service);
+               info->share_name   = tcon->share_name;
                info->connect_time = timeval_to_nttime(&tcon->statistics.connect_time);
                i++;
        }
index 8430871c1920047e7087a34ab5e985a3be3d8568..4eed107d9749fcaf23c5b7198770b84b90197651 100644 (file)
 /*
   send an oplock break request to a client
 */
-BOOL req_send_oplock_break(struct smbsrv_tcon *tcon, uint16_t fnum, uint8_t level)
+NTSTATUS smbsrv_send_oplock_break(void *p, uint16_t fnum, uint8_t level)
 {
+       struct smbsrv_tcon *tcon = talloc_get_type(p, struct smbsrv_tcon);
        struct smbsrv_request *req;
 
        req = smbsrv_init_request(tcon->smb_conn);
-       if (!req) {
-               return False;
-       }
+       NT_STATUS_HAVE_NO_MEMORY(req);
 
        smbsrv_setup_reply(req, 8, 0);
-       
+
        SCVAL(req->out.hdr,HDR_COM,SMBlockingX);
        SSVAL(req->out.hdr,HDR_TID,tcon->tid);
        SSVAL(req->out.hdr,HDR_PID,0xFFFF);
@@ -59,7 +58,7 @@ BOOL req_send_oplock_break(struct smbsrv_tcon *tcon, uint16_t fnum, uint8_t leve
        SSVAL(req->out.vwv, VWV(7), 0);
 
        smbsrv_send_reply(req);
-       return True;
+       return NT_STATUS_OK;
 }
 
 static void switch_message(int type, struct smbsrv_request *req);
index 49c2384e98c090a7f0596d520bc502aa3f518d33..c805d081df009dc02aa646e48c0db5315920dd50 100644 (file)
@@ -67,35 +67,45 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req,
                return NT_STATUS_ACCESS_DENIED;
        }
 
-       tcon = smbsrv_smb_tcon_new(req->smb_conn);
+       tcon = smbsrv_smb_tcon_new(req->smb_conn, lp_servicename(snum));
        if (!tcon) {
                DEBUG(0,("Couldn't find free connection.\n"));
                return NT_STATUS_INSUFFICIENT_RESOURCES;
        }
        req->tcon = tcon;
 
-       tcon->service = snum;
-
        /* init ntvfs function pointers */
-       status = ntvfs_init_connection(req, type);
+       status = ntvfs_init_connection(tcon, snum, type,
+                                      req->smb_conn->negotiate.protocol,
+                                      req->smb_conn->connection->event.ctx,
+                                      req->smb_conn->connection->msg_ctx,
+                                      req->smb_conn->connection->server_id,
+                                      &tcon->ntvfs);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("ntvfs_init_connection failed for service %s\n", 
-                         lp_servicename(tcon->service)));
-               req->tcon = NULL;
-               talloc_free(tcon);
-               return status;
+                         lp_servicename(snum)));
+               goto failed;
+       }
+
+       status = ntvfs_set_oplock_handler(tcon->ntvfs, smbsrv_send_oplock_break, tcon);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0,("make_connection: NTVFS failed to set the oplock handler!\n"));
+               goto failed;
        }
 
        /* Invoke NTVFS connection hook */
        status = ntvfs_connect(req, lp_servicename(snum));
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("make_connection: NTVFS make connection failed!\n"));
-               req->tcon = NULL;
-               talloc_free(tcon);
-               return status;
+               goto failed;
        }
 
        return NT_STATUS_OK;
+
+failed:
+       req->tcon = NULL;
+       talloc_free(tcon);
+       return status;
 }
 
 /****************************************************************************
@@ -155,6 +165,7 @@ static NTSTATUS make_connection(struct smbsrv_request *req,
 NTSTATUS smbsrv_tcon_backend(struct smbsrv_request *req, union smb_tcon *con)
 {
        NTSTATUS status;
+       int snum;
 
        /* can only do bare tcon in share level security */
        if (!req->session && lp_security() != SEC_SHARE) {
@@ -183,11 +194,13 @@ NTSTATUS smbsrv_tcon_backend(struct smbsrv_request *req, union smb_tcon *con)
                return status;
        }
 
+       snum = req->tcon->ntvfs->config.snum;
+
        con->tconx.out.tid = req->tcon->tid;
-       con->tconx.out.dev_type = talloc_strdup(req, req->tcon->dev_type);
-       con->tconx.out.fs_type = talloc_strdup(req, req->tcon->fs_type);
-       con->tconx.out.options = SMB_SUPPORT_SEARCH_BITS | (lp_csc_policy(req->tcon->service) << 2);
-       if (lp_msdfs_root(req->tcon->service) && lp_host_msdfs()) {
+       con->tconx.out.dev_type = talloc_strdup(req, req->tcon->ntvfs->dev_type);
+       con->tconx.out.fs_type = talloc_strdup(req, req->tcon->ntvfs->fs_type);
+       con->tconx.out.options = SMB_SUPPORT_SEARCH_BITS | (lp_csc_policy(snum) << 2);
+       if (lp_msdfs_root(snum) && lp_host_msdfs()) {
                con->tconx.out.options |= SMB_SHARE_IN_DFS;
        }
 
index 9fb2a03ce33363f1da25956c58dda6ce246c2197..836c13a019f43e8a3e99468777ff79877557c307 100644 (file)
@@ -28,7 +28,7 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, struct smb2_tr
 {
        struct smbsrv_tcon *tcon;
 
-       tcon = smbsrv_smb2_tcon_new(req->session);
+       tcon = smbsrv_smb2_tcon_new(req->session, "fake");
        NT_STATUS_HAVE_NO_MEMORY(tcon);
 
        /* TODO: do real tree connect */
index ab24381026fb08399965e2f2e4100dbd23f574ed..2b06eb9d5b4f865580e12ced716f79029541d77c 100644 (file)
@@ -103,16 +103,11 @@ struct smbsrv_tcon {
         */
        uint32_t tid; /* an index passed over the wire (the TID) */
 
-       int service;
+       /* the share name */
+       const char *share_name;
 
        /* the NTVFS context - see source/ntvfs/ for details */
-       struct ntvfs_context *ntvfs_ctx;
-
-       /* the reported filesystem type */
-       char *fs_type;
-
-       /* the reported device type */
-       char *dev_type;
+       struct ntvfs_context *ntvfs;
 
        /* some stuff to support share level security */
        struct {
index 90fe20a4c8be7d74b9066f461640988a82bfbe67..95e42d6537c9db366794c8d66d21666eb6f156f7 100644 (file)
@@ -93,16 +93,16 @@ static int smbsrv_tcon_destructor(void *ptr)
 {
        struct smbsrv_tcon *tcon = talloc_get_type(ptr, struct smbsrv_tcon);
        struct smbsrv_tcons_context *tcons_ctx;
-
        struct socket_address *client_addr;
+
        client_addr = socket_get_peer_addr(tcon->smb_conn->connection->socket, ptr);
        DEBUG(3,("%s closed connection to service %s\n",
                 client_addr ? client_addr->addr : "(unknown)",
-                lp_servicename(tcon->service)));
+                tcon->share_name));
 
        /* tell the ntvfs backend that we are disconnecting */
-       if (tcon->ntvfs_ctx) {
-               ntvfs_disconnect(tcon->ntvfs_ctx);
+       if (tcon->ntvfs) {
+               ntvfs_disconnect(tcon->ntvfs);
        }
 
        if (tcon->smb2.session) {
@@ -119,7 +119,9 @@ static int smbsrv_tcon_destructor(void *ptr)
 /*
   find first available connection slot
 */
-static struct smbsrv_tcon *smbsrv_tcon_new(struct smbsrv_connection *smb_conn, struct smbsrv_session *smb_sess)
+static struct smbsrv_tcon *smbsrv_tcon_new(struct smbsrv_connection *smb_conn,
+                                          struct smbsrv_session *smb_sess,
+                                          const char *share_name)
 {
        TALLOC_CTX *mem_ctx;
        struct smbsrv_tcons_context *tcons_ctx;
@@ -138,11 +140,13 @@ static struct smbsrv_tcon *smbsrv_tcon_new(struct smbsrv_connection *smb_conn, s
        if (!tcon) return NULL;
        tcon->smb_conn          = smb_conn;
        tcon->smb2.session      = smb_sess;
+       tcon->share_name        = talloc_strdup(tcon, share_name);
+       if (!tcon->share_name) goto failed;
 
        i = idr_get_new_random(tcons_ctx->idtree_tid, tcon, tcons_ctx->idtree_limit);
        if (i == -1) {
                DEBUG(1,("ERROR! Out of connection structures\n"));
-               return NULL;
+               goto failed;
        }
        tcon->tid = i;
 
@@ -153,14 +157,18 @@ static struct smbsrv_tcon *smbsrv_tcon_new(struct smbsrv_connection *smb_conn, s
        tcon->statistics.connect_time = timeval_current();
 
        return tcon;
+
+failed:
+       talloc_free(tcon);
+       return NULL;
 }
 
-struct smbsrv_tcon *smbsrv_smb_tcon_new(struct smbsrv_connection *smb_conn)
+struct smbsrv_tcon *smbsrv_smb_tcon_new(struct smbsrv_connection *smb_conn, const char *share_name)
 {
-       return smbsrv_tcon_new(smb_conn, NULL);
+       return smbsrv_tcon_new(smb_conn, NULL, share_name);
 }
 
-struct smbsrv_tcon *smbsrv_smb2_tcon_new(struct smbsrv_session *smb_sess)
+struct smbsrv_tcon *smbsrv_smb2_tcon_new(struct smbsrv_session *smb_sess, const char *share_name)
 {
-       return smbsrv_tcon_new(smb_sess->smb_conn, smb_sess);
+       return smbsrv_tcon_new(smb_sess->smb_conn, smb_sess, share_name);
 }