Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Pali Rohár and committed by
Jan Kara
28ce50f8 b6453334

+15 -19
+14 -15
fs/isofs/inode.c
··· 155 155 unsigned int overriderockperm:1; 156 156 unsigned int uid_set:1; 157 157 unsigned int gid_set:1; 158 - unsigned int utf8:1; 159 158 unsigned char map; 160 159 unsigned char check; 161 160 unsigned int blocksize; ··· 355 356 popt->gid = GLOBAL_ROOT_GID; 356 357 popt->uid = GLOBAL_ROOT_UID; 357 358 popt->iocharset = NULL; 358 - popt->utf8 = 0; 359 359 popt->overriderockperm = 0; 360 360 popt->session=-1; 361 361 popt->sbsector=-1; ··· 387 389 case Opt_cruft: 388 390 popt->cruft = 1; 389 391 break; 390 - case Opt_utf8: 391 - popt->utf8 = 1; 392 - break; 393 392 #ifdef CONFIG_JOLIET 393 + case Opt_utf8: 394 + kfree(popt->iocharset); 395 + popt->iocharset = kstrdup("utf8", GFP_KERNEL); 396 + if (!popt->iocharset) 397 + return 0; 398 + break; 394 399 case Opt_iocharset: 395 400 kfree(popt->iocharset); 396 401 popt->iocharset = match_strdup(&args[0]); ··· 496 495 if (sbi->s_nocompress) seq_puts(m, ",nocompress"); 497 496 if (sbi->s_overriderockperm) seq_puts(m, ",overriderockperm"); 498 497 if (sbi->s_showassoc) seq_puts(m, ",showassoc"); 499 - if (sbi->s_utf8) seq_puts(m, ",utf8"); 500 498 501 499 if (sbi->s_check) seq_printf(m, ",check=%c", sbi->s_check); 502 500 if (sbi->s_mapping) seq_printf(m, ",map=%c", sbi->s_mapping); ··· 518 518 seq_printf(m, ",fmode=%o", sbi->s_fmode); 519 519 520 520 #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) 523 522 seq_printf(m, ",iocharset=%s", sbi->s_nls_iocharset->charset); 523 + else 524 + seq_puts(m, ",iocharset=utf8"); 524 525 #endif 525 526 return 0; 526 527 } ··· 864 863 sbi->s_nls_iocharset = NULL; 865 864 866 865 #ifdef CONFIG_JOLIET 867 - if (joliet_level && opt.utf8 == 0) { 866 + if (joliet_level) { 868 867 char *p = opt.iocharset ? opt.iocharset : CONFIG_NLS_DEFAULT; 869 - sbi->s_nls_iocharset = load_nls(p); 870 - if (! sbi->s_nls_iocharset) { 871 - /* Fail only if explicit charset specified */ 872 - 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) 873 872 goto out_freesbi; 874 - sbi->s_nls_iocharset = load_nls_default(); 875 873 } 876 874 } 877 875 #endif ··· 886 886 sbi->s_gid = opt.gid; 887 887 sbi->s_uid_set = opt.uid_set; 888 888 sbi->s_gid_set = opt.gid_set; 889 - sbi->s_utf8 = opt.utf8; 890 889 sbi->s_nocompress = opt.nocompress; 891 890 sbi->s_overriderockperm = opt.overriderockperm; 892 891 /*
-1
fs/isofs/isofs.h
··· 44 44 unsigned char s_session; 45 45 unsigned int s_high_sierra:1; 46 46 unsigned int s_rock:2; 47 - unsigned int s_utf8:1; 48 47 unsigned int s_cruft:1; /* Broken disks with high byte of length 49 48 * containing junk */ 50 49 unsigned int s_nocompress:1;
+1 -3
fs/isofs/joliet.c
··· 41 41 int 42 42 get_joliet_filename(struct iso_directory_record * de, unsigned char *outname, struct inode * inode) 43 43 { 44 - unsigned char utf8; 45 44 struct nls_table *nls; 46 45 unsigned char len = 0; 47 46 48 - utf8 = ISOFS_SB(inode->i_sb)->s_utf8; 49 47 nls = ISOFS_SB(inode->i_sb)->s_nls_iocharset; 50 48 51 - if (utf8) { 49 + if (!nls) { 52 50 len = utf16s_to_utf8s((const wchar_t *) de->name, 53 51 de->name_len[0] >> 1, UTF16_BIG_ENDIAN, 54 52 outname, PAGE_SIZE);