16580
|
1 |
--- gnome-mount-0.4/src/gnome-mount.c-orig 2009-09-17 10:30:23.371242221 -0500
|
|
2 |
+++ gnome-mount-0.4/src/gnome-mount.c 2009-09-17 10:30:28.283317232 -0500
|
7490
|
3 |
@@ -42,7 +42,11 @@
|
|
4 |
#include <libhal.h>
|
|
5 |
#include <libhal-storage.h>
|
|
6 |
|
|
7 |
+#ifndef sun
|
|
8 |
#include <mntent.h>
|
|
9 |
+#else
|
|
10 |
+#include <sys/mnttab.h>
|
|
11 |
+#endif
|
|
12 |
|
|
13 |
static DBusConnection *dbus_connection;
|
|
14 |
static LibHalContext *hal_ctx;
|
16580
|
15 |
@@ -54,6 +58,8 @@ static gboolean opt_noui = FALSE;
|
|
16 |
static gboolean opt_block = FALSE;
|
|
17 |
static gboolean opt_nodisplay = FALSE;
|
|
18 |
|
|
19 |
+#define DBUS_TIMEOUT G_MAXINT
|
|
20 |
+
|
|
21 |
static void
|
|
22 |
notify_parent (gboolean success)
|
|
23 |
{
|
|
24 |
@@ -396,6 +402,51 @@ get_dev_file (LibHalVolume *volume, LibH
|
7490
|
25 |
return NULL;
|
|
26 |
}
|
|
27 |
|
|
28 |
+static char *
|
|
29 |
+get_mntent_mount_point(const char *device_file)
|
|
30 |
+{
|
|
31 |
+ char *mount_point;
|
|
32 |
+ FILE *f;
|
|
33 |
+#ifndef sun
|
|
34 |
+ struct mntent mnt;
|
|
35 |
+ struct mntent *mnte;
|
|
36 |
+ char buf[512];
|
|
37 |
+#else
|
|
38 |
+ struct mnttab mnt;
|
|
39 |
+ struct mnttab mpref = { NULL, NULL, NULL, NULL, NULL };
|
|
40 |
+#endif
|
|
41 |
+
|
|
42 |
+ mount_point = NULL;
|
|
43 |
+
|
|
44 |
+#ifndef sun
|
|
45 |
+ if ((f = setmntent ("/proc/mounts", "r")) != NULL) {
|
|
46 |
+
|
|
47 |
+ while ((mnte = getmntent_r (f, &mnt, buf, sizeof(buf))) != NULL) {
|
|
48 |
+ if (strcmp (mnt.mnt_fsname, device_file) == 0) {
|
|
49 |
+ if (mnt.mnt_dir != NULL) {
|
|
50 |
+ mount_point = g_strdup (mnt.mnt_dir);
|
|
51 |
+ }
|
|
52 |
+ break;
|
|
53 |
+ }
|
|
54 |
+ }
|
|
55 |
+ endmntent (f);
|
|
56 |
+ }
|
|
57 |
+
|
|
58 |
+#else /* sun */
|
|
59 |
+
|
|
60 |
+ if ((f = fopen(MNTTAB, "r")) != NULL) {
|
|
61 |
+ mpref.mnt_special = (char *)device_file;
|
|
62 |
+ if (getmntany(f, &mnt, &mpref) == 0) {
|
|
63 |
+ mount_point = g_strdup (mnt.mnt_mountp);
|
|
64 |
+ }
|
|
65 |
+ fclose(f);
|
|
66 |
+ }
|
|
67 |
+
|
|
68 |
+#endif /* sun */
|
|
69 |
+
|
|
70 |
+out:
|
|
71 |
+ return (mount_point);
|
|
72 |
+}
|
|
73 |
|
|
74 |
static gboolean
|
|
75 |
volume_mount_with_options (const char *udi, LibHalVolume *volume, LibHalDrive *drive,
|
16580
|
76 |
@@ -406,6 +457,8 @@ volume_mount_with_options (const char *u
|
7490
|
77 |
gboolean ret = FALSE;
|
|
78 |
DBusError error;
|
|
79 |
unsigned int i;
|
|
80 |
+ const char *device_file;
|
|
81 |
+ char *mounted_at;
|
|
82 |
|
|
83 |
if (mount_point == NULL)
|
|
84 |
mount_point = "";
|
16580
|
85 |
@@ -437,7 +490,7 @@ volume_mount_with_options (const char *u
|
|
86 |
}
|
|
87 |
|
|
88 |
dbus_error_init (&error);
|
|
89 |
- if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, dmesg, -1, &error)) ||
|
|
90 |
+ if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, dmesg, DBUS_TIMEOUT, &error)) ||
|
|
91 |
dbus_error_is_set (&error)) {
|
|
92 |
g_warning ("Mount failed for %s\n%s : %s\n", udi, error.name, error.message);
|
|
93 |
|
|
94 |
@@ -471,35 +524,11 @@ volume_mount_with_options (const char *u
|
7490
|
95 |
goto out;
|
|
96 |
}
|
|
97 |
|
|
98 |
- {
|
|
99 |
- char *mount_point;
|
|
100 |
- const char *device_file;
|
|
101 |
-
|
|
102 |
- mount_point = NULL;
|
|
103 |
- device_file = get_dev_file (volume, drive);
|
|
104 |
-
|
|
105 |
- if (device_file != NULL) {
|
|
106 |
- FILE *f;
|
|
107 |
- struct mntent mnt;
|
|
108 |
- struct mntent *mnte;
|
|
109 |
- char buf[512];
|
|
110 |
-
|
|
111 |
- if ((f = setmntent ("/proc/mounts", "r")) != NULL) {
|
|
112 |
-
|
|
113 |
- while ((mnte = getmntent_r (f, &mnt, buf, sizeof(buf))) != NULL) {
|
|
114 |
- if (strcmp (mnt.mnt_fsname, device_file) == 0) {
|
|
115 |
- if (mnt.mnt_dir != NULL) {
|
|
116 |
- mount_point = g_strdup (mnt.mnt_dir);
|
|
117 |
- }
|
|
118 |
- break;
|
|
119 |
- }
|
|
120 |
- }
|
|
121 |
- endmntent (f);
|
|
122 |
- }
|
|
123 |
+ if ((device_file = get_dev_file (volume, drive)) != NULL) {
|
|
124 |
+ if ((mounted_at = get_mntent_mount_point(device_file)) != NULL) {
|
|
125 |
+ g_print (_("Mounted %s at \"%s\"\n"), device_file, mounted_at);
|
|
126 |
+ g_free (mounted_at);
|
|
127 |
}
|
|
128 |
-
|
|
129 |
- g_print (_("Mounted %s at \"%s\"\n"), device_file, mount_point);
|
|
130 |
- g_free (mount_point);
|
|
131 |
}
|
|
132 |
|
|
133 |
ret = TRUE;
|
16580
|
134 |
@@ -722,7 +751,7 @@ volume_unmount (const char *udi, LibHalV
|
|
135 |
}
|
|
136 |
|
|
137 |
dbus_error_init (&error);
|
|
138 |
- if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, -1, &error)) ||
|
|
139 |
+ if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, DBUS_TIMEOUT, &error)) ||
|
|
140 |
dbus_error_is_set (&error)) {
|
|
141 |
g_warning ("Unmount failed for %s: %s : %s\n", udi, error.name, error.message);
|
|
142 |
show_error_dialog_unmount (udi, volume, drive, error.name, error.message);
|
|
143 |
@@ -771,7 +800,7 @@ volume_eject (const char *udi, LibHalVol
|
|
144 |
}
|
|
145 |
|
|
146 |
dbus_error_init (&error);
|
|
147 |
- if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, -1, &error))) {
|
|
148 |
+ if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, DBUS_TIMEOUT, &error))) {
|
|
149 |
g_warning ("Eject failed for %s: %s : %s\n", udi, error.name, error.message);
|
|
150 |
dbus_error_free (&error);
|
|
151 |
goto out;
|
|
152 |
@@ -1092,7 +1121,7 @@ setup_crypto (const char *udi, LibHalVol
|
|
153 |
}
|
|
154 |
|
|
155 |
dbus_error_init (&error);
|
|
156 |
- if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, -1, &error)) ||
|
|
157 |
+ if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, DBUS_TIMEOUT, &error)) ||
|
|
158 |
dbus_error_is_set (&error)) {
|
|
159 |
g_warning ("Setup failed for %s: %s : %s\n", udi, error.name, error.message);
|
|
160 |
if (strcmp (error.name, "org.freedesktop.Hal.Device.Volume.Crypto.SetupPasswordError") == 0) {
|
|
161 |
@@ -1164,7 +1193,7 @@ teardown_crypto (const char *udi, LibHal
|
|
162 |
}
|
|
163 |
|
|
164 |
dbus_error_init (&error);
|
|
165 |
- if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, -1, &error)) ||
|
|
166 |
+ if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, DBUS_TIMEOUT, &error)) ||
|
|
167 |
dbus_error_is_set (&error)) {
|
|
168 |
g_warning ("Teardown failed for %s: %s : %s\n", udi, error.name, error.message);
|
|
169 |
dbus_error_free (&error);
|
|
170 |
@@ -1480,6 +1509,7 @@ main (int argc, char *argv[])
|
7490
|
171 |
goto out;
|
|
172 |
|
|
173 |
if (opt_device_file != NULL) {
|
|
174 |
+#ifndef sun
|
|
175 |
resolved_device_file = resolve_symlink (opt_device_file);
|
|
176 |
if (resolved_device_file == NULL) {
|
|
177 |
goto out;
|
16580
|
178 |
@@ -1487,6 +1517,9 @@ main (int argc, char *argv[])
|
7490
|
179 |
if (strcmp (resolved_device_file, opt_device_file) != 0) {
|
|
180 |
g_print (_("Resolved device file %s -> %s\n"), opt_device_file, resolved_device_file);
|
|
181 |
}
|
|
182 |
+#else /* sun */
|
|
183 |
+ resolved_device_file = g_strdup (opt_device_file);
|
|
184 |
+#endif /* sun */
|
|
185 |
}
|
|
186 |
|
|
187 |
if (opt_hal_udi != NULL) {
|