aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSteve French <smfrench@gmail.com>2016-06-22 22:07:32 -0400
committerSteve French <smfrench@gmail.com>2016-06-24 13:05:52 -0400
commit45e8a2583d97ca758a55c608f78c4cef562644d1 (patch)
tree3766108644c9e0fa15136d042ed2143a37796e1a /fs
parent4fcd1813e6404dd4420c7d12fb483f9320f0bf93 (diff)
File names with trailing period or space need special case conversion
POSIX allows files with trailing spaces or a trailing period but SMB3 does not, so convert these using the normal Services For Mac mapping as we do for other reserved characters such as : < > | ? * This is similar to what Macs do for the same problem over SMB3. CC: Stable <stable@vger.kernel.org> Signed-off-by: Steve French <steve.french@primarydata.com> Acked-by: Pavel Shilovsky <pshilovsky@samba.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/cifs_unicode.c33
-rw-r--r--fs/cifs/cifs_unicode.h2
2 files changed, 31 insertions, 4 deletions
diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
index 5a53ac6b1e02..02b071bf3732 100644
--- a/fs/cifs/cifs_unicode.c
+++ b/fs/cifs/cifs_unicode.c
@@ -101,6 +101,12 @@ convert_sfm_char(const __u16 src_char, char *target)
101 case SFM_SLASH: 101 case SFM_SLASH:
102 *target = '\\'; 102 *target = '\\';
103 break; 103 break;
104 case SFM_SPACE:
105 *target = ' ';
106 break;
107 case SFM_PERIOD:
108 *target = '.';
109 break;
104 default: 110 default:
105 return false; 111 return false;
106 } 112 }
@@ -404,7 +410,7 @@ static __le16 convert_to_sfu_char(char src_char)
404 return dest_char; 410 return dest_char;
405} 411}
406 412
407static __le16 convert_to_sfm_char(char src_char) 413static __le16 convert_to_sfm_char(char src_char, bool end_of_string)
408{ 414{
409 __le16 dest_char; 415 __le16 dest_char;
410 416
@@ -427,6 +433,18 @@ static __le16 convert_to_sfm_char(char src_char)
427 case '|': 433 case '|':
428 dest_char = cpu_to_le16(SFM_PIPE); 434 dest_char = cpu_to_le16(SFM_PIPE);
429 break; 435 break;
436 case '.':
437 if (end_of_string)
438 dest_char = cpu_to_le16(SFM_PERIOD);
439 else
440 dest_char = 0;
441 break;
442 case ' ':
443 if (end_of_string)
444 dest_char = cpu_to_le16(SFM_SPACE);
445 else
446 dest_char = 0;
447 break;
430 default: 448 default:
431 dest_char = 0; 449 dest_char = 0;
432 } 450 }
@@ -469,9 +487,16 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
469 /* see if we must remap this char */ 487 /* see if we must remap this char */
470 if (map_chars == SFU_MAP_UNI_RSVD) 488 if (map_chars == SFU_MAP_UNI_RSVD)
471 dst_char = convert_to_sfu_char(src_char); 489 dst_char = convert_to_sfu_char(src_char);
472 else if (map_chars == SFM_MAP_UNI_RSVD) 490 else if (map_chars == SFM_MAP_UNI_RSVD) {
473 dst_char = convert_to_sfm_char(src_char); 491 bool end_of_string;
474 else 492
493 if (i == srclen - 1)
494 end_of_string = true;
495 else
496 end_of_string = false;
497
498 dst_char = convert_to_sfm_char(src_char, end_of_string);
499 } else
475 dst_char = 0; 500 dst_char = 0;
476 /* 501 /*
477 * FIXME: We can not handle remapping backslash (UNI_SLASH) 502 * FIXME: We can not handle remapping backslash (UNI_SLASH)
diff --git a/fs/cifs/cifs_unicode.h b/fs/cifs/cifs_unicode.h
index bdc52cb9a676..479bc0a941f3 100644
--- a/fs/cifs/cifs_unicode.h
+++ b/fs/cifs/cifs_unicode.h
@@ -64,6 +64,8 @@
64#define SFM_LESSTHAN ((__u16) 0xF023) 64#define SFM_LESSTHAN ((__u16) 0xF023)
65#define SFM_PIPE ((__u16) 0xF027) 65#define SFM_PIPE ((__u16) 0xF027)
66#define SFM_SLASH ((__u16) 0xF026) 66#define SFM_SLASH ((__u16) 0xF026)
67#define SFM_PERIOD ((__u16) 0xF028)
68#define SFM_SPACE ((__u16) 0xF029)
67 69
68/* 70/*
69 * Mapping mechanism to use when one of the seven reserved characters is 71 * Mapping mechanism to use when one of the seven reserved characters is