ports/114199: Patch to make konqueror's mediamanager respect HAL's "volume.policy.mount_option" for msdosfs

Rechistov Grigory ggg_mail at inbox.ru
Sun Jul 1 23:20:04 UTC 2007


>Number:         114199
>Category:       ports
>Synopsis:       Patch to make konqueror's mediamanager respect HAL's "volume.policy.mount_option" for msdosfs
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jul 01 23:20:04 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Rechistov Grigory
>Release:        6.2-STABLE
>Organization:
>Environment:
FreeBSD ip82-180.private.rt.mipt.ru 6.2-STABLE FreeBSD 6.2-STABLE #0: Thu Jun  7 01:06:01 UTC 2007     root at ip82-180.private.rt.mipt.ru:/usr/obj/usr/src/sys/DELL_v8  i386
>Description:
There's a bug in current implementation of konqueror mediamanager (KDE 3.5.6_1) - for example, flash drives with msdosfs (vfat) are mounted without locale setting, resulting in not showing certain filenames (e.g. written with russian letters). 

The same problem has been existed for other types of filesystems (ntfs, cd9660, udf) but was recently solved: the current locale is passed to /sbin/mount with "-C" flag. But this method doesn't work for msdosfs because its locale is set with -L and -D flags (there are different approaches to character conversion in kernel modules I suppose). There is a way to set a policy in HAL to pass the options. One need to create a file with smth like this:

$ cat /usr/local/etc/hal/fdi/policy/20-flash.fdi 
<?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>

The bug is - mediamanager does not respect this policy.

lissyara created a patch to solve this problem - see his article at http://www.lissyara.su/?id=1355 (russian)

I applied this patch and it works, so I wonder whether it can be merged in ports tree.

btw, there is a rumour that "mount_option" stuff is deprecated in HAL and will be replaced with smth, but I don't see any replacement keys in specs.

Software I use:

hal-0.5.8.20070403_2 (with FIXED_MOUNTPOINTS knob)
kdebase-3.5.6_3

>How-To-Repeat:
Insert FAT32 Flash drive with files that have international letters in names and mount it in konqueror with media:/ koislave.  You'll notice that such files has dissapeared.
>Fix:
Put the patch in /usr/ports/x11/kdebase3/files/ , recompile and reinstall kdebase3.
Create a policy file /usr/local/etc/hal/fdi/policy/20-flash.fdi, set your locale instead of ru_RU.KOI8-R an CP866.

Restart hald as root: /usr/local/etc/rc.d/hald restart
Restart KDE.


Patch attached with submission follows:

diff -Naur kioslave/media/mediamanager/halbackend.cpp kioslave/media/mediamanager/halbackend.cpp
--- kioslave/media/mediamanager/halbackend.cpp	Tue Apr 24 12:46:02 2007
+++ kioslave/media/mediamanager/halbackend.cpp	Tue Apr 24 13:01:21 2007
@@ -803,6 +803,33 @@
     s_HALBackend->DeviceCondition(udi, condition_name);
 }
 
+QStringList HALBackend::getHALmountoptions(QString udi)
+{
+   const char*   _ppt_string;
+    LibHalVolume* volume;
+    LibHalDrive* drive;
+
+    QString _ppt_QString;
+
+    volume = libhal_volume_from_udi( m_halContext, udi.latin1() );
+    if( volume )
+        drive = libhal_drive_from_udi( m_halContext, libhal_volume_get_storage_device_udi( volume ) );
+    else
+        drive = libhal_drive_from_udi( m_halContext, udi.latin1() );
+
+    if( !drive )
+           return QString::null;
+
+    if( volume )
+       _ppt_string = libhal_volume_policy_get_mount_options ( drive, volume, NULL );
+    else
+       _ppt_string = libhal_drive_policy_get_mount_options ( drive, NULL );
+
+    _ppt_QString = QString(_ppt_string ? _ppt_string : "");
+
+   return QStringList::split(",",_ppt_QString);
+}
+
 QStringList HALBackend::mountoptions(const QString &name)
 {
     const Medium* medium = m_mediaList.findById(name);
@@ -1246,10 +1273,25 @@
     }
 #endif
 
+    QStringList hal_mount_options = getHALmountoptions(medium->id());
+    for (QValueListIterator<QString> it=hal_mount_options.begin();it!=hal_mount_options.end();it++)
+    {
+       soptions << *it;
+       kdDebug()<<"HALOption: "<<*it<<endl;
+       if ((*it).startsWith("-L="))
+       {
+           soptions.remove("utf8");
+           kdDebug()<<"\"-L=\" found. Removing \"utf8\" from options."<<endl;
+       }
+    }
+
     const char **options = new const char*[soptions.size() + 1];
     uint noptions = 0;
     for (QStringList::ConstIterator it = soptions.begin(); it != soptions.end(); ++it, ++noptions)
-        options[noptions] = (*it).latin1();
+    {
+	options[noptions] = (*it).latin1();
+	kdDebug()<<"Option: "<<*it<<endl;
+    }
     options[noptions] = NULL;
 
     QString qerror = mount_priv(medium->id().latin1(), mount_point.utf8(), options, noptions, dbus_connection);
diff -Naur kioslave/media/mediamanager/halbackend.h kioslave/media/mediamanager/halbackend.h
--- kioslave/media/mediamanager/halbackend.h	Tue Apr 24 12:46:02 2007
+++ kioslave/media/mediamanager/halbackend.h	Tue Apr 24 13:03:13 2007
@@ -200,6 +200,8 @@
 				const char* message
 				);
 
+	QStringList getHALmountoptions(QString udi);
+
 /* HAL and DBus structures */
 private:
 	/**


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list