diff options
author | bubulle <bubulle@alioth.debian.org> | 2011-11-12 13:00:54 +0000 |
---|---|---|
committer | bubulle <bubulle@alioth.debian.org> | 2011-11-12 13:00:54 +0000 |
commit | 6fba685eec3a1165ec0b82d72d3ae71e946a1404 (patch) | |
tree | f3c0543c8f9df4a22ed62e3bd99d9d7bc1054c14 /source4/ntvfs/common | |
parent | 77a7925c0509068d5cd2affd94a3996d0a86035a (diff) | |
download | samba-6fba685eec3a1165ec0b82d72d3ae71e946a1404.tar.gz |
Merge upstream 3.6.1 source
git-svn-id: svn://svn.debian.org/svn/pkg-samba/trunk/samba@3972 fc4039ab-9d04-0410-8cac-899223bdd6b0
Diffstat (limited to 'source4/ntvfs/common')
-rw-r--r-- | source4/ntvfs/common/brlock.c | 12 | ||||
-rw-r--r-- | source4/ntvfs/common/brlock.h | 3 | ||||
-rw-r--r-- | source4/ntvfs/common/brlock_tdb.c | 52 | ||||
-rw-r--r-- | source4/ntvfs/common/config.mk | 11 | ||||
-rw-r--r-- | source4/ntvfs/common/notify.c | 22 | ||||
-rw-r--r-- | source4/ntvfs/common/opendb_tdb.c | 8 | ||||
-rw-r--r-- | source4/ntvfs/common/wscript_build | 8 |
7 files changed, 84 insertions, 32 deletions
diff --git a/source4/ntvfs/common/brlock.c b/source4/ntvfs/common/brlock.c index a5bc5c1db4..94041d2014 100644 --- a/source4/ntvfs/common/brlock.c +++ b/source4/ntvfs/common/brlock.c @@ -26,7 +26,7 @@ #include "includes.h" #include "system/filesys.h" -#include "../tdb/include/tdb.h" +#include <tdb.h> #include "messaging/messaging.h" #include "lib/messaging/irpc.h" #include "libcli/libcli.h" @@ -125,3 +125,13 @@ NTSTATUS brl_close(struct brl_context *brl, { return ops->brl_close(brl, brlh); } + +/* + Get a number of locks associated with a open file. +*/ +NTSTATUS brl_count(struct brl_context *brl, + struct brl_handle *brlh, + int *count) +{ + return ops->brl_count(brl, brlh, count); +} diff --git a/source4/ntvfs/common/brlock.h b/source4/ntvfs/common/brlock.h index 75f142b6f6..e5e618d045 100644 --- a/source4/ntvfs/common/brlock.h +++ b/source4/ntvfs/common/brlock.h @@ -46,6 +46,9 @@ struct brlock_ops { enum brl_type ); NTSTATUS (*brl_close)(struct brl_context *, struct brl_handle *); + NTSTATUS (*brl_count)(struct brl_context *, + struct brl_handle *, + int *count); }; diff --git a/source4/ntvfs/common/brlock_tdb.c b/source4/ntvfs/common/brlock_tdb.c index 299400b96c..b61137cc20 100644 --- a/source4/ntvfs/common/brlock_tdb.c +++ b/source4/ntvfs/common/brlock_tdb.c @@ -26,9 +26,9 @@ #include "includes.h" #include "system/filesys.h" -#include "../tdb/include/tdb.h" +#include <tdb.h> #include "messaging/messaging.h" -#include "tdb_wrap.h" +#include "lib/util/tdb_wrap.h" #include "lib/messaging/irpc.h" #include "libcli/libcli.h" #include "cluster/cluster.h" @@ -80,6 +80,13 @@ struct brl_handle { struct lock_struct last_lock; }; +/* see if we have wrapped locks, which are no longer allowed (windows + * changed this in win7 */ +static bool brl_invalid_lock_range(uint64_t start, uint64_t size) +{ + return (size > 1 && (start + size < start)); +} + /* Open up the brlock.tdb database. Close it down using talloc_free(). We need the messaging_ctx to allow for @@ -299,6 +306,10 @@ static NTSTATUS brl_tdb_lock(struct brl_context *brl, kbuf.dptr = brlh->key.data; kbuf.dsize = brlh->key.length; + if (brl_invalid_lock_range(start, size)) { + return NT_STATUS_INVALID_LOCK_RANGE; + } + if (tdb_chainlock(brl->w->tdb, kbuf) != 0) { return NT_STATUS_INTERNAL_DB_CORRUPTION; } @@ -449,6 +460,10 @@ static NTSTATUS brl_tdb_unlock(struct brl_context *brl, kbuf.dptr = brlh->key.data; kbuf.dsize = brlh->key.length; + if (brl_invalid_lock_range(start, size)) { + return NT_STATUS_INVALID_LOCK_RANGE; + } + if (tdb_chainlock(brl->w->tdb, kbuf) != 0) { return NT_STATUS_INTERNAL_DB_CORRUPTION; } @@ -620,6 +635,10 @@ static NTSTATUS brl_tdb_locktest(struct brl_context *brl, kbuf.dptr = brlh->key.data; kbuf.dsize = brlh->key.length; + if (brl_invalid_lock_range(start, size)) { + return NT_STATUS_INVALID_LOCK_RANGE; + } + dbuf = tdb_fetch(brl->w->tdb, kbuf); if (dbuf.dptr == NULL) { return NT_STATUS_OK; @@ -719,6 +738,32 @@ static NTSTATUS brl_tdb_close(struct brl_context *brl, return status; } +static NTSTATUS brl_tdb_count(struct brl_context *brl, struct brl_handle *brlh, + int *count) +{ + TDB_DATA kbuf, dbuf; + + kbuf.dptr = brlh->key.data; + kbuf.dsize = brlh->key.length; + *count = 0; + + if (tdb_chainlock(brl->w->tdb, kbuf) != 0) { + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } + + dbuf = tdb_fetch(brl->w->tdb, kbuf); + if (!dbuf.dptr) { + tdb_chainunlock(brl->w->tdb, kbuf); + return NT_STATUS_OK; + } + + *count = dbuf.dsize / sizeof(struct lock_struct); + + free(dbuf.dptr); + tdb_chainunlock(brl->w->tdb, kbuf); + + return NT_STATUS_OK; +} static const struct brlock_ops brlock_tdb_ops = { .brl_init = brl_tdb_init, @@ -727,7 +772,8 @@ static const struct brlock_ops brlock_tdb_ops = { .brl_unlock = brl_tdb_unlock, .brl_remove_pending = brl_tdb_remove_pending, .brl_locktest = brl_tdb_locktest, - .brl_close = brl_tdb_close + .brl_close = brl_tdb_close, + .brl_count = brl_tdb_count }; diff --git a/source4/ntvfs/common/config.mk b/source4/ntvfs/common/config.mk deleted file mode 100644 index a6957ace2f..0000000000 --- a/source4/ntvfs/common/config.mk +++ /dev/null @@ -1,11 +0,0 @@ -################################################ -# Start LIBRARY ntvfs_common -[SUBSYSTEM::ntvfs_common] -PUBLIC_DEPENDENCIES = NDR_OPENDB NDR_NOTIFY sys_notify sys_lease share -# End LIBRARY ntvfs_common -################################################ - -ntvfs_common_OBJ_FILES = $(addprefix $(ntvfssrcdir)/common/, init.o brlock.o brlock_tdb.o opendb.o opendb_tdb.o notify.o) - -$(eval $(call proto_header_template,$(ntvfssrcdir)/common/proto.h,$(ntvfs_common_OBJ_FILES:.o=.c))) - diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 135458a00f..36c7b8769d 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -25,17 +25,18 @@ #include "includes.h" #include "system/filesys.h" -#include "../tdb/include/tdb.h" +#include <tdb.h> #include "../lib/util/util_tdb.h" #include "messaging/messaging.h" -#include "tdb_wrap.h" +#include "lib/util/tdb_wrap.h" #include "lib/messaging/irpc.h" -#include "librpc/gen_ndr/ndr_notify.h" +#include "librpc/gen_ndr/ndr_s4_notify.h" #include "../lib/util/dlinklist.h" #include "ntvfs/common/ntvfs_common.h" #include "ntvfs/sysdep/sys_notify.h" #include "cluster/cluster.h" #include "param/param.h" +#include "lib/util/tsort.h" struct notify_context { struct tdb_wrap *w; @@ -45,7 +46,6 @@ struct notify_context { struct notify_array *array; int seqnum; struct sys_notify_context *sys_notify_ctx; - struct smb_iconv_convenience *iconv_convenience; }; @@ -112,7 +112,6 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server, notify->messaging_ctx = messaging_ctx; notify->list = NULL; notify->array = NULL; - notify->iconv_convenience = lp_iconv_convenience(lp_ctx); notify->seqnum = tdb_get_seqnum(notify->w->tdb); talloc_set_destructor(notify, notify_destructor); @@ -177,8 +176,7 @@ static NTSTATUS notify_load(struct notify_context *notify) blob.data = dbuf.dptr; blob.length = dbuf.dsize; - ndr_err = ndr_pull_struct_blob(&blob, notify->array, notify->iconv_convenience, - notify->array, + ndr_err = ndr_pull_struct_blob(&blob, notify->array, notify->array, (ndr_pull_flags_fn_t)ndr_pull_notify_array); free(dbuf.dptr); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -226,7 +224,7 @@ static NTSTATUS notify_save(struct notify_context *notify) tmp_ctx = talloc_new(notify); NT_STATUS_HAVE_NO_MEMORY(tmp_ctx); - ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, notify->iconv_convenience, notify->array, + ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, notify->array, (ndr_push_flags_fn_t)ndr_push_notify_array); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); @@ -262,7 +260,7 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private_data return; } - ndr_err = ndr_pull_struct_blob(data, tmp_ctx, notify->iconv_convenience, &ev, + ndr_err = ndr_pull_struct_blob(data, tmp_ctx, &ev, (ndr_pull_flags_fn_t)ndr_pull_notify_event); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); @@ -328,9 +326,7 @@ static NTSTATUS notify_add_array(struct notify_context *notify, struct notify_en d->max_mask |= e->filter; d->max_mask_subdir |= e->subdir_filter; - if (d->num_entries > 1) { - qsort(d->entries, d->num_entries, sizeof(d->entries[0]), notify_compare); - } + TYPESAFE_QSORT(d->entries, d->num_entries, notify_compare); /* recalculate the maximum masks */ d->max_mask = 0; @@ -561,7 +557,7 @@ static void notify_send(struct notify_context *notify, struct notify_entry *e, tmp_ctx = talloc_new(notify); - ndr_err = ndr_push_struct_blob(&data, tmp_ctx, notify->iconv_convenience, &ev, (ndr_push_flags_fn_t)ndr_push_notify_event); + ndr_err = ndr_push_struct_blob(&data, tmp_ctx, &ev, (ndr_push_flags_fn_t)ndr_push_notify_event); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); return; diff --git a/source4/ntvfs/common/opendb_tdb.c b/source4/ntvfs/common/opendb_tdb.c index 8f5d10f902..9c9bbd031d 100644 --- a/source4/ntvfs/common/opendb_tdb.c +++ b/source4/ntvfs/common/opendb_tdb.c @@ -40,9 +40,9 @@ #include "includes.h" #include "system/filesys.h" -#include "../tdb/include/tdb.h" +#include <tdb.h> #include "messaging/messaging.h" -#include "tdb_wrap.h" +#include "lib/util/tdb_wrap.h" #include "lib/messaging/irpc.h" #include "librpc/gen_ndr/ndr_opendb.h" #include "ntvfs/ntvfs.h" @@ -246,7 +246,7 @@ static NTSTATUS odb_pull_record(struct odb_lock *lck, struct opendb_file *file) blob.data = dbuf.dptr; blob.length = dbuf.dsize; - ndr_err = ndr_pull_struct_blob(&blob, lck, lp_iconv_convenience(lck->odb->ntvfs_ctx->lp_ctx), file, (ndr_pull_flags_fn_t)ndr_pull_opendb_file); + ndr_err = ndr_pull_struct_blob(&blob, lck, file, (ndr_pull_flags_fn_t)ndr_pull_opendb_file); free(dbuf.dptr); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { return ndr_map_error2ntstatus(ndr_err); @@ -274,7 +274,7 @@ static NTSTATUS odb_push_record(struct odb_lock *lck, struct opendb_file *file) return NT_STATUS_OK; } - ndr_err = ndr_push_struct_blob(&blob, lck, lp_iconv_convenience(lck->odb->ntvfs_ctx->lp_ctx), file, (ndr_push_flags_fn_t)ndr_push_opendb_file); + ndr_err = ndr_push_struct_blob(&blob, lck, file, (ndr_push_flags_fn_t)ndr_push_opendb_file); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { return ndr_map_error2ntstatus(ndr_err); } diff --git a/source4/ntvfs/common/wscript_build b/source4/ntvfs/common/wscript_build new file mode 100644 index 0000000000..4977b7097f --- /dev/null +++ b/source4/ntvfs/common/wscript_build @@ -0,0 +1,8 @@ +#!/usr/bin/env python + +bld.SAMBA_SUBSYSTEM('ntvfs_common', + source='init.c brlock.c brlock_tdb.c opendb.c opendb_tdb.c notify.c', + autoproto='proto.h', + public_deps='NDR_OPENDB NDR_NOTIFY sys_notify sys_lease share' + ) + |