svn commit: samba r20451 - in branches/SAMBA_3_0/source: include smbd

vlendec at samba.org vlendec at samba.org
Mon Jan 1 18:11:33 GMT 2007


Author: vlendec
Date: 2007-01-01 18:11:32 +0000 (Mon, 01 Jan 2007)
New Revision: 20451

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

Log:
Survive the first of the filter-tests (mkdir).

Add lots of TODOs :-)

Volker

Modified:
   branches/SAMBA_3_0/source/include/smb.h
   branches/SAMBA_3_0/source/smbd/notify.c
   branches/SAMBA_3_0/source/smbd/nttrans.c
   branches/SAMBA_3_0/source/smbd/open.c
   branches/SAMBA_3_0/source/smbd/reply.c


Changeset:
Modified: branches/SAMBA_3_0/source/include/smb.h
===================================================================
--- branches/SAMBA_3_0/source/include/smb.h	2007-01-01 17:40:19 UTC (rev 20450)
+++ branches/SAMBA_3_0/source/include/smb.h	2007-01-01 18:11:32 UTC (rev 20451)
@@ -440,6 +440,7 @@
 	struct notify_change_request *prev, *next;
 	struct files_struct *fsp;	/* backpointer for cancel by mid */
 	char request_buf[smb_size];
+	uint32 filter;
 	uint32 max_param_count;
 	struct notify_mid_map *mid_map;
 };

Modified: branches/SAMBA_3_0/source/smbd/notify.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/notify.c	2007-01-01 17:40:19 UTC (rev 20450)
+++ branches/SAMBA_3_0/source/smbd/notify.c	2007-01-01 18:11:32 UTC (rev 20451)
@@ -171,7 +171,7 @@
 }
 
 NTSTATUS change_notify_add_request(const char *inbuf, uint32 max_param_count,
-				   struct files_struct *fsp)
+				   uint32 filter, struct files_struct *fsp)
 {
 	struct notify_change_request *request = NULL;
 	struct notify_mid_map *map = NULL;
@@ -187,6 +187,7 @@
 
 	memcpy(request->request_buf, inbuf, sizeof(request->request_buf));
 	request->max_param_count = max_param_count;
+	request->filter = filter;
 	request->fsp = fsp;
 	DLIST_ADD_END(fsp->notify->requests, request,
 		      struct notify_change_request *);
@@ -406,16 +407,18 @@
 Offset  Data			length.
 0	SMB_DEV_T dev		8
 8	SMB_INO_T inode		8
-16	uint32 action		4
-20..	name
+16	uint32 filter           4
+20	uint32 action		4
+24..	name
 */
 
-#define MSG_NOTIFY_MESSAGE_SIZE 21 /* Includes at least the '\0' terminator */
+#define MSG_NOTIFY_MESSAGE_SIZE 25 /* Includes at least the '\0' terminator */
 
 struct notify_message {
 	SMB_DEV_T dev;
 	SMB_INO_T inode;
-	uint32_t action;
+	uint32 filter;
+	uint32 action;
 	char *name;
 };
 
@@ -433,8 +436,9 @@
 
 	SDEV_T_VAL(result.data, 0, msg->dev);
 	SINO_T_VAL(result.data, 8, msg->inode);
-	SIVAL(result.data, 16, msg->action);
-	memcpy(result.data+20, msg->name, len+1);
+	SIVAL(result.data, 16, msg->filter);
+	SIVAL(result.data, 20, msg->action);
+	memcpy(result.data+24, msg->name, len+1);
 
 	return result;
 }
@@ -450,13 +454,14 @@
 
 	msg->dev     = DEV_T_VAL(buf, 0);
 	msg->inode   = INO_T_VAL(buf, 8);
-	msg->action  = IVAL(buf, 16);
-	msg->name    = ((char *)buf)+20;
+	msg->filter  = IVAL(buf, 16);
+	msg->action  = IVAL(buf, 20);
+	msg->name    = ((char *)buf)+24;
 	return True;
 }
 
 void notify_action(connection_struct *conn, const char *parent,
-		   const char *name, uint32_t action)
+		   const char *name, uint32 filter, uint32_t action)
 {
 	struct share_mode_lock *lck;
 	SMB_STRUCT_STAT sbuf;
@@ -484,6 +489,7 @@
 
 	msg.dev = sbuf.st_dev;
 	msg.inode = sbuf.st_ino;
+	msg.filter = filter;
 	msg.action = action;
 	msg.name = CONST_DISCARD(char *, name);
 
@@ -546,10 +552,13 @@
 		return;
 	}
 
-	if (fsp->notify->requests != NULL) {
+	if ((fsp->notify->requests != NULL)
+	    && (fsp->notify->requests->filter & msg->filter)) {
 		/*
 		 * Someone is waiting for the change, trigger the reply
-		 * immediately
+		 * immediately.
+		 *
+		 * TODO: do we have to walk the lists of requests pending?
 		 */
 
 		struct notify_change_request *req = fsp->notify->requests;
@@ -560,15 +569,14 @@
 
 		change_notify_reply(req->request_buf, req->max_param_count,
 				    1, &onechange);
-
-		DLIST_REMOVE(fsp->notify->requests, req);
-		SAFE_FREE(req);
+		change_notify_remove_request(req);
 		return;
 	}
 
 	/*
 	 * Someone has triggered a notify previously, queue the change for
-	 * later. TODO: Limit the number of changes queued.
+	 * later. TODO: Limit the number of changes queued, test how filters
+	 * apply here. Do we have to store them?
 	 */
 
 	if (!(changes = TALLOC_REALLOC_ARRAY(

Modified: branches/SAMBA_3_0/source/smbd/nttrans.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/nttrans.c	2007-01-01 17:40:19 UTC (rev 20450)
+++ branches/SAMBA_3_0/source/smbd/nttrans.c	2007-01-01 18:11:32 UTC (rev 20451)
@@ -1825,7 +1825,7 @@
 {
 	uint16 *setup = *ppsetup;
 	files_struct *fsp;
-	uint32 flags;
+	uint32 filter;
 	NTSTATUS status;
 
 	if(setup_count < 6) {
@@ -1833,7 +1833,7 @@
 	}
 
 	fsp = file_fsp((char *)setup,4);
-	flags = IVAL(setup, 0);
+	filter = IVAL(setup, 0);
 
 	DEBUG(3,("call_nt_transact_notify_change\n"));
 
@@ -1861,6 +1861,11 @@
 		 * We've got changes pending, respond immediately
 		 */
 
+		/*
+		 * TODO: write a torture test to check the filtering behaviour
+		 * here.
+		 */
+
 		SMB_ASSERT(fsp->notify->requests == NULL);
 
 		change_notify_reply(inbuf, max_param_count,
@@ -1881,7 +1886,8 @@
 	 * No changes pending, queue the request
 	 */
 
-	status = change_notify_add_request(inbuf, max_param_count, fsp);
+	status = change_notify_add_request(inbuf, max_param_count, filter,
+					   fsp);
 	if (!NT_STATUS_IS_OK(status)) {
 		return ERROR_NT(status);
 	}

Modified: branches/SAMBA_3_0/source/smbd/open.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/open.c	2007-01-01 17:40:19 UTC (rev 20450)
+++ branches/SAMBA_3_0/source/smbd/open.c	2007-01-01 18:11:32 UTC (rev 20451)
@@ -309,7 +309,7 @@
 							    fsp);
 			}
 
-			notify_action(conn, parent_dir, name,
+			notify_action(conn, parent_dir, name, -1,
 				      NOTIFY_ACTION_ADDED);
 		}
 
@@ -1944,7 +1944,8 @@
 		change_dir_owner_to_parent(conn, parent_dir, name, psbuf);
 	}
 
-	notify_action(conn, parent_dir, dirname, NOTIFY_ACTION_ADDED);
+	notify_action(conn, parent_dir, dirname, FILE_NOTIFY_CHANGE_DIR_NAME,
+		      NOTIFY_ACTION_ADDED);
 
 	return NT_STATUS_OK;
 }

Modified: branches/SAMBA_3_0/source/smbd/reply.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/reply.c	2007-01-01 17:40:19 UTC (rev 20450)
+++ branches/SAMBA_3_0/source/smbd/reply.c	2007-01-01 18:11:32 UTC (rev 20451)
@@ -2035,7 +2035,7 @@
 
 		if (parent_dirname_talloc(tmp_talloc_ctx(), orig_name,
 					  &dir, &fname)) {
-			notify_action(conn, dir, fname,
+			notify_action(conn, dir, fname, -1,
 				      NOTIFY_ACTION_REMOVED);
 			TALLOC_FREE(dir); /* not strictly necessary */
 		}
@@ -2097,7 +2097,8 @@
 				}
 				if (SMB_VFS_UNLINK(conn,fname) == 0)
 					count++;
-				notify_action(conn, directory, dname, NOTIFY_ACTION_REMOVED);
+				notify_action(conn, directory, dname,
+					      -1, NOTIFY_ACTION_REMOVED);
 				DEBUG(3,("unlink_internals: succesful unlink [%s]\n",fname));
 			}
 			CloseDir(dir_hnd);
@@ -3964,7 +3965,7 @@
 
 		if (parent_dirname_talloc(tmp_talloc_ctx(), directory,
 					  &parent_dir, &dirname)) {
-			notify_action(conn, parent_dir, dirname,
+			notify_action(conn, parent_dir, dirname, -1,
 				      NOTIFY_ACTION_REMOVED);
 			TALLOC_FREE(parent_dir); /* Not strictly necessary */
 		}



More information about the samba-cvs mailing list