10139N/A--- gnome-mount-0.4/src/gnome-mount.c-orig 2009-09-17 10:30:23.371242221 -0500
10139N/A+++ gnome-mount-0.4/src/gnome-mount.c 2009-09-17 10:30:28.283317232 -0500
10139N/A@@ -42,7 +42,11 @@
12147N/A #include <libhal.h>
10139N/A #include <libhal-storage.h>
10139N/A
10139N/A+#ifndef sun
10139N/A #include <mntent.h>
10139N/A+#else
10139N/A+#include <sys/mnttab.h>
10139N/A+#endif
10139N/A
10139N/A static DBusConnection *dbus_connection;
12334N/A static LibHalContext *hal_ctx;
10139N/A@@ -54,6 +58,8 @@ static gboolean opt_noui = FALSE;
10139N/A static gboolean opt_block = FALSE;
10139N/A static gboolean opt_nodisplay = FALSE;
10139N/A
11819N/A+#define DBUS_TIMEOUT G_MAXINT
10139N/A+
10139N/A static void
10139N/A notify_parent (gboolean success)
10139N/A {
10139N/A@@ -396,6 +402,51 @@ get_dev_file (LibHalVolume *volume, LibH
11023N/A return NULL;
11875N/A }
10139N/A
10139N/A+static char *
10139N/A+get_mntent_mount_point(const char *device_file)
10139N/A+{
10139N/A+ char *mount_point;
10139N/A+ FILE *f;
10139N/A+#ifndef sun
10139N/A+ struct mntent mnt;
10139N/A+ struct mntent *mnte;
10139N/A+ char buf[512];
10139N/A+#else
10139N/A+ struct mnttab mnt;
10139N/A+ struct mnttab mpref = { NULL, NULL, NULL, NULL, NULL };
10139N/A+#endif
10139N/A+
10139N/A+ mount_point = NULL;
10139N/A+
10139N/A+#ifndef sun
10139N/A+ if ((f = setmntent ("/proc/mounts", "r")) != NULL) {
10139N/A+
10139N/A+ while ((mnte = getmntent_r (f, &mnt, buf, sizeof(buf))) != NULL) {
10139N/A+ if (strcmp (mnt.mnt_fsname, device_file) == 0) {
10139N/A+ if (mnt.mnt_dir != NULL) {
10139N/A+ mount_point = g_strdup (mnt.mnt_dir);
10139N/A+ }
10139N/A+ break;
10139N/A+ }
10139N/A+ }
10139N/A+ endmntent (f);
10139N/A+ }
10139N/A+
10139N/A+#else /* sun */
11891N/A+
10139N/A+ if ((f = fopen(MNTTAB, "r")) != NULL) {
10139N/A+ mpref.mnt_special = (char *)device_file;
10139N/A+ if (getmntany(f, &mnt, &mpref) == 0) {
10139N/A+ mount_point = g_strdup (mnt.mnt_mountp);
10139N/A+ }
10139N/A+ fclose(f);
10139N/A+ }
10139N/A+
10139N/A+#endif /* sun */
10139N/A+
10139N/A+out:
10139N/A+ return (mount_point);
10139N/A+}
10139N/A
10139N/A static gboolean
10139N/A volume_mount_with_options (const char *udi, LibHalVolume *volume, LibHalDrive *drive,
10139N/A@@ -406,6 +457,8 @@ volume_mount_with_options (const char *u
10139N/A gboolean ret = FALSE;
10139N/A DBusError error;
10139N/A unsigned int i;
10139N/A+ const char *device_file;
10139N/A+ char *mounted_at;
11149N/A
10139N/A if (mount_point == NULL)
10139N/A mount_point = "";
10139N/A@@ -437,7 +490,7 @@ volume_mount_with_options (const char *u
10139N/A }
10139N/A
11103N/A dbus_error_init (&error);
10139N/A- if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, dmesg, -1, &error)) ||
10139N/A+ if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, dmesg, DBUS_TIMEOUT, &error)) ||
10139N/A dbus_error_is_set (&error)) {
10139N/A g_warning ("Mount failed for %s\n%s : %s\n", udi, error.name, error.message);
10139N/A
10139N/A@@ -471,35 +524,11 @@ volume_mount_with_options (const char *u
10139N/A goto out;
10139N/A }
10139N/A
10139N/A- {
10139N/A- char *mount_point;
10139N/A- const char *device_file;
10139N/A-
10139N/A- mount_point = NULL;
10139N/A- device_file = get_dev_file (volume, drive);
10139N/A-
10139N/A- if (device_file != NULL) {
10139N/A- FILE *f;
10139N/A- struct mntent mnt;
10139N/A- struct mntent *mnte;
10139N/A- char buf[512];
10139N/A-
10139N/A- if ((f = setmntent ("/proc/mounts", "r")) != NULL) {
10139N/A-
10139N/A- while ((mnte = getmntent_r (f, &mnt, buf, sizeof(buf))) != NULL) {
10139N/A- if (strcmp (mnt.mnt_fsname, device_file) == 0) {
10139N/A- if (mnt.mnt_dir != NULL) {
10139N/A- mount_point = g_strdup (mnt.mnt_dir);
10139N/A- }
10139N/A- break;
10139N/A- }
10139N/A- }
10139N/A- endmntent (f);
10139N/A- }
10139N/A+ if ((device_file = get_dev_file (volume, drive)) != NULL) {
10139N/A+ if ((mounted_at = get_mntent_mount_point(device_file)) != NULL) {
10139N/A+ g_print (_("Mounted %s at \"%s\"\n"), device_file, mounted_at);
10139N/A+ g_free (mounted_at);
10139N/A }
10139N/A-
10139N/A- g_print (_("Mounted %s at \"%s\"\n"), device_file, mount_point);
10139N/A- g_free (mount_point);
10139N/A }
10139N/A
10139N/A ret = TRUE;
10139N/A@@ -722,7 +751,7 @@ volume_unmount (const char *udi, LibHalV
10139N/A }
10139N/A
10139N/A dbus_error_init (&error);
10139N/A- if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, -1, &error)) ||
10139N/A+ if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, DBUS_TIMEOUT, &error)) ||
10139N/A dbus_error_is_set (&error)) {
12334N/A g_warning ("Unmount failed for %s: %s : %s\n", udi, error.name, error.message);
12334N/A show_error_dialog_unmount (udi, volume, drive, error.name, error.message);
12147N/A@@ -771,7 +800,7 @@ volume_eject (const char *udi, LibHalVol
12147N/A }
12017N/A
12017N/A dbus_error_init (&error);
11912N/A- if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, -1, &error))) {
11912N/A+ if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, DBUS_TIMEOUT, &error))) {
11912N/A g_warning ("Eject failed for %s: %s : %s\n", udi, error.name, error.message);
11875N/A dbus_error_free (&error);
11875N/A goto out;
11875N/A@@ -1092,7 +1121,7 @@ setup_crypto (const char *udi, LibHalVol
11875N/A }
11875N/A
11827N/A dbus_error_init (&error);
11838N/A- if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, -1, &error)) ||
11838N/A+ if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, DBUS_TIMEOUT, &error)) ||
11833N/A dbus_error_is_set (&error)) {
11832N/A g_warning ("Setup failed for %s: %s : %s\n", udi, error.name, error.message);
11827N/A if (strcmp (error.name, "org.freedesktop.Hal.Device.Volume.Crypto.SetupPasswordError") == 0) {
11819N/A@@ -1164,7 +1193,7 @@ teardown_crypto (const char *udi, LibHal
11838N/A }
11426N/A
11426N/A dbus_error_init (&error);
11266N/A- if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, -1, &error)) ||
11266N/A+ if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, DBUS_TIMEOUT, &error)) ||
11149N/A dbus_error_is_set (&error)) {
11149N/A g_warning ("Teardown failed for %s: %s : %s\n", udi, error.name, error.message);
11103N/A dbus_error_free (&error);
11103N/A@@ -1480,6 +1509,7 @@ main (int argc, char *argv[])
11103N/A goto out;
11094N/A
11094N/A if (opt_device_file != NULL) {
10847N/A+#ifndef sun
10847N/A resolved_device_file = resolve_symlink (opt_device_file);
10838N/A if (resolved_device_file == NULL) {
10838N/A goto out;
10838N/A@@ -1487,6 +1517,9 @@ main (int argc, char *argv[])
10746N/A if (strcmp (resolved_device_file, opt_device_file) != 0) {
10746N/A g_print (_("Resolved device file %s -> %s\n"), opt_device_file, resolved_device_file);
10681N/A }
10681N/A+#else /* sun */
10681N/A+ resolved_device_file = g_strdup (opt_device_file);
10681N/A+#endif /* sun */
10675N/A }
10675N/A
10653N/A if (opt_hal_udi != NULL) {
10653N/A