diff --git a/exo-mount/exo-mount-hal.c b/exo-mount/exo-mount-hal.c index 9e42ccb..23d6938 100644 --- a/exo-mount/exo-mount-hal.c +++ b/exo-mount/exo-mount-hal.c @@ -61,6 +61,7 @@ struct _ExoMountHalDevice /* file system options */ gchar **fsoptions; const gchar *fstype; + gchar *altfstype; LibHalVolumeUsage fsusage; }; @@ -168,6 +169,7 @@ exo_mount_hal_device_from_udi (const gchar *udi, gchar *volume_udi = NULL; gint n_volume_udis; gint n; + gchar *key; g_return_val_if_fail (udi != NULL, NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); @@ -243,6 +245,7 @@ err1: g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("Given device \"% /* setup the file system internals */ device->fstype = libhal_volume_get_fstype (device->volume); + device->altfstype = libhal_device_get_property_string (hal_context, udi, "volume.fstype.alternative.preferred", NULL); device->fsusage = libhal_volume_get_fsusage (device->volume); } } @@ -263,7 +266,16 @@ err1: g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("Given device \"% } /* determine the valid mount options from the UDI */ - device->fsoptions = libhal_device_get_property_strlist (hal_context, udi, "volume.mount.valid_options", &derror); + if (device->altfstype != NULL) + { + key = g_strdup_printf ("volume.mount.%s.valid_options", device->altfstype); + device->fsoptions = libhal_device_get_property_strlist (hal_context, udi, key, &derror); + g_free (key); + } + else + { + device->fsoptions = libhal_device_get_property_strlist (hal_context, udi, "volume.mount.valid_options", &derror); + } /* sanity checking */ if (G_UNLIKELY (device->file == NULL || device->name == NULL)) @@ -400,6 +412,7 @@ exo_mount_hal_device_free (ExoMountHalDevice *device) g_free (device->file); g_free (device->name); g_free (device->udi); + g_free (device->altfstype); g_free (device); } } @@ -665,6 +678,7 @@ exo_mount_hal_device_mount (ExoMountHalDevice *device, && (strcmp (device->fstype, "vfat") == 0 || strcmp (device->fstype, "iso9660") == 0 || strcmp (device->fstype, "udf") == 0 + || (device->altfstype && strcmp (device->altfstype, "ntfs-3g") == 0) || device->volume == NULL)) { options[n++] = g_strdup_printf ("uid=%u", (guint) getuid ()); @@ -686,6 +700,13 @@ exo_mount_hal_device_mount (ExoMountHalDevice *device, /* however this one is FreeBSD specific */ options[n++] = g_strdup ("longnames"); } + else if (strcmp (device->fsoptions[m], "umask=") == 0 + && device->altfstype != NULL + && strcmp (device->altfstype, "ntfs-3g") == 0) + { + /* we need to pass umask=0077 to ntfs-3g or else it gets 0777 perms */ + options[n++] = g_strdup_printf ("umask=0077"); + } } } @@ -703,11 +724,14 @@ exo_mount_hal_device_mount (ExoMountHalDevice *device, /* make sure that the mount point is usable (i.e. does not contain G_DIR_SEPARATOR's) */ mount_point = (mount_point != NULL && *mount_point != '\0') - ? exo_str_replace (mount_point, G_DIR_SEPARATOR_S, "_") + ? exo_str_replace (mount_point, G_DIR_SEPARATOR_S, "_") : g_strdup (""); /* let HAL guess the fstype */ - fstype = g_strdup (""); + if (G_UNLIKELY (device->altfstype != NULL)) + fstype = g_strdup (device->altfstype); + else + fstype = g_strdup (""); /* setup the D-Bus error */ dbus_error_init (&derror); @@ -835,7 +859,7 @@ oom: g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_NOMEM, "%s", g_strerror if (dbus_error_is_set (&derror)) { /* try to translate the error appropriately */ - if (strcmp (derror.name, "org.freedesktop.Hal.Device.Volume.PermissionDenied") == 0) + if (strcmp (derror.name, "org.freedesktop.Hal.Device.Volume.PermissionDenied") == 0) { /* TRANSLATORS: User tried to mount a volume, but is not privileged to do so. */ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("You are not privileged to mount the volume \"%s\""), device->name); @@ -1015,7 +1039,7 @@ oom: g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_NOMEM, "%s", g_strerror (EN if (G_UNLIKELY (dbus_error_is_set (&derror))) { /* try to translate the error appropriately */ - if (strcmp (derror.name, "org.freedesktop.Hal.Device.Volume.PermissionDenied") == 0) + if (strcmp (derror.name, "org.freedesktop.Hal.Device.Volume.PermissionDenied") == 0) { /* TRANSLATORS: User tried to unmount a volume, but is not privileged to do so. */ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("You are not privileged to unmount the volume \"%s\""), device->name);