lkml.org 
[lkml]   [2022]   [Dec]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH v2 08/18] befs: Allow to use native UTF-8 mode
Date
befs driver already has a code which avoids usage of NLS when befs_sb->nls
is not set.

But befs_fill_super() always set befs_sb->nls, so activating native UTF-8
is not possible.

Fix it by not setting befs_sb->nls when iocharset is set to utf8. So now
after this cgange mount option iocharset=utf8 activates usage of native
UTF-8 code path in befs driver.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
fs/befs/linuxvfs.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 8d2954e3afd6..e5400123d33f 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -769,6 +769,7 @@ static int befs_show_options(struct seq_file *m, struct dentry *root)
{
struct befs_sb_info *befs_sb = BEFS_SB(root->d_sb);
struct befs_mount_options *opts = &befs_sb->mount_opts;
+ struct nls_table *nls = befs_sb->nls;

if (!uid_eq(opts->uid, GLOBAL_ROOT_UID))
seq_printf(m, ",uid=%u",
@@ -776,8 +777,10 @@ static int befs_show_options(struct seq_file *m, struct dentry *root)
if (!gid_eq(opts->gid, GLOBAL_ROOT_GID))
seq_printf(m, ",gid=%u",
from_kgid_munged(&init_user_ns, opts->gid));
- if (opts->iocharset)
- seq_printf(m, ",iocharset=%s", opts->iocharset);
+ if (nls)
+ seq_printf(m, ",iocharset=%s", nls->charset);
+ else
+ seq_puts(m, ",iocharset=utf8");
if (opts->debug)
seq_puts(m, ",debug");
return 0;
@@ -815,6 +818,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
const unsigned long sb_block = 0;
const off_t x86_sb_off = 512;
int blocksize;
+ const char *p;

sb->s_fs_info = kzalloc(sizeof(*befs_sb), GFP_KERNEL);
if (sb->s_fs_info == NULL)
@@ -907,8 +911,11 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
goto unacquire_priv_sbp;
}

+ p = befs_sb->mount_opts.iocharset ? befs_sb->mount_opts.iocharset : CONFIG_NLS_DEFAULT;
+ if (strcmp(p, "utf8") == 0) {
+ befs_debug(sb, "Using native UTF-8 without nls");
/* load nls library */
- if (befs_sb->mount_opts.iocharset) {
+ } else if (befs_sb->mount_opts.iocharset) {
befs_debug(sb, "Loading nls: %s",
befs_sb->mount_opts.iocharset);
befs_sb->nls = load_nls(befs_sb->mount_opts.iocharset);
--
2.20.1
\
 
 \ /
  Last update: 2023-03-26 23:20    [W:0.145 / U:0.920 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site