aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/misc.c
diff options
context:
space:
mode:
authorSteve French <smfrench@austin.rr.com>2005-04-29 01:41:06 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-29 01:41:06 -0400
commit6c91d362f1e1ebbd4513adb68fc79d552c11e2c0 (patch)
treeb86a48f6a44cd924684aa5efc55b2760e2365f78 /fs/cifs/misc.c
parentd14537f103bf746ca766f739f9f5a5bf7a8b4806 (diff)
[PATCH] cifs: finish up of special character mapping capable unicode conversion routine part 2 of 3
Signed-off-by: Steve French (sfrench@us.ibm.com) Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/cifs/misc.c')
-rw-r--r--fs/cifs/misc.c80
1 files changed, 75 insertions, 5 deletions
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index f2a026073b62..6d7bb427e4fa 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -28,6 +28,7 @@
28#include "cifs_debug.h" 28#include "cifs_debug.h"
29#include "smberr.h" 29#include "smberr.h"
30#include "nterr.h" 30#include "nterr.h"
31#include "cifs_unicode.h"
31 32
32extern mempool_t *cifs_sm_req_poolp; 33extern mempool_t *cifs_sm_req_poolp;
33extern mempool_t *cifs_req_poolp; 34extern mempool_t *cifs_req_poolp;
@@ -515,7 +516,6 @@ dump_smb(struct smb_hdr *smb_buf, int smb_buf_length)
515 return; 516 return;
516} 517}
517 518
518#ifdef CONFIG_CIFS_EXPERIMENTAL
519/* Windows maps these to the user defined 16 bit Unicode range since they are 519/* Windows maps these to the user defined 16 bit Unicode range since they are
520 reserved symbols (along with \ and /), otherwise illegal to store 520 reserved symbols (along with \ and /), otherwise illegal to store
521 in filenames in NTFS */ 521 in filenames in NTFS */
@@ -552,9 +552,12 @@ cifs_convertUCSpath(char *target, const __le16 * source, int maxlen,
552 case UNI_QUESTION: 552 case UNI_QUESTION:
553 target[j] = '?'; 553 target[j] = '?';
554 break; 554 break;
555 case UNI_SLASH: 555 /* BB We can not handle remapping slash until
556 target[j] = '\\'; /* BB check this - is there risk here of converting path sep BB */ 556 all the calls to build_path_from_dentry
557 break; 557 are modified, as they use slash as separator BB */
558 /* case UNI_SLASH:
559 target[j] = '\\';
560 break;*/
558 case UNI_PIPE: 561 case UNI_PIPE:
559 target[j] = '|'; 562 target[j] = '|';
560 break; 563 break;
@@ -582,4 +585,71 @@ cUCS_out:
582 target[j] = 0; 585 target[j] = 0;
583 return j; 586 return j;
584} 587}
585#endif /* CIFS_EXPERIMENTAL */ 588
589/* Convert 16 bit Unicode pathname to wire format from string in current code
590 page. Conversion may involve remapping up the seven characters that are
591 only legal in POSIX-like OS (if they are present in the string). Path
592 names are little endian 16 bit Unicode on the wire */
593int
594cifsConvertToUCS(__le16 * target, const char *source, int maxlen,
595 const struct nls_table * cp, int mapChars)
596{
597 int i,j,charlen;
598 int len_remaining = maxlen;
599 char src_char;
600
601 if(!mapChars)
602 return cifs_strtoUCS((wchar_t *) target, source, PATH_MAX, cp);
603
604 for(i = 0, j = 0; i < maxlen; j++) {
605 src_char = source[i];
606 switch (src_char) {
607 case 0:
608 goto ctoUCS_out;
609 case ':':
610 target[j] = cpu_to_le16(UNI_COLON);
611 break;
612 case '*':
613 target[j] = cpu_to_le16(UNI_ASTERIK);
614 break;
615 case '?':
616 target[j] = cpu_to_le16(UNI_QUESTION);
617 break;
618 case '<':
619 target[j] = cpu_to_le16(UNI_LESSTHAN);
620 break;
621 case '>':
622 target[j] = cpu_to_le16(UNI_GRTRTHAN);
623 break;
624 case '|':
625 target[j] = cpu_to_le16(UNI_PIPE);
626 break;
627 /* BB We can not handle remapping slash until
628 all the calls to build_path_from_dentry
629 are modified, as they use slash as separator BB */
630 /* case '\\':
631 target[j] = cpu_to_le16(UNI_SLASH);
632 break;*/
633 default:
634 charlen = cp->char2uni(source+i,
635 len_remaining, target+j);
636 /* if no match, use question mark, which
637 at least in some cases servers as wild card */
638 if(charlen < 1) {
639 target[j] = cpu_to_le16(0x003f);
640 charlen = 1;
641 }
642 len_remaining -= charlen;
643 /* character may take more than one byte in the
644 the source string, but will take exactly two
645 bytes in the target string */
646 i+= charlen;
647 continue;
648 }
649 i++; /* move to next char in source string */
650 len_remaining--;
651 }
652
653ctoUCS_out:
654 return i;
655}