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