Skip to content

Commit 28ce50f

Browse files
palijankara
authored andcommitted
isofs: joliet: Fix iocharset=utf8 mount option
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>
1 parent b645333 commit 28ce50f

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;
@@ -356,7 +355,6 @@ static int parse_options(char *options, struct iso9660_options *popt)
356355
popt->gid = GLOBAL_ROOT_GID;
357356
popt->uid = GLOBAL_ROOT_UID;
358357
popt->iocharset = NULL;
359-
popt->utf8 = 0;
360358
popt->overriderockperm = 0;
361359
popt->session=-1;
362360
popt->sbsector=-1;
@@ -389,10 +387,13 @@ static int parse_options(char *options, struct iso9660_options *popt)
389387
case Opt_cruft:
390388
popt->cruft = 1;
391389
break;
390+
#ifdef CONFIG_JOLIET
392391
case Opt_utf8:
393-
popt->utf8 = 1;
392+
kfree(popt->iocharset);
393+
popt->iocharset = kstrdup("utf8", GFP_KERNEL);
394+
if (!popt->iocharset)
395+
return 0;
394396
break;
395-
#ifdef CONFIG_JOLIET
396397
case Opt_iocharset:
397398
kfree(popt->iocharset);
398399
popt->iocharset = match_strdup(&args[0]);
@@ -495,7 +496,6 @@ static int isofs_show_options(struct seq_file *m, struct dentry *root)
495496
if (sbi->s_nocompress) seq_puts(m, ",nocompress");
496497
if (sbi->s_overriderockperm) seq_puts(m, ",overriderockperm");
497498
if (sbi->s_showassoc) seq_puts(m, ",showassoc");
498-
if (sbi->s_utf8) seq_puts(m, ",utf8");
499499

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

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

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

‎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)