]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
udf: Convert ident strings to proper charset
authorJan Kara <jack@suse.cz>
Mon, 16 Apr 2018 13:44:19 +0000 (15:44 +0200)
committerJan Kara <jack@suse.cz>
Thu, 19 Apr 2018 14:00:48 +0000 (16:00 +0200)
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>
fs/udf/super.c
fs/udf/udfdecl.h
fs/udf/unicode.c

index 37d2565a7f785e0196ffe820d3d1038cb4f54188..0d27d41f5c6e70e51c12d9d702b8ec32e239bfff 100644 (file)
@@ -890,14 +890,14 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
 #endif
        }
 
-       ret = udf_dstrCS0toUTF8(outstr, 31, pvoldesc->volIdent, 32);
+       ret = udf_dstrCS0toChar(sb, outstr, 31, pvoldesc->volIdent, 32);
        if (ret < 0)
                goto out_bh;
 
        strncpy(UDF_SB(sb)->s_volume_ident, outstr, ret);
        udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident);
 
-       ret = udf_dstrCS0toUTF8(outstr, 127, pvoldesc->volSetIdent, 128);
+       ret = udf_dstrCS0toChar(sb, outstr, 127, pvoldesc->volSetIdent, 128);
        if (ret < 0)
                goto out_bh;
 
index 68e8a64d22e08a1561516485b45c2a36d622fa40..fc8d1b3384d25767df9d083ab1088a3dbbc52d5c 100644 (file)
@@ -220,7 +220,8 @@ extern int udf_get_filename(struct super_block *, const uint8_t *, int,
                            uint8_t *, int);
 extern int udf_put_filename(struct super_block *, const uint8_t *, int,
                            uint8_t *, int);
-extern int udf_dstrCS0toUTF8(uint8_t *, int, const uint8_t *, int);
+extern int udf_dstrCS0toChar(struct super_block *, uint8_t *, int,
+                            const uint8_t *, int);
 
 /* ialloc.c */
 extern void udf_free_inode(struct inode *);
index 18df831afd3de0a66c08426a306f3a0965938847..ad806c3125c12746b5593793d879ec151aa64562 100644 (file)
@@ -295,9 +295,10 @@ try_again:
        return u_len;
 }
 
-int udf_dstrCS0toUTF8(uint8_t *utf_o, int o_len,
+int udf_dstrCS0toChar(struct super_block *sb, uint8_t *utf_o, int o_len,
                      const uint8_t *ocu_i, int i_len)
 {
+       int (*conv_f)(wchar_t, unsigned char *, int);
        int s_len = 0;
 
        if (i_len > 0) {
@@ -309,8 +310,14 @@ int udf_dstrCS0toUTF8(uint8_t *utf_o, int o_len,
                }
        }
 
-       return udf_name_from_CS0(utf_o, o_len, ocu_i, s_len,
-                                udf_uni2char_utf8, 0);
+       if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
+               conv_f = udf_uni2char_utf8;
+       } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
+               conv_f = UDF_SB(sb)->s_nls_map->uni2char;
+       } else
+               BUG();
+
+       return udf_name_from_CS0(utf_o, o_len, ocu_i, s_len, conv_f, 0);
 }
 
 int udf_get_filename(struct super_block *sb, const uint8_t *sname, int slen,