summaryrefslogtreecommitdiffstats
path: root/fs/cifs/smb1ops.c
diff options
context:
space:
mode:
authorSteve French <smfrench@gmail.com>2014-09-27 03:19:01 -0400
committerSteve French <smfrench@gmail.com>2014-10-16 16:20:20 -0400
commit2baa2682531ff02928e2d3904800696d9e7193db (patch)
tree5da390e5e3d825b085481529205e5ca171ec9f38 /fs/cifs/smb1ops.c
parenta4153cb1d3cb7d7c16968b0a9cf7c8aacf31424e (diff)
Remap reserved posix characters by default (part 3/3)
This is a bigger patch, but its size is mostly due to a single change for how we check for remapping illegal characters in file names - a lot of repeated, small changes to the way callers request converting file names. The final patch in the series does the following: 1) changes default behavior for cifs to be more intuitive. Currently we do not map by default to seven reserved characters, ie those valid in POSIX but not in NTFS/CIFS/SMB3/Windows, unless a mount option (mapchars) is specified. Change this to by default always map and map using the SFM maping (like the Mac uses) unless the server negotiates the CIFS Unix Extensions (like Samba does when mounting with the cifs protocol) when the remapping of the characters is unnecessary. This should help SMB3 mounts in particular since Samba will likely be able to implement this mapping with its new "vfs_fruit" module as it will be doing for the Mac. 2) if the user specifies the existing "mapchars" mount option then use the "SFU" (Microsoft Services for Unix, SUA) style mapping of the seven characters instead. 3) if the user specifies "nomapposix" then disable SFM/MAC style mapping (so no character remapping would be used unless the user specifies "mapchars" on mount as well, as above). 4) change all the places in the code that check for the superblock flag on the mount which is set by mapchars and passed in on all path based operation and change it to use a small function call instead to set the mapping type properly (and check for the mapping type in the cifs unicode functions) Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/smb1ops.c')
-rw-r--r--fs/cifs/smb1ops.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index 2aca620193cd..d2979036a4c7 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -23,6 +23,7 @@
23#include "cifsproto.h" 23#include "cifsproto.h"
24#include "cifs_debug.h" 24#include "cifs_debug.h"
25#include "cifspdu.h" 25#include "cifspdu.h"
26#include "cifs_unicode.h"
26 27
27/* 28/*
28 * An NT cancel request header looks just like the original request except: 29 * An NT cancel request header looks just like the original request except:
@@ -530,13 +531,11 @@ cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
530 531
531 rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info, 532 rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info,
532 0 /* not legacy */, cifs_sb->local_nls, 533 0 /* not legacy */, cifs_sb->local_nls,
533 cifs_sb->mnt_cifs_flags & 534 cifs_remap(cifs_sb));
534 CIFS_MOUNT_MAP_SPECIAL_CHR);
535 535
536 if (rc == -EOPNOTSUPP || rc == -EINVAL) 536 if (rc == -EOPNOTSUPP || rc == -EINVAL)
537 rc = SMBQueryInformation(xid, tcon, full_path, file_info, 537 rc = SMBQueryInformation(xid, tcon, full_path, file_info,
538 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & 538 cifs_sb->local_nls, cifs_remap(cifs_sb));
539 CIFS_MOUNT_MAP_SPECIAL_CHR);
540 kfree(file_info); 539 kfree(file_info);
541 return rc; 540 return rc;
542} 541}
@@ -552,8 +551,7 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
552 551
553 /* could do find first instead but this returns more info */ 552 /* could do find first instead but this returns more info */
554 rc = CIFSSMBQPathInfo(xid, tcon, full_path, data, 0 /* not legacy */, 553 rc = CIFSSMBQPathInfo(xid, tcon, full_path, data, 0 /* not legacy */,
555 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & 554 cifs_sb->local_nls, cifs_remap(cifs_sb));
556 CIFS_MOUNT_MAP_SPECIAL_CHR);
557 /* 555 /*
558 * BB optimize code so we do not make the above call when server claims 556 * BB optimize code so we do not make the above call when server claims
559 * no NT SMB support and the above call failed at least once - set flag 557 * no NT SMB support and the above call failed at least once - set flag
@@ -562,8 +560,7 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
562 if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) { 560 if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) {
563 rc = SMBQueryInformation(xid, tcon, full_path, data, 561 rc = SMBQueryInformation(xid, tcon, full_path, data,
564 cifs_sb->local_nls, 562 cifs_sb->local_nls,
565 cifs_sb->mnt_cifs_flags & 563 cifs_remap(cifs_sb));
566 CIFS_MOUNT_MAP_SPECIAL_CHR);
567 *adjustTZ = true; 564 *adjustTZ = true;
568 } 565 }
569 566
@@ -611,8 +608,7 @@ cifs_get_srv_inum(const unsigned int xid, struct cifs_tcon *tcon,
611 */ 608 */
612 return CIFSGetSrvInodeNumber(xid, tcon, full_path, uniqueid, 609 return CIFSGetSrvInodeNumber(xid, tcon, full_path, uniqueid,
613 cifs_sb->local_nls, 610 cifs_sb->local_nls,
614 cifs_sb->mnt_cifs_flags & 611 cifs_remap(cifs_sb));
615 CIFS_MOUNT_MAP_SPECIAL_CHR);
616} 612}
617 613
618static int 614static int
@@ -703,8 +699,7 @@ cifs_mkdir_setinfo(struct inode *inode, const char *full_path,
703 dosattrs = cifsInode->cifsAttrs|ATTR_READONLY; 699 dosattrs = cifsInode->cifsAttrs|ATTR_READONLY;
704 info.Attributes = cpu_to_le32(dosattrs); 700 info.Attributes = cpu_to_le32(dosattrs);
705 rc = CIFSSMBSetPathInfo(xid, tcon, full_path, &info, cifs_sb->local_nls, 701 rc = CIFSSMBSetPathInfo(xid, tcon, full_path, &info, cifs_sb->local_nls,
706 cifs_sb->mnt_cifs_flags & 702 cifs_remap(cifs_sb));
707 CIFS_MOUNT_MAP_SPECIAL_CHR);
708 if (rc == 0) 703 if (rc == 0)
709 cifsInode->cifsAttrs = dosattrs; 704 cifsInode->cifsAttrs = dosattrs;
710} 705}
@@ -720,8 +715,7 @@ cifs_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
720 oparms->create_options, 715 oparms->create_options,
721 &oparms->fid->netfid, oplock, buf, 716 &oparms->fid->netfid, oplock, buf,
722 oparms->cifs_sb->local_nls, 717 oparms->cifs_sb->local_nls,
723 oparms->cifs_sb->mnt_cifs_flags 718 cifs_remap(oparms->cifs_sb));
724 & CIFS_MOUNT_MAP_SPECIAL_CHR);
725 return CIFS_open(xid, oparms, oplock, buf); 719 return CIFS_open(xid, oparms, oplock, buf);
726} 720}
727 721
@@ -800,8 +794,7 @@ smb_set_file_info(struct inode *inode, const char *full_path,
800 tcon = tlink_tcon(tlink); 794 tcon = tlink_tcon(tlink);
801 795
802 rc = CIFSSMBSetPathInfo(xid, tcon, full_path, buf, cifs_sb->local_nls, 796 rc = CIFSSMBSetPathInfo(xid, tcon, full_path, buf, cifs_sb->local_nls,
803 cifs_sb->mnt_cifs_flags & 797 cifs_remap(cifs_sb));
804 CIFS_MOUNT_MAP_SPECIAL_CHR);
805 if (rc == 0) { 798 if (rc == 0) {
806 cinode->cifsAttrs = le32_to_cpu(buf->Attributes); 799 cinode->cifsAttrs = le32_to_cpu(buf->Attributes);
807 goto out; 800 goto out;