diff options
author | Jeff Layton <jlayton@redhat.com> | 2009-04-30 07:18:00 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2009-04-30 11:45:01 -0400 |
commit | f58841666bc22e827ca0dcef7b71c7bc2758ce82 (patch) | |
tree | 5391996d11f791a6ade2c1df1ed795be2cc6e1ab | |
parent | 460b96960d1946914e50316ffeefe7b41dddce91 (diff) |
cifs: change cifs_get_name_from_search_buf to use new unicode helper
...and remove cifs_convertUCSpath. There are no more callers. Also add a
#define for the buffer used in the readdir path so that we don't have so
many magic numbers floating around.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Acked-by: Suresh Jayaraman <sjayaraman@suse.de>
Signed-off-by: Steve French <sfrench@us.ibm.com>
-rw-r--r-- | fs/cifs/cifsproto.h | 2 | ||||
-rw-r--r-- | fs/cifs/misc.c | 60 | ||||
-rw-r--r-- | fs/cifs/readdir.c | 26 |
3 files changed, 13 insertions, 75 deletions
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 7d54a5a4dd55..fae083930eee 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h | |||
@@ -306,8 +306,6 @@ extern int CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon, | |||
306 | const unsigned char *searchName, __u64 *inode_number, | 306 | const unsigned char *searchName, __u64 *inode_number, |
307 | const struct nls_table *nls_codepage, | 307 | const struct nls_table *nls_codepage, |
308 | int remap_special_chars); | 308 | int remap_special_chars); |
309 | extern int cifs_convertUCSpath(char *target, const __le16 *source, int maxlen, | ||
310 | const struct nls_table *codepage); | ||
311 | extern int cifsConvertToUCS(__le16 *target, const char *source, int maxlen, | 309 | extern int cifsConvertToUCS(__le16 *target, const char *source, int maxlen, |
312 | const struct nls_table *cp, int mapChars); | 310 | const struct nls_table *cp, int mapChars); |
313 | 311 | ||
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index bb81c8af6a93..e079a9190ec4 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c | |||
@@ -635,66 +635,6 @@ dump_smb(struct smb_hdr *smb_buf, int smb_buf_length) | |||
635 | return; | 635 | return; |
636 | } | 636 | } |
637 | 637 | ||
638 | /* Convert 16 bit Unicode pathname from wire format to string in current code | ||
639 | page. Conversion may involve remapping up the seven characters that are | ||
640 | only legal in POSIX-like OS (if they are present in the string). Path | ||
641 | names are little endian 16 bit Unicode on the wire */ | ||
642 | int | ||
643 | cifs_convertUCSpath(char *target, const __le16 *source, int maxlen, | ||
644 | const struct nls_table *cp) | ||
645 | { | ||
646 | int i, j, len; | ||
647 | __u16 src_char; | ||
648 | |||
649 | for (i = 0, j = 0; i < maxlen; i++) { | ||
650 | src_char = le16_to_cpu(source[i]); | ||
651 | switch (src_char) { | ||
652 | case 0: | ||
653 | goto cUCS_out; /* BB check this BB */ | ||
654 | case UNI_COLON: | ||
655 | target[j] = ':'; | ||
656 | break; | ||
657 | case UNI_ASTERIK: | ||
658 | target[j] = '*'; | ||
659 | break; | ||
660 | case UNI_QUESTION: | ||
661 | target[j] = '?'; | ||
662 | break; | ||
663 | /* BB We can not handle remapping slash until | ||
664 | all the calls to build_path_from_dentry | ||
665 | are modified, as they use slash as separator BB */ | ||
666 | /* case UNI_SLASH: | ||
667 | target[j] = '\\'; | ||
668 | break;*/ | ||
669 | case UNI_PIPE: | ||
670 | target[j] = '|'; | ||
671 | break; | ||
672 | case UNI_GRTRTHAN: | ||
673 | target[j] = '>'; | ||
674 | break; | ||
675 | case UNI_LESSTHAN: | ||
676 | target[j] = '<'; | ||
677 | break; | ||
678 | default: | ||
679 | len = cp->uni2char(src_char, &target[j], | ||
680 | NLS_MAX_CHARSET_SIZE); | ||
681 | if (len > 0) { | ||
682 | j += len; | ||
683 | continue; | ||
684 | } else { | ||
685 | target[j] = '?'; | ||
686 | } | ||
687 | } | ||
688 | j++; | ||
689 | /* make sure we do not overrun callers allocated temp buffer */ | ||
690 | if (j >= (2 * NAME_MAX)) | ||
691 | break; | ||
692 | } | ||
693 | cUCS_out: | ||
694 | target[j] = 0; | ||
695 | return j; | ||
696 | } | ||
697 | |||
698 | /* Convert 16 bit Unicode pathname to wire format from string in current code | 638 | /* Convert 16 bit Unicode pathname to wire format from string in current code |
699 | page. Conversion may involve remapping up the seven characters that are | 639 | page. Conversion may involve remapping up the seven characters that are |
700 | only legal in POSIX-like OS (if they are present in the string). Path | 640 | only legal in POSIX-like OS (if they are present in the string). Path |
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index ebd0da7ecb3d..e1351fe18a15 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c | |||
@@ -31,6 +31,13 @@ | |||
31 | #include "cifs_fs_sb.h" | 31 | #include "cifs_fs_sb.h" |
32 | #include "cifsfs.h" | 32 | #include "cifsfs.h" |
33 | 33 | ||
34 | /* | ||
35 | * To be safe - for UCS to UTF-8 with strings loaded with the rare long | ||
36 | * characters alloc more to account for such multibyte target UTF-8 | ||
37 | * characters. | ||
38 | */ | ||
39 | #define UNICODE_NAME_MAX ((4 * NAME_MAX) + 2) | ||
40 | |||
34 | #ifdef CONFIG_CIFS_DEBUG2 | 41 | #ifdef CONFIG_CIFS_DEBUG2 |
35 | static void dump_cifs_file_struct(struct file *file, char *label) | 42 | static void dump_cifs_file_struct(struct file *file, char *label) |
36 | { | 43 | { |
@@ -881,14 +888,11 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst, | |||
881 | } | 888 | } |
882 | 889 | ||
883 | if (unicode) { | 890 | if (unicode) { |
884 | /* BB fixme - test with long names */ | 891 | pqst->len = cifs_from_ucs2((char *) pqst->name, |
885 | /* Note converted filename can be longer than in unicode */ | 892 | (__le16 *) filename, |
886 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR) | 893 | UNICODE_NAME_MAX, max_len, nlt, |
887 | pqst->len = cifs_convertUCSpath((char *)pqst->name, | 894 | cifs_sb->mnt_cifs_flags & |
888 | (__le16 *)filename, len/2, nlt); | 895 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
889 | else | ||
890 | pqst->len = cifs_strfromUCS_le((char *)pqst->name, | ||
891 | (__le16 *)filename, len/2, nlt); | ||
892 | } else { | 896 | } else { |
893 | pqst->name = filename; | 897 | pqst->name = filename; |
894 | pqst->len = len; | 898 | pqst->len = len; |
@@ -1070,11 +1074,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir) | |||
1070 | cifsFile->srch_inf.ntwrk_buf_start); | 1074 | cifsFile->srch_inf.ntwrk_buf_start); |
1071 | end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + max_len; | 1075 | end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + max_len; |
1072 | 1076 | ||
1073 | /* To be safe - for UCS to UTF-8 with strings loaded | 1077 | tmp_buf = kmalloc(UNICODE_NAME_MAX, GFP_KERNEL); |
1074 | with the rare long characters alloc more to account for | ||
1075 | such multibyte target UTF-8 characters. cifs_unicode.c, | ||
1076 | which actually does the conversion, has the same limit */ | ||
1077 | tmp_buf = kmalloc((4 * NAME_MAX) + 2, GFP_KERNEL); | ||
1078 | for (i = 0; (i < num_to_fill) && (rc == 0); i++) { | 1078 | for (i = 0; (i < num_to_fill) && (rc == 0); i++) { |
1079 | if (current_entry == NULL) { | 1079 | if (current_entry == NULL) { |
1080 | /* evaluate whether this case is an error */ | 1080 | /* evaluate whether this case is an error */ |