aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fat
diff options
context:
space:
mode:
authorNamjae Jeon <linkinjeon@gmail.com>2012-03-23 18:02:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-23 19:58:40 -0400
commit41f0c02eacec9f984adb22e8fecda49e13b7eb13 (patch)
treea057fc5dacd08251e826a9588b5e9fc937d3082c /fs/fat
parent9eab0a788d2d6e513f43b7c0e5bb9d60446233cb (diff)
fat: clean up xlate_to_uni()
xlate_to_uni() is called by vfat_build_slots() with sbi->nls_io as the final argument. nls_io can never be null at this point because the check is already being done in fat_fill_super() wherein the mount fails if it is null. Signed-off-by: Namjae Jeon <linkinjeon@gmail.com> Signed-off-by: Ravishankar N <cyberax82@gmail.com> Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/fat')
-rw-r--r--fs/fat/namei_vfat.c83
1 files changed, 36 insertions, 47 deletions
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index a81eb2367d39..aae3b4e1057d 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -521,57 +521,46 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
521 521
522 op = &outname[*outlen * sizeof(wchar_t)]; 522 op = &outname[*outlen * sizeof(wchar_t)];
523 } else { 523 } else {
524 if (nls) { 524 for (i = 0, ip = name, op = outname, *outlen = 0;
525 for (i = 0, ip = name, op = outname, *outlen = 0; 525 i < len && *outlen <= FAT_LFN_LEN;
526 i < len && *outlen <= FAT_LFN_LEN; 526 *outlen += 1) {
527 *outlen += 1) 527 if (escape && (*ip == ':')) {
528 { 528 if (i > len - 5)
529 if (escape && (*ip == ':')) { 529 return -EINVAL;
530 if (i > len - 5) 530 ec = 0;
531 return -EINVAL; 531 for (k = 1; k < 5; k++) {
532 ec = 0; 532 nc = ip[k];
533 for (k = 1; k < 5; k++) { 533 ec <<= 4;
534 nc = ip[k]; 534 if (nc >= '0' && nc <= '9') {
535 ec <<= 4; 535 ec |= nc - '0';
536 if (nc >= '0' && nc <= '9') { 536 continue;
537 ec |= nc - '0';
538 continue;
539 }
540 if (nc >= 'a' && nc <= 'f') {
541 ec |= nc - ('a' - 10);
542 continue;
543 }
544 if (nc >= 'A' && nc <= 'F') {
545 ec |= nc - ('A' - 10);
546 continue;
547 }
548 return -EINVAL;
549 } 537 }
550 *op++ = ec & 0xFF; 538 if (nc >= 'a' && nc <= 'f') {
551 *op++ = ec >> 8; 539 ec |= nc - ('a' - 10);
552 ip += 5; 540 continue;
553 i += 5; 541 }
554 } else { 542 if (nc >= 'A' && nc <= 'F') {
555 if ((charlen = nls->char2uni(ip, len - i, (wchar_t *)op)) < 0) 543 ec |= nc - ('A' - 10);
556 return -EINVAL; 544 continue;
557 ip += charlen; 545 }
558 i += charlen; 546 return -EINVAL;
559 op += 2;
560 } 547 }
548 *op++ = ec & 0xFF;
549 *op++ = ec >> 8;
550 ip += 5;
551 i += 5;
552 } else {
553 charlen = nls->char2uni(ip, len - i,
554 (wchar_t *)op);
555 if (charlen < 0)
556 return -EINVAL;
557 ip += charlen;
558 i += charlen;
559 op += 2;
561 } 560 }
562 if (i < len)
563 return -ENAMETOOLONG;
564 } else {
565 for (i = 0, ip = name, op = outname, *outlen = 0;
566 i < len && *outlen <= FAT_LFN_LEN;
567 i++, *outlen += 1)
568 {
569 *op++ = *ip++;
570 *op++ = 0;
571 }
572 if (i < len)
573 return -ENAMETOOLONG;
574 } 561 }
562 if (i < len)
563 return -ENAMETOOLONG;
575 } 564 }
576 565
577 *longlen = *outlen; 566 *longlen = *outlen;