[Utopia] [patch] gnome-mount, read mount options from HAL



Hi,

Here's a patch for reading by the gnome-mount per-volume mount options
from HAL policy.


Example fdi:

<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- -->
<!-- /etc/hal/fdi/policy/preferences.fdi -->
<deviceinfo version="0.2">
<device>
   <match key="volume.fstype" string="vfat">
     <merge key="volume.policy.mount_option.codepage=866"
type="bool">true</merge>
     <merge key="volume.policy.mount_option.noatime"
type="bool">true</merge>
   </match>
</device>
</deviceinfo>


diff -ruN gnome-mount-0.5.orig/src/gnome-mount.c gnome-mount-0.5/src/gnome-mount.c
--- gnome-mount-0.5.orig/src/gnome-mount.c	2006-09-17 11:17:54.000000000 +0600
+++ gnome-mount-0.5/src/gnome-mount.c	2006-11-27 15:42:11.000000000 +0500
@@ -1183,10 +1183,7 @@
 		g_free (udi2);
 	}
 
-	/* read legacy settings from HAL properties (GNOME bug #345546) 
-	 * 
-	 * We *could* also read volume.policy.mount_option.* properties but...
-	 */
+	/* read legacy settings from HAL properties (GNOME bug #345546) */
 	if (volume != NULL) {
 		char *mount_point_from_hal;
 		const char *drive_udi;
@@ -1219,6 +1216,34 @@
 		}
 	}
 
+    /* override per-volume settings from HAL volume.policy.mount_option.* properties, if given */
+    if (volume != NULL) {
+        int i;
+        char **opt_from_hal_volume_policy;
+        const char *mount_options_from_hal;
+        LibHalDrive *volume_drive;
+
+        volume_drive = libhal_drive_from_udi (hal_ctx, 
+                            libhal_volume_get_storage_device_udi (volume));
+        if (volume_drive != NULL) {	
+
+            mount_options_from_hal = libhal_volume_policy_get_mount_options (volume_drive, volume, NULL);
+            if (mount_options_from_hal != NULL) {
+
+                g_ptr_array_free (mount_options, TRUE);
+                mount_options = g_ptr_array_new ();
+
+                opt_from_hal_volume_policy = g_strsplit (mount_options_from_hal, ",", 0);
+                for (i = 0; opt_from_hal_volume_policy[i] != NULL; i++) {
+                    g_ptr_array_add (mount_options, g_strdup (opt_from_hal_volume_policy[i]));
+                }
+                g_strfreev (opt_from_hal_volume_policy);
+            }
+
+            libhal_drive_free(volume_drive);
+        }
+    }
+
 	/* read per-volume settings from gconf and adjust if found */
 	if (volume != NULL && gconf_client != NULL) {
 		int n;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]