From dcad0f6fd492506efd9a69b4e32c7bbfa5da90e5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 29 Sep 2004 13:17:09 +0000 Subject: r2751: this is a new ntvfs design which tries to solve: - the stacking of modules - finding the modules private data - hide the ntvfs details from the calling layer - I set NTVFS_INTERFACE_VERSION 0 till we are closer to release (because we need to solve some async problems with the module stacking) metze (This used to be commit 3ff03b5cb21bb79afdd3b1609be9635f6688a539) --- source4/ntvfs/ntvfs_base.c | 54 +++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 17 deletions(-) (limited to 'source4/ntvfs/ntvfs_base.c') diff --git a/source4/ntvfs/ntvfs_base.c b/source4/ntvfs/ntvfs_base.c index 72f4759cd5..acbd02d915 100644 --- a/source4/ntvfs/ntvfs_base.c +++ b/source4/ntvfs/ntvfs_base.c @@ -100,8 +100,9 @@ const struct ntvfs_critical_sizes *ntvfs_interface_version(void) { static const struct ntvfs_critical_sizes critical_sizes = { NTVFS_INTERFACE_VERSION, + sizeof(struct ntvfs_context), + sizeof(struct ntvfs_module_context), sizeof(struct ntvfs_ops), - sizeof(SMB_OFF_T), sizeof(struct smbsrv_tcon), sizeof(struct smbsrv_request), }; @@ -133,28 +134,47 @@ BOOL ntvfs_init(void) /* initialise a connection structure to point at a NTVFS backend */ -NTSTATUS ntvfs_init_connection(struct smbsrv_request *req) +NTSTATUS ntvfs_init_connection(struct smbsrv_request *req, enum ntvfs_type type) { const char **handlers = lp_ntvfs_handler(req->tcon->service); + int i; + struct ntvfs_context *ctx; - req->tcon->ntvfs_ops = ntvfs_backend_byname(handlers[0], req->tcon->type); + if (!handlers) { + return NT_STATUS_FOOBAR; + } - if (!req->tcon->ntvfs_ops) { - DEBUG(1,("ntvfs_init_connection: failed to find backend=%s, type=%d\n", handlers[0], req->tcon->type)); - return NT_STATUS_UNSUCCESSFUL; + ctx = talloc_p(req->tcon, struct ntvfs_context); + if (!ctx) { + return NT_STATUS_NO_MEMORY; } + ctx->type = type; + ctx->modules = NULL; - return NT_STATUS_OK; -} + for (i=0; handlers[i]; i++) { + struct ntvfs_module_context *ntvfs; + ntvfs = talloc_p(ctx, struct ntvfs_module_context); + if (!ntvfs) { + return NT_STATUS_NO_MEMORY; + } -/* - set the private pointer for a backend -*/ -void ntvfs_set_private(struct smbsrv_tcon *tcon, int depth, void *value) -{ - tcon->ntvfs_private_list = talloc_realloc_p(tcon, - tcon->ntvfs_private_list, - void *, depth+1); - tcon->ntvfs_private_list[depth] = value; + 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", + handlers[i], ctx->type)); + return NT_STATUS_UNSUCCESSFUL; + } + ntvfs->depth = i; + DLIST_ADD_END(ctx->modules, ntvfs, struct ntvfs_module_context *); + } + + if (!ctx->modules) { + talloc_free(ctx); + return NT_STATUS_FOOBAR; + } + + req->tcon->ntvfs_ctx = ctx; + + return NT_STATUS_OK; } -- cgit