summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2018-04-16 09:44:19 -0400
committerJan Kara <jack@suse.cz>2018-04-19 10:00:48 -0400
commite966fc8d9953167fe7c29495495436846467a5d2 (patch)
treefd2e428de30446512098ea185808807af88db48a
parentb8a41c44a4ed8bad89b91584a7c7e4610c4b8c88 (diff)
udf: Convert ident strings to proper charset
iocharset= mount option specifies the character set used on *console* (not on disk). So even dstrings from VRS need to be converted from CS0 to the specified charset and not always UTF-8. This is barely user visible as those strings are shown only in UDF debug messages. CC: Andrew Gabbasov <andrew_gabbasov@mentor.com> Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--fs/udf/super.c4
-rw-r--r--fs/udf/udfdecl.h3
-rw-r--r--fs/udf/unicode.c13
3 files changed, 14 insertions, 6 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 37d2565a7f78..0d27d41f5c6e 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -890,14 +890,14 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
890#endif 890#endif
891 } 891 }
892 892
893 ret = udf_dstrCS0toUTF8(outstr, 31, pvoldesc->volIdent, 32); 893 ret = udf_dstrCS0toChar(sb, outstr, 31, pvoldesc->volIdent, 32);
894 if (ret < 0) 894 if (ret < 0)
895 goto out_bh; 895 goto out_bh;
896 896
897 strncpy(UDF_SB(sb)->s_volume_ident, outstr, ret); 897 strncpy(UDF_SB(sb)->s_volume_ident, outstr, ret);
898 udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident); 898 udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident);
899 899
900 ret = udf_dstrCS0toUTF8(outstr, 127, pvoldesc->volSetIdent, 128); 900 ret = udf_dstrCS0toChar(sb, outstr, 127, pvoldesc->volSetIdent, 128);
901 if (ret < 0) 901 if (ret < 0)
902 goto out_bh; 902 goto out_bh;
903 903
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index 68e8a64d22e0..fc8d1b3384d2 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -220,7 +220,8 @@ extern int udf_get_filename(struct super_block *, const uint8_t *, int,
220 uint8_t *, int); 220 uint8_t *, int);
221extern int udf_put_filename(struct super_block *, const uint8_t *, int, 221extern int udf_put_filename(struct super_block *, const uint8_t *, int,
222 uint8_t *, int); 222 uint8_t *, int);
223extern int udf_dstrCS0toUTF8(uint8_t *, int, const uint8_t *, int); 223extern int udf_dstrCS0toChar(struct super_block *, uint8_t *, int,
224 const uint8_t *, int);
224 225
225/* ialloc.c */ 226/* ialloc.c */
226extern void udf_free_inode(struct inode *); 227extern void udf_free_inode(struct inode *);
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index 18df831afd3d..ad806c3125c1 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -295,9 +295,10 @@ try_again:
295 return u_len; 295 return u_len;
296} 296}
297 297
298int udf_dstrCS0toUTF8(uint8_t *utf_o, int o_len, 298int udf_dstrCS0toChar(struct super_block *sb, uint8_t *utf_o, int o_len,
299 const uint8_t *ocu_i, int i_len) 299 const uint8_t *ocu_i, int i_len)
300{ 300{
301 int (*conv_f)(wchar_t, unsigned char *, int);
301 int s_len = 0; 302 int s_len = 0;
302 303
303 if (i_len > 0) { 304 if (i_len > 0) {
@@ -309,8 +310,14 @@ int udf_dstrCS0toUTF8(uint8_t *utf_o, int o_len,
309 } 310 }
310 } 311 }
311 312
312 return udf_name_from_CS0(utf_o, o_len, ocu_i, s_len, 313 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
313 udf_uni2char_utf8, 0); 314 conv_f = udf_uni2char_utf8;
315 } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
316 conv_f = UDF_SB(sb)->s_nls_map->uni2char;
317 } else
318 BUG();
319
320 return udf_name_from_CS0(utf_o, o_len, ocu_i, s_len, conv_f, 0);
314} 321}
315 322
316int udf_get_filename(struct super_block *sb, const uint8_t *sname, int slen, 323int udf_get_filename(struct super_block *sb, const uint8_t *sname, int slen,