Skip to content

Commit 48aa6e4

Browse files
paligregkh
authored andcommitted
isofs: joliet: Fix iocharset=utf8 mount option
[ Upstream commit 28ce50f ] Currently iocharset=utf8 mount option is broken. To use UTF-8 as iocharset, it is required to use utf8 mount option. Fix iocharset=utf8 mount option to use be equivalent to the utf8 mount option. If UTF-8 as iocharset is used then s_nls_iocharset is set to NULL. So simplify code around, remove s_utf8 field as to distinguish between UTF-8 and non-UTF-8 it is needed just to check if s_nls_iocharset is set to NULL or not. Link: https://lore.kernel.org/r/20210808162453.1653-5-pali@kernel.org Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 940ac46 commit 48aa6e4

3 files changed

Lines changed: 14 additions & 18 deletions

File tree

‎fs/isofs/inode.c‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ struct iso9660_options{
155155
unsigned int overriderockperm:1;
156156
unsigned int uid_set:1;
157157
unsigned int gid_set:1;
158-
unsigned int utf8:1;
159158
unsigned char map;
160159
unsigned char check;
161160
unsigned int blocksize;
@@ -355,7 +354,6 @@ static int parse_options(char *options, struct iso9660_options *popt)
355354
popt->gid = GLOBAL_ROOT_GID;
356355
popt->uid = GLOBAL_ROOT_UID;
357356
popt->iocharset = NULL;
358-
popt->utf8 = 0;
359357
popt->overriderockperm = 0;
360358
popt->session=-1;
361359
popt->sbsector=-1;
@@ -388,10 +386,13 @@ static int parse_options(char *options, struct iso9660_options *popt)
388386
case Opt_cruft:
389387
popt->cruft = 1;
390388
break;
389+
#ifdef CONFIG_JOLIET
391390
case Opt_utf8:
392-
popt->utf8 = 1;
391+
kfree(popt->iocharset);
392+
popt->iocharset = kstrdup("utf8", GFP_KERNEL);
393+
if (!popt->iocharset)
394+
return 0;
393395
break;
394-
#ifdef CONFIG_JOLIET
395396
case Opt_iocharset:
396397
kfree(popt->iocharset);
397398
popt->iocharset = match_strdup(&args[0]);
@@ -494,7 +495,6 @@ static int isofs_show_options(struct seq_file *m, struct dentry *root)
494495
if (sbi->s_nocompress) seq_puts(m, ",nocompress");
495496
if (sbi->s_overriderockperm) seq_puts(m, ",overriderockperm");
496497
if (sbi->s_showassoc) seq_puts(m, ",showassoc");
497-
if (sbi->s_utf8) seq_puts(m, ",utf8");
498498

499499
if (sbi->s_check) seq_printf(m, ",check=%c", sbi->s_check);
500500
if (sbi->s_mapping) seq_printf(m, ",map=%c", sbi->s_mapping);
@@ -517,9 +517,10 @@ static int isofs_show_options(struct seq_file *m, struct dentry *root)
517517
seq_printf(m, ",fmode=%o", sbi->s_fmode);
518518

519519
#ifdef CONFIG_JOLIET
520-
if (sbi->s_nls_iocharset &&
521-
strcmp(sbi->s_nls_iocharset->charset, CONFIG_NLS_DEFAULT) != 0)
520+
if (sbi->s_nls_iocharset)
522521
seq_printf(m, ",iocharset=%s", sbi->s_nls_iocharset->charset);
522+
else
523+
seq_puts(m, ",iocharset=utf8");
523524
#endif
524525
return 0;
525526
}
@@ -862,14 +863,13 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
862863
sbi->s_nls_iocharset = NULL;
863864

864865
#ifdef CONFIG_JOLIET
865-
if (joliet_level && opt.utf8 == 0) {
866+
if (joliet_level) {
866867
char *p = opt.iocharset ? opt.iocharset : CONFIG_NLS_DEFAULT;
867-
sbi->s_nls_iocharset = load_nls(p);
868-
if (! sbi->s_nls_iocharset) {
869-
/* Fail only if explicit charset specified */
870-
if (opt.iocharset)
868+
if (strcmp(p, "utf8") != 0) {
869+
sbi->s_nls_iocharset = opt.iocharset ?
870+
load_nls(opt.iocharset) : load_nls_default();
871+
if (!sbi->s_nls_iocharset)
871872
goto out_freesbi;
872-
sbi->s_nls_iocharset = load_nls_default();
873873
}
874874
}
875875
#endif
@@ -885,7 +885,6 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
885885
sbi->s_gid = opt.gid;
886886
sbi->s_uid_set = opt.uid_set;
887887
sbi->s_gid_set = opt.gid_set;
888-
sbi->s_utf8 = opt.utf8;
889888
sbi->s_nocompress = opt.nocompress;
890889
sbi->s_overriderockperm = opt.overriderockperm;
891890
/*

‎fs/isofs/isofs.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ struct isofs_sb_info {
4444
unsigned char s_session;
4545
unsigned int s_high_sierra:1;
4646
unsigned int s_rock:2;
47-
unsigned int s_utf8:1;
4847
unsigned int s_cruft:1; /* Broken disks with high byte of length
4948
* containing junk */
5049
unsigned int s_nocompress:1;

‎fs/isofs/joliet.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,12 @@ uni16_to_x8(unsigned char *ascii, __be16 *uni, int len, struct nls_table *nls)
4141
int
4242
get_joliet_filename(struct iso_directory_record * de, unsigned char *outname, struct inode * inode)
4343
{
44-
unsigned char utf8;
4544
struct nls_table *nls;
4645
unsigned char len = 0;
4746

48-
utf8 = ISOFS_SB(inode->i_sb)->s_utf8;
4947
nls = ISOFS_SB(inode->i_sb)->s_nls_iocharset;
5048

51-
if (utf8) {
49+
if (!nls) {
5250
len = utf16s_to_utf8s((const wchar_t *) de->name,
5351
de->name_len[0] >> 1, UTF16_BIG_ENDIAN,
5452
outname, PAGE_SIZE);

0 commit comments

Comments
 (0)