File gnome-vfs2-114473-ensure-mounted-subfs-volume.diff of Package gnome-vfs2

--- gnome-vfs-2.15.90/modules/file-method.c
+++ gnome-vfs-2.15.90/modules/file-method.c
@@ -1935,6 +1935,7 @@
 	const char *home_directory;
 	char *target_directory_path;
 	char *target_directory_uri;
+	DIR *near_item_dir;
 
 	
 	target_directory_path = NULL;
@@ -1952,7 +1953,19 @@
 		return GNOME_VFS_ERROR_CANCELLED;
 	}
 
+	/* HACK ALERT: We keep this directory open while we stat() so that even
+	 * if the directory is submounted, it will be really mounted in the
+	 * kernel and stat() will return the right device number.  If the
+	 * directory is not really mounted in the kernel, we'll get a weird
+	 * device number corresponding to submount, not the "real" device
+	 * number.  See bug #114473 in bugzilla.novell.com for the details.
+	 */
+
+	near_item_dir = opendir (full_name_near);
 	retval = g_lstat (full_name_near, &near_item_stat);
+	if (near_item_dir != NULL)
+		closedir (near_item_dir);
+
 	if (retval != 0) {
 		g_free (full_name_near);
 		return gnome_vfs_result_from_errno ();