|-h||Display short help.|
|-v||Turn on verbose output.|
|-m||Display amount of memory used by tables already loaded into kernel. This is similar to vmstat -m | grep iconv_data.|
|-d||Display list of currently loaded charset conversion tables.|
|Specify local charset(s). Usually locale(s) of user(s) who will mount file systems.|
|Specify foreign charset(s). These are charset(s) used inside file systems to store file names.|
|Specify charset pair(s). Each pair consists of local charset and foreign charset, separated by colon.|
To load needed charset conversion tables, you should specify one or more local-foreign charset pairs. You can do it in two ways:
kiconvtool -p KOI8-R:CP866 KOI8-R:UTF-16BE
kiconvtool -l KOI8-R -f CP866 UTF-16BE
You can combine those two ways (first, pairs are formed from all possible combinations of provided local/foreign charsets, then explicitly defined pairs are added).
To know which character sets you need for your media, first mount it under root user, then use the following command:
to get list of charset tables loaded after your mounts. Note, that for each charset pair (LOCAL, FOREIGN), there will be two conversions (LOCAL -> FOREIGN and FOREIGN -> LOCAL).
Dont forget, that you need iconv library and iconv support for specific file system(s) to either be compiled into kernel or loaded as modules. Thus, for msdosfs you either need
in your /boot/loader.conf or
options LIBICONV options MSDOSFS_ICONV
in your kernel config. Alternatively, rc.d script provided with kiconvtool can load required modules for you (see below).
1) My locale is ru_RU.KOI8-R, and I want to mount FAT32 with Russian file names from my USB flash drive with the following command:mount_msdosfs -L ru_RU.KOI8-R -D CP866 /dev/da0s1 ~/mnt/flash
In my case, msdosfs uses both CP866 for 8.3 legacy file names and UTF16-BE for Win95 long names. So to be able to execute the mount command above as unprivileged user, I need to run this as root first:kiconvtool -l KOI8-R -f UTF-16BE CP866
2) The same thing, but for mounting CD-ROM. I want to run this as a user:mount_cd9660 -C KOI8-R /dev/acd0 ~/mnt/cdrom
ISO9660 only uses UTF16-BE internally, so I only need one pair:kiconvtool -l KOI8-R -f UTF-16BE
You only need to call kiconvtool once to load charset tables - after that, mounting will work until reboot. For convenience, you can use rcNG script provided with kiconvtool to load charset conversion tables on system startup. Just add the following lines to /etc/rc.conf:# enable kiconv script kiconv_preload="YES"
# specify local/foreign encodings (all 4 ways demonstrated here load the same set): kiconv_local_charsets="KOI8-R UTF-8" kiconv_foreign_charsets="CP866 UTF-16BE" # or kiconv_charset_pairs="UTF-8:CP866 UTF-8:UTF-16BE KOI8-R:CP866 KOI8-R:UTF-16BE" # or (you may specify kiconvtool flags directly) kiconv_flags="-l KOI8-R UTF-8 -f CP866 UTF-16BE" # or kiconv_flags="-p UTF-8:CP866 UTF-8:UTF-16BE KOI8-R:CP866 KOI8-R:UTF-16BE"
# script also offers a convenient way to load required kernel iconv modules kiconv_fstypes="msdosfs cd9660"
mount_cd9660(8), mount_msdosfs(8), mount_smbfs(8), mount_udf(8), kiconv(3)
.An Dmitry Marakasov Aq amdmi3@FreeBSD.org
The main bug is not in kiconvtool itself, but in kernel iconv implementation: charset names are case sensitive. So if youre using KOI8-R for mounting, you should use KOI8-R (not koi8-r or Koi8-R) in kiconvtool as well. The best idea is to use uppercase charset names everywhere.