Index: smbd/vfs.c
===================================================================
RCS file: /cvsroot/samba/source/smbd/vfs.c,v
retrieving revision 1.75
diff -u -r1.75 vfs.c
--- smbd/vfs.c	31 Mar 2003 01:30:19 -0000	1.75
+++ smbd/vfs.c	31 Mar 2003 10:17:42 -0000
@@ -200,7 +200,7 @@
  Function to load old VFS modules. Should go away after a while.
  **************************************************************************/
 
-static BOOL vfs_load_old_plugin(connection_struct *conn, const char *vfs_object)
+static vfs_op_tuple *vfs_load_old_plugin(connection_struct *conn, const char *vfs_object)
 {
 	int vfs_version = -1;
 	vfs_op_tuple *ops, *(*init_fptr)(int *, const struct vfs_ops *, struct smb_vfs_handle_struct *);
@@ -208,7 +208,7 @@
 
 	if ((conn->vfs_private->handle = sys_dlopen(vfs_object, RTLD_NOW)) == NULL) {
 		DEBUG(0, ("Error opening %s: %s\n", vfs_object, sys_dlerror()));
-		return False;
+		return NULL;
 	}
 
 	/* Get handle on vfs_init() symbol */
@@ -218,21 +218,21 @@
 	if (init_fptr == NULL) {
 		DEBUG(0, ("No vfs_init() symbol found in %s\n", vfs_object));
 		sys_dlclose(conn->vfs_private->handle);
-		return False;
+		return NULL;
 	}
 
 	/* Initialise vfs_ops structure */
 	if ((ops = init_fptr(&vfs_version, &conn->vfs_ops, conn->vfs_private)) == NULL) {
 		DEBUG(0, ("vfs_init() function from %s failed\n", vfs_object));
 		sys_dlclose(conn->vfs_private->handle);
-		return False;
+		return NULL;
 	}
 
 	if ((vfs_version < SMB_VFS_INTERFACE_CASCADED)) {
 		DEBUG(0, ("vfs_init() returned wrong interface version info (was %d, should be no less than %d)\n",
 				  vfs_version, SMB_VFS_INTERFACE_VERSION ));
 		sys_dlclose(conn->vfs_private->handle);
-		return False;
+		return NULL;
 	}
 
 	if ((vfs_version < SMB_VFS_INTERFACE_VERSION)) {
@@ -240,10 +240,10 @@
 				  Proceeding in compatibility mode, new operations (since version #%d) will fallback to default ones.\n",
 				  vfs_version, SMB_VFS_INTERFACE_VERSION, vfs_version ));
 		sys_dlclose(conn->vfs_private->handle);
-		return False;
+		return NULL;
 	}
 	
-	return True;
+	return ops;
 }
 
 
@@ -277,10 +277,14 @@
 		/* If that doesn't work, fall back to the old system 
 		 * (This part should go away after a while, it's only here 
 		 * for backwards compatibility) */
-		DEBUG(2, ("Can't load module with new modules system, falling back to old\n"));
-		if (!vfs_load_old_plugin(conn, vfs_object)) return False;
+		DEBUG(2, ("Can't load module[%s] with new modules system, falling back to old\n",
+			vfs_object));
+		if ((ops = vfs_load_old_plugin(conn, vfs_object)) == NULL) {
+			DEBUG(0, ("vfs init function from %s failed\n", vfs_object));
+			return False;
+		}
 	}
-  
+
  	for(i=0; ops[i].op != NULL; i++) {
  	  DEBUG(3, ("Checking operation #%d (type %d, layer %d)\n", i, ops[i].type, ops[i].layer));
  	  if(ops[i].layer == SMB_VFS_LAYER_OPAQUE) {
@@ -307,7 +311,7 @@
 {
 	const char **vfs_objects;
 	char *vfs_module, *vfs_path;
-	unsigned int i;
+	unsigned int i = 0;
 	unsigned int j = 0;
 	struct smb_vfs_handle_struct *handle;
 	
@@ -327,17 +331,20 @@
 
 	vfs_path = lp_vfs_path(SNUM(conn));
 	
-	for (j=0; vfs_objects[j]; j++) {
-		conn->vfs_private = NULL;
+	for (i=0; (vfs_objects && vfs_objects[i]) ;) {
+		i++;
+	}
+
+	for (j=i; j>0 ; j--) {
 		handle = (struct smb_vfs_handle_struct *) smb_xmalloc(sizeof(smb_vfs_handle_struct));
 		/* Loadable object file */
 		handle->handle = NULL;
 		DLIST_ADD(conn->vfs_private, handle);
 		vfs_module = NULL;
 		if (vfs_path && *vfs_path) {
-			asprintf(&vfs_module, "%s/%s", vfs_path, vfs_objects[j]);
+			asprintf(&vfs_module, "%s/%s", vfs_path, vfs_objects[j-1]);
 		} else {
-			asprintf(&vfs_module, "%s", vfs_objects[j]);
+			asprintf(&vfs_module, "%s", vfs_objects[j-1]);
 		}
 		if (!vfs_init_custom(conn, vfs_module)) {
 			DEBUG(0, ("smbd_vfs_init: vfs_init_custom failed for %s\n", vfs_module));
