aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--fs/cifs/cifs_debug.c10
-rw-r--r--fs/cifs/cifs_unicode.c4
-rw-r--r--fs/cifs/misc.c80
3 files changed, 83 insertions, 11 deletions
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index db28b561cd4b..e7bd93e6226d 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -29,6 +29,7 @@
29#include "cifsglob.h" 29#include "cifsglob.h"
30#include "cifsproto.h" 30#include "cifsproto.h"
31#include "cifs_debug.h" 31#include "cifs_debug.h"
32#include "cifsfs.h"
32 33
33void 34void
34cifs_dump_mem(char *label, void *data, int length) 35cifs_dump_mem(char *label, void *data, int length)
@@ -78,8 +79,9 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
78 "Display Internal CIFS Data Structures for Debugging\n" 79 "Display Internal CIFS Data Structures for Debugging\n"
79 "---------------------------------------------------\n"); 80 "---------------------------------------------------\n");
80 buf += length; 81 buf += length;
81 82 length = sprintf(buf,"CIFS Version %s\n",CIFS_VERSION);
82 length = sprintf(buf, "Servers:\n"); 83 buf += length;
84 length = sprintf(buf, "Servers:");
83 buf += length; 85 buf += length;
84 86
85 i = 0; 87 i = 0;
@@ -100,7 +102,7 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
100 ses->server->secMode, 102 ses->server->secMode,
101 atomic_read(&ses->server->inFlight)); 103 atomic_read(&ses->server->inFlight));
102 104
103 length = sprintf(buf, "\nMIDs: \n"); 105 length = sprintf(buf, "\nMIDs:\n");
104 buf += length; 106 buf += length;
105 107
106 spin_lock(&GlobalMid_Lock); 108 spin_lock(&GlobalMid_Lock);
@@ -121,7 +123,7 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
121 sprintf(buf, "\n"); 123 sprintf(buf, "\n");
122 buf++; 124 buf++;
123 125
124 length = sprintf(buf, "\nShares:\n"); 126 length = sprintf(buf, "Shares:");
125 buf += length; 127 buf += length;
126 128
127 i = 0; 129 i = 0;
diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
index a17adf4cb9ba..99a096d3f84d 100644
--- a/fs/cifs/cifs_unicode.c
+++ b/fs/cifs/cifs_unicode.c
@@ -76,8 +76,8 @@ cifs_strtoUCS(wchar_t * to, const char *from, int len,
76 charlen)); 76 charlen));
77 to[i] = cpu_to_le16(0x003f); /* a question mark */ 77 to[i] = cpu_to_le16(0x003f); /* a question mark */
78 charlen = 1; 78 charlen = 1;
79 } 79 } else
80 to[i] = cpu_to_le16(to[i]); 80 to[i] = cpu_to_le16(to[i]);
81 81
82 } 82 }
83 83
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}