hal: Branch 'master' - 3 commits

Danny Kukawka dkukawka at kemper.freedesktop.org
Mon Oct 27 10:43:54 PDT 2008


 doc/spec/hal-spec-properties.xml |   44 ++++++++++++++++++++
 tools/hal-storage-mount.c        |   84 +++++++++++++++++++++++++++++++--------
 2 files changed, 112 insertions(+), 16 deletions(-)

New commits:
commit 434b23a05ff61ca8c3002c6649831c14d5b96736
Merge: 0c3ec43... 9ef488e...
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Mon Oct 27 18:36:30 2008 +0100

    Merge branch 'master' of ssh://dkukawka@git.freedesktop.org/git/hal

commit 0c3ec436bfc5e6e64f0afc2baa82e80c16258aad
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Mon Oct 27 18:34:43 2008 +0100

    added support for alternative fstype to Mount()
    
    Added support for the new volume.fstype.alternative related
    keys to hal-storage-mount.c for proper Mount() support.

diff --git a/tools/hal-storage-mount.c b/tools/hal-storage-mount.c
index 3fa59f6..741b362 100644
--- a/tools/hal-storage-mount.c
+++ b/tools/hal-storage-mount.c
@@ -469,6 +469,7 @@ handle_mount (LibHalContext *hal_ctx,
 	char *action;
 	gboolean is_remount;
 	gboolean explicit_mount_point_given;
+	gboolean found_alternative_fstype = FALSE;
 	const char *end;
 #ifdef __FreeBSD__
 	struct passwd *pw;
@@ -640,10 +641,76 @@ handle_mount (LibHalContext *hal_ctx,
 			
 			i++;
 		}
+	}	
+
+	/* construct arguments to mount */
+	na = 0;
+	
+	args[na++] = MOUNT;
+
+	if (strlen (mount_fstype) > 0) {
+		mount_do_fstype = (char *) map_fstype (mount_fstype);
+		if (volume && strcmp(mount_do_fstype, mount_fstype) == 0) {
+			/* there was nothing mapped and we have a volume */
+			const char *_fstype;
+
+			_fstype = libhal_volume_get_fstype (volume);
+			/* check if the given fstype differs from the volume.fstype */
+			if (_fstype && (strcmp(_fstype, mount_fstype) != 0)) {
+				/* the fstype differs from the give fstype mount options, check if it's allowed as alternative */
+				char **alternative;
+
+				dbus_error_init (&error);
+			        alternative = libhal_device_get_property_strlist (hal_ctx, udi, "volume.fstype.alternative", &error);
+			        if (dbus_error_is_set (&error)) {
+			                unknown_error ("Cannot get volume.fstype.alternative");
+			                dbus_error_free (&error);
+        			} else if (alternative != NULL) {
+					for (i = 0; alternative[i] != NULL; i++) {
+#ifdef DEBUG
+						printf ("check volume.fstype.alternative[%d]='%s' for given fstype '%s'\n", i, alternative[i], mount_fstype);
+#endif
+						if (strcmp(alternative[i], mount_fstype) == 0) {
+							printf ("found_alternative_fstype = TRUE\n");
+							found_alternative_fstype = TRUE;
+							break;
+						}
+					}
+					libhal_free_string_array(alternative);
+				}
+				if (!found_alternative_fstype) {
+					/* We have a given fstype option, which isn't allowed as 
+					   as alternative fstype.
+					   TODO: add error message and handling or exit/refuse mount
+					*/
+				}
+
+			}
+		}
+
+	} else if (volume == NULL) {
+		/* non-pollable drive; force auto */
+		mount_do_fstype = "auto";
+	} else if (libhal_volume_get_fstype (volume) != NULL && strlen (libhal_volume_get_fstype (volume)) > 0) {
+		mount_do_fstype = (char *) map_fstype (libhal_volume_get_fstype (volume));
+	} else {
+		mount_do_fstype = "auto";
 	}
 
+	/* check the mount options */
 	dbus_error_init (&error);
-	allowed_options = libhal_device_get_property_strlist (hal_ctx, udi, "volume.mount.valid_options", &error);
+	
+	if (found_alternative_fstype) {
+		char key[128];
+
+		sprintf(key, "volume.mount.%s.valid_options", mount_do_fstype);		
+#ifdef DEBUG
+		printf ("found alternative fstype='mount_do_fstype' checking now '%s'", key);
+#endif
+		allowed_options = libhal_device_get_property_strlist (hal_ctx, udi, key, &error);
+	} else {
+		allowed_options = libhal_device_get_property_strlist (hal_ctx, udi, "volume.mount.valid_options", &error);
+	}
 	if (dbus_error_is_set (&error)) {
 		unknown_error ("Cannot get volume.mount.valid_options");
 		dbus_error_free (&error);
@@ -727,21 +794,6 @@ handle_mount (LibHalContext *hal_ctx,
 		}
 	}
 
-
-	/* construct arguments to mount */
-	na = 0;
-	
-	args[na++] = MOUNT;
-	if (strlen (mount_fstype) > 0) {
-		mount_do_fstype = (char *) map_fstype (mount_fstype);
-	} else if (volume == NULL) {
-		/* non-pollable drive; force auto */
-		mount_do_fstype = "auto";
-	} else if (libhal_volume_get_fstype (volume) != NULL && strlen (libhal_volume_get_fstype (volume)) > 0) {
-		mount_do_fstype = (char *) map_fstype (libhal_volume_get_fstype (volume));
-	} else {
-		mount_do_fstype = "auto";
-	}
 	args[na++] = MOUNT_TYPE_OPT;
 	args[na++] = mount_do_fstype;
 
commit c6eb44926efaa0e406ccab33964745e1f8e3e24d
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Mon Oct 27 18:25:12 2008 +0100

    added new properties to mount alternative fstypes as e.g. ntfs-3g
    
    Added new properties to mount alternative fstypes as e.g. ntfs-3g
    to the spec:
    - volume.fstype.alternative (string list)
      --> e.g. ntfs-3g, ntfs-fuse
    - volume.mount.[alternative].valid_options
      --> e.g. volume.mount.ntfs-3g.valid_options={'ro','nodev',...}
    - volume.unmount.[alternative].valid_options
      --> e.g. volume.unmount.ntfs-3g.valid_options={'lazy',...}
    
    These new keys need some changes in the existing mount tools (as
    e.g. under KDE, GNOME) to use the new features. To take advantage
    of the new keys, the related mount handler (or filesystem) as e.g.
    ntfs-3g need to deliver a own FDI-file which set the needed keys.
    
    To use the new feature with the Mount() method of the
    org.freedesktop.Hal.Device.Volume interface the caller need to
    pass the alternative fstype to the fstype parameter of the method.
    Otherwise the original fstype (detected by HAL) is used to mount.
    If a alternative fstype is passed to the method, only the in
    volume.mount.[alternative].valid_options listed options are allowed.

diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 9960525..3d47c13 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -7437,6 +7437,50 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
             </row>
             <row>
               <entry>
+                <literal>volume.fstype.alternative</literal> (string list)
+              </entry>
+              <entry>examples: ntfs-3g, ntfs-fuse</entry>
+              <entry>No (only if there is a alternative mount handler)</entry>
+              <entry>The allowed (and installed) alternative mount handler/filesystem(s).</entry>
+            </row>
+            <row>
+              <entry>
+                <literal>volume.mount.[alternative].valid_options</literal> (string list)
+              </entry>
+              <entry>examples: locale=, uid=</entry>
+              <entry>
+		Yes, if <literal>volume.fstype.alternative</literal> is set and if the 
+		<literal>org.freedesktop.Hal.Device.Volume</literal> interface is defined.
+	      </entry>
+              <entry>
+		List of the allowed (valid) mount options for the defined alternative filesystem
+		handler. Replace <literal>[alternative]</literal> in the property string with the 
+		name of the alternative filesystem handler. For e.g. ntfs-3g the property would be: 
+		<literal>volume.mount.ntfs-3g.valid_options</literal>.
+		
+		NOTE: To mount the volume with the alternative handler/filesystem you have
+		      to pass the correct (alternative) fstype parameter to the Mount() method
+		      of the <literal>org.freedesktop.Hal.Device.Volume</literal> interface
+	      </entry>
+            </row>
+            <row>
+              <entry>
+                <literal>volume.unmount.[alternative].valid_options</literal> (string list)
+              </entry>
+              <entry>examples: lazy</entry>
+              <entry>
+		No, only available if <literal>volume.fstype.alternative</literal> is set and 
+		if the <literal>org.freedesktop.Hal.Device.Volume</literal> interface is defined.
+	      </entry>
+              <entry>
+		List of the allowed (valid) unmount options for the defined alternative filesystem
+		handler. Replace <literal>[alternative]</literal> in the property string with the 
+		name of the alternative filesystem handler. For e.g. ntfs-3g the property would be: 
+		<literal>volume.unmount.ntfs-3g.valid_options</literal>
+	      </entry>
+            </row>
+            <row>
+              <entry>
                 <literal>volume.fsversion</literal> (string)
               </entry>
               <entry>example: FAT32</entry>


More information about the hal-commit mailing list