Modifying Samba3 vfs opendir()

Jeremy Allison jra at samba.org
Sat Jun 25 02:31:20 GMT 2005


On Fri, Jun 24, 2005 at 06:11:01PM -0700, Jeremy Allison wrote:
> 
> This will mean a revision number change, and is very easy to
> add to the next release (ie. extra parameters we will by default
> ignore) but I wanted to get some feedback.

And because no proposal is complete without code, here's a patch
for the current SAMBA_3_0 SVN :-).

Jeremy.
-------------- next part --------------
Index: source/smbd/msdfs.c
===================================================================
--- source/smbd/msdfs.c	(revision 7881)
+++ source/smbd/msdfs.c	(working copy)
@@ -989,7 +989,7 @@
 	cnt++;
 	
 	/* Now enumerate all dfs links */
-	dirp = SMB_VFS_OPENDIR(conn, ".");
+	dirp = SMB_VFS_OPENDIR(conn, ".", NULL, 0);
 	if(!dirp)
 		goto out;
 
Index: source/smbd/reply.c
===================================================================
--- source/smbd/reply.c	(revision 7881)
+++ source/smbd/reply.c	(working copy)
@@ -1014,9 +1014,9 @@
 	pstring directory;
 	pstring fname;
 	SMB_OFF_T size;
-	int mode;
+	uint32 mode;
 	time_t date;
-	int dirtype;
+	uint32 dirtype;
 	int outsize = 0;
 	unsigned int numentries = 0;
 	unsigned int maxentries = 0;
@@ -1115,7 +1115,7 @@
 		ok = True;
      
 		if (status_len == 0) {
-			dptr_num = dptr_create(conn,directory,True,expect_close,SVAL(inbuf,smb_pid));
+			dptr_num = dptr_create(conn,directory,True,expect_close,SVAL(inbuf,smb_pid), mask, dirtype);
 			if (dptr_num < 0) {
 				if(dptr_num == -2) {
 					END_PROFILE(SMBsearch);
@@ -1124,10 +1124,6 @@
 				END_PROFILE(SMBsearch);
 				return ERROR_DOS(ERRDOS,ERRnofids);
 			}
-			if (!dptr_set_wcard_and_attributes(dptr_num, mask, dirtype)) {
-				END_PROFILE(SMBsearch);
-				return ERROR_DOS(ERRDOS,ERRnomem);
-			}
 		} else {
 			dirtype = dptr_attr(dptr_num);
 		}
@@ -1743,10 +1739,10 @@
  Check if a user is allowed to delete a file.
 ********************************************************************/
 
-NTSTATUS can_delete(connection_struct *conn, char *fname, int dirtype, BOOL bad_path, BOOL check_is_at_open)
+NTSTATUS can_delete(connection_struct *conn, char *fname, uint32 dirtype, BOOL bad_path, BOOL check_is_at_open)
 {
 	SMB_STRUCT_STAT sbuf;
-	int fmode;
+	uint32 fmode;
 	int smb_action;
 	int access_mode;
 	files_struct *fsp;
@@ -1817,7 +1813,7 @@
  code.
 ****************************************************************************/
 
-NTSTATUS unlink_internals(connection_struct *conn, int dirtype, char *name)
+NTSTATUS unlink_internals(connection_struct *conn, uint32 dirtype, char *name)
 {
 	pstring directory;
 	pstring mask;
@@ -1879,8 +1875,11 @@
 		struct smb_Dir *dir_hnd = NULL;
 		const char *dname;
 		
+		if (strequal(mask,"????????.???"))
+			pstrcpy(mask,"*");
+
 		if (check_name(directory,conn))
-			dir_hnd = OpenDir(conn, directory);
+			dir_hnd = OpenDir(conn, directory, mask, dirtype);
 		
 		/* XXXX the CIFS spec says that if bit0 of the flags2 field is set then
 		   the pattern matches against the long name, otherwise the short name 
@@ -1891,9 +1890,6 @@
 			long offset = 0;
 			error = NT_STATUS_NO_SUCH_FILE;
 
-			if (strequal(mask,"????????.???"))
-				pstrcpy(mask,"*");
-
 			while ((dname = ReadDirName(dir_hnd, &offset))) {
 				SMB_STRUCT_STAT st;
 				pstring fname;
@@ -1954,7 +1950,7 @@
 {
 	int outsize = 0;
 	pstring name;
-	int dirtype;
+	uint32 dirtype;
 	NTSTATUS status;
 	START_PROFILE(SMBunlink);
 	
@@ -3707,7 +3703,7 @@
 	const char *dname = NULL;
 	BOOL ret = False;
 	long offset = 0;
-	struct smb_Dir *dir_hnd = OpenDir(conn, directory);
+	struct smb_Dir *dir_hnd = OpenDir(conn, directory, NULL, 0);
 
 	if(dir_hnd == NULL)
 		return True;
@@ -3775,7 +3771,7 @@
 		 */
 		BOOL all_veto_files = True;
 		const char *dname;
-		struct smb_Dir *dir_hnd = OpenDir(conn, directory);
+		struct smb_Dir *dir_hnd = OpenDir(conn, directory, NULL, 0);
 
 		if(dir_hnd != NULL) {
 			long dirpos = 0;
@@ -3997,7 +3993,7 @@
  Rename an open file - given an fsp.
 ****************************************************************************/
 
-NTSTATUS rename_internals_fsp(connection_struct *conn, files_struct *fsp, char *newname, uint16 attrs, BOOL replace_if_exists)
+NTSTATUS rename_internals_fsp(connection_struct *conn, files_struct *fsp, char *newname, uint32 attrs, BOOL replace_if_exists)
 {
 	SMB_STRUCT_STAT sbuf;
 	BOOL bad_path = False;
@@ -4111,7 +4107,7 @@
  code. 
 ****************************************************************************/
 
-NTSTATUS rename_internals(connection_struct *conn, char *name, char *newname, uint16 attrs, BOOL replace_if_exists)
+NTSTATUS rename_internals(connection_struct *conn, char *name, char *newname, uint32 attrs, BOOL replace_if_exists)
 {
 	pstring directory;
 	pstring mask;
@@ -4333,17 +4329,17 @@
 		const char *dname;
 		pstring destname;
 		
+		if (strequal(mask,"????????.???"))
+			pstrcpy(mask,"*");
+			
 		if (check_name(directory,conn))
-			dir_hnd = OpenDir(conn, directory);
+			dir_hnd = OpenDir(conn, directory, mask, attrs);
 		
 		if (dir_hnd) {
 			long offset = 0;
 			error = NT_STATUS_NO_SUCH_FILE;
 /*			Was error = NT_STATUS_OBJECT_NAME_NOT_FOUND; - gentest fix. JRA */
 			
-			if (strequal(mask,"????????.???"))
-				pstrcpy(mask,"*");
-			
 			while ((dname = ReadDirName(dir_hnd, &offset))) {
 				pstring fname;
 				BOOL sysdir_entry = False;
@@ -4444,7 +4440,7 @@
 	pstring name;
 	pstring newname;
 	char *p;
-	uint16 attrs = SVAL(inbuf,smb_vwv0);
+	uint32 attrs = SVAL(inbuf,smb_vwv0);
 	NTSTATUS status;
 
 	START_PROFILE(SMBmv);
@@ -4689,16 +4685,16 @@
 		const char *dname;
 		pstring destname;
 
+		if (strequal(mask,"????????.???"))
+			pstrcpy(mask,"*");
+
 		if (check_name(directory,conn))
-			dir_hnd = OpenDir(conn, directory);
+			dir_hnd = OpenDir(conn, directory, mask, 0);
 
 		if (dir_hnd) {
 			long offset = 0;
 			error = ERRbadfile;
 
-			if (strequal(mask,"????????.???"))
-				pstrcpy(mask,"*");
-
 			while ((dname = ReadDirName(dir_hnd, &offset))) {
 				pstring fname;
 				pstrcpy(fname,dname);
Index: source/smbd/vfs-wrap.c
===================================================================
--- source/smbd/vfs-wrap.c	(revision 7882)
+++ source/smbd/vfs-wrap.c	(working copy)
@@ -88,7 +88,7 @@
     
 /* Directory operations */
 
-DIR *vfswrap_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname)
+DIR *vfswrap_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr)
 {
 	DIR *result;
 
Index: source/smbd/trans2.c
===================================================================
--- source/smbd/trans2.c	(revision 7881)
+++ source/smbd/trans2.c	(working copy)
@@ -996,7 +996,7 @@
 
 static BOOL get_lanman2_dir_entry(connection_struct *conn,
 				  void *inbuf, void *outbuf,
-				 char *path_mask,int dirtype,int info_level,
+				 char *path_mask,uint32 dirtype,int info_level,
 				 int requires_resume_key,
 				 BOOL dont_descend,char **ppdata, 
 				 char *base_data, int space_remaining, 
@@ -1012,7 +1012,7 @@
 	char *p, *q, *pdata = *ppdata;
 	uint32 reskey=0;
 	long prev_dirpos=0;
-	int mode=0;
+	uint32 mode=0;
 	SMB_OFF_T file_size = 0;
 	SMB_BIG_UINT allocation_size = 0;
 	uint32 len;
@@ -1020,7 +1020,7 @@
 	char *nameptr;
 	char *last_entry_ptr;
 	BOOL was_8_3;
-	int nt_extmode; /* Used for NT connections instead of mode */
+	uint32 nt_extmode; /* Used for NT connections instead of mode */
 	BOOL needslash = ( conn->dirpath[strlen(conn->dirpath) -1] != '/');
 	BOOL check_mangled_names = lp_manglednames(SNUM(conn));
 
@@ -1576,7 +1576,7 @@
 		requested. */
 	char *params = *pparams;
 	char *pdata = *ppdata;
-	int dirtype = SVAL(params,0);
+	uint32 dirtype = SVAL(params,0);
 	int maxentries = SVAL(params,2);
 	uint16 findfirst_flags = SVAL(params,4);
 	BOOL close_after_first = (findfirst_flags & FLAG_TRANS2_FIND_CLOSE);
@@ -1606,9 +1606,9 @@
 
 	*directory = *mask = 0;
 
-	DEBUG(3,("call_trans2findfirst: dirtype = %d, maxentries = %d, close_after_first=%d, \
+	DEBUG(3,("call_trans2findfirst: dirtype = %x, maxentries = %d, close_after_first=%d, \
 close_if_end = %d requires_resume_key = %d level = 0x%x, max_data_bytes = %d\n",
-		dirtype, maxentries, close_after_first, close_if_end, requires_resume_key,
+		(unsigned int)dirtype, maxentries, close_after_first, close_if_end, requires_resume_key,
 		info_level, max_data_bytes));
 
 	if (!maxentries) {
@@ -1711,19 +1711,13 @@
 	}
 	*pparams = params;
 
-	dptr_num = dptr_create(conn,directory, False, True ,SVAL(inbuf,smb_pid));
-	if (dptr_num < 0) {
-		talloc_destroy(ea_ctx);
-		return(UNIXERROR(ERRDOS,ERRbadfile));
-	}
-
 	/* Save the wildcard match and attribs we are using on this directory - 
 		needed as lanman2 assumes these are being saved between calls */
 
-	if (!dptr_set_wcard_and_attributes(dptr_num, mask, dirtype)) {
-		dptr_close(&dptr_num);
+	dptr_num = dptr_create(conn,directory, False, True ,SVAL(inbuf,smb_pid), mask, dirtype);
+	if (dptr_num < 0) {
 		talloc_destroy(ea_ctx);
-		return ERROR_NT(NT_STATUS_NO_MEMORY);
+		return(UNIXERROR(ERRDOS,ERRbadfile));
 	}
 
 	DEBUG(4,("dptr_num is %d, wcard = %s, attr = %d\n",dptr_num, mask, dirtype));
Index: source/smbd/notify_hash.c
===================================================================
--- source/smbd/notify_hash.c	(revision 7881)
+++ source/smbd/notify_hash.c	(working copy)
@@ -76,7 +76,7 @@
 	 * larger than the max time_t value).
 	 */
 
-	dp = OpenDir(conn, path);
+	dp = OpenDir(conn, path, NULL, 0);
 	if (dp == NULL)
 		return False;
 
Index: source/smbd/dir.c
===================================================================
--- source/smbd/dir.c	(revision 7881)
+++ source/smbd/dir.c	(working copy)
@@ -53,7 +53,7 @@
 	struct smb_Dir *dir_hnd;
 	BOOL expect_close;
 	char *wcard;
-	uint16 attr;
+	uint32 attr;
 	char *path;
 	BOOL has_wild; /* Set to true if the wcard entry has MS wildcard characters in it. */
 };
@@ -68,7 +68,7 @@
  Make a dir struct.
 ****************************************************************************/
 
-void make_dir_struct(char *buf, const char *mask, const char *fname,SMB_OFF_T size,int mode,time_t date, BOOL uc)
+void make_dir_struct(char *buf, const char *mask, const char *fname,SMB_OFF_T size,uint32 mode,time_t date, BOOL uc)
 {  
 	char *p;
 	pstring mask2;
@@ -175,7 +175,7 @@
 				if (dirhandles_open >= MAX_OPEN_DIRECTORIES)
 					dptr_idleoldest();
 				DEBUG(4,("dptr_get: Reopening dptr key %d\n",key));
-				if (!(dptr->dir_hnd = OpenDir(dptr->conn, dptr->path))) {
+				if (!(dptr->dir_hnd = OpenDir(dptr->conn, dptr->path, dptr->wcard, dptr->attr))) {
 					DEBUG(4,("dptr_get: Failed to open %s (%s)\n",dptr->path,
 						strerror(errno)));
 					return False;
@@ -225,30 +225,6 @@
 }
 
 /****************************************************************************
- Set the dir wcard for a dir index.
- Returns 0 on ok, 1 on fail.
-****************************************************************************/
-
-BOOL dptr_set_wcard_and_attributes(int key, const char *wcard, uint16 attr)
-{
-	struct dptr_struct *dptr = dptr_get(key, False);
-
-	if (dptr) {
-		dptr->attr = attr;
-		dptr->wcard = SMB_STRDUP(wcard);
-		if (!dptr->wcard)
-			return False;
-		if (lp_posix_pathnames() || (wcard[0] == '.' && wcard[1] == 0)) {
-			dptr->has_wild = True;
-		} else {
-			dptr->has_wild = ms_has_wild(wcard);
-		}
-		return True;
-	}
-	return False;
-}
-
-/****************************************************************************
  Close a dptr (internal func).
 ****************************************************************************/
 
@@ -399,7 +375,8 @@
  a directory handle is never zero.
 ****************************************************************************/
 
-int dptr_create(connection_struct *conn, pstring path, BOOL old_handle, BOOL expect_close,uint16 spid)
+int dptr_create(connection_struct *conn, pstring path, BOOL old_handle, BOOL expect_close,uint16 spid,
+		const char *wcard, uint32 attr)
 {
 	struct dptr_struct *dptr = NULL;
 	struct smb_Dir *dir_hnd;
@@ -415,7 +392,7 @@
 	if (!*dir2)
 		dir2 = ".";
 
-	dir_hnd = OpenDir(conn, dir2);
+	dir_hnd = OpenDir(conn, dir2, wcard, attr);
 	if (!dir_hnd) {
 		return (-2);
 	}
@@ -503,9 +480,23 @@
 	dptr->dir_hnd = dir_hnd;
 	dptr->spid = spid;
 	dptr->expect_close = expect_close;
-	dptr->wcard = NULL; /* Only used in lanman2 searches */
-	dptr->attr = 0; /* Only used in lanman2 searches */
-	dptr->has_wild = True; /* Only used in lanman2 searches */
+	if (wcard) {
+		dptr->wcard = SMB_STRDUP(wcard);
+		if (!dptr->wcard) {
+			bitmap_clear(dptr_bmap, dptr->dnum - 1);
+			SAFE_FREE(dptr);
+			CloseDir(dir_hnd);
+			return -1;
+		}
+	} else {
+		dptr->wcard = NULL;
+	}
+	dptr->attr = attr;
+	if (lp_posix_pathnames() || (wcard && (wcard[0] == '.' && wcard[1] == 0))) {
+		dptr->has_wild = True;
+	} else {
+		dptr->has_wild = ms_has_wild(wcard);
+	}
 
 	DLIST_ADD(dirptrs, dptr);
 
@@ -715,9 +706,9 @@
  Check a filetype for being valid.
 ****************************************************************************/
 
-BOOL dir_check_ftype(connection_struct *conn,int mode,int dirtype)
+BOOL dir_check_ftype(connection_struct *conn, uint32 mode, uint32 dirtype)
 {
-	int mask;
+	uint32 mask;
 
 	/* Check the "may have" search bits. */
 	if (((mode & ~dirtype) & (aHIDDEN | aSYSTEM | aDIR)) != 0)
@@ -747,8 +738,8 @@
  Get an 8.3 directory entry.
 ****************************************************************************/
 
-BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype, pstring fname,
-                   SMB_OFF_T *size,int *mode,time_t *date,BOOL check_descend)
+BOOL get_dir_entry(connection_struct *conn,char *mask,uint32 dirtype, pstring fname,
+                   SMB_OFF_T *size,uint32 *mode,time_t *date,BOOL check_descend)
 {
 	const char *dname;
 	BOOL found = False;
@@ -804,7 +795,7 @@
 			*mode = dos_mode(conn,pathreal,&sbuf);
 
 			if (!dir_check_ftype(conn,*mode,dirtype)) {
-				DEBUG(5,("[%s] attribs didn't match %x\n",filename,dirtype));
+				DEBUG(5,("[%s] attribs didn't match %x\n",filename,(unsigned int)dirtype));
 				continue;
 			}
 
@@ -1000,7 +991,7 @@
  Open a directory.
 ********************************************************************/
 
-struct smb_Dir *OpenDir(connection_struct *conn, const char *name)
+struct smb_Dir *OpenDir(connection_struct *conn, const char *name, const char *mask, uint32 attr)
 {
 	struct smb_Dir *dirp = SMB_MALLOC_P(struct smb_Dir);
 	if (!dirp) {
@@ -1014,7 +1005,7 @@
 	if (!dirp->dir_path) {
 		goto fail;
 	}
-	dirp->dir = SMB_VFS_OPENDIR(conn, dirp->dir_path);
+	dirp->dir = SMB_VFS_OPENDIR(conn, dirp->dir_path, mask, attr);
 	if (!dirp->dir) {
 		DEBUG(5,("OpenDir: Can't open %s. %s\n", dirp->dir_path, strerror(errno) ));
 		goto fail;
Index: source/smbd/filename.c
===================================================================
--- source/smbd/filename.c	(revision 7881)
+++ source/smbd/filename.c	(working copy)
@@ -450,7 +450,7 @@
 		mangled = !mangle_check_cache( name, maxlength, SNUM(conn));
 
 	/* open the directory */
-	if (!(cur_dir = OpenDir(conn, path))) {
+	if (!(cur_dir = OpenDir(conn, path, NULL, 0))) {
 		DEBUG(3,("scan dir didn't open dir [%s]\n",path));
 		return(False);
 	}
Index: source/modules/vfs_catia.c
===================================================================
--- source/modules/vfs_catia.c	(revision 7881)
+++ source/modules/vfs_catia.c	(working copy)
@@ -72,13 +72,13 @@
 }
 
 static DIR *catia_opendir(vfs_handle_struct *handle, connection_struct 
-			  *conn, const char *fname)
+			  *conn, const char *fname, const char *mask, uint32 attr)
 {
         pstring name;
         pstrcpy(name, fname);
         to_unix(name);
 
-        return SMB_VFS_NEXT_OPENDIR(handle, conn, name);
+        return SMB_VFS_NEXT_OPENDIR(handle, conn, name, mask, attr);
 }
 
 static SMB_STRUCT_DIRENT *catia_readdir(vfs_handle_struct *handle, 
Index: source/modules/vfs_full_audit.c
===================================================================
--- source/modules/vfs_full_audit.c	(revision 7882)
+++ source/modules/vfs_full_audit.c	(working copy)
@@ -87,7 +87,7 @@
                                 SHADOW_COPY_DATA *shadow_copy_data, BOOL labels);
 
 static DIR *smb_full_audit_opendir(vfs_handle_struct *handle, connection_struct *conn,
-			  const char *fname);
+			  const char *fname, const char *mask, uint32 attr);
 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
 				    connection_struct *conn, DIR *dirp);
 static void smb_full_audit_seekdir(vfs_handle_struct *handle, connection_struct *conn,
@@ -816,11 +816,11 @@
 }
 
 static DIR *smb_full_audit_opendir(vfs_handle_struct *handle, connection_struct *conn,
-			  const char *fname)
+			  const char *fname, const char *mask, uint32 attr)
 {
 	DIR *result;
 
-	result = SMB_VFS_NEXT_OPENDIR(handle, conn, fname);
+	result = SMB_VFS_NEXT_OPENDIR(handle, conn, fname, mask, attr);
 
 	do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname);
 
Index: source/modules/vfs_extd_audit.c
===================================================================
--- source/modules/vfs_extd_audit.c	(revision 7882)
+++ source/modules/vfs_extd_audit.c	(working copy)
@@ -34,7 +34,7 @@
 
 static int audit_connect(vfs_handle_struct *handle, connection_struct *conn, const char *svc, const char *user);
 static void audit_disconnect(vfs_handle_struct *handle, connection_struct *conn);
-static DIR *audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname);
+static DIR *audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr);
 static int audit_mkdir(vfs_handle_struct *handle, connection_struct *conn, const char *path, mode_t mode);
 static int audit_rmdir(vfs_handle_struct *handle, connection_struct *conn, const char *path);
 static int audit_open(vfs_handle_struct *handle, connection_struct *conn, const char *fname, int flags, mode_t mode);
@@ -125,11 +125,11 @@
 	return;
 }
 
-static DIR *audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname)
+static DIR *audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr)
 {
 	DIR *result;
 
-	result = SMB_VFS_NEXT_OPENDIR(handle, conn, fname);
+	result = SMB_VFS_NEXT_OPENDIR(handle, conn, fname, mask, attr);
 
 	syslog(audit_syslog_priority(handle), "opendir %s %s%s\n",
 	       fname,
Index: source/modules/vfs_netatalk.c
===================================================================
--- source/modules/vfs_netatalk.c	(revision 7882)
+++ source/modules/vfs_netatalk.c	(working copy)
@@ -172,11 +172,11 @@
 
 /* Directory operations */
 
-DIR *atalk_opendir(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *fname)
+DIR *atalk_opendir(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *fname, const char *mask, uint32 attr)
 {
 	DIR *ret = 0;
 
-	ret = SMB_VFS_NEXT_OPENDIR(handle, conn, fname);
+	ret = SMB_VFS_NEXT_OPENDIR(handle, conn, fname, mask, attr);
 
 	/*
 	 * when we try to perform delete operation upon file which has fork
@@ -379,7 +379,7 @@
     
 	/* Directory operations */
 
-	{SMB_VFS_OP(atalk_opendir), 	SMB_VFS_OP_OPENDIR, 	SMB_VFS_LAYER_TRANSPARENT},
+	{SMB_VFS_OP(atalk_opendir),	 	SMB_VFS_OP_OPENDIR, 	SMB_VFS_LAYER_TRANSPARENT},
 	{SMB_VFS_OP(atalk_rmdir), 		SMB_VFS_OP_RMDIR, 	SMB_VFS_LAYER_TRANSPARENT},
 
 	/* File operations */
Index: source/modules/vfs_cap.c
===================================================================
--- source/modules/vfs_cap.c	(revision 7882)
+++ source/modules/vfs_cap.c	(working copy)
@@ -38,11 +38,11 @@
 					 dfree, dsize);
 }
 
-static DIR *cap_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname)
+static DIR *cap_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr)
 {
         pstring capname;
         capencode(capname, fname);
-	return SMB_VFS_NEXT_OPENDIR(handle, conn, capname);
+	return SMB_VFS_NEXT_OPENDIR(handle, conn, capname, mask, attr);
 }
 
 static SMB_STRUCT_DIRENT *cap_readdir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp)
Index: source/modules/vfs_audit.c
===================================================================
--- source/modules/vfs_audit.c	(revision 7882)
+++ source/modules/vfs_audit.c	(working copy)
@@ -31,7 +31,7 @@
 
 static int audit_connect(vfs_handle_struct *handle, connection_struct *conn, const char *svc, const char *user);
 static void audit_disconnect(vfs_handle_struct *handle, connection_struct *conn);
-static DIR *audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname);
+static DIR *audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr);
 static int audit_mkdir(vfs_handle_struct *handle, connection_struct *conn, const char *path, mode_t mode);
 static int audit_rmdir(vfs_handle_struct *handle, connection_struct *conn, const char *path);
 static int audit_open(vfs_handle_struct *handle, connection_struct *conn, const char *fname, int flags, mode_t mode);
@@ -119,11 +119,11 @@
 	return;
 }
 
-static DIR *audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname)
+static DIR *audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr)
 {
 	DIR *result;
 	
-	result = SMB_VFS_NEXT_OPENDIR(handle, conn, fname);
+	result = SMB_VFS_NEXT_OPENDIR(handle, conn, fname, mask, attr);
 
 	syslog(audit_syslog_priority(handle), "opendir %s %s%s\n",
 	       fname,
Index: source/modules/vfs_shadow_copy.c
===================================================================
--- source/modules/vfs_shadow_copy.c	(revision 7881)
+++ source/modules/vfs_shadow_copy.c	(working copy)
@@ -72,10 +72,10 @@
 	return False;
 }
 
-static DIR *shadow_copy_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname)
+static DIR *shadow_copy_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr)
 {
 	shadow_copy_Dir *dirp;
-	DIR *p = SMB_VFS_NEXT_OPENDIR(handle,conn,fname);
+	DIR *p = SMB_VFS_NEXT_OPENDIR(handle,conn,fname,mask,attr);
 
 	if (!p) {
 		DEBUG(0,("shadow_copy_opendir: SMB_VFS_NEXT_OPENDIR() failed for [%s]\n",fname));
@@ -166,7 +166,7 @@
 
 static int shadow_copy_get_shadow_copy_data(vfs_handle_struct *handle, files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, BOOL labels)
 {
-	DIR *p = SMB_VFS_NEXT_OPENDIR(handle,fsp->conn,fsp->conn->connectpath);
+	DIR *p = SMB_VFS_NEXT_OPENDIR(handle,fsp->conn,fsp->conn->connectpath,NULL,0);
 
 	shadow_copy_data->num_volumes = 0;
 	shadow_copy_data->labels = NULL;
Index: source/include/vfs_macros.h
===================================================================
--- source/include/vfs_macros.h	(revision 7881)
+++ source/include/vfs_macros.h	(working copy)
@@ -36,7 +36,7 @@
 #define SMB_VFS_GET_SHADOW_COPY_DATA(fsp,shadow_copy_data,labels) ((fsp)->conn->vfs.ops.get_shadow_copy_data((fsp)->conn->vfs.handles.get_shadow_copy_data,(fsp),(shadow_copy_data),(labels)))
 
 /* Directory operations */
-#define SMB_VFS_OPENDIR(conn, fname) ((conn)->vfs.ops.opendir((conn)->vfs.handles.opendir, (conn), (fname)))
+#define SMB_VFS_OPENDIR(conn, fname, mask, attr) ((conn)->vfs.ops.opendir((conn)->vfs.handles.opendir, (conn), (fname), (mask), (attr)))
 #define SMB_VFS_READDIR(conn, dirp) ((conn)->vfs.ops.readdir((conn)->vfs.handles.readdir, (conn), (dirp))) 
 #define SMB_VFS_SEEKDIR(conn, dirp, offset) ((conn)->vfs.ops.seekdir((conn)->vfs.handles.seekdir, (conn), (dirp), (offset)))
 #define SMB_VFS_TELLDIR(conn, dirp) ((conn)->vfs.ops.telldir((conn)->vfs.handles.telldir, (conn), (dirp)))
@@ -137,7 +137,7 @@
 #define SMB_VFS_OPAQUE_GET_SHADOW_COPY_DATA(fsp,shadow_copy_data,labels) ((fsp)->conn->vfs_opaque.ops.get_shadow_copy_data((fsp)->conn->vfs_opaque.handles.get_shadow_copy_data,(fsp),(shadow_copy_data),(labels)))
 
 /* Directory operations */
-#define SMB_VFS_OPAQUE_OPENDIR(conn, fname) ((conn)->vfs_opaque.ops.opendir((conn)->vfs_opaque.handles.opendir, (conn), (fname)))
+#define SMB_VFS_OPAQUE_OPENDIR(conn, fname, mask, attr) ((conn)->vfs_opaque.ops.opendir((conn)->vfs_opaque.handles.opendir, (conn), (fname), (mask), (attr)))
 #define SMB_VFS_OPAQUE_READDIR(conn, dirp) ((conn)->vfs_opaque.ops.readdir((conn)->vfs_opaque.handles.readdir, (conn), (dirp))) 
 #define SMB_VFS_OPAQUE_SEEKDIR(conn, dirp, offset) ((conn)->vfs_opaque.ops.seekdir((conn)->vfs_opaque.handles.seekdir, (conn), (dirp), (offset))) 
 #define SMB_VFS_OPAQUE_TELLDIR(conn, dirp) ((conn)->vfs_opaque.ops.telldir((conn)->vfs_opaque.handles.telldir, (conn), (dirp))) 
@@ -238,7 +238,7 @@
 #define SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data ,labels) ((handle)->vfs_next.ops.get_shadow_copy_data((handle)->vfs_next.handles.get_shadow_copy_data,(fsp),(shadow_copy_data),(labels)))
 
 /* Directory operations */
-#define SMB_VFS_NEXT_OPENDIR(handle, conn, fname) ((handle)->vfs_next.ops.opendir((handle)->vfs_next.handles.opendir, (conn), (fname)))
+#define SMB_VFS_NEXT_OPENDIR(handle, conn, fname, mask, attr) ((handle)->vfs_next.ops.opendir((handle)->vfs_next.handles.opendir, (conn), (fname), (mask), (attr)))
 #define SMB_VFS_NEXT_READDIR(handle, conn, dirp) ((handle)->vfs_next.ops.readdir((handle)->vfs_next.handles.readdir, (conn), (dirp))) 
 #define SMB_VFS_NEXT_SEEKDIR(handle, conn, dirp, offset) ((handle)->vfs_next.ops.seekdir((handle)->vfs_next.handles.seekdir, (conn), (dirp), (offset))) 
 #define SMB_VFS_NEXT_TELLDIR(handle, conn, dirp) ((handle)->vfs_next.ops.telldir((handle)->vfs_next.handles.telldir, (conn), (dirp))) 
Index: source/include/vfs.h
===================================================================
--- source/include/vfs.h	(revision 7882)
+++ source/include/vfs.h	(working copy)
@@ -56,7 +56,8 @@
 /* Changed to version 9 to include the get_shadow_data call. --metze */
 /* Changed to version 10 to include pread/pwrite calls. */
 /* Changed to version 11 to include seekdir/telldir/rewinddir calls. JRA */
-#define SMB_VFS_INTERFACE_VERSION 11
+/* Changed to version 12 to add mask and attributes to opendir(). JRA */
+#define SMB_VFS_INTERFACE_VERSION 12
 
 
 /* to bug old modules witch are trying to compile with the old functions */
@@ -212,7 +213,7 @@
 		
 		/* Directory operations */
 		
-		DIR *(*opendir)(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *fname);
+		DIR *(*opendir)(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *fname, const char *mask, uint32 attributes);
 		SMB_STRUCT_DIRENT *(*readdir)(struct vfs_handle_struct *handle, struct connection_struct *conn, DIR *dirp);
 		void (*seekdir)(struct vfs_handle_struct *handle, struct connection_struct *conn, DIR *dirp, long offset);
 		long (*telldir)(struct vfs_handle_struct *handle, struct connection_struct *conn, DIR *dirp);
Index: examples/VFS/skel_transparent.c
===================================================================
--- examples/VFS/skel_transparent.c	(revision 7882)
+++ examples/VFS/skel_transparent.c	(working copy)
@@ -70,9 +70,9 @@
 	return SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
 }
 
-static DIR *skel_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname)
+static DIR *skel_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr)
 {
-	return SMB_VFS_NEXT_OPENDIR(handle, conn, fname);
+	return SMB_VFS_NEXT_OPENDIR(handle, conn, fname, mask, attr);
 }
 
 static SMB_STRUCT_DIRENT *skel_readdir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp)
Index: examples/VFS/skel_opaque.c
===================================================================
--- examples/VFS/skel_opaque.c	(revision 7882)
+++ examples/VFS/skel_opaque.c	(working copy)
@@ -71,9 +71,9 @@
 	return vfswrap_get_shadow_copy_data(NULL, fsp, shadow_copy_data, labels);
 }
 
-static DIR *skel_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname)
+static DIR *skel_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr)
 {
-	return vfswrap_opendir(NULL, conn, fname);
+	return vfswrap_opendir(NULL, conn, fname, mask, attr);
 }
 
 static SMB_STRUCT_DIRENT *skel_readdir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp)


More information about the samba-technical mailing list