Bug 93857 - [iconv] [patch] new utility: kiconv_cs_preload(8): Utility for loading the kernel charset translation tables on system boot
Summary: [iconv] [patch] new utility: kiconv_cs_preload(8): Utility for loading the ke...
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 6.1-PRERELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-26 14:30 UTC by Dmitry Kazarov
Modified: 2018-01-03 05:12 UTC (History)
0 users

See Also:


Attachments
file.shar (5.50 KB, text/plain)
2006-02-26 14:30 UTC, Dmitry Kazarov
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Kazarov 2006-02-26 14:30:03 UTC
I have to allow non-root users to mount a CD-ROMs(CD9660, UDF) and
diskettes (MSDOSFS) filesystems.

I've set vfs.usermount to 1, changed permissions of devices in
/etc/devfs.conf, permissions of mount points - everything according to
FreeBSD faq #9.22.

But our users speak Russian and use CD-ROM/diskettes with Cyrillic
letters in filenames and I've added corresponding options to /etc/fstab
/dev/acd0 /cdrom cd9660  ro,noauto,-CUTF-8 0 0
(users use KDE so their locale is ru_RU.UTF-8).

And this option made impossible for users to mount cdrom!

Because it loads kiconv charset translation table that is allowed to
root only.  Searching internet showed a common solution to this problem
is creating small startup script in /usr/local/etc/rc.d with mount/umount
commands only:

  #!/bin/sh
  mount /cdrom
  umount /cdrom

Besides ugly error messages on console this script increases boot time.

So I've written this little utility that loads the charset conversion tables.
IMHO, it could be useful for many other people. And it's worth to include it in FreeBSD.

Script loadfscharsets should be placed in /etc/rc.d/.
Script expects next variables in /etc/rc.conf:

loadfscharsets_enabled={YES|NO}
loadfscharsets_fstypes={list of filesystems that use kiconv filename translation, defaults to "cd9660 udf msdosfs"}
loadfscharsets_cspairs={list of charset pairs|Russian|Japanese}

loadfscharsets_fstypes specifies list of filesystem types that use
external kernel modules for file name translation.

The kernel module <filesystem type name>_iconv have to exist in
/boot/kernel directory.

loadfscharsets_cspairs could be list of charsets pairs like UTF-8 (which
is equal to UTF-8:UTF-16BE), UTF-8:CP866, eucJP:CP932 or words like
Russian (equal to "UTF-8 UTF-8:CP866" list), Japanese (equal to
"UTF-8 UTF-8:CP92), some locale names (ru_RU.UTF-8, ru_RU.KOI-8 etc)

How-To-Repeat: After boot:
root# sysctl vfs.usermount=1
root# chown user /dev/acd0
root# chown user /cdrom
root# su user
user$ mount_cd9660 -CUTF-8 /dev/acd0 /cdrom
mount_cd9660: cd9660_iconv: Operation not permitted
root# mount_cd9660 -CUTF-8 /dev/acd0 /cdrom
root# umount /cdrom
user$ mount_cd9660 -CUTF-8 /dev/acd0 /cdrom
user$ mount | fgrep cdrom
/dev/acd0 on /cdrom (cd9660, local, nosuid, read-only, mounted by user)
Comment 1 Gleb Smirnoff freebsd_committer 2006-02-27 07:39:29 UTC
On Sun, Feb 26, 2006 at 02:20:57PM +0000, Dmitry Kazarov wrote:
D> >Synopsis:       Utility for loading the kernel charset translation tables on system boot

I've heard opinion that current API for loading tables into kernel is
hack. Don't remember exactly, who said this. Afaik it can be found in
some other PR.

Now in FreeBSD we have a special API to load some data blob into kernel -
firmwire(9). Is it possible to rewrite charset translation tables
loading code to use this API? Is it a good idea?

-- 
Totus tuus, Glebius.
GLEBIUS-RIPN GLEB-RIPE
Comment 2 Dmitry Kazarov 2006-02-27 10:17:19 UTC
Hi, Gleb!

I have not digged deeply into kiconv functionality - I do not know way it 
loads data into kernel. I use /usr/lib/libkiconv.so which makes all work for 
me.  System utils mount_{cd9660,udf,msdosfs,ntfs} works just this way.
IMHO if kernel interface is going to be changed the libkiconv.so is the best 
place for changes. 

In other hand I can not find anything about firmwire(9) - no mans, no pages on 
www.freebsd.org

Sincerely yours
Dmitry

÷ ÓÏÏÂÝÅÎÉÉ ÏÔ ðÏÎÅÄÅÌØÎÉË 27 ÆÅ×ÒÁÌÑ 2006 10:39 Gleb Smirnoff ÎÁÐÉÓÁÌ(a):
> On Sun, Feb 26, 2006 at 02:20:57PM +0000, Dmitry Kazarov wrote:
> D> >Synopsis:       Utility for loading the kernel charset translation
> tables on system boot
>
> I've heard opinion that current API for loading tables into kernel is
> hack. Don't remember exactly, who said this. Afaik it can be found in
> some other PR.
>
> Now in FreeBSD we have a special API to load some data blob into kernel -
> firmwire(9). Is it possible to rewrite charset translation tables
> loading code to use this API? Is it a good idea?
Comment 3 ota 2009-02-04 09:24:51 UTC
There have been patches on http://people.freebsd.org/~imura/kiconv/ since
5.x releases.  After 7.0, these patches do not apply cleanly.

I used them back then but I am not sure its current status.

I think it was not merged back into the src.

Thanks,
Hiro
Comment 4 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:42 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped