Bug 74614 - Mounting removable media with wrong iocharset option.
Summary: Mounting removable media with wrong iocharset option.
Status: VERIFIED FIXED
: 78101 (view as bug list)
Alias: None
Product: SUSE LINUX 10.0
Classification: openSUSE
Component: Basesystem (show other bugs)
Version: Beta 3
Hardware: All All
: P5 - None : Major
Target Milestone: ---
Assignee: Danny Kukawka
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-28 12:41 UTC by Zhe Su
Modified: 2007-06-05 11:11 UTC (History)
2 users (show)

See Also:
Found By: Other
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
Patch to export iocharset option according to system locale setting. (2.03 KB, text/x-patch)
2005-08-12 06:22 UTC, Zhe Su
Details
new mount-subfs.c to make use of the iocharset information exported by hal. (14.41 KB, text/plain)
2005-08-12 06:23 UTC, Zhe Su
Details
New rc.hal to load system language setting before launching hald. (3.96 KB, application/octet-stream)
2005-08-12 06:24 UTC, Zhe Su
Details
Patch to get rid off kernel vfat warning when using iocharset=utf8 option. (760 bytes, text/x-patch)
2005-08-12 07:14 UTC, Zhe Su
Details
submount-get-iocharset script to print the corresponding iocharset value of current locale. (726 bytes, application/octet-stream)
2005-08-12 15:11 UTC, Zhe Su
Details
patch for mount-subfs.c to get iocharset value by invoking submount-get-iocharset script. (1.61 KB, text/x-patch)
2005-08-12 15:13 UTC, Zhe Su
Details
Patch for submountd to ensure correct mount options for any filesystems. (773 bytes, patch)
2005-08-13 06:26 UTC, Zhe Su
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zhe Su 2005-03-28 12:41:34 UTC
In SL 9.2 the script /etc/hotplug/hotplug.subfs.functions mount_media () is used
to mount removable media, correct iocharset option is set there corresponding to
current system language.

But I found that this script is not used anymore in SL9.3. iocharset option will
never be set for removable media.
Comment 1 Zhe Su 2005-03-28 12:53:00 UTC
See bug #55268 to see what we have done for old hotplug system.
Comment 2 Mike Fabian 2005-03-30 10:25:49 UTC
See also bug #62785.

Comment 3 Mike Fabian 2005-03-30 10:27:29 UTC
According to bug #62785 we should use "utf8=true" instead of "iocharset=utf8"
in the case of UTF-8 because "utf8=true" works without a warning.
Comment 4 Zhe Su 2005-03-30 10:37:32 UTC
But the current problem is that hotplug.subfs.functions is obsoleted in SL9.3.
We can't fix this issue in this script like what we have done for SL9.2.

And I couldn't understand how does current hotplug subsystem work, especially
where the removable media is actually mounted.

btw, we should use utf8=true only for UTF-8 locale combined with vfat/fat
filesystem. iocharset=xxx should always be used for other locales and filesystems.
Comment 5 Mike Fabian 2005-03-30 10:40:31 UTC
Zhe> But the current problem is that hotplug.subfs.functions is
Zhe> obsoleted in SL9.3.  We can't fix this issue in this script like
Zhe> what we have done for SL9.2.

Yes.

Zhe> btw, we should use utf8=true only for UTF-8 locale combined with
Zhe> vfat/fat filesystem. iocharset=xxx should always be used for
Zhe> other locales and filesystems.

Yes, that's true. utf8=true is a special case.
Comment 6 Danny Al-Gaaf 2005-03-30 16:22:59 UTC
This is IMHO a problem of subfs, reassign this bug
Comment 7 Mike Fabian 2005-04-26 09:26:27 UTC
*** Bug 78101 has been marked as a duplicate of this bug. ***
Comment 8 Zhe Su 2005-07-04 02:18:47 UTC
How about this bug? Is it fixed in current stable?
Comment 9 Danny Al-Gaaf 2005-07-04 07:40:42 UTC
I can fix the utf part for fat/vfat by default and/or through HAL information 
(volume.policy.mount_option.iocharset=utf8 = true/false), no problem. 

I can add also a check of HAL for a other than utf8 iocharset option, set by 
user through a fdi-file to the submount binary.

But for stable was planed a new solution for mount. But I'm not sure if there 
anything happens.
Comment 10 Mike Fabian 2005-07-06 11:25:09 UTC
Please try to fix this for the next SuSE Linux release!

It is very annoying that this was broken again in SuSE Linux 9.3.
Comment 11 Danny Al-Gaaf 2005-07-06 11:38:02 UTC
Currently the submount binary called by hal mount never a device with utf8=true 
or iocharset=??? . I'm not sure if this is really a problem, but I can as I sad 
add this to the binary. But as I also sad: I'm not sure if this is maybe lost 
work if there is a other solution for 10.0.

@Adrian: what should we do for 10.0?
Comment 12 Adrian Schröter 2005-07-06 11:43:29 UTC
first of all we should use the mount options provided by HAL. It is disabled 
currently because they was mostly wrong and prevented a successfull mounting. 
This should get fixed. 
 
The new solution is only an extended solution, so no work here will be lost. 
 
 
Comment 13 Danny Al-Gaaf 2005-07-06 12:00:57 UTC
o.k. I add utf support to the submount binary like the fix for sync option. 

Is it really needed to mount the other devices with iocharset option (besides 
for fat/vfat) in 10.0? Is there a case where a hotplugged device is mounted with 
a iocharset other than the system iocharset?

For general iocharset option I can do this:
- add a function to hal to check the current iocharset (like in hotplug.subfs.
functions) and add a entry to the machine root-entry in hal (../Hal/devices/
computer).
- check by mount for the hal entry and if there is maybe a other entry (maybe 
merged by a fdi file) for the volume and use them.


Other question: Who add on STABLE Snapshot the /media/dvdram entry to fstab? If 
this was yast: Is this really needed since hal/submount mount the CD/DVD 
volumes? Same problem for the dirs in /media. Must Yast changed?
Comment 14 Zhe Su 2005-07-06 14:27:31 UTC
Hi, the following is my understanding by reading the source code:

1) Now we have four kernel module options for encoding issue: iocharset, nls,
codepage and utf8.
2) As I know the following filesystems need encoding setting:
  * fat/vfat:
    support codepage, iocharset and utf8 options. codepage is for short file
name, while utf8 and iocharset are for long file name. utf8 has higher priority
than iocharset, but iocharset is necessary even utf8 is used. So for fat/vfat,
all this three options should be set according to the current locale setting.
  * ntfs:
    support iocharset and nls. iocharset is obsoleted by nls. utf8 is not
supported by ntfs. So use nls for ntfs. 
  * ISO9660/JOLIET:
    support utf8 and iocharset. For utf8 locale use either utf8 or iocharset.
For other locale iocharset is necessary.
  * UDF:
    same as ISO9660.
  * Other filesystems: smbfs, cifs, ncpfs, jfs, befs all support iocharset or
codepage options.

3) the default kernel codepage and iocharset are set to "cp437" and "iso8859-1"

So you see, it's not so easy. We must use appoprate option(s) for different
filesystems and locale settings.
Comment 15 Zhe Su 2005-08-12 02:33:34 UTC
Is there any progress on this bug? I think we should fix this bug asap. It's so
anonying.

According to comment #13, we need implement the following features:

- add a function to hal to check the current iocharset (like in hotplug.subfs.
functions) and add a entry to the machine root-entry in hal (../Hal/devices/
computer).
- check by mount for the hal entry and if there is maybe a other entry (maybe 
merged by a fdi file) for the volume and use them.

So I think we need patch both hal and submount (mount-subfs.c).

If you are too busy to implement it, I'd like to have a try.
Comment 16 Zhe Su 2005-08-12 02:45:42 UTC
I'm thinking about whether it's suitable to add an entry to hal for current
iocharset (locale ctype). Because hal stands for hardware abstract layer
(right?), while iocharset information is nothing to do with hardware.
Comment 17 Zhe Su 2005-08-12 06:13:56 UTC
Ok, I tried to fix this issue by patching hal and submount. The patch and
updated files will be attached.

I did the following work:

1) hal-0.5.4cvs/hald/linux2/osspec.c was patched to attach property
"system.default_iocharset" to "/org/freedesktop/Hal/devices/computer" device,
according to the current locale.
2) modify rc.hal to load /etc/SuSEconfig/profile or /etc/profile.d/lang.sh, so
that hald could get current locale setting.
3) modify mount-subfs.c in submount package to get "system.default_iocharset"
property and use it as value of iocharset mount option.

I use only "iocharset" option here, because submountd will handle all exceptions
when iocharset is not valid.

I tested it on SUSE 10 beta 1, tt worked correctly.
Comment 18 Zhe Su 2005-08-12 06:22:06 UTC
Created attachment 45851 [details]
Patch to export iocharset option according to system locale setting.
Comment 19 Zhe Su 2005-08-12 06:23:31 UTC
Created attachment 45852 [details]
new mount-subfs.c to make use of the iocharset information exported by hal.
Comment 20 Zhe Su 2005-08-12 06:24:51 UTC
Created attachment 45853 [details]
New rc.hal to load system language setting before launching hald.
Comment 21 Zhe Su 2005-08-12 06:35:01 UTC
Please review this solution and fix this bug asap.
There is only one issue that iocharset=utf8 on vfat will cause a kernel warning.
See bug #60085.
I'll try to patch submount to get rid off this warning.
Comment 22 Zhe Su 2005-08-12 07:14:35 UTC
Created attachment 45857 [details]
Patch to get rid off kernel vfat warning when using iocharset=utf8 option.

See bug #60085 and #62785 for details of this issue.
Comment 23 Zhe Su 2005-08-12 07:18:12 UTC
With patches and updated files in comment #18, comment #19, comment 20 and
comment #22, this bug could be fixed completely.

I tested it on SUSE 10 beta 1 i386 system, it worked without problem, no matter
whether the system locale is UTF-8 or not.
Comment 24 Danny Al-Gaaf 2005-08-12 09:12:50 UTC
to comment #16: We can't add this this HAL. The reason: if the someone change e.
g. with yast the language of the system hal never get a information about this 
and hence hal provides wrong information. We need to move the check to mount-
subfs.c (patch rc.hal isn't needed)

to comment #17: IMHO submountd does not handle all exceptions when iocharset 
option is not valid. For example: iocharset for ntfs is depricated. We must use 
nls for ntfs and submount never check or change this.

to patch of mount-subfs.c: please use getpac for the last version of the file .
.. you removed a important codepart. :-)

I'm not sure if we need to patch submountd-0.9/submountd.c because the fstype 
check in mount-subfs.c is not up-to-date. HAL should detect also ext2 and vfat 
correct, so we should change the mountoption for vfat as for ntfs
Comment 25 Zhe Su 2005-08-12 09:26:23 UTC
So, could you please help fix this issue? Or if you have no time, could you
please send me the latest version of submount so that I could try to fix it again.
Comment 26 Zhe Su 2005-08-12 09:30:53 UTC
And for ntfs issue, we could handle it within submountd just like vfat. Because
it's much simpler. Then we could use only iocharset within mount-subfs.c to make
it as simple as possible.
Comment 27 Zhe Su 2005-08-12 15:10:00 UTC
Ok, another try.

A script submount-get-iocharset was added to print the corresponding iocharset
of current locale setting.

A patch for mount-subfs.c to get iocharset value by invoking
submount-get-iocharset script.

So that patching hal is not necessary anymore.
Comment 28 Zhe Su 2005-08-12 15:11:34 UTC
Created attachment 45930 [details]
submount-get-iocharset script to print the corresponding iocharset value of current locale.
Comment 29 Zhe Su 2005-08-12 15:13:30 UTC
Created attachment 45931 [details]
patch for mount-subfs.c to get iocharset value by invoking submount-get-iocharset script.

submount-get-iocharset should be put into /usr/sbin
Comment 30 Danny Al-Gaaf 2005-08-12 15:28:36 UTC
Sorry for the delay to comment #26.

The new version (from #27 - #29) looks good for me. I would add this to the 
submount package if it's o.k. for you. 

Thanks for the patch.
Comment 31 Zhe Su 2005-08-12 15:42:22 UTC
Thanks.

Please merge the patch in comment #22 as well. It replaces iocharset=utf8 by
utf8=true for vfat filesystem.

And I think using iocharset for ntfs is ok at least for now. I'll try to fix the
ntfs issue if you think we should get rid off the "iocharset obsolete" warning.
Comment 32 Danny Al-Gaaf 2005-08-12 16:46:51 UTC
Yes, I merge also this patch. 

For vfat and ntfs I added also a check in hald-block-subfs to try to create the 
correct mount command. But if it fail we have the patch from #22 as fallback
Comment 33 Zhe Su 2005-08-13 02:41:48 UTC
Ok thank you very much. When could I get the updated package from dist.suse.de?
That's the only way I get new package.
Comment 34 Danny Al-Gaaf 2005-08-13 02:47:59 UTC
for which arch did you need the package? I add the rpms to my export (~dkukawka/
Export/submount)
Comment 35 Zhe Su 2005-08-13 02:59:23 UTC
How can I get it? I just need source rpm, so that I could build it by myself.
I'd like to help you test it so that we could close this bug if it's ok.
Comment 36 Danny Al-Gaaf 2005-08-13 03:26:21 UTC
I mail you a source rpm directly! 
Comment 37 Danny Al-Gaaf 2005-08-13 03:34:56 UTC
mailed the rpm . I close the bug now. If there are any problems with the fix, 
please reopen the bug
Comment 38 Danny Al-Gaaf 2005-08-13 04:08:09 UTC
I must reopen: you can't mount ext3 and xfs with iocharset=utf8. This is not a 
option for them!
Comment 39 Danny Al-Gaaf 2005-08-13 04:13:19 UTC
se above
Comment 40 Danny Al-Gaaf 2005-08-13 05:06:49 UTC
fixed:

-------------------------------------------------------------------
Sat Aug 13 06:56:37 CEST 2005 - dkukawka@suse.de

- fixed bug #74614 again:
  * only this filesystems support iocharset: vfat (if not urf8).
    udf, iso9960, jfs and ntfs use nls instead of iocharset
  * other filesystems e.g. reiserfs, ext* and xfs don't support
    this option and can't be mnounted with iocharset !!!

Comment 41 Zhe Su 2005-08-13 06:23:57 UTC
I have another patch for submount to fix a potential iocharset issue.
And I found in mount-subfs.c that you removed iocharset option in fstype==NULL case.
I just wonder in what kind of situation that fstype (volume) could be NULL?
I think we should use iocharset option even in such situation, and let submountd
to  decide whether iocharset should be used or not.
Comment 42 Zhe Su 2005-08-13 06:26:37 UTC
Created attachment 45961 [details]
Patch for submountd to ensure correct mount options for any filesystems.
Comment 43 Danny Al-Gaaf 2005-08-13 15:28:45 UTC
to #41: I think this is the only one correct behavior. If HAL call hald-subfs-
mount without to have a fstype for the added volume we have already a problem. 
Since I saw the problem with xfs and ext* to mount with iocharset (no accessable 
mount, hanging processes ...) I prefer to mount a volume with unknown fstype 
without iocharset options. In such cases the chance is greater to get a 
succsessful mount without iocharset. Better mount with default than no mount. 

I'll review the attached patch
Comment 44 Zhe Su 2005-08-13 15:45:28 UTC
With the patch in comment #42, the xfs and ext* issue could be avoided, because
submount will remove iocharset option when the fstype doesn't support it.
Comment 45 Danny Al-Gaaf 2005-08-15 15:06:11 UTC
submitted new package for beta2
Comment 46 Zhe Su 2005-08-27 02:53:19 UTC
I found a typo in mount-subfs.c:

--- mount-subfs.c       2005-08-21 04:28:06.000000000 +0800
+++ mount-subfs.c.new   2005-08-27 10:46:01.000000000 +0800
@@ -533,7 +533,7 @@
                 snprintf( cmd, MOUNT_LENGTH,
                           "/bin/mount -t subfs -o %snosuid,nodev,exec,utf8=true
%s \"%s\"",
                           subfs_type, device_file, mount_point );
-            } else if (!strcmp( fstype, "udf" ) || !strcmp( fstype, "iso9960" ) ||
+            } else if (!strcmp( fstype, "udf" ) || !strcmp( fstype, "iso9660" ) ||
                       !strcmp( fstype, "vfat" ) || !strcmp( fstype, "jfs" )) {
                 snprintf( cmd, MOUNT_LENGTH,
                           "/bin/mount -t subfs -o
%snosuid,nodev,exec,iocharset=%s %s \"%s\"",
Comment 47 Danny Al-Gaaf 2005-08-27 13:50:56 UTC
thanks for the report, fixed commited should be in next beta