Skip to content

Commit

Permalink
fat: add config option to set UTF-8 mount option by default
Browse files Browse the repository at this point in the history
FAT has long supported its own default file name encoding config
setting, separate from CONFIG_NLS_DEFAULT.

However, if UTF-8 encoded file names are desired FAT character set
should not be set to utf8 since this would make file names case
sensitive even if case insensitive matching is requested.  Instead,
"utf8" mount options should be provided to enable UTF-8 file names in
FAT file system.

Unfortunately, there was no possibility to set the default value of this
option so on UTF-8 system "utf8" mount option had to be added manually
to most FAT mounts.

This patch adds config option to set such default value.

Signed-off-by: Maciej S. Szmigiero <[email protected]>
Acked-by: OGAWA Hirofumi <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
maciejsszmigiero authored and torvalds committed Mar 22, 2016
1 parent f970165 commit 3873938
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
7 changes: 4 additions & 3 deletions Documentation/filesystems/vfat.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ iocharset=<name> -- Character set to use for converting between the
you should consider the following option instead.

utf8=<bool> -- UTF-8 is the filesystem safe version of Unicode that
is used by the console. It can be enabled for the
filesystem with this option. If 'uni_xlate' gets set,
UTF-8 gets disabled.
is used by the console. It can be enabled or disabled
for the filesystem with this option.
If 'uni_xlate' gets set, UTF-8 gets disabled.
By default, FAT_DEFAULT_UTF8 setting is used.

uni_xlate=<bool> -- Translate unhandled Unicode characters to special
escaped sequences. This would let you backup and
Expand Down
18 changes: 17 additions & 1 deletion fs/fat/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,24 @@ config FAT_DEFAULT_IOCHARSET
that most of your FAT filesystems use, and can be overridden
with the "iocharset" mount option for FAT filesystems.
Note that "utf8" is not recommended for FAT filesystems.
If unsure, you shouldn't set "utf8" here.
If unsure, you shouldn't set "utf8" here - select the next option
instead if you would like to use UTF-8 encoded file names by default.
See <file:Documentation/filesystems/vfat.txt> for more information.

Enable any character sets you need in File Systems/Native Language
Support.

config FAT_DEFAULT_UTF8
bool "Enable FAT UTF-8 option by default"
depends on VFAT_FS
default n
help
Set this if you would like to have "utf8" mount option set
by default when mounting FAT filesystems.

Even if you say Y here can always disable UTF-8 for
particular mount by adding "utf8=0" to mount options.

Say Y if you use UTF-8 encoding for file names, N otherwise.

See <file:Documentation/filesystems/vfat.txt> for more information.
4 changes: 3 additions & 1 deletion fs/fat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1127,14 +1127,16 @@ static int parse_options(struct super_block *sb, char *options, int is_vfat,
}
opts->name_check = 'n';
opts->quiet = opts->showexec = opts->sys_immutable = opts->dotsOK = 0;
opts->utf8 = opts->unicode_xlate = 0;
opts->unicode_xlate = 0;
opts->numtail = 1;
opts->usefree = opts->nocase = 0;
opts->tz_set = 0;
opts->nfs = 0;
opts->errors = FAT_ERRORS_RO;
*debug = 0;

opts->utf8 = IS_ENABLED(CONFIG_FAT_DEFAULT_UTF8) && is_vfat;

if (!options)
goto out;

Expand Down

0 comments on commit 3873938

Please sign in to comment.