diff options
Diffstat (limited to 'fs/fat')
-rw-r--r-- | fs/fat/dir.c | 29 | ||||
-rw-r--r-- | fs/fat/namei_vfat.c | 4 |
2 files changed, 17 insertions, 16 deletions
diff --git a/fs/fat/dir.c b/fs/fat/dir.c index 3b8e71b412fd..38ff75a0fe22 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c | |||
@@ -22,6 +22,19 @@ | |||
22 | #include <asm/uaccess.h> | 22 | #include <asm/uaccess.h> |
23 | #include "fat.h" | 23 | #include "fat.h" |
24 | 24 | ||
25 | /* | ||
26 | * Maximum buffer size of short name. | ||
27 | * [(MSDOS_NAME + '.') * max one char + nul] | ||
28 | * For msdos style, ['.' (hidden) + MSDOS_NAME + '.' + nul] | ||
29 | */ | ||
30 | #define FAT_MAX_SHORT_SIZE ((MSDOS_NAME + 1) * NLS_MAX_CHARSET_SIZE + 1) | ||
31 | /* | ||
32 | * Maximum buffer size of unicode chars from slots. | ||
33 | * [(max longname slots * 13 (size in a slot) + nul) * sizeof(wchar_t)] | ||
34 | */ | ||
35 | #define FAT_MAX_UNI_CHARS ((MSDOS_SLOTS - 1) * 13 + 1) | ||
36 | #define FAT_MAX_UNI_SIZE (FAT_MAX_UNI_CHARS * sizeof(wchar_t)) | ||
37 | |||
25 | static inline loff_t fat_make_i_pos(struct super_block *sb, | 38 | static inline loff_t fat_make_i_pos(struct super_block *sb, |
26 | struct buffer_head *bh, | 39 | struct buffer_head *bh, |
27 | struct msdos_dir_entry *de) | 40 | struct msdos_dir_entry *de) |
@@ -171,7 +184,8 @@ static inline int fat_uni_to_x8(struct msdos_sb_info *sbi, const wchar_t *uni, | |||
171 | unsigned char *buf, int size) | 184 | unsigned char *buf, int size) |
172 | { | 185 | { |
173 | if (sbi->options.utf8) | 186 | if (sbi->options.utf8) |
174 | return utf8_wcstombs(buf, uni, size); | 187 | return utf16s_to_utf8s(uni, FAT_MAX_UNI_CHARS, |
188 | UTF16_HOST_ENDIAN, buf, size); | ||
175 | else | 189 | else |
176 | return uni16_to_x8(buf, uni, size, sbi->options.unicode_xlate, | 190 | return uni16_to_x8(buf, uni, size, sbi->options.unicode_xlate, |
177 | sbi->nls_io); | 191 | sbi->nls_io); |
@@ -325,19 +339,6 @@ parse_long: | |||
325 | } | 339 | } |
326 | 340 | ||
327 | /* | 341 | /* |
328 | * Maximum buffer size of short name. | ||
329 | * [(MSDOS_NAME + '.') * max one char + nul] | ||
330 | * For msdos style, ['.' (hidden) + MSDOS_NAME + '.' + nul] | ||
331 | */ | ||
332 | #define FAT_MAX_SHORT_SIZE ((MSDOS_NAME + 1) * NLS_MAX_CHARSET_SIZE + 1) | ||
333 | /* | ||
334 | * Maximum buffer size of unicode chars from slots. | ||
335 | * [(max longname slots * 13 (size in a slot) + nul) * sizeof(wchar_t)] | ||
336 | */ | ||
337 | #define FAT_MAX_UNI_CHARS ((MSDOS_SLOTS - 1) * 13 + 1) | ||
338 | #define FAT_MAX_UNI_SIZE (FAT_MAX_UNI_CHARS * sizeof(wchar_t)) | ||
339 | |||
340 | /* | ||
341 | * Return values: negative -> error, 0 -> not found, positive -> found, | 342 | * Return values: negative -> error, 0 -> not found, positive -> found, |
342 | * value is the total amount of slots, including the shortname entry. | 343 | * value is the total amount of slots, including the shortname entry. |
343 | */ | 344 | */ |
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c index 8d6fdcfd41df..73471b7ecc8c 100644 --- a/fs/fat/namei_vfat.c +++ b/fs/fat/namei_vfat.c | |||
@@ -502,11 +502,11 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname, | |||
502 | if (utf8) { | 502 | if (utf8) { |
503 | int name_len = strlen(name); | 503 | int name_len = strlen(name); |
504 | 504 | ||
505 | *outlen = utf8_mbstowcs((wchar_t *)outname, name, PATH_MAX); | 505 | *outlen = utf8s_to_utf16s(name, PATH_MAX, (wchar_t *) outname); |
506 | 506 | ||
507 | /* | 507 | /* |
508 | * We stripped '.'s before and set len appropriately, | 508 | * We stripped '.'s before and set len appropriately, |
509 | * but utf8_mbstowcs doesn't care about len | 509 | * but utf8s_to_utf16s doesn't care about len |
510 | */ | 510 | */ |
511 | *outlen -= (name_len - len); | 511 | *outlen -= (name_len - len); |
512 | 512 | ||