svn commit: samba r21084 - in branches/SAMBA_3_0/source: . include lib smbd

vlendec at samba.org vlendec at samba.org
Wed Jan 31 13:47:37 GMT 2007


Author: vlendec
Date: 2007-01-31 13:47:37 +0000 (Wed, 31 Jan 2007)
New Revision: 21084

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21084

Log:
Make the Samba4 files compile in Samba3, not activated yet.

Volker

Modified:
   branches/SAMBA_3_0/source/Makefile.in
   branches/SAMBA_3_0/source/include/nt_status.h
   branches/SAMBA_3_0/source/include/smb.h
   branches/SAMBA_3_0/source/lib/util.c
   branches/SAMBA_3_0/source/smbd/notify.c
   branches/SAMBA_3_0/source/smbd/notify_inotify.c
   branches/SAMBA_3_0/source/smbd/notify_internal.c


Changeset:
Modified: branches/SAMBA_3_0/source/Makefile.in
===================================================================
--- branches/SAMBA_3_0/source/Makefile.in	2007-01-31 13:12:38 UTC (rev 21083)
+++ branches/SAMBA_3_0/source/Makefile.in	2007-01-31 13:47:37 UTC (rev 21084)
@@ -409,7 +409,7 @@
 OPLOCK_OBJ = smbd/oplock.o smbd/oplock_irix.o smbd/oplock_linux.o
 
 NOTIFY_OBJ = smbd/notify.o smbd/notify_hash.o smbd/notify_kernel.o \
-	smbd/notify_fam.o
+	smbd/notify_fam.o smbd/notify_inotify.o smbd/notify_internal.o
 
 VFS_DEFAULT_OBJ = modules/vfs_default.o
 VFS_AUDIT_OBJ = modules/vfs_audit.o

Modified: branches/SAMBA_3_0/source/include/nt_status.h
===================================================================
--- branches/SAMBA_3_0/source/include/nt_status.h	2007-01-31 13:12:38 UTC (rev 21083)
+++ branches/SAMBA_3_0/source/include/nt_status.h	2007-01-31 13:47:37 UTC (rev 21084)
@@ -66,6 +66,11 @@
         }\
 } while (0)
 
+#define NT_STATUS_NOT_OK_RETURN(x) do { \
+	if (!NT_STATUS_IS_OK(x)) {\
+		return x;\
+	}\
+} while (0)
 
 /* The top byte in an NTSTATUS code is used as a type field.
  * Windows only uses value 0xC0 as an indicator for an NT error

Modified: branches/SAMBA_3_0/source/include/smb.h
===================================================================
--- branches/SAMBA_3_0/source/include/smb.h	2007-01-31 13:12:38 UTC (rev 21083)
+++ branches/SAMBA_3_0/source/include/smb.h	2007-01-31 13:47:37 UTC (rev 21084)
@@ -446,6 +446,11 @@
 };
 
 struct notify_mid_map;
+struct sys_notify_backend;
+struct sys_notify_context {
+	struct event_context *ev;
+	void *private_data;
+};
 
 struct notify_change_request {
 	struct notify_change_request *prev, *next;

Modified: branches/SAMBA_3_0/source/lib/util.c
===================================================================
--- branches/SAMBA_3_0/source/lib/util.c	2007-01-31 13:12:38 UTC (rev 21083)
+++ branches/SAMBA_3_0/source/lib/util.c	2007-01-31 13:47:37 UTC (rev 21084)
@@ -3007,11 +3007,24 @@
 	return pid_to_procid(sys_getpid());
 }
 
+struct server_id server_id_self(void)
+{
+	struct server_id id;
+	id.id = procid_self();
+	return id;
+}
+
 BOOL procid_equal(const struct process_id *p1, const struct process_id *p2)
 {
 	return (p1->pid == p2->pid);
 }
 
+BOOL cluster_id_equal(const struct server_id *id1,
+		      const struct server_id *id2)
+{
+	return procid_equal(&id1->id, &id2->id);
+}
+
 BOOL procid_is_me(const struct process_id *pid)
 {
 	return (pid->pid == sys_getpid());

Modified: branches/SAMBA_3_0/source/smbd/notify.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/notify.c	2007-01-31 13:12:38 UTC (rev 21083)
+++ branches/SAMBA_3_0/source/smbd/notify.c	2007-01-31 13:47:37 UTC (rev 21084)
@@ -548,3 +548,30 @@
 
 	return True;
 }
+
+struct sys_notify_context *sys_notify_context_create(struct share_params *scfg,
+						     TALLOC_CTX *mem_ctx, 
+						     struct event_context *ev)
+{
+	struct sys_notify_context *ctx;
+
+	if (!(ctx = TALLOC_P(mem_ctx, struct sys_notify_context))) {
+		DEBUG(0, ("talloc failed\n"));
+		return NULL;
+	}
+
+	ctx->ev = ev;
+	ctx->private_data = NULL;
+	return ctx;
+}
+
+NTSTATUS sys_notify_watch(struct sys_notify_context *ctx,
+			  struct notify_entry *e,
+			  void (*callback)(struct sys_notify_context *ctx, 
+					   void *private_data,
+					   struct notify_event *ev),
+			  void *private_data, void *handle)
+{
+	return inotify_watch(ctx, e, callback, private_data, handle);
+}
+

Modified: branches/SAMBA_3_0/source/smbd/notify_inotify.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/notify_inotify.c	2007-01-31 13:12:38 UTC (rev 21083)
+++ branches/SAMBA_3_0/source/smbd/notify_inotify.c	2007-01-31 13:47:37 UTC (rev 21084)
@@ -23,12 +23,9 @@
 */
 
 #include "includes.h"
-#include "system/filesys.h"
-#include "ntvfs/sysdep/sys_notify.h"
-#include "lib/events/events.h"
-#include "lib/util/dlinklist.h"
-#include "libcli/raw/smb.h"
 
+#ifdef HAVE_INOTIFY
+
 #include <linux/inotify.h>
 #include <asm/unistd.h>
 
@@ -71,7 +68,9 @@
 	struct watch_context *next, *prev;
 	struct inotify_private *in;
 	int wd;
-	sys_notify_callback_t callback;
+	void (*callback)(struct sys_notify_context *ctx, 
+			 void *private_data,
+			 struct notify_event *ev);
 	void *private_data;
 	uint32_t mask; /* the inotify mask */
 	uint32_t filter; /* the windows completion filter */
@@ -95,6 +94,9 @@
 */
 static BOOL filter_match(struct watch_context *w, struct inotify_event *e)
 {
+	DEBUG(10, ("filter_match: e->mask=%x, w->mask=%x, w->filter=%x\n",
+		   e->mask, w->mask, w->filter));
+
 	if ((e->mask & w->mask) == 0) {
 		/* this happens because inotify_add_watch() coalesces watches on the same
 		   path, oring their masks together */
@@ -142,6 +144,9 @@
 	struct watch_context *w, *next;
 	struct notify_event ne;
 
+	DEBUG(10, ("inotify_dispatch called with mask=%x, name=[%s]\n",
+		   e->mask, e->len ? e->name : ""));
+
 	/* ignore extraneous events, such as unmount and IN_IGNORED events */
 	if ((e->mask & (IN_ATTRIB|IN_MODIFY|IN_CREATE|IN_DELETE|
 			IN_MOVED_FROM|IN_MOVED_TO)) == 0) {
@@ -171,6 +176,9 @@
 	}
 	ne.path = e->name;
 
+	DEBUG(10, ("inotify_dispatch: ne.action = %d, ne.path = %s\n",
+		   ne.action, ne.path));
+
 	/* find any watches that have this watch descriptor */
 	for (w=in->watches;w;w=next) {
 		next = w->next;
@@ -222,7 +230,7 @@
 		return;
 	}
 
-	e0 = e = talloc_size(in, bufsize);
+	e0 = e = (struct inotify_event *)talloc_size(in, bufsize);
 	if (e == NULL) return;
 
 	if (read(in->fd, e0, bufsize) != bufsize) {
@@ -323,7 +331,12 @@
 		if (w->wd == wd) break;
 	}
 	if (w == NULL) {
-		inotify_rm_watch(in->fd, wd);
+		DEBUG(10, ("Deleting inotify watch %d\n", wd));
+		if (inotify_rm_watch(in->fd, wd) == -1) {
+			DEBUG(1, ("inotify_rm_watch returned %s\n",
+				  strerror(errno)));
+		}
+		
 	}
 	return 0;
 }
@@ -333,11 +346,13 @@
   add a watch. The watch is removed when the caller calls
   talloc_free() on *handle
 */
-static NTSTATUS inotify_watch(struct sys_notify_context *ctx,
-			      struct notify_entry *e,
-			      sys_notify_callback_t callback,
-			      void *private_data, 
-			      void *handle_p)
+NTSTATUS inotify_watch(struct sys_notify_context *ctx,
+		       struct notify_entry *e,
+		       void (*callback)(struct sys_notify_context *ctx, 
+					void *private_data,
+					struct notify_event *ev),
+		       void *private_data, 
+		       void *handle_p)
 {
 	struct inotify_private *in;
 	int wd;
@@ -369,9 +384,13 @@
 	wd = inotify_add_watch(in->fd, e->path, mask);
 	if (wd == -1) {
 		e->filter = filter;
+		DEBUG(1, ("inotify_add_watch returned %s\n", strerror(errno)));
 		return map_nt_error_from_unix(errno);
 	}
 
+	DEBUG(10, ("inotify_add_watch for %s mask %x returned wd %d\n",
+		   e->path, mask, wd));
+
 	w = talloc(in, struct watch_context);
 	if (w == NULL) {
 		inotify_rm_watch(in->fd, wd);
@@ -402,17 +421,4 @@
 	return NT_STATUS_OK;
 }
 
-
-static struct sys_notify_backend inotify = {
-	.name = "inotify",
-	.notify_watch = inotify_watch
-};
-
-/*
-  initialialise the inotify module
- */
-NTSTATUS sys_notify_inotify_init(void)
-{
-	/* register ourselves as a system inotify module */
-	return sys_notify_register(&inotify);
-}
+#endif

Modified: branches/SAMBA_3_0/source/smbd/notify_internal.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/notify_internal.c	2007-01-31 13:12:38 UTC (rev 21083)
+++ branches/SAMBA_3_0/source/smbd/notify_internal.c	2007-01-31 13:47:37 UTC (rev 21084)
@@ -25,17 +25,7 @@
 */
 
 #include "includes.h"
-#include "system/filesys.h"
-#include "lib/tdb/include/tdb.h"
-#include "lib/util/util_tdb.h"
-#include "messaging/messaging.h"
-#include "db_wrap.h"
-#include "lib/messaging/irpc.h"
 #include "librpc/gen_ndr/ndr_notify.h"
-#include "lib/util/dlinklist.h"
-#include "ntvfs/common/ntvfs_common.h"
-#include "ntvfs/sysdep/sys_notify.h"
-#include "cluster/cluster.h"
 
 struct notify_context {
 	struct tdb_wrap *w;
@@ -83,11 +73,11 @@
 struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server, 
 				   struct messaging_context *messaging_ctx,
 				   struct event_context *ev,
-				   struct share_config *scfg)
+				   struct share_params *scfg)
 {
 	struct notify_context *notify;
 
-	if (share_bool_option(scfg, NOTIFY_ENABLE, NOTIFY_ENABLE_DEFAULT) != True) {
+	if (!lp_parm_bool(scfg->service, "notify", "enable", True)) {
 		return NULL;
 	}
 
@@ -96,7 +86,9 @@
 		return NULL;
 	}
 
-	notify->w = cluster_tdb_tmp_open(notify, "notify.tdb", TDB_SEQNUM);
+	notify->w = tdb_wrap_open(notify, lock_path("notify.tdb"),
+				  0, TDB_SEQNUM|TDB_CLEAR_IF_FIRST,
+				  O_RDWR|O_CREAT, 0644);
 	if (notify->w == NULL) {
 		talloc_free(notify);
 		return NULL;
@@ -167,7 +159,7 @@
 		return NT_STATUS_OK;
 	}
 
-	blob.data = dbuf.dptr;
+	blob.data = (uint8 *)dbuf.dptr;
 	blob.length = dbuf.dsize;
 
 	status = ndr_pull_struct_blob(&blob, notify->array, notify->array, 
@@ -182,7 +174,8 @@
 */
 static int notify_compare(const void *p1, const void *p2)
 {
-	const struct notify_entry *e1 = p1, *e2 = p2;
+	const struct notify_entry *e1 = (const struct notify_entry *)p1;
+	const struct notify_entry *e2 = (const struct notify_entry *)p2;
 	return strcmp(e1->path, e2->path);
 }
 
@@ -222,7 +215,7 @@
 		return status;
 	}
 
-	dbuf.dptr = blob.data;
+	dbuf.dptr = (char *)blob.data;
 	dbuf.dsize = blob.length;
 		
 	ret = tdb_store_bystring(notify->w->tdb, NOTIFY_KEY, dbuf, TDB_REPLACE);
@@ -276,6 +269,8 @@
 {
 	struct notify_list *listel = talloc_get_type(ptr, struct notify_list);
 	ev->private_data = listel;
+	DEBUG(10, ("sys_notify_callback called with action=%d, for %s\n",
+		   ev->action, ev->path));
 	listel->callback(listel->private_data, ev);
 }
 
@@ -576,6 +571,9 @@
 	int depth;
 	const char *p, *next_p;
 
+	DEBUG(10, ("notify_trigger called action=0x%x, filter=0x%x, "
+		   "path=%s\n", (unsigned)action, (unsigned)filter, path));
+
 	/* see if change notify is enabled at all */
 	if (notify == NULL) {
 		return;



More information about the samba-cvs mailing list