summaryrefslogtreecommitdiff
path: root/source4/ntvfs/ntvfs_util.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-05-20 08:15:22 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:08:10 -0500
commit9ef33f5f5c786b83311ca088357fb2f0aa72fc9e (patch)
tree66335dced1641119f94e6c656dd1ccc673218d0c /source4/ntvfs/ntvfs_util.c
parent0dcecc314899b6f36e9215e0b3881220062ba4f9 (diff)
downloadsamba-9ef33f5f5c786b83311ca088357fb2f0aa72fc9e.tar.gz
samba-9ef33f5f5c786b83311ca088357fb2f0aa72fc9e.tar.bz2
samba-9ef33f5f5c786b83311ca088357fb2f0aa72fc9e.zip
r15734: This is a major change to the NTVFS subsystem:
- to use a struct ntvfs_handle instead of a uint16_t fnum. (to make it independend from the frontend protocol) - the allocation of handles now is provided by the frontend (smbsrv_*) via callbacks and not by each backend module - this also makes sure that file handles are only passed to the ntvfs subsystem when the tcon and session matches, so modules can rely on this and need to check this. - this allows multiple modules in the ntvfs module chain to allocate file handles. This can be used for virtual files like "\\$Extend\\$Quota:$Q:$INDEX_ALLOCATION"... - also this will make SMB2 with 128 bit file handles possible metze (This used to be commit 287fc1c22d670f6e568014b420f7f4cb31dc7958)
Diffstat (limited to 'source4/ntvfs/ntvfs_util.c')
-rw-r--r--source4/ntvfs/ntvfs_util.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/source4/ntvfs/ntvfs_util.c b/source4/ntvfs/ntvfs_util.c
index 52f03430ce..de19a9c352 100644
--- a/source4/ntvfs/ntvfs_util.c
+++ b/source4/ntvfs/ntvfs_util.c
@@ -98,3 +98,100 @@ _PUBLIC_ void ntvfs_async_state_pop(struct ntvfs_request *req)
talloc_free(async);
}
+
+_PUBLIC_ NTSTATUS ntvfs_handle_new(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req,
+ struct ntvfs_handle **h)
+{
+ return ntvfs->ctx->handles.create_new(ntvfs->ctx->handles.private_data, req, h);
+}
+
+_PUBLIC_ NTSTATUS ntvfs_handle_set_backend_data(struct ntvfs_handle *h,
+ struct ntvfs_module_context *ntvfs,
+ TALLOC_CTX *private_data)
+{
+ struct ntvfs_handle_data *d;
+ BOOL first_time = h->backend_data?False:True;
+
+ for (d=h->backend_data; d; d = d->next) {
+ if (d->owner != ntvfs) continue;
+ d->private_data = talloc_steal(d, private_data);
+ return NT_STATUS_OK;
+ }
+
+ d = talloc(h, struct ntvfs_handle_data);
+ NT_STATUS_HAVE_NO_MEMORY(d);
+ d->owner = ntvfs;
+ d->private_data = talloc_steal(d, private_data);
+
+ DLIST_ADD(h->backend_data, d);
+
+ if (first_time) {
+ NTSTATUS status;
+ status = h->ctx->handles.make_valid(h->ctx->handles.private_data, h);
+ NT_STATUS_NOT_OK_RETURN(status);
+ }
+
+ return NT_STATUS_OK;
+}
+
+_PUBLIC_ void *ntvfs_handle_get_backend_data(struct ntvfs_handle *h,
+ struct ntvfs_module_context *ntvfs)
+{
+ struct ntvfs_handle_data *d;
+
+ for (d=h->backend_data; d; d = d->next) {
+ if (d->owner != ntvfs) continue;
+ return d->private_data;
+ }
+
+ return NULL;
+}
+
+_PUBLIC_ void ntvfs_handle_remove_backend_data(struct ntvfs_handle *h,
+ struct ntvfs_module_context *ntvfs)
+{
+ struct ntvfs_handle_data *d,*n;
+
+ for (d=h->backend_data; d; d = n) {
+ n = d->next;
+ if (d->owner != ntvfs) continue;
+ DLIST_REMOVE(h->backend_data, d);
+ talloc_free(d);
+ d = NULL;
+ }
+
+ if (h->backend_data) return;
+
+ /* if there's no backend_data anymore, destroy the handle */
+ h->ctx->handles.destroy(h->ctx->handles.private_data, h);
+}
+
+_PUBLIC_ struct ntvfs_handle *ntvfs_handle_search_by_wire_key(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req,
+ const DATA_BLOB *key)
+{
+ return ntvfs->ctx->handles.search_by_wire_key(ntvfs->ctx->handles.private_data, req, key);
+}
+
+_PUBLIC_ DATA_BLOB ntvfs_handle_get_wire_key(struct ntvfs_handle *h, TALLOC_CTX *mem_ctx)
+{
+ return h->ctx->handles.get_wire_key(h->ctx->handles.private_data, h, mem_ctx);
+}
+
+_PUBLIC_ NTSTATUS ntvfs_set_handle_callbacks(struct ntvfs_context *ntvfs,
+ NTSTATUS (*create_new)(void *private_data, struct ntvfs_request *req, struct ntvfs_handle **h),
+ NTSTATUS (*make_valid)(void *private_data, struct ntvfs_handle *h),
+ void (*destroy)(void *private_data, struct ntvfs_handle *h),
+ struct ntvfs_handle *(*search_by_wire_key)(void *private_data, struct ntvfs_request *req, const DATA_BLOB *key),
+ DATA_BLOB (*get_wire_key)(void *private_data, struct ntvfs_handle *handle, TALLOC_CTX *mem_ctx),
+ void *private_data)
+{
+ ntvfs->handles.create_new = create_new;
+ ntvfs->handles.make_valid = make_valid;
+ ntvfs->handles.destroy = destroy;
+ ntvfs->handles.search_by_wire_key = search_by_wire_key;
+ ntvfs->handles.get_wire_key = get_wire_key;
+ ntvfs->handles.private_data = private_data;
+ return NT_STATUS_OK;
+}