[Utopia] [patch] solaris fixes for gnome-mount 0.4+
- From: Artem Kachitchkine <Artem Kachitchkin Sun COM>
- To: utopia-list gnome org
- Subject: [Utopia] [patch] solaris fixes for gnome-mount 0.4+
- Date: Mon, 12 Jun 2006 20:28:44 -0700
A little patch that makes gnome-mount usable again on Solaris.
-Artem.
Index: src/gnome-mount.c
===================================================================
RCS file: /cvs/gnome/gnome-mount/src/gnome-mount.c,v
retrieving revision 1.18
diff -u -r1.18 gnome-mount.c
--- src/gnome-mount.c 1 Mar 2006 16:25:10 -0000 1.18
+++ src/gnome-mount.c 11 Jun 2006 21:40:34 -0000
@@ -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;
@@ -400,6 +404,51 @@
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,
@@ -410,6 +459,8 @@
gboolean ret = FALSE;
DBusError error;
unsigned int i;
+ const char *device_file;
+ char *mounted_at;
if (mount_point == NULL)
mount_point = "";
@@ -475,35 +526,11 @@
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;
@@ -1484,6 +1511,7 @@
goto out;
if (opt_device_file != NULL) {
+#ifndef sun
resolved_device_file = resolve_symlink (opt_device_file);
if (resolved_device_file == NULL) {
goto out;
@@ -1491,6 +1519,9 @@
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) {
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]