! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Incomplete compilance of exo-mount to HAL 0.5.9 specification, resulting in n...
Status:
RESOLVED: FIXED

Comments

Description GGG 2007-02-10 13:04:00 CET
I have Xfce 4.4.0 with thunar-volman installed. I also have ru_RU.KOI8-R (Russian) locale. When new storage appears, it is mounted without respecting locale, and files with russian names do not show. So I added next lines into /usr/local/share/hal/fdi/policy/10osvendor/20-storage-methods.fdi in appropriate place to allow such options:
<!-- allow these mount options for vfat -->
...
<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="FreeBSD">
...
<append key="volume.mount.valid_options" type="strlist">-L=</append>
<append key="volume.mount.valid_options" type="strlist">-D=</append>
</match>

(In FreeBSD mount call has somewhat weird look: mount -t msdosfs -o-L=ru_RU.KOI8-R,-D=CP866 ; In Linux there are already options "iocharset=" and "codepage=" )

Then I created /usr/local/etc/hal/fdi/policy/codepage.fdi according to some research in Internet:

<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- -->
<deviceinfo version="0.2">
<device>
<match key="volume.fstype" string="vfat">
<merge key="volume.policy.mount_option.-L=ru_RU.KOI8-R" type="bool">true</merge>
<merge key="volume.policy.mount_option.-D=CP866" type="bool">true</merge>
</match>
</device>
</deviceinfo>

Then I expected that everything will be fine. Alas, nothiing changed.
lshal --long reports that options are present:

info.hal_mount.created_mount_point = '/media/GGG'S FLASH'  (string)
volume.policy.mount_option.-D=CP866 = true  (bool)
volume.policy.mount_option.-L=ru_RU.KOI8-R = true  (bool)
volume.mount.valid_options = {'ro', 'noexec', 'longnames', 'shortnames', 'nowi
n95', '-L=', '-D='} (string list)

But if you have a look into thunar-volman's code, you'll see it calls exo-mount, and when you check exo-mount-hal.c file, you'll see next:

/* determine the valid mount options from the UDI */
  device->fsoptions = libhal_device_get_property_strlist (hal_context, udi, "volume.mount.valid_options", 
&derror);

I.e. program checks valid options, but doesn't use any _given_ ones! They should be taken from volume.policy.mount_option.* . For example, code shipped in hal package do the same mounting with respect of options (in file hal-stroage-mount.c in handle_mount() ):

 /* construct arguments to mount */
        na = 0;
        args[na++] = MOUNT;
        if (strlen (mount_fstype) > 0) {
                args[na++] = "-t";
                args[na++] = (char *) map_fstype (mount_fstype);
        } else if (volume == NULL) {
                /* non-pollable drive; force auto */
                args[na++] = "-t";
                args[na++] = "auto";
        } else if (libhal_volume_get_fstype (volume) != NULL && strlen (libhal_volume_get_fstype (volume)) > 0) {
                args[na++] = "-t";
                args[na++] = (char *) map_fstype (libhal_volume_get_fstype (volume));
        }

        args[na++] = "-o";
        mount_option_str = g_string_new(MOUNT_OPTIONS);
        for (i = 0; given_options[i] != NULL; i++) {
                g_string_append (mount_option_str, ",");
                g_string_append (mount_option_str, given_options[i]);
        }
        args[na++] = g_string_free (mount_option_str, FALSE); /* leak! */
        args[na++] = (char *) device;
        args[na++] = mount_dir;
        args[na++] = NULL;

        /* now try to mount */
        if (!g_spawn_sync ("/",
                           args,
                           NULL,
                           0,
                           NULL,
                           NULL,
                           &sout,
                           &serr,
                           &exit_status,
                           &err)) {
                printf ("Cannot execute %s\n", MOUNT);
                g_unlink (cbh_path);
                g_rmdir (mount_dir);
                unknown_error ();
        }

So, exo-mount should either use hal-storage-mount (by means of hald) either implement its own similar method to respect this policiy and, may be, some GUI to allow to edit such options. I've read that the similar bug is present in KDE's hal-using mounting system.

Thank you.
Comment 1 George Kibardin 2007-02-24 17:57:55 CET
I've created patch and I'm using it. I hope this may help:

--- exo-mount/exo-mount-hal.c.orig      2007-01-20 16:58:22.000000000 +0300
+++ exo-mount/exo-mount-hal.c   2007-02-24 20:27:42.000000000 +0300
@@ -679,6 +679,25 @@
         }
     }
 
+  if (G_LIKELY (device->volume != NULL))
+    {      
+      const gchar *mount_options = libhal_volume_policy_get_mount_options(device->drive, device->volume, NULL);
+      gint pos = 0;
+      do
+       {
+         if (mount_options[pos] == ',' || mount_options[pos] == '\0')
+           {
+             options[n++] = g_strndup (mount_options, pos);
+             if (mount_options[pos] == ',')
+               pos++;
+             mount_options += pos;
+             pos = 0;
+           }
+       }
+      while (mount_options[pos++] != '\0');
+    }
+
+
   /* try to determine a usable mount point */
   if (G_LIKELY (device->volume != NULL))
     {
Comment 2 Brian J. Tarricone (not reading bugmail) 2007-05-05 07:15:48 CEST
The libhal_policy_*() API is deprecated, and there's currently no replacement (well, some of it is replaced with PolicyKit, I believe, but not volume-/mount-related stuff).  What HAL 0.5.9 specification are you looking at?  The current spec doesn't define any 'volume.policy.*' properties.

See http://people.freedesktop.org/~david/hal-spec/hal-spec.html
That's 0.5.10, but at present it's more or less identical to 0.5.9.
Comment 3 GGG 2007-05-06 13:23:50 CEST
(In reply to comment #2)
> The libhal_policy_*() API is deprecated, and there's currently no replacement
> (well, some of it is replaced with PolicyKit, I believe, but not
> volume-/mount-related stuff).  What HAL 0.5.9 specification are you looking at?
>  The current spec doesn't define any 'volume.policy.*' properties.
> 
> See http://people.freedesktop.org/~david/hal-spec/hal-spec.html
> That's 0.5.10, but at present it's more or less identical to 0.5.9.
> 

Actually, HAL version 0.5.10 is quite different from 0.5.9, that's why there are no volume.policy.* properties. Nevertheless the problem still exists - no options are passed to mount (3) and indeed no customiseable settings are available in HAL itself (at least according to 0.5.10 spec)
Comment 4 Benedikt Meurer editbugs 2007-05-20 14:19:43 CEST
I'm not up2date with the HAL stuff atm, but from my understanding, all the policy stuff introduced earlier is now deprecated and should not be used by applications.
Comment 5 Alexander E. Patrakov 2007-09-13 13:51:06 CEST
Still, there must be a per-filestsrem preference about mount options. Keep them in a configuration file or whatever else, if HAL has no place to keep them. With default options, FAT filesystems are just unusable for non-English speakers.
Comment 6 Alexander Drozdov 2007-11-29 15:02:09 CET
Hi all, I observe that this issue is not fixed on latest SVN trunk. I create some draft solution for assign per-fs options for mounting. Also I am very confused that in HAL 0.5.10 was remove volume.policy rules :(

My path:
------------- begin
--- exo-mount-hal.c.orig        2007-11-29 20:26:09.000000000 +1000
+++ exo-mount-hal.c     2007-11-30 00:46:42.000000000 +1000
@@ -40,8 +40,6 @@
 
 #include <exo-mount/exo-mount-hal.h>
 
-
-
 static gboolean exo_mount_hal_init            (GError   **error);
 static void     exo_mount_hal_propagate_error (GError   **error,
                                                DBusError *derror);
@@ -70,7 +68,6 @@
 static DBusConnection *dbus_connection = NULL;
 
 
-
 static gboolean
 exo_mount_hal_init (GError **error)
 {
@@ -636,13 +633,67 @@
   gchar      **options;
   gchar       *fstype;
   gchar       *s;
+  gchar        opt_string[1024];
+  gchar      **sub_str;
+  gchar      **add_options;
+  gchar      **add_s;
+  const gchar *cs = g_getenv("HOME");;
+  gchar       *opt_file;
+  gint         add_opt_count = 0;
   gint         m, n = 0;
 
   g_return_val_if_fail (device != NULL, FALSE);
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
+  if(cs == NULL)
+  {
+       opt_file = "/.exo_mount_ops";
+  }
+  else
+  {
+       opt_file = g_strconcat(cs, "/.exo_mount_ops", NULL);
+  }
+
+  /* Get additional mount options */
+  FILE *fp = fopen(opt_file, "r");
+  if (fp != NULL)
+  {
+     printf("Additional fs options found\n");
+
+     while(1)
+     {
+        fgets(opt_string, sizeof(opt_string), fp);
+        sub_str = g_strsplit(opt_string, ":", -1);
+
+        printf("FS: %s\nOP: %s\nHAL_FS: %s\n", sub_str[0], sub_str[1], device->fstype);
+        if (strcmp(device->fstype, sub_str[0]) == 0)
+        {
+           add_options = g_strsplit(sub_str[1], ",", -1);
+           for(add_s = add_options; *add_s != NULL; ++add_s)
+           {
+              add_opt_count++;
+           }
+           printf("Hatred: hal_opt_count = %d\n", add_opt_count);
+           break;
+        }
+
+        if(feof(fp))
+        {
+           break;
+        }
+     }
+     
+     fclose(fp);
+  }
+  else
+  {
+       printf("Can't find user opt file: %s\n", opt_file);
+  }
+  
+  g_free(opt_file);
+
   /* determine the required mount options */
-  options = g_new0 (gchar *, 20);
+  options = g_new0 (gchar *, (20 + add_opt_count));
 
   /* check if we know any valid mount options */
   if (G_LIKELY (device->fsoptions != NULL))
@@ -679,6 +730,16 @@
         }
     }
 
+  if (add_opt_count != 0)
+  {
+       for(m = 0; m < add_opt_count; ++m)
+       {
+               options[n++] = g_strdup (add_options[m]);
+               g_free(add_options[m]);
+       }
+       g_free(add_options);
+  }
+
   /* try to determine a usable mount point */
   if (G_LIKELY (device->volume != NULL))
     {
------------- end

Config file is '.exo_mount_ops' and stored in user's home dir:
------------- begin
vfat:iocharset=utf8,codepage=1251,quiet
iso9660:iocharset=utf8
------------- end
All options should be assepted for use in HAL (can check by call hal-device)

I think, that best solution is create xml config file for more difficult configuration, for ex: mount floppy without 'sync' opt but mount flash with 'flush' opt
Comment 7 Franck Vandelanoitte 2007-11-29 15:39:54 CET
Nice patch.
However it would be better if you could follow the freedesktop recommendations for the location of the config file:
http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
Most XFCE components are followig this.
The default location should be $HOME/.config
Comment 8 Alexander Drozdov 2007-11-29 16:01:35 CET
It draft and quick solution ;) I will develop more clear solution, and, also will fix config paths.
Comment 9 Brian J. Tarricone (not reading bugmail) 2007-11-29 18:33:20 CET
As I said before, policykit will handle this sort of thing.  A half-baked temporary solution until your distro supports it doesn't sound like a good idea, IMHO.
Comment 10 Yves-Alexis Perez editbugs 2008-03-27 18:31:25 CET
(In reply to comment #9)
> As I said before, policykit will handle this sort of thing.  A half-baked
> temporary solution until your distro supports it doesn't sound like a good
> idea, IMHO.
> 

It seems that Desktop Environment should be the one responsible for managing this. Currently only Gnome manages to do this. http://www.linuxfromscratch.org/blfs/view/svn/general/hal.html has some tips about this (search for Configuration).
Comment 11 Yves-Alexis Perez editbugs 2008-04-27 13:30:15 CEST
Is there any news on this? :/
Comment 12 Artyom Smirnov 2008-05-27 12:10:45 CEST
How about this patch? http://www.sisyphus.ru/srpm/Sisyphus/exo/patches/4
I use all patchset from ALT Linux in Arch Linux.
Comment 13 Yves-Alexis Perez editbugs 2008-05-27 12:29:04 CEST
Does (In reply to comment #12)
> How about this patch? http://www.sisyphus.ru/srpm/Sisyphus/exo/patches/4
> I use all patchset from ALT Linux in Arch Linux.
> 

Hmhmh, I have two questions about this patch:

- why clearing LC_CTYPE?
- does this mean there's a global environment variable for all filesystems where you can set a charset?

Cheers,
Comment 14 Artyom Smirnov 2008-05-27 12:48:09 CEST
(In reply to comment #13)
> - why clearing LC_CTYPE?
I don't know exactly, this is not my patch :)


> - does this mean there's a global environment variable for all filesystems
> where you can set a charset?
No, this variable only for forcing iocharset. This patch adds ability to add iocharset into mount options if iocharset exists in HAL policy for this file system.


Comment 15 Yves-Alexis Perez editbugs 2008-05-27 13:04:34 CEST
(In reply to comment #14)
> (In reply to comment #13)
> > - why clearing LC_CTYPE?
> I don't know exactly, this is not my patch :)

You use patches you don't know exactly what they do? :)
> 
> 
> > - does this mean there's a global environment variable for all filesystems
> > where you can set a charset?
> No, this variable only for forcing iocharset. This patch adds ability to add
> iocharset into mount options if iocharset exists in HAL policy for this file
> system.
>
ha yes, ok, understood. Looks nice. I may try it, but it'd be indeed nice if Benny could comment on it.

Does it work fine on your users systems?

Cheers,

Comment 16 Artyom Smirnov 2008-05-27 13:12:08 CEST
(In reply to comment #15)
> You use patches you don't know exactly what they do? :)
Second part was more interesting for me :D

> ha yes, ok, understood. Looks nice. I may try it, but it'd be indeed nice if
> Benny could comment on it.
> 
> Does it work fine on your users systems?
Yes, looks like all work fine, but HAL policies must be setted correctly of course. Like:

<match key="volume.fstype" string="vfat">
  ...
  <append key="volume.mount.valid_options" type="strlist">iocharset=</append>
  ...
</match>

in /usr/share/hal/fdi/policy/10osvendor/20-storage-methods.fdi (in Arch Linux).

Comment 17 Alexander E. Patrakov 2008-05-27 13:28:52 CEST
(In reply to comment #13)
> - why clearing LC_CTYPE?

Read the patch: it doesn't _clear_ LC_CTYPE, but sets it from the environment instead. This is required for nl_langinfo (CODESET) to work.

> - does this mean there's a global environment variable for all filesystems
> where you can set a charset?

Yes, because the character set from the locale is the only sensible choice (all other values lead to wrong output of "ls").

However, the patch is linux-specific.
Comment 18 Evgeny V. Tregubov 2009-03-11 12:00:50 CET
Hm, as I can see in xfce-4.6 don't have support of codepage too? Why? :(
Comment 19 Alexander Drozdov 2009-03-14 16:41:15 CET
Created attachment 2233 
Solution for setting up mount options

Hi all, my second patch for exo-mount ;)

now it is based on code from PCManFM and used ini-like configuration file for setting up mount options.

Example of configuration file:
------ cut ------
[vfat]
mount_options=shortname=mixed;uid=;utf8;umask=077;exec;flush

# mount_options=shortname=mixed;uid=;utf8;umask=077;exec;usefree
# Sometimes, adding a 'usefree' option is required due to bugs in the kernel.
# See: https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/133567

[udf]
mount_options=uid=;exec

[ntfs-3g]
mount_options=locale=;exec

[ntfs]
mount_options=umask=222;utf8;exec
fstype_override=ntfs-3g

[iso9660]
mount_options=uid=;utf8;exec

[hfs]
mount_options=uid=
------ cut ------

yes, now we can override file system type: useful when we use ntfs-3g for ex.

Patch & config in one file: http://hatred.homelinux.net/wiki/_media/zhurnal:2009-03-15_02.10_xfce_4.6_exo_i_opjat_opcii_montirovanija:patch.tar.gz
For russian users: http://hatred.homelinux.net/wiki/zhurnal:2009-03-15_02.10_xfce_4.6_exo_i_opjat_opcii_montirovanija
Comment 20 Alexander Drozdov 2009-03-14 16:45:05 CET
Wow, bug is two years old :-)
Comment 21 Alexander Drozdov 2009-03-15 10:44:38 CET
In my patch present error: exo-mount can't found global configuration file.

for fix change:
#define CONFIG_FILE_GLOBAL     DATADIR "xfce4/mount.rules"

to
#define CONFIG_FILE_GLOBAL     DATADIR "/xfce4/mount.rules"
Comment 22 Yves-Alexis Perez editbugs 2009-10-09 13:25:31 CEST
Is this one a dupe from (now closed) bug #4294 ?
Comment 23 Nick Schermer editbugs 2009-10-17 11:08:44 CEST
Ok implemented. All the hard coded mount options are now read from an rc file. See this commit for the patch: http://git.xfce.org/xfce/exo/patch/?id=94acf3844546d235dc310ab9303917fe96efeec3
Comment 24 Nick Schermer editbugs 2009-10-17 11:16:19 CEST
Patch in the xfce-4.6 branch (against exo 0.3.104) http://git.xfce.org/xfce/exo/patch/?id=54ffc5d16920b60ecddb66777fcff90d9e6251c2.
Comment 25 Nick Schermer editbugs 2009-10-17 11:25:52 CEST
*** Bug 3792 has been marked as a duplicate of this bug. ***

Bug #2891

Reported by:
GGG
Reported on: 2007-02-10
Last modified on: 2009-10-17
Duplicates (1):
  • 3792 UTF-8 and mounting vfat/ntfs partitions

People

Assignee:
Nick Schermer
CC List:
12 users

Version

Attachments

Solution for setting up mount options (10.17 KB, patch)
2009-03-14 16:41 CET , Alexander Drozdov
no flags

Additional information