--- /tmp/g/gnome-volume-manager-0.9.10+cvs20040902/src/manager.c	2004-09-02 21:26:48.000000000 +0200
+++ src/manager.c	2004-09-02 21:52:30.000000000 +0200
@@ -23,6 +23,8 @@
 #include <libhal.h>
 #include <signal.h>
 
+#include <mntent.h>
+
 #include "gvm.h"
 
 #ifdef ENABLE_NLS
@@ -450,6 +452,61 @@
 }
 
 /*
+ * gvm_get_fstab_path - scans the fstab file for an entry matching the
+ * specified device name, even if this entry is a symbolic link that eventually
+ * resolves to the real device
+ */
+static gchar *
+gvm_get_fstab_path (gchar *device) {
+	struct mntent *mnt; /* pointer to the next mntent record */
+ 	gchar *result = NULL; /* result of realpath, NULL if error */
+	gchar *dest; /* destination of a symlink */
+	gchar *tmp, *tmp2;
+ 	FILE *fstab = setmntent("/etc/fstab" /* get this some other way? */, "r");
+
+ 	if (fstab == NULL) {
+    	warn("failed to open /etc/fstab");
+     	return NULL;
+ 	}
+    
+ 	/* loop over each fstab entry */
+ 	while ((mnt = getmntent (fstab)) != NULL) {
+		if (mnt->mnt_fsname[0] != '/' &&
+				!g_file_test(mnt->mnt_fsname, G_FILE_TEST_EXISTS)) {
+			continue;
+		}
+		if (!strcmp(mnt->mnt_fsname, device)) {
+			result = g_strdup(mnt->mnt_fsname);
+			break;
+		}
+   if (!g_file_test(mnt->mnt_fsname, G_FILE_TEST_IS_SYMLINK)) continue;
+		/* symlink check if it links to the real device file */
+		dest = g_file_read_link(mnt->mnt_fsname, NULL);
+		if (dest == NULL) {
+			continue;
+		}
+		if (dest[0] != '/') {
+			/* not an absolute path, need to make it to one */
+			tmp = g_path_get_dirname(mnt->mnt_fsname);
+			tmp2 = dest; 
+			dest = g_build_filename(tmp, tmp2, NULL);
+			g_free(tmp); g_free(tmp2);
+		}
+		if (!strcmp(dest, device)) {
+			result = g_strdup(mnt->mnt_fsname);
+			g_free(dest);
+			break;
+		} 
+		g_free(dest);
+	}
+	endmntent (fstab);
+	if (result == NULL) {
+	  warn("%s not found in /etc/fstab", device);
+	}
+	return result;
+}
+
+/*
  * gvm_device_mount - use BIN_MOUNT to mount the given device node.
  *
  * Note that this requires that the given device node is in /etc/fstab.  This
@@ -462,18 +519,25 @@
 {
 	char *argv[3];
 	GError *error = NULL;
+  char *fstab_device;
 	gint exit_status;
 
+  fstab_device = gvm_get_fstab_path(device);
+  if (fstab_device == NULL) {
+    return FALSE;
+  }
+
 	argv[0] = BIN_MOUNT;
-	argv[1] = device;
+	argv[1] = fstab_device;
 	argv[2] = NULL;
 
-	if (!g_spawn_sync (g_get_home_dir (), argv, NULL, 0, NULL,
-			   NULL, NULL, NULL, &exit_status, &error)) {
+	g_spawn_sync (g_get_home_dir (), argv, NULL, 0, NULL, NULL, 
+                NULL, NULL, &exit_status, &error);
+  g_free(fstab_device);
+  if (error) {
 		warn ("failed to exec " BIN_MOUNT ": %s\n", error->message);
 		return FALSE;
 	}
-
 	return (exit_status == 0);
 }
 
