Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 316439 Details for
Bug 247489
CIFS support for multibyte characters : euc-jp for this case.
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
patch: add codepage option to CIFS
cifs-nls-path.patch (text/plain), 104.50 KB, created by
Jeff Layton
on 2008-09-11 13:33:56 UTC
(
hide
)
Description:
patch: add codepage option to CIFS
Filename:
MIME Type:
Creator:
Jeff Layton
Created:
2008-09-11 13:33:56 UTC
Size:
104.50 KB
patch
obsolete
>------------------------------------------------------------------------------- >cifs-add-codepage-mount-option >------------------------------------------------------------------------------- >[CIFS] add codepage= mount option and have it set up remote_nls > >From: Jeff Layton <jlayton@redhat.com> > >For non-ASCII, non-UTF8 legacy servers, we need to be able to translate >to and from their codepage. Add a "codepage" mount option that performs >a similar function to the one used in smbfs. The idea is to translate >strings to and from our local character set from and to the remote one. > >Signed-off-by: Jeff Layton <jlayton@redhat.com> >--- > > fs/cifs/cifs_fs_sb.h | 1 + > fs/cifs/cifsfs.c | 4 ++++ > fs/cifs/connect.c | 29 +++++++++++++++++++++++++++++ > 3 files changed, 34 insertions(+), 0 deletions(-) > > >diff --git a/fs/cifs/cifs_fs_sb.h b/fs/cifs/cifs_fs_sb.h >index 877c854..41e46b9 100644 >--- a/fs/cifs/cifs_fs_sb.h >+++ b/fs/cifs/cifs_fs_sb.h >@@ -36,6 +36,7 @@ struct cifs_sb_info { > struct cifsTconInfo *tcon; /* primary mount */ > struct list_head nested_tcon_q; > struct nls_table *local_nls; >+ struct nls_table *remote_nls; > unsigned int rsize; > unsigned int wsize; > uid_t mnt_uid; >diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c >index 25ecbd5..7a04cec 100644 >--- a/fs/cifs/cifsfs.c >+++ b/fs/cifs/cifsfs.c >@@ -187,6 +187,8 @@ out_mount_failed: > #endif > if (cifs_sb->local_nls) > unload_nls(cifs_sb->local_nls); >+ if (cifs_sb->remote_nls) >+ unload_nls(cifs_sb->remote_nls); > kfree(cifs_sb); > } > return rc; >@@ -215,6 +217,8 @@ cifs_put_super(struct super_block *sb) > #endif > > unload_nls(cifs_sb->local_nls); >+ if (cifs_sb->remote_nls) >+ unload_nls(cifs_sb->remote_nls); > kfree(cifs_sb); > return; > } >diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c >index 4c13bcd..fa3eda4 100644 >--- a/fs/cifs/connect.c >+++ b/fs/cifs/connect.c >@@ -62,6 +62,7 @@ struct smb_vol { > char *UNCip; > char *in6_addr; /* ipv6 address as human readable form of in6_addr */ > char *iocharset; /* local code page for mapping to and from Unicode */ >+ char *codepage; /* remote code page in use by server */ > char source_rfc1001_name[16]; /* netbios name of client */ > char target_rfc1001_name[16]; /* netbios name of server for Win9x/ME */ > uid_t linux_uid; >@@ -1081,6 +1082,21 @@ cifs_parse_mount_options(char *options, const char *devname, > "too long.\n"); > return 1; > } >+ } else if (strnicmp(data, "codepage", 8) == 0) { >+ if (!value || !*value) { >+ printk(KERN_WARNING "CIFS: invalid codepage " >+ "specified\n"); >+ return 1; /* needs_arg; */ >+ } >+ if (strnlen(value, 65) < 65) { >+ if (strnicmp(value, "default", 7)) >+ vol->codepage = value; >+ cFYI(1, ("codepage set to %s", value)); >+ } else { >+ printk(KERN_WARNING "CIFS: codepage name " >+ "too long.\n"); >+ return 1; >+ } > } else if (strnicmp(data, "uid", 3) == 0) { > if (value && *value) { > vol->linux_uid = >@@ -1936,6 +1952,19 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, > } > } > >+ /* this is needed when non-local_nls/non-utf8 codepage in use on server */ >+ if (volume_info.codepage == NULL) { >+ cifs_sb->remote_nls = NULL; >+ } else { >+ cifs_sb->remote_nls = load_nls(volume_info.codepage); >+ if (cifs_sb->remote_nls == NULL) { >+ cERROR(1, ("CIFS mount error: codepage %s not found", >+ volume_info.codepage)); >+ rc = -ELIBACC; >+ goto out; >+ } >+ } >+ > if (address_type == AF_INET) > existingCifsSes = cifs_find_tcp_session(&sin_server.sin_addr, > NULL /* no ipv6 addr */, >------------------------------------------------------------------------------- >cifs-add-new-nls-conversion-ro >------------------------------------------------------------------------------- >[CIFS] add new NLS conversion routines > >From: Jeff Layton <jlayton@redhat.com> > >Add a cifs_nls_convert function, that does a conversion from one codepage >to another. When one or both codepages is NULL, it just does a memcpy >from one to the other. Also add some helper functions for converting >paths to and from the format that the server expects. > >Signed-off-by: Jeff Layton <jlayton@redhat.com> >--- > > fs/cifs/cifs_unicode.c | 57 +++++++++++++++++++++++++++++++++++++++++ > fs/cifs/cifs_unicode.h | 3 ++ > fs/cifs/cifsproto.h | 8 ++++++ > fs/cifs/misc.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ > 4 files changed, 135 insertions(+), 0 deletions(-) > > >diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c >index 7d75272..c6432fa 100644 >--- a/fs/cifs/cifs_unicode.c >+++ b/fs/cifs/cifs_unicode.c >@@ -88,3 +88,60 @@ cifs_strtoUCS(__le16 *to, const char *from, int len, > return i; > } > >+/* >+ * cifs_nls_convert - convert string from one character set to another >+ * @from: original string >+ * @to: destination for converted string >+ * @from_nls: nls that the "from" string is in >+ * @to_nls: nls to which we need to convert the "to" string >+ * @len: from string length >+ * @from_le: is the original string in little endian format? >+ * >+ * convert a string from one nls_codepage to another. If either codepage is >+ * NULL, then we assume that both ends are using the same codepage and just >+ * do a memcpy. >+ */ >+int >+cifs_nls_convert(const unsigned char *from, unsigned char *to, >+ const struct nls_table *from_nls, >+ const struct nls_table *to_nls, unsigned int inlen) >+{ >+ int charlen, outlen = 0; >+ wchar_t temp; >+ >+ >+ /* if either codepage is NULL, then just strlcpy */ >+ if (!from_nls || !to_nls) { >+ /* add 1 for terminating NULL */ >+ strlcpy(to, from, inlen + 1); >+ return inlen; >+ } >+ >+ while (inlen && *from) { >+ /* convert character to unicode */ >+ charlen = from_nls->char2uni(from, inlen, &temp); >+ if (charlen < 1) { >+ cFYI(1, ("strtoUCS: char2uni of 0x%x returned %d", >+ *from, charlen)); >+ /* A question mark */ >+ temp = 0x003f; >+ charlen = 1; >+ } >+ >+ /* adjust input lengths */ >+ from += charlen; >+ inlen -= charlen; >+ >+ /* convert temp char from unicode to to_nls */ >+ charlen = to_nls->uni2char(temp, &to[outlen], >+ NLS_MAX_CHARSET_SIZE); >+ if (charlen > 0) >+ outlen += charlen; >+ else >+ to[outlen++] = '?'; >+ } >+ >+ /* NULL terminate */ >+ to[outlen] = 0; >+ return outlen; >+} >diff --git a/fs/cifs/cifs_unicode.h b/fs/cifs/cifs_unicode.h >index 14eb9a2..9577972 100644 >--- a/fs/cifs/cifs_unicode.h >+++ b/fs/cifs/cifs_unicode.h >@@ -61,6 +61,9 @@ extern struct UniCaseRange UniLowerRange[]; > #ifdef __KERNEL__ > int cifs_strfromUCS_le(char *, const __le16 *, int, const struct nls_table *); > int cifs_strtoUCS(__le16 *, const char *, int, const struct nls_table *); >+int cifs_nls_convert(const unsigned char *from, unsigned char *to, >+ const struct nls_table *from_nls, >+ const struct nls_table *to_nls, unsigned int inlen); > #endif > > /* >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index a729d08..ee369c2 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -296,6 +296,14 @@ extern int cifs_convertUCSpath(char *target, const __le16 *source, int maxlen, > const struct nls_table *codepage); > extern int cifsConvertToUCS(__le16 *target, const char *source, int maxlen, > const struct nls_table *cp, int mapChars); >+extern int _cifs_path_to_remote(char *target, const char *source, int maxlen, >+ const struct cifs_sb_info *cifs_sb, bool unicode, >+ bool mapchar); >+extern int cifs_path_to_remote(char *target, const char * source, int maxlen, >+ const struct cifs_sb_info *cifs_sb, bool unicode); >+extern int cifs_path_to_local(char *target, const char * source, int maxlen, >+ const struct cifs_sb_info *cifs_sb, bool unicode, >+ bool mapchar); > > extern int CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, > const __u16 netfid, const __u64 len, >diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c >index 4b17f8f..b86952c 100644 >--- a/fs/cifs/misc.c >+++ b/fs/cifs/misc.c >@@ -778,3 +778,70 @@ cifsConvertToUCS(__le16 *target, const char *source, int maxlen, > ctoUCS_out: > return i; > } >+ >+/* >+ * cifs_path_to_remote: convert a path from local_nls to whatever nls the >+ * server is using. Takes into account he mapchars >+ * variable for unicode. Returns number of bytes in >+ * target string (including terminating NULLs). >+ */ >+int >+_cifs_path_to_remote(char *target, const char *source, int maxlen, >+ const struct cifs_sb_info *cifs_sb, bool unicode, >+ bool mapchar) >+{ >+ int len; >+ >+ if (unicode) { >+ len = cifsConvertToUCS((__le16 *) target, source, maxlen, >+ cifs_sb->local_nls, mapchar); >+ ++len; >+ len *= 2; >+ } else { >+ len = cifs_nls_convert(source, target, cifs_sb->local_nls, >+ cifs_sb->remote_nls, maxlen); >+ ++len; >+ } >+ >+ return len; >+} >+ >+int >+cifs_path_to_remote(char *target, const char *source, int maxlen, >+ const struct cifs_sb_info *cifs_sb, bool unicode) >+{ >+ return _cifs_path_to_remote(target, source, maxlen, cifs_sb, unicode, >+ cifs_sb->mnt_cifs_flags & >+ CIFS_MOUNT_MAP_SPECIAL_CHR); >+} >+ >+/* >+ * cifs_path_to_local: convert a path from whatever nls the server is using >+ * to local_nls. Takes into account he mapchars variable >+ * for unicode. Returns number of bytes in target string >+ * (including terminating NULLs). >+ */ >+int >+cifs_path_to_local(char *target, const char *source, int maxlen, >+ const struct cifs_sb_info *cifs_sb, bool unicode, >+ bool mapchar) >+{ >+ int len; >+ >+ if (unicode) { >+ if (mapchar) >+ len = cifs_convertUCSpath(target, (__le16 *) source, >+ maxlen, cifs_sb->local_nls); >+ else >+ len = cifs_strfromUCS_le(target, (__le16 *) source, >+ maxlen, cifs_sb->local_nls); >+ ++len; >+ len *= 2; >+ } else { >+ len = cifs_nls_convert(source, target, cifs_sb->remote_nls, >+ cifs_sb->local_nls, maxlen); >+ ++len; >+ } >+ >+ return len; >+} >------------------------------------------------------------------------------- >cifs-convert-cifsposixdelfile- >------------------------------------------------------------------------------- >[CIFS] convert CIFSPOSIXDelFile and CIFSSMBDelFile to take cifs_sb arg > >From: Jeff Layton <jlayton@redhat.com> > >...and convert them to use the new string conversion routine. > >Signed-off-by: Jeff Layton <jlayton@redhat.com> >--- > > fs/cifs/cifsproto.h | 6 ++---- > fs/cifs/cifssmb.c | 33 +++++++++------------------------ > fs/cifs/inode.c | 11 +++-------- > 3 files changed, 14 insertions(+), 36 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index ee369c2..2030047 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -218,12 +218,10 @@ extern int CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon, > int remap_special_chars); > extern int CIFSPOSIXDelFile(const int xid, struct cifsTconInfo *tcon, > const char *name, __u16 type, >- const struct nls_table *nls_codepage, >- int remap_special_chars); >+ const struct cifs_sb_info *cifs_sb); > extern int CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon, > const char *name, >- const struct nls_table *nls_codepage, >- int remap_special_chars); >+ const struct cifs_sb_info *cifs_sb); > extern int CIFSSMBRename(const int xid, struct cifsTconInfo *tcon, > const char *fromName, const char *toName, > const struct nls_table *nls_codepage, >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index 994de7c..5b084d1 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -845,7 +845,7 @@ CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses) > > int > CIFSPOSIXDelFile(const int xid, struct cifsTconInfo *tcon, const char *fileName, >- __u16 type, const struct nls_table *nls_codepage, int remap) >+ __u16 type, const struct cifs_sb_info *cifs_sb) > { > TRANSACTION2_SPI_REQ *pSMB = NULL; > TRANSACTION2_SPI_RSP *pSMBr = NULL; >@@ -862,17 +862,9 @@ PsxDelete: > if (rc) > return rc; > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB add path length overrun check */ >- name_len = strnlen(fileName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->FileName, fileName, name_len); >- } >+ name_len = cifs_path_to_remote(pSMB->FileName, fileName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); > > params = 6 + name_len; > pSMB->MaxParameterCount = cpu_to_le16(2); >@@ -920,7 +912,7 @@ PsxDelete: > > int > CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon, const char *fileName, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_sb_info *cifs_sb) > { > DELETE_FILE_REQ *pSMB = NULL; > DELETE_FILE_RSP *pSMBr = NULL; >@@ -934,17 +926,10 @@ DelFileRetry: > if (rc) > return rc; > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->fileName, fileName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB improve check for buffer overruns BB */ >- name_len = strnlen(fileName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->fileName, fileName, name_len); >- } >+ name_len = cifs_path_to_remote(pSMB->fileName, fileName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); >+ > pSMB->SearchAttributes = > cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM); > pSMB->BufferFormat = 0x04; >diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c >index 9c548f1..78f1e87 100644 >--- a/fs/cifs/inode.c >+++ b/fs/cifs/inode.c >@@ -699,15 +699,13 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) > (CIFS_UNIX_POSIX_PATH_OPS_CAP & > le64_to_cpu(pTcon->fsUnixInfo.Capability))) { > rc = CIFSPOSIXDelFile(xid, pTcon, full_path, >- SMB_POSIX_UNLINK_FILE_TARGET, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); >+ SMB_POSIX_UNLINK_FILE_TARGET, cifs_sb); > cFYI(1, ("posix del rc %d", rc)); > if ((rc == 0) || (rc == -ENOENT)) > goto psx_del_no_retry; > } > >- rc = CIFSSMBDelFile(xid, pTcon, full_path, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); >+ rc = CIFSSMBDelFile(xid, pTcon, full_path, cifs_sb); > psx_del_no_retry: > if (!rc) { > if (direntry->d_inode) >@@ -779,10 +777,7 @@ psx_del_no_retry: > kfree(pinfo_buf); > } > if (rc == 0) { >- rc = CIFSSMBDelFile(xid, pTcon, full_path, >- cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ rc = CIFSSMBDelFile(xid, pTcon, full_path, cifs_sb); > if (!rc) { > if (direntry->d_inode) > drop_nlink(direntry->d_inode); >------------------------------------------------------------------------------- >cifs-convert-cifssmbrmdir-to-n >------------------------------------------------------------------------------- >[CIFS] convert CIFSSMBRmDir to new name conversion routine > >From: Jeff Layton <jlayton@redhat.com> > > >--- > > fs/cifs/cifsproto.h | 3 +-- > fs/cifs/cifssmb.c | 15 ++++----------- > fs/cifs/inode.c | 4 +--- > 3 files changed, 6 insertions(+), 16 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index 2030047..ba2c781 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -214,8 +214,7 @@ extern int CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon, > const struct nls_table *nls_codepage, > int remap_special_chars); > extern int CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon, >- const char *name, const struct nls_table *nls_codepage, >- int remap_special_chars); >+ const char *name, const struct cifs_sb_info *cifs_sb); > extern int CIFSPOSIXDelFile(const int xid, struct cifsTconInfo *tcon, > const char *name, __u16 type, > const struct cifs_sb_info *cifs_sb); >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index 5b084d1..0686996 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -950,7 +950,7 @@ DelFileRetry: > > int > CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon, const char *dirName, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_sb_info *cifs_sb) > { > DELETE_DIRECTORY_REQ *pSMB = NULL; > DELETE_DIRECTORY_RSP *pSMBr = NULL; >@@ -965,16 +965,9 @@ RmDirRetry: > if (rc) > return rc; > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = cifsConvertToUCS((__le16 *) pSMB->DirName, dirName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB improve check for buffer overruns BB */ >- name_len = strnlen(dirName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->DirName, dirName, name_len); >- } >+ name_len = cifs_path_to_remote(pSMB->DirName, dirName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); > > pSMB->BufferFormat = 0x04; > pSMB->hdr.smb_buf_length += name_len + 1; >diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c >index 78f1e87..d980615 100644 >--- a/fs/cifs/inode.c >+++ b/fs/cifs/inode.c >@@ -1069,9 +1069,7 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry) > return -ENOMEM; > } > >- rc = CIFSSMBRmDir(xid, pTcon, full_path, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); >- >+ rc = CIFSSMBRmDir(xid, pTcon, full_path, cifs_sb); > if (!rc) { > drop_nlink(inode); > spin_lock(&direntry->d_inode->i_lock); >------------------------------------------------------------------------------- >cifs-convert-cifssmbmkdir-and- >------------------------------------------------------------------------------- >[CIFS] convert CIFSSMBMkDir and CIFSPOSIXCreate to new name conversion routine > >From: Jeff Layton <jlayton@redhat.com> > > >--- > > fs/cifs/cifsproto.h | 5 ++--- > fs/cifs/cifssmb.c | 29 ++++++----------------------- > fs/cifs/inode.c | 7 ++----- > 3 files changed, 10 insertions(+), 31 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index ba2c781..8328bab 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -211,8 +211,7 @@ extern int CIFSSMBUnixSetInfo(const int xid, struct cifsTconInfo *pTcon, > > extern int CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon, > const char *newName, >- const struct nls_table *nls_codepage, >- int remap_special_chars); >+ const struct cifs_sb_info *cifs_sb); > extern int CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon, > const char *name, const struct cifs_sb_info *cifs_sb); > extern int CIFSPOSIXDelFile(const int xid, struct cifsTconInfo *tcon, >@@ -268,7 +267,7 @@ extern int CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, > u32 posix_flags, __u64 mode, __u16 *netfid, > FILE_UNIX_BASIC_INFO *pRetData, > __u32 *pOplock, const char *name, >- const struct nls_table *nls_codepage, int remap); >+ const struct cifs_sb_info *cifs_sb); > extern int CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, > const int smb_file_id); > >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index 0686996..b94af0a 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -986,7 +986,7 @@ RmDirRetry: > > int > CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon, >- const char *name, const struct nls_table *nls_codepage, int remap) >+ const char *name, const struct cifs_sb_info *cifs_sb) > { > int rc = 0; > CREATE_DIRECTORY_REQ *pSMB = NULL; >@@ -1001,16 +1001,8 @@ MkDirRetry: > if (rc) > return rc; > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = cifsConvertToUCS((__le16 *) pSMB->DirName, name, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB improve check for buffer overruns BB */ >- name_len = strnlen(name, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->DirName, name, name_len); >- } >+ name_len = cifs_path_to_remote(pSMB->DirName, name, PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); > > pSMB->BufferFormat = 0x04; > pSMB->hdr.smb_buf_length += name_len + 1; >@@ -1031,7 +1023,7 @@ int > CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, __u32 posix_flags, > __u64 mode, __u16 *netfid, FILE_UNIX_BASIC_INFO *pRetData, > __u32 *pOplock, const char *name, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_sb_info *cifs_sb) > { > TRANSACTION2_SPI_REQ *pSMB = NULL; > TRANSACTION2_SPI_RSP *pSMBr = NULL; >@@ -1049,17 +1041,8 @@ PsxCreat: > if (rc) > return rc; > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->FileName, name, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(name, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->FileName, name, name_len); >- } >+ name_len = cifs_path_to_remote(pSMB->FileName, name, PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); > > params = 6 + name_len; > count = sizeof(OPEN_PSX_REQ); >diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c >index d980615..9594189 100644 >--- a/fs/cifs/inode.c >+++ b/fs/cifs/inode.c >@@ -898,9 +898,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) > mode &= ~current->fs->umask; > rc = CIFSPOSIXCreate(xid, pTcon, SMB_O_DIRECTORY | SMB_O_CREAT, > mode, NULL /* netfid */, pInfo, &oplock, >- full_path, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ full_path, cifs_sb); > if (rc == -EOPNOTSUPP) { > kfree(pInfo); > goto mkdir_retry_old; >@@ -958,8 +956,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) > } > mkdir_retry_old: > /* BB add setting the equivalent of mode via CreateX w/ACLs */ >- rc = CIFSSMBMkDir(xid, pTcon, full_path, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); >+ rc = CIFSSMBMkDir(xid, pTcon, full_path, cifs_sb); > if (rc) { > cFYI(1, ("cifs_mkdir returned 0x%x", rc)); > d_drop(direntry); >------------------------------------------------------------------------------- >cifs-convert-cifssmbsetposixac >------------------------------------------------------------------------------- >[CIFS] convert CIFSSMBSetPosixACL and SMBQueryInformation to use new name conversion routines > >From: Jeff Layton <jlayton@redhat.com> > > >--- > > fs/cifs/cifsproto.h | 4 ++-- > fs/cifs/cifssmb.c | 34 ++++++++++------------------------ > fs/cifs/inode.c | 4 +--- > fs/cifs/xattr.c | 8 ++------ > 4 files changed, 15 insertions(+), 35 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index 8328bab..0805231 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -136,7 +136,7 @@ extern int CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, > extern int SMBQueryInformation(const int xid, struct cifsTconInfo *tcon, > const unsigned char *searchName, > FILE_ALL_INFO *findData, >- const struct nls_table *nls_codepage, int remap); >+ const struct cifs_sb_info *cifs_sb); > > extern int CIFSSMBUnixQPathInfo(const int xid, > struct cifsTconInfo *tcon, >@@ -368,7 +368,7 @@ extern int CIFSSMBGetPosixACL(const int xid, struct cifsTconInfo *tcon, > extern int CIFSSMBSetPosixACL(const int xid, struct cifsTconInfo *tcon, > const unsigned char *fileName, > const char *local_acl, const int buflen, const int acl_type, >- const struct nls_table *nls_codepage, int remap_special_chars); >+ const struct cifs_sb_info *cifs_sb); > extern int CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon, > const int netfid, __u64 *pExtAttrBits, __u64 *pMask); > #endif /* _CIFSPROTO_H */ >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index b94af0a..83f12d7 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -2893,7 +2893,7 @@ CIFSSMBSetPosixACL(const int xid, struct cifsTconInfo *tcon, > const unsigned char *fileName, > const char *local_acl, const int buflen, > const int acl_type, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_sb_info *cifs_sb) > { > struct smb_com_transaction2_spi_req *pSMB = NULL; > struct smb_com_transaction2_spi_rsp *pSMBr = NULL; >@@ -2909,17 +2909,11 @@ setAclRetry: > (void **) &pSMBr); > if (rc) > return rc; >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(fileName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->FileName, fileName, name_len); >- } >+ >+ name_len = cifs_path_to_remote(pSMB->FileName, fileName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); >+ > params = 6 + name_len; > pSMB->MaxParameterCount = cpu_to_le16(2); > /* BB find max SMB size from sess */ >@@ -3216,7 +3210,7 @@ setCifsAclRetry: > int SMBQueryInformation(const int xid, struct cifsTconInfo *tcon, > const unsigned char *searchName, > FILE_ALL_INFO *pFinfo, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_sb_info *cifs_sb) > { > QUERY_INFORMATION_REQ *pSMB; > QUERY_INFORMATION_RSP *pSMBr; >@@ -3231,17 +3225,9 @@ QInfRetry: > if (rc) > return rc; > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { >- name_len = strnlen(searchName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->FileName, searchName, name_len); >- } >+ name_len = cifs_path_to_remote(pSMB->FileName, searchName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); > pSMB->BufferFormat = 0x04; > name_len++; /* account for buffer type byte */ > pSMB->hdr.smb_buf_length += (__u16) name_len; >diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c >index 9594189..3ab7f7e 100644 >--- a/fs/cifs/inode.c >+++ b/fs/cifs/inode.c >@@ -447,9 +447,7 @@ int cifs_get_inode_info(struct inode **pinode, > failed at least once - set flag in tcon or mount */ > if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) { > rc = SMBQueryInformation(xid, pTcon, full_path, >- pfindData, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ pfindData, cifs_sb); > adjustTZ = true; > } > } >diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c >index e9527ee..79a58ea 100644 >--- a/fs/cifs/xattr.c >+++ b/fs/cifs/xattr.c >@@ -163,9 +163,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, > if (sb->s_flags & MS_POSIXACL) > rc = CIFSSMBSetPosixACL(xid, pTcon, full_path, > ea_value, (const int)value_size, >- ACL_TYPE_ACCESS, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ ACL_TYPE_ACCESS, cifs_sb); > cFYI(1, ("set POSIX ACL rc %d", rc)); > #else > cFYI(1, ("set POSIX ACL not supported")); >@@ -176,9 +174,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, > if (sb->s_flags & MS_POSIXACL) > rc = CIFSSMBSetPosixACL(xid, pTcon, full_path, > ea_value, (const int)value_size, >- ACL_TYPE_DEFAULT, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ ACL_TYPE_DEFAULT, cifs_sb); > cFYI(1, ("set POSIX default ACL rc %d", rc)); > #else > cFYI(1, ("set default POSIX ACL not supported")); >------------------------------------------------------------------------------- >cifs-convert-cifssmbqpathinfo- >------------------------------------------------------------------------------- >[CIFS] convert CIFSSMBQPathInfo to new name conversion routines > >From: Jeff Layton <jlayton@redhat.com> > > >--- > > fs/cifs/cifsproto.h | 2 +- > fs/cifs/cifssmb.c | 17 ++++------------- > fs/cifs/inode.c | 4 +--- > 3 files changed, 6 insertions(+), 17 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index 0805231..49824ed 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -132,7 +132,7 @@ extern int CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, > const unsigned char *searchName, > FILE_ALL_INFO *findData, > int legacy /* whether to use old info level */, >- const struct nls_table *nls_codepage, int remap); >+ const struct cifs_sb_info *cifs_sb); > extern int SMBQueryInformation(const int xid, struct cifsTconInfo *tcon, > const unsigned char *searchName, > FILE_ALL_INFO *findData, >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index 83f12d7..4221277 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -3274,7 +3274,7 @@ CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, > const unsigned char *searchName, > FILE_ALL_INFO *pFindData, > int legacy /* old style infolevel */, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_sb_info *cifs_sb) > { > /* level 263 SMB_QUERY_FILE_ALL_INFO */ > TRANSACTION2_QPI_REQ *pSMB = NULL; >@@ -3291,18 +3291,9 @@ QPathInfoRetry: > if (rc) > return rc; > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(searchName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->FileName, searchName, name_len); >- } >- >+ name_len = cifs_path_to_remote(pSMB->FileName, searchName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); > params = 2 /* level */ + 4 /* reserved */ + name_len /* includes NUL */; > pSMB->TotalDataCount = 0; > pSMB->MaxParameterCount = cpu_to_le16(2); >diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c >index 3ab7f7e..e4092a3 100644 >--- a/fs/cifs/inode.c >+++ b/fs/cifs/inode.c >@@ -439,9 +439,7 @@ int cifs_get_inode_info(struct inode **pinode, > > /* could do find first instead but this returns more info */ > rc = CIFSSMBQPathInfo(xid, pTcon, full_path, pfindData, >- 0 /* not legacy */, >- cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ 0 /* not legacy */, cifs_sb); > /* BB optimize code so we do not make the above call > when server claims no NT SMB support and the above call > failed at least once - set flag in tcon or mount */ >------------------------------------------------------------------------------- >cifs-convert-cifssmbunixqpathi >------------------------------------------------------------------------------- >[CIFS] convert CIFSSMBUnixQPathInfo to new name conversion routines > >From: Jeff Layton <jlayton@redhat.com> > > >--- > > fs/cifs/cifsproto.h | 2 +- > fs/cifs/cifssmb.c | 17 ++++------------- > fs/cifs/inode.c | 19 +++++-------------- > 3 files changed, 10 insertions(+), 28 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index 49824ed..60263ba 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -142,7 +142,7 @@ extern int CIFSSMBUnixQPathInfo(const int xid, > struct cifsTconInfo *tcon, > const unsigned char *searchName, > FILE_UNIX_BASIC_INFO *pFindData, >- const struct nls_table *nls_codepage, int remap); >+ const struct cifs_sb_info *cifs_sb); > > extern int CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses, > const unsigned char *searchName, >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index 4221277..907010b 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -3365,7 +3365,7 @@ int > CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon, > const unsigned char *searchName, > FILE_UNIX_BASIC_INFO *pFindData, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_sb_info *cifs_sb) > { > /* SMB_QUERY_FILE_UNIX_BASIC */ > TRANSACTION2_QPI_REQ *pSMB = NULL; >@@ -3382,18 +3382,9 @@ UnixQPathInfoRetry: > if (rc) > return rc; > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(searchName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->FileName, searchName, name_len); >- } >- >+ name_len = cifs_path_to_remote(pSMB->FileName, searchName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); > params = 2 /* level */ + 4 /* reserved */ + name_len /* includes NUL */; > pSMB->TotalDataCount = 0; > pSMB->MaxParameterCount = cpu_to_le16(2); >diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c >index e4092a3..b56135e 100644 >--- a/fs/cifs/inode.c >+++ b/fs/cifs/inode.c >@@ -216,9 +216,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, > cFYI(1, ("Getting info on %s", full_path)); > > /* could have done a find first instead but this returns more info */ >- rc = CIFSSMBUnixQPathInfo(xid, pTcon, full_path, &find_data, >- cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ rc = CIFSSMBUnixQPathInfo(xid, pTcon, full_path, &find_data, cifs_sb); > if (rc == -EREMOTE && !is_dfs_referral) { > is_dfs_referral = true; > cFYI(DBG2, ("DFS ref")); >@@ -1131,20 +1129,13 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry, > info_buf_target = info_buf_source + 1; > if (pTcon->unix_ext) > rc = CIFSSMBUnixQPathInfo(xid, pTcon, fromName, >- info_buf_source, >- cifs_sb_source->local_nls, >- cifs_sb_source->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ info_buf_source, cifs_sb_source); > /* else rc is still EEXIST so will fall through to > unlink the target and retry rename */ >- if (rc == 0) { >+ if (rc == 0) > rc = CIFSSMBUnixQPathInfo(xid, pTcon, toName, >- info_buf_target, >- cifs_sb_target->local_nls, >- /* remap based on source sb */ >- cifs_sb_source->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >- } >+ info_buf_target, cifs_sb_target); >+ > if ((rc == 0) && > (info_buf_source->UniqueId == > info_buf_target->UniqueId)) { >------------------------------------------------------------------------------- >cifs-convert-cifsgetsrvinodenu >------------------------------------------------------------------------------- >[CIFS] convert CIFSGetSrvInodeNumber and CIFSSMBSetEOF to new name conversion > >From: Jeff Layton <jlayton@redhat.com> > > >--- > > fs/cifs/cifsproto.h | 6 ++---- > fs/cifs/cifssmb.c | 34 ++++++++-------------------------- > fs/cifs/inode.c | 11 +++-------- > 3 files changed, 13 insertions(+), 38 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index 60263ba..6e495d0 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -187,8 +187,7 @@ extern int CIFSSMBSetAttrLegacy(int xid, struct cifsTconInfo *tcon, > extern int CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, > const char *fileName, __u64 size, > bool setAllocationSizeFlag, >- const struct nls_table *nls_codepage, >- int remap_special_chars); >+ const struct cifs_sb_info *cifs_sb); > extern int CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, > __u64 size, __u16 fileHandle, __u32 opener_pid, > bool AllocSizeFlag); >@@ -286,8 +285,7 @@ extern int CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon, > struct kvec *iov, const int nvec, const int long_op); > extern int CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon, > const unsigned char *searchName, __u64 *inode_number, >- const struct nls_table *nls_codepage, >- int remap_special_chars); >+ const struct cifs_sb_info *cifs_sb); > extern int cifs_convertUCSpath(char *target, const __le16 *source, int maxlen, > const struct nls_table *codepage); > extern int cifsConvertToUCS(__le16 *target, const char *source, int maxlen, >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index 907010b..422c786 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -3734,8 +3734,7 @@ CIFSFindClose(const int xid, struct cifsTconInfo *tcon, > int > CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon, > const unsigned char *searchName, >- __u64 *inode_number, >- const struct nls_table *nls_codepage, int remap) >+ __u64 *inode_number, const struct cifs_sb_info *cifs_sb) > { > int rc = 0; > TRANSACTION2_QPI_REQ *pSMB = NULL; >@@ -3753,18 +3752,9 @@ GetInodeNumberRetry: > if (rc) > return rc; > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(searchName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->FileName, searchName, name_len); >- } >- >+ name_len = cifs_path_to_remote(pSMB->FileName, searchName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); > params = 2 /* level */ + 4 /* rsrvd */ + name_len /* incl null */ ; > pSMB->TotalDataCount = 0; > pSMB->MaxParameterCount = cpu_to_le16(2); >@@ -4570,7 +4560,7 @@ QFSPosixRetry: > int > CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, const char *fileName, > __u64 size, bool SetAllocation, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_sb_info *cifs_sb) > { > struct smb_com_transaction2_spi_req *pSMB = NULL; > struct smb_com_transaction2_spi_rsp *pSMBr = NULL; >@@ -4587,17 +4577,9 @@ SetEOFRetry: > if (rc) > return rc; > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(fileName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->FileName, fileName, name_len); >- } >+ name_len = cifs_path_to_remote(pSMB->FileName, fileName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); > params = 6 + name_len; > data_count = sizeof(struct file_end_of_file_info); > pSMB->MaxParameterCount = cpu_to_le16(2); >diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c >index b56135e..20c29d1 100644 >--- a/fs/cifs/inode.c >+++ b/fs/cifs/inode.c >@@ -482,11 +482,8 @@ int cifs_get_inode_info(struct inode **pinode, > int rc1 = 0; > __u64 inode_num; > >- rc1 = CIFSGetSrvInodeNumber(xid, pTcon, >- full_path, &inode_num, >- cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ rc1 = CIFSGetSrvInodeNumber(xid, pTcon, full_path, >+ &inode_num, cifs_sb); > if (rc1) { > cFYI(1, ("GetSrvInodeNum rc %d", rc1)); > /* BB EOPNOSUPP disable SERVER_INUM? */ >@@ -1449,9 +1446,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs, > it was found or because there was an error setting > it by handle */ > rc = CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size, >- false, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ false, cifs_sb); > cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc)); > if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { > __u16 netfid; >------------------------------------------------------------------------------- >cifs-convert-cifssmbsetpathinf >------------------------------------------------------------------------------- >[CIFS] convert CIFSSMBSetPathInfo to new name conversion > >From: Jeff Layton <jlayton@redhat.com> > > >--- > > fs/cifs/cifsproto.h | 3 +-- > fs/cifs/cifssmb.c | 17 ++++------------- > fs/cifs/inode.c | 13 +++---------- > 3 files changed, 8 insertions(+), 25 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index 6e495d0..433c818 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -174,8 +174,7 @@ extern int CIFSSMBQFSPosixInfo(const int xid, struct cifsTconInfo *tcon, > > extern int CIFSSMBSetPathInfo(const int xid, struct cifsTconInfo *tcon, > const char *fileName, const FILE_BASIC_INFO *data, >- const struct nls_table *nls_codepage, >- int remap_special_chars); >+ const struct cifs_sb_info *cifs_sb); > extern int CIFSSMBSetFileInfo(const int xid, struct cifsTconInfo *tcon, > const FILE_BASIC_INFO *data, __u16 fid, > __u32 pid_of_opener); >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index 422c786..68cc577 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -4791,7 +4791,7 @@ CIFSSMBSetFileInfo(const int xid, struct cifsTconInfo *tcon, > int > CIFSSMBSetPathInfo(const int xid, struct cifsTconInfo *tcon, > const char *fileName, const FILE_BASIC_INFO *data, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_sb_info *cifs_sb) > { > TRANSACTION2_SPI_REQ *pSMB = NULL; > TRANSACTION2_SPI_RSP *pSMBr = NULL; >@@ -4809,18 +4809,9 @@ SetTimesRetry: > if (rc) > return rc; > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(fileName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->FileName, fileName, name_len); >- } >- >+ name_len = cifs_path_to_remote(pSMB->FileName, fileName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); > params = 6 + name_len; > count = sizeof(FILE_BASIC_INFO); > pSMB->MaxParameterCount = cpu_to_le16(2); >diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c >index 20c29d1..ab36543 100644 >--- a/fs/cifs/inode.c >+++ b/fs/cifs/inode.c >@@ -729,10 +729,7 @@ psx_del_no_retry: > pinfo_buf->Attributes = cpu_to_le32(ATTR_NORMAL); > if (!(pTcon->ses->flags & CIFS_SES_NT4)) > rc = CIFSSMBSetPathInfo(xid, pTcon, full_path, >- pinfo_buf, >- cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ pinfo_buf, cifs_sb); > else > rc = -EOPNOTSUPP; > >@@ -1005,9 +1002,7 @@ mkdir_get_info: > memset(&pInfo, 0, sizeof(pInfo)); > pInfo.Attributes = cpu_to_le32(ATTR_READONLY); > CIFSSMBSetPathInfo(xid, pTcon, full_path, >- &pInfo, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ &pInfo, cifs_sb); > } > if (direntry->d_inode) { > if (cifs_sb->mnt_cifs_flags & >@@ -1539,9 +1534,7 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, int xid, > */ > if (!(pTcon->ses->flags & CIFS_SES_NT4)) { > rc = CIFSSMBSetPathInfo(xid, pTcon, full_path, >- &info_buf, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ &info_buf, cifs_sb); > if (rc != -EOPNOTSUPP && rc != -EINVAL) > goto out; > } >------------------------------------------------------------------------------- >cifs-convert-cifssmbunixsetinf >------------------------------------------------------------------------------- >[CIFS] convert CIFSSMBUnixSetInfo to new name conversion > >From: Jeff Layton <jlayton@redhat.com> > > >--- > > fs/cifs/cifsproto.h | 3 +-- > fs/cifs/cifssmb.c | 19 +++++-------------- > fs/cifs/dir.c | 8 ++------ > fs/cifs/file.c | 4 +--- > fs/cifs/inode.c | 8 ++------ > 5 files changed, 11 insertions(+), 31 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index 433c818..3fbc138 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -204,8 +204,7 @@ struct cifs_unix_set_info_args { > extern int CIFSSMBUnixSetInfo(const int xid, struct cifsTconInfo *pTcon, > char *fileName, > const struct cifs_unix_set_info_args *args, >- const struct nls_table *nls_codepage, >- int remap_special_chars); >+ const struct cifs_sb_info *cifs_sb); > > extern int CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon, > const char *newName, >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index 68cc577..deb43a9 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -4912,8 +4912,8 @@ SetAttrLgcyRetry: > > int > CIFSSMBUnixSetInfo(const int xid, struct cifsTconInfo *tcon, char *fileName, >- const struct cifs_unix_set_info_args *args, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_unix_set_info_args *args, >+ const struct cifs_sb_info *cifs_sb) > { > TRANSACTION2_SPI_REQ *pSMB = NULL; > TRANSACTION2_SPI_RSP *pSMBr = NULL; >@@ -4931,18 +4931,9 @@ setPermsRetry: > if (rc) > return rc; > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(fileName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->FileName, fileName, name_len); >- } >- >+ name_len = cifs_path_to_remote(pSMB->FileName, fileName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); > params = 6 + name_len; > count = sizeof(FILE_UNIX_BASIC_INFO); > pSMB->MaxParameterCount = cpu_to_le16(2); >diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c >index e962e75..1911242 100644 >--- a/fs/cifs/dir.c >+++ b/fs/cifs/dir.c >@@ -245,9 +245,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, > args.gid = NO_CHANGE_64; > } > CIFSSMBUnixSetInfo(xid, pTcon, full_path, &args, >- cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ cifs_sb); > } else { > /* BB implement mode setting via Windows security > descriptors e.g. */ >@@ -382,9 +380,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, > args.gid = NO_CHANGE_64; > } > rc = CIFSSMBUnixSetInfo(xid, pTcon, full_path, >- &args, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ &args, cifs_sb); > > if (!rc) { > rc = cifs_get_inode_info_unix(&newinode, full_path, >diff --git a/fs/cifs/file.c b/fs/cifs/file.c >index cbefe1f..fd291b6 100644 >--- a/fs/cifs/file.c >+++ b/fs/cifs/file.c >@@ -320,9 +320,7 @@ int cifs_open(struct inode *inode, struct file *file) > .device = 0, > }; > CIFSSMBUnixSetInfo(xid, pTcon, full_path, &args, >- cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ cifs_sb); > } > } > >diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c >index ab36543..84c9415 100644 >--- a/fs/cifs/inode.c >+++ b/fs/cifs/inode.c >@@ -992,9 +992,7 @@ mkdir_get_info: > args.gid = NO_CHANGE_64; > } > CIFSSMBUnixSetInfo(xid, pTcon, full_path, &args, >- cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ cifs_sb); > } else { > if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) && > (mode & S_IWUGO) == 0) { >@@ -1663,9 +1661,7 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs) > > args->device = 0; > rc = CIFSSMBUnixSetInfo(xid, pTcon, full_path, args, >- cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ cifs_sb); > > if (!rc) > rc = inode_setattr(inode, attrs); >------------------------------------------------------------------------------- >cifs-convert-cifssmbqalleas-to >------------------------------------------------------------------------------- >[CIFS] convert CIFSSMBQAllEAs to new name conversion > >From: Jeff Layton <jlayton@redhat.com> > > >--- > > fs/cifs/cifsproto.h | 3 +-- > fs/cifs/cifssmb.c | 17 ++++------------- > fs/cifs/xattr.c | 5 +---- > 3 files changed, 6 insertions(+), 19 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index 3fbc138..2cc3a44 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -343,8 +343,7 @@ extern int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon, > const struct nls_table *nls_codepage); > extern ssize_t CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon, > const unsigned char *searchName, char *EAData, >- size_t bufsize, const struct nls_table *nls_codepage, >- int remap_special_chars); >+ size_t bufsize, const struct cifs_sb_info *cifs_sb); > extern ssize_t CIFSSMBQueryEA(const int xid, struct cifsTconInfo *tcon, > const unsigned char *searchName, const unsigned char *ea_name, > unsigned char *ea_value, size_t buf_size, >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index deb43a9..fe74571 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -5086,7 +5086,7 @@ ssize_t > CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon, > const unsigned char *searchName, > char *EAData, size_t buf_size, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_sb_info *cifs_sb) > { > /* BB assumes one setup word */ > TRANSACTION2_QPI_REQ *pSMB = NULL; >@@ -5105,18 +5105,9 @@ QAllEAsRetry: > if (rc) > return rc; > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(searchName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->FileName, searchName, name_len); >- } >- >+ name_len = cifs_path_to_remote(pSMB->FileName, searchName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); > params = 2 /* level */ + 4 /* reserved */ + name_len /* includes NUL */; > pSMB->TotalDataCount = 0; > pSMB->MaxParameterCount = cpu_to_le16(2); >diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c >index 79a58ea..53892cb 100644 >--- a/fs/cifs/xattr.c >+++ b/fs/cifs/xattr.c >@@ -356,10 +356,7 @@ ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size) > /* if proc/fs/cifs/streamstoxattr is set then > search server for EAs or streams to > returns as xattrs */ >- rc = CIFSSMBQAllEAs(xid, pTcon, full_path, data, buf_size, >- cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ rc = CIFSSMBQAllEAs(xid, pTcon, full_path, data, buf_size, cifs_sb); > > kfree(full_path); > FreeXid(xid); >------------------------------------------------------------------------------- >cifs-convert-cifssmbqueryea-ci >------------------------------------------------------------------------------- >[CIFS] convert CIFSSMBQueryEA, CIFSSMBSetEA and CIFSUnixCreateHardLink to new name conversion > >From: Jeff Layton <jlayton@redhat.com> > > >--- > > fs/cifs/cifsproto.h | 7 ++--- > fs/cifs/cifssmb.c | 67 ++++++++++++--------------------------------------- > fs/cifs/inode.c | 3 +- > fs/cifs/link.c | 4 +-- > fs/cifs/xattr.c | 15 ++++------- > 5 files changed, 26 insertions(+), 70 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index 2cc3a44..c9e5cb6 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -233,8 +233,7 @@ extern int CIFSCreateHardLink(const int xid, > extern int CIFSUnixCreateHardLink(const int xid, > struct cifsTconInfo *tcon, > const char *fromName, const char *toName, >- const struct nls_table *nls_codepage, >- int remap_special_chars); >+ const struct cifs_sb_info *cifs_sb); > extern int CIFSUnixCreateSymLink(const int xid, > struct cifsTconInfo *tcon, > const char *fromName, const char *toName, >@@ -347,11 +346,11 @@ extern ssize_t CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon, > extern ssize_t CIFSSMBQueryEA(const int xid, struct cifsTconInfo *tcon, > const unsigned char *searchName, const unsigned char *ea_name, > unsigned char *ea_value, size_t buf_size, >- const struct nls_table *nls_codepage, int remap_special_chars); >+ const struct cifs_sb_info *cifs_sb); > extern int CIFSSMBSetEA(const int xid, struct cifsTconInfo *tcon, > const char *fileName, const char *ea_name, > const void *ea_value, const __u16 ea_value_len, >- const struct nls_table *nls_codepage, int remap_special_chars); >+ const struct cifs_sb_info *cifs_sb); > extern int CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, > __u16 fid, struct cifs_ntsd **acl_inf, __u32 *buflen); > extern int CIFSSMBSetCIFSACL(const int, struct cifsTconInfo *, __u16, >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index fe74571..be32797 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -2216,7 +2216,7 @@ createSymLinkRetry: > int > CIFSUnixCreateHardLink(const int xid, struct cifsTconInfo *tcon, > const char *fromName, const char *toName, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_sb_info *cifs_sb) > { > TRANSACTION2_SPI_REQ *pSMB = NULL; > TRANSACTION2_SPI_RSP *pSMBr = NULL; >@@ -2234,17 +2234,9 @@ createHardLinkRetry: > if (rc) > return rc; > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = cifsConvertToUCS((__le16 *) pSMB->FileName, toName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(toName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->FileName, toName, name_len); >- } >+ name_len = cifs_path_to_remote(pSMB->FileName, toName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); > params = 6 + name_len; > pSMB->MaxSetupCount = 0; > pSMB->Reserved = 0; >@@ -2256,18 +2248,10 @@ createHardLinkRetry: > offset = param_offset + params; > > data_offset = (char *) (&pSMB->hdr.Protocol) + offset; >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len_target = >- cifsConvertToUCS((__le16 *) data_offset, fromName, PATH_MAX, >- nls_codepage, remap); >- name_len_target++; /* trailing null */ >- name_len_target *= 2; >- } else { /* BB improve the check for buffer overruns BB */ >- name_len_target = strnlen(fromName, PATH_MAX); >- name_len_target++; /* trailing null */ >- strncpy(data_offset, fromName, name_len_target); >- } >- >+ name_len_target = cifs_path_to_remote(data_offset, fromName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & >+ SMBFLG2_UNICODE); > pSMB->MaxParameterCount = cpu_to_le16(2); > /* BB find exact max on data count below from sess*/ > pSMB->MaxDataCount = cpu_to_le16(1000); >@@ -5226,7 +5210,7 @@ QAllEAsRetry: > ssize_t CIFSSMBQueryEA(const int xid, struct cifsTconInfo *tcon, > const unsigned char *searchName, const unsigned char *ea_name, > unsigned char *ea_value, size_t buf_size, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_sb_info *cifs_sb) > { > TRANSACTION2_QPI_REQ *pSMB = NULL; > TRANSACTION2_QPI_RSP *pSMBr = NULL; >@@ -5244,18 +5228,9 @@ QEARetry: > if (rc) > return rc; > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(searchName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->FileName, searchName, name_len); >- } >- >+ name_len = cifs_path_to_remote(pSMB->FileName, searchName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); > params = 2 /* level */ + 4 /* reserved */ + name_len /* includes NUL */; > pSMB->TotalDataCount = 0; > pSMB->MaxParameterCount = cpu_to_le16(2); >@@ -5375,8 +5350,7 @@ QEARetry: > int > CIFSSMBSetEA(const int xid, struct cifsTconInfo *tcon, const char *fileName, > const char *ea_name, const void *ea_value, >- const __u16 ea_value_len, const struct nls_table *nls_codepage, >- int remap) >+ const __u16 ea_value_len, const struct cifs_sb_info *cifs_sb) > { > struct smb_com_transaction2_spi_req *pSMB = NULL; > struct smb_com_transaction2_spi_rsp *pSMBr = NULL; >@@ -5393,18 +5367,9 @@ SetEARetry: > if (rc) > return rc; > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(fileName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->FileName, fileName, name_len); >- } >- >+ name_len = cifs_path_to_remote(pSMB->FileName, fileName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); > params = 6 + name_len; > > /* done calculating parms using name_len of file name, >diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c >index 84c9415..eebbb84 100644 >--- a/fs/cifs/inode.c >+++ b/fs/cifs/inode.c >@@ -355,8 +355,7 @@ static int get_sfu_mode(struct inode *inode, > __u32 mode; > > rc = CIFSSMBQueryEA(xid, cifs_sb->tcon, path, "SETFILEBITS", >- ea_value, 4 /* size of buf */, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); >+ ea_value, 4 /* size of buf */, cifs_sb); > if (rc < 0) > return (int)rc; > else if (rc > 3) { >diff --git a/fs/cifs/link.c b/fs/cifs/link.c >index 63f6440..d2ec15f 100644 >--- a/fs/cifs/link.c >+++ b/fs/cifs/link.c >@@ -58,9 +58,7 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode, > /* if (cifs_sb_target->tcon->ses->capabilities & CAP_UNIX)*/ > if (pTcon->unix_ext) > rc = CIFSUnixCreateHardLink(xid, pTcon, fromName, toName, >- cifs_sb_target->local_nls, >- cifs_sb_target->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ cifs_sb_target); > else { > rc = CIFSCreateHardLink(xid, pTcon, fromName, toName, > cifs_sb_target->local_nls, >diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c >index 53892cb..54f9967 100644 >--- a/fs/cifs/xattr.c >+++ b/fs/cifs/xattr.c >@@ -83,8 +83,7 @@ int cifs_removexattr(struct dentry *direntry, const char *ea_name) > > ea_name += 5; /* skip past user. prefix */ > rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, NULL, >- (__u16)0, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); >+ (__u16)0, cifs_sb); > } > remove_ea_exit: > kfree(full_path); >@@ -144,16 +143,14 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, > > ea_name += 5; /* skip past user. prefix */ > rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value, >- (__u16)value_size, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); >+ (__u16)value_size, cifs_sb); > } else if (strncmp(ea_name, CIFS_XATTR_OS2_PREFIX, 4) == 0) { > if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) > goto set_ea_exit; > > ea_name += 4; /* skip past os2. prefix */ > rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value, >- (__u16)value_size, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); >+ (__u16)value_size, cifs_sb); > } else { > int temp; > temp = strncmp(ea_name, POSIX_ACL_XATTR_ACCESS, >@@ -238,16 +235,14 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name, > } /* BB add else when above is implemented */ > ea_name += 5; /* skip past user. prefix */ > rc = CIFSSMBQueryEA(xid, pTcon, full_path, ea_name, ea_value, >- buf_size, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); >+ buf_size, cifs_sb); > } else if (strncmp(ea_name, CIFS_XATTR_OS2_PREFIX, 4) == 0) { > if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) > goto get_ea_exit; > > ea_name += 4; /* skip past os2. prefix */ > rc = CIFSSMBQueryEA(xid, pTcon, full_path, ea_name, ea_value, >- buf_size, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); >+ buf_size, cifs_sb); > } else if (strncmp(ea_name, POSIX_ACL_XATTR_ACCESS, > strlen(POSIX_ACL_XATTR_ACCESS)) == 0) { > #ifdef CONFIG_CIFS_POSIX >------------------------------------------------------------------------------- >cifs-convert-cifsgetdfsrefer-t >------------------------------------------------------------------------------- >[CIFS] convert CIFSGetDFSRefer to new name conversion > >From: Jeff Layton <jlayton@redhat.com> > > >--- > > fs/cifs/cifs_dfs_ref.c | 5 ++--- > fs/cifs/cifsproto.h | 7 +++---- > fs/cifs/cifssmb.c | 22 +++++++--------------- > fs/cifs/connect.c | 9 +++++---- > 4 files changed, 17 insertions(+), 26 deletions(-) > > >diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c >index d2c8eef..5239f67 100644 >--- a/fs/cifs/cifs_dfs_ref.c >+++ b/fs/cifs/cifs_dfs_ref.c >@@ -292,9 +292,8 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd) > goto out_err; > } > >- rc = get_dfs_path(xid, ses , full_path, cifs_sb->local_nls, >- &num_referrals, &referrals, >- cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); >+ rc = get_dfs_path(xid, ses , full_path, cifs_sb, &num_referrals, >+ &referrals); > > for (i = 0; i < num_referrals; i++) { > dump_referral(referrals+i); >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index c9e5cb6..a863da7 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -148,14 +148,13 @@ extern int CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses, > const unsigned char *searchName, > struct dfs_info3_param **target_nodes, > unsigned int *number_of_nodes_in_array, >- const struct nls_table *nls_codepage, int remap); >+ const struct cifs_sb_info *cifs_sb); > > extern int get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, > const char *old_path, >- const struct nls_table *nls_codepage, >+ const struct cifs_sb_info *cifs_sb, > unsigned int *pnum_referrals, >- struct dfs_info3_param **preferrals, >- int remap); >+ struct dfs_info3_param **preferrals); > extern void reset_cifs_unix_caps(int xid, struct cifsTconInfo *tcon, > struct super_block *sb, struct smb_vol *vol); > extern int CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon, >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index be32797..e37896c 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -3895,8 +3895,7 @@ int > CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses, > const unsigned char *searchName, > struct dfs_info3_param **target_nodes, >- unsigned int *num_of_nodes, >- const struct nls_table *nls_codepage, int remap) >+ unsigned int *num_of_nodes, const struct cifs_sb_info *cifs_sb) > { > /* TRANS2_GET_DFS_REFERRAL */ > TRANSACTION2_GET_DFS_REFER_REQ *pSMB = NULL; >@@ -3926,19 +3925,12 @@ getDFSRetry: > pSMB->hdr.Flags2 |= SMBFLG2_ERR_STATUS; > if (ses->capabilities & CAP_DFS) > pSMB->hdr.Flags2 |= SMBFLG2_DFS; >- >- if (ses->capabilities & CAP_UNICODE) { >+ if (ses->capabilities & CAP_UNICODE) > pSMB->hdr.Flags2 |= SMBFLG2_UNICODE; >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->RequestFileName, >- searchName, PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(searchName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->RequestFileName, searchName, name_len); >- } >+ >+ name_len = cifs_path_to_remote(pSMB->RequestFileName, searchName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); > > if (ses->server) { > if (ses->server->secMode & >@@ -3992,7 +3984,7 @@ getDFSRetry: > > /* parse returned result into more usable form */ > rc = parse_DFS_referrals(pSMBr, num_of_nodes, >- target_nodes, nls_codepage); >+ target_nodes, cifs_sb->local_nls); > > GetDFSRefExit: > cifs_buf_release(pSMB); >diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c >index fa3eda4..271056f 100644 >--- a/fs/cifs/connect.c >+++ b/fs/cifs/connect.c >@@ -1437,8 +1437,8 @@ find_unc(__be32 new_target_ip_addr, char *uncName, char *userName) > > int > get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path, >- const struct nls_table *nls_codepage, unsigned int *pnum_referrals, >- struct dfs_info3_param **preferrals, int remap) >+ const struct cifs_sb_info *cifs_sb, unsigned int *pnum_referrals, >+ struct dfs_info3_param **preferrals) > { > char *temp_unc; > int rc = 0; >@@ -1458,14 +1458,15 @@ get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path, > temp_unc[1] = '\\'; > strcpy(temp_unc + 2, pSesInfo->serverName); > strcpy(temp_unc + 2 + strlen(pSesInfo->serverName), "\\IPC$"); >- rc = CIFSTCon(xid, pSesInfo, temp_unc, NULL, nls_codepage); >+ rc = CIFSTCon(xid, pSesInfo, temp_unc, NULL, >+ cifs_sb->local_nls); > cFYI(1, > ("CIFS Tcon rc = %d ipc_tid = %d", rc, pSesInfo->ipc_tid)); > kfree(temp_unc); > } > if (rc == 0) > rc = CIFSGetDFSRefer(xid, pSesInfo, old_path, preferrals, >- pnum_referrals, nls_codepage, remap); >+ pnum_referrals, cifs_sb); > /* BB map targetUNCs to dfs_info3 structures, here or > in CIFSGetDFSRefer BB */ > >------------------------------------------------------------------------------- >cifs-convert-smblegacyopen-to- >------------------------------------------------------------------------------- >[CIFS] convert SMBLegacyOpen to new name conversion routine > >From: Jeff Layton <jlayton@redhat.com> > > >--- > > fs/cifs/cifsproto.h | 2 +- > fs/cifs/cifssmb.c | 20 ++++++++------------ > fs/cifs/dir.c | 3 +-- > fs/cifs/file.c | 5 ++--- > fs/cifs/inode.c | 7 ++----- > 5 files changed, 14 insertions(+), 23 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index a863da7..b9568d2 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -257,7 +257,7 @@ extern int SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon, > const char *fileName, const int disposition, > const int access_flags, const int omode, > __u16 *netfid, int *pOplock, FILE_ALL_INFO *, >- const struct nls_table *nls_codepage, int remap); >+ const struct cifs_sb_info *cifs_sb); > extern int CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, > u32 posix_flags, __u64 mode, __u16 *netfid, > FILE_UNIX_BASIC_INFO *pRetData, >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index e37896c..0a0c9af 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -1178,7 +1178,7 @@ SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon, > const char *fileName, const int openDisposition, > const int access_flags, const int create_options, __u16 *netfid, > int *pOplock, FILE_ALL_INFO *pfile_info, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_sb_info *cifs_sb) > { > int rc = -EACCES; > OPENX_REQ *pSMB = NULL; >@@ -1195,19 +1195,15 @@ OldOpenRetry: > > pSMB->AndXCommand = 0xFF; /* none */ > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) > count = 1; /* account for one byte pad to word boundary */ >- name_len = >- cifsConvertToUCS((__le16 *) (pSMB->fileName + 1), >- fileName, PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB improve check for buffer overruns BB */ >+ else > count = 0; /* no pad */ >- name_len = strnlen(fileName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->fileName, fileName, name_len); >- } >+ >+ name_len = cifs_path_to_remote(pSMB->fileName + count, fileName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); >+ > if (*pOplock & REQ_OPLOCK) > pSMB->OpenFlags = cpu_to_le16(REQ_OPLOCK); > else if (*pOplock & REQ_BATCHOPLOCK) >diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c >index 1911242..6f9324a 100644 >--- a/fs/cifs/dir.c >+++ b/fs/cifs/dir.c >@@ -217,8 +217,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, > /* old server, retry the open legacy style */ > rc = SMBLegacyOpen(xid, pTcon, full_path, disposition, > desiredAccess, create_options, >- &fileHandle, &oplock, buf, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); >+ &fileHandle, &oplock, buf, cifs_sb); > } > if (rc) { > cFYI(1, ("cifs_create returned 0x%x", rc)); >diff --git a/fs/cifs/file.c b/fs/cifs/file.c >index fd291b6..fd20c42 100644 >--- a/fs/cifs/file.c >+++ b/fs/cifs/file.c >@@ -279,9 +279,8 @@ int cifs_open(struct inode *inode, struct file *file) > if (rc == -EIO) { > /* Old server, try legacy style OpenX */ > rc = SMBLegacyOpen(xid, pTcon, full_path, disposition, >- desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf, >- cifs_sb->local_nls, cifs_sb->mnt_cifs_flags >- & CIFS_MOUNT_MAP_SPECIAL_CHR); >+ desiredAccess, CREATE_NOT_DIR, &netfid, >+ &oplock, buf, cifs_sb); > } > if (rc) { > cFYI(1, ("cifs_open returned 0x%x", rc)); >diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c >index eebbb84..62ea130 100644 >--- a/fs/cifs/inode.c >+++ b/fs/cifs/inode.c >@@ -1445,11 +1445,8 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs, > int oplock = 0; > > rc = SMBLegacyOpen(xid, pTcon, full_path, >- FILE_OPEN, GENERIC_WRITE, >- CREATE_NOT_DIR, &netfid, &oplock, NULL, >- cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ FILE_OPEN, GENERIC_WRITE, CREATE_NOT_DIR, >+ &netfid, &oplock, NULL, cifs_sb); > if (rc == 0) { > unsigned int bytes_written; > rc = CIFSSMBWrite(xid, pTcon, netfid, 0, >------------------------------------------------------------------------------- >cifs-convert-cifssmbopen-to-ne >------------------------------------------------------------------------------- >[CIFS] convert CIFSSMBOpen to new name conversion scheme > >From: Jeff Layton <jlayton@redhat.com> > > >--- > > fs/cifs/cifsacl.c | 8 ++------ > fs/cifs/cifsproto.h | 2 +- > fs/cifs/cifssmb.c | 22 ++++++++-------------- > fs/cifs/dir.c | 8 ++------ > fs/cifs/fcntl.c | 3 +-- > fs/cifs/file.c | 9 +++------ > fs/cifs/inode.c | 28 +++++++--------------------- > fs/cifs/link.c | 8 +++----- > fs/cifs/xattr.c | 4 +--- > 9 files changed, 28 insertions(+), 64 deletions(-) > > >diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c >index 57ecdc8..fbb2d4b 100644 >--- a/fs/cifs/cifsacl.c >+++ b/fs/cifs/cifsacl.c >@@ -591,9 +591,7 @@ static struct cifs_ntsd *get_cifs_acl(u32 *pacllen, struct inode *inode, > int oplock = 0; > /* open file */ > rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN, >- READ_CONTROL, 0, &fid, &oplock, NULL, >- cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ READ_CONTROL, 0, &fid, &oplock, NULL, cifs_sb); > if (rc != 0) { > cERROR(1, ("Unable to open file to get ACL")); > FreeXid(xid); >@@ -645,9 +643,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, > int oplock = 0; > /* open file */ > rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN, >- WRITE_DAC, 0, &fid, &oplock, NULL, >- cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ WRITE_DAC, 0, &fid, &oplock, NULL, cifs_sb); > if (rc != 0) { > cERROR(1, ("Unable to open file to set ACL")); > FreeXid(xid); >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index b9568d2..eaf62bd 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -252,7 +252,7 @@ extern int CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon, > const char *fileName, const int disposition, > const int access_flags, const int omode, > __u16 *netfid, int *pOplock, FILE_ALL_INFO *, >- const struct nls_table *nls_codepage, int remap); >+ const struct cifs_sb_info *cifs_sb); > extern int SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon, > const char *fileName, const int disposition, > const int access_flags, const int omode, >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index 0a0c9af..62a3259 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -1280,7 +1280,7 @@ CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon, > const char *fileName, const int openDisposition, > const int access_flags, const int create_options, __u16 *netfid, > int *pOplock, FILE_ALL_INFO *pfile_info, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_sb_info *cifs_sb) > { > int rc = -EACCES; > OPEN_REQ *pSMB = NULL; >@@ -1297,21 +1297,15 @@ openRetry: > > pSMB->AndXCommand = 0xFF; /* none */ > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) > count = 1; /* account for one byte pad to word boundary */ >- name_len = >- cifsConvertToUCS((__le16 *) (pSMB->fileName + 1), >- fileName, PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- pSMB->NameLength = cpu_to_le16(name_len); >- } else { /* BB improve check for buffer overruns BB */ >+ else > count = 0; /* no pad */ >- name_len = strnlen(fileName, PATH_MAX); >- name_len++; /* trailing null */ >- pSMB->NameLength = cpu_to_le16(name_len); >- strncpy(pSMB->fileName, fileName, name_len); >- } >+ >+ name_len = cifs_path_to_remote(pSMB->fileName + count, fileName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); >+ > if (*pOplock & REQ_OPLOCK) > pSMB->OpenFlags = cpu_to_le32(REQ_OPLOCK); > else if (*pOplock & REQ_BATCHOPLOCK) >diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c >index 6f9324a..9a4b173 100644 >--- a/fs/cifs/dir.c >+++ b/fs/cifs/dir.c >@@ -208,8 +208,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, > if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS) > rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, > desiredAccess, create_options, >- &fileHandle, &oplock, buf, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); >+ &fileHandle, &oplock, buf, cifs_sb); > else > rc = -EIO; /* no NT SMB support fall into legacy open below */ > >@@ -413,10 +412,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, > /* Create a file and set the > file attribute to SYSTEM */ > CREATE_NOT_DIR | CREATE_OPTION_SPECIAL, >- &fileHandle, &oplock, buf, >- cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ &fileHandle, &oplock, buf, cifs_sb); > > /* BB FIXME - add handling for backlevel servers > which need legacy open and check for all >diff --git a/fs/cifs/fcntl.c b/fs/cifs/fcntl.c >index 5a57581..f178bdc 100644 >--- a/fs/cifs/fcntl.c >+++ b/fs/cifs/fcntl.c >@@ -90,8 +90,7 @@ int cifs_dir_notify(struct file *file, unsigned long arg) > cFYI(1, ("dir notify on file %s Arg 0x%lx", full_path, arg)); > rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, > GENERIC_READ | SYNCHRONIZE, 0 /* create options */, >- &netfid, &oplock, NULL, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); >+ &netfid, &oplock, NULL, cifs_sb); > /* BB fixme - add this handle to a notify handle list */ > if (rc) { > cFYI(1, ("Could not open directory for notify")); >diff --git a/fs/cifs/file.c b/fs/cifs/file.c >index fd20c42..d2dc257 100644 >--- a/fs/cifs/file.c >+++ b/fs/cifs/file.c >@@ -270,9 +270,8 @@ int cifs_open(struct inode *inode, struct file *file) > > if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS) > rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, >- desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf, >- cifs_sb->local_nls, cifs_sb->mnt_cifs_flags >- & CIFS_MOUNT_MAP_SPECIAL_CHR); >+ desiredAccess, CREATE_NOT_DIR, &netfid, >+ &oplock, buf, cifs_sb); > else > rc = -EIO; /* no NT SMB support fall into legacy open below */ > >@@ -415,9 +414,7 @@ reopen_error_exit: > that inode was not dirty locally we could do this */ > > rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess, >- CREATE_NOT_DIR, &netfid, &oplock, NULL, >- cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ CREATE_NOT_DIR, &netfid, &oplock, NULL, cifs_sb); > if (rc) { > up(&pCifsFile->fh_sem); > cFYI(1, ("cifs_open returned 0x%x", rc)); >diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c >index 62ea130..f025d6a 100644 >--- a/fs/cifs/inode.c >+++ b/fs/cifs/inode.c >@@ -293,10 +293,7 @@ static int decode_sfu_inode(struct inode *inode, __u64 size, > } > > rc = CIFSSMBOpen(xid, pTcon, path, FILE_OPEN, GENERIC_READ, >- CREATE_NOT_DIR, &netfid, &oplock, NULL, >- cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ CREATE_NOT_DIR, &netfid, &oplock, NULL, cifs_sb); > if (rc == 0) { > int buf_type = CIFS_NO_BUFFER; > /* Read header */ >@@ -708,9 +705,7 @@ psx_del_no_retry: > > rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, DELETE, > CREATE_NOT_DIR | CREATE_DELETE_ON_CLOSE, >- &netfid, &oplock, NULL, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ &netfid, &oplock, NULL, cifs_sb); > if (rc == 0) { > CIFSSMBRenameOpenFile(xid, pTcon, netfid, NULL, > cifs_sb->local_nls, >@@ -750,9 +745,7 @@ psx_del_no_retry: > FILE_OPEN, SYNCHRONIZE | > FILE_WRITE_ATTRIBUTES, 0, > &netfid, &oplock, NULL, >- cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ cifs_sb); > if (rc == 0) { > rc = CIFSSMBSetFileInfo(xid, pTcon, > pinfo_buf, >@@ -777,9 +770,7 @@ psx_del_no_retry: > CREATE_NOT_DIR | > CREATE_DELETE_ON_CLOSE, > &netfid, &oplock, NULL, >- cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ cifs_sb); > if (rc == 0) { > CIFSSMBRenameOpenFile(xid, pTcon, > netfid, NULL, >@@ -1160,9 +1151,7 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry, > might not right be right access to request */ > rc = CIFSSMBOpen(xid, pTcon, fromName, FILE_OPEN, GENERIC_READ, > CREATE_NOT_DIR, &netfid, &oplock, NULL, >- cifs_sb_source->local_nls, >- cifs_sb_source->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ cifs_sb_source); > if (rc == 0) { > rc = CIFSSMBRenameOpenFile(xid, pTcon, netfid, toName, > cifs_sb_source->local_nls, >@@ -1536,11 +1525,8 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, int xid, > cFYI(1, ("calling SetFileInfo since SetPathInfo for " > "times not supported by this server")); > rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, >- SYNCHRONIZE | FILE_WRITE_ATTRIBUTES, >- CREATE_NOT_DIR, &netfid, &oplock, >- NULL, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ SYNCHRONIZE | FILE_WRITE_ATTRIBUTES, CREATE_NOT_DIR, >+ &netfid, &oplock, NULL, cifs_sb); > > if (rc != 0) { > if (rc == -EIO) >diff --git a/fs/cifs/link.c b/fs/cifs/link.c >index d2ec15f..ba60e7e 100644 >--- a/fs/cifs/link.c >+++ b/fs/cifs/link.c >@@ -277,11 +277,9 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen) > cERROR(1, ("SFU style symlinks not implemented yet")); > /* add open and read as in fs/cifs/inode.c */ > } else { >- rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, GENERIC_READ, >- OPEN_REPARSE_POINT, &fid, &oplock, NULL, >- cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, >+ GENERIC_READ, OPEN_REPARSE_POINT, &fid, >+ &oplock, NULL, cifs_sb); > if (!rc) { > rc = CIFSSMBQueryReparseLinkInfo(xid, pTcon, full_path, > tmpbuffer, >diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c >index 54f9967..e7ab2bb 100644 >--- a/fs/cifs/xattr.c >+++ b/fs/cifs/xattr.c >@@ -261,9 +261,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name, > if (experimEnabled) > rc = CIFSSMBOpen(xid, pTcon, full_path, > FILE_OPEN, GENERIC_READ, 0, &fid, >- &oplock, NULL, cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ &oplock, NULL, cifs_sb); > /* else rc is EOPNOTSUPP from above */ > > if (rc == 0) { >------------------------------------------------------------------------------- >cifs-convert-cifssmbrename-to- >------------------------------------------------------------------------------- >[CIFS] convert CIFSSMBRename to new name conversion > >From: Jeff Layton <jlayton@redhat.com> > > >--- > > fs/cifs/cifsproto.h | 3 +-- > fs/cifs/cifssmb.c | 45 +++++++++++++++++++-------------------------- > fs/cifs/inode.c | 10 ++-------- > 3 files changed, 22 insertions(+), 36 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index eaf62bd..7a0164f 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -218,8 +218,7 @@ extern int CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon, > const struct cifs_sb_info *cifs_sb); > extern int CIFSSMBRename(const int xid, struct cifsTconInfo *tcon, > const char *fromName, const char *toName, >- const struct nls_table *nls_codepage, >- int remap_special_chars); >+ const struct cifs_sb_info *cifs_sb); > extern int CIFSSMBRenameOpenFile(const int xid, struct cifsTconInfo *pTcon, > int netfid, char *target_name, > const struct nls_table *nls_codepage, >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index 62a3259..0bb6256 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -1900,9 +1900,8 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id) > } > > int >-CIFSSMBRename(const int xid, struct cifsTconInfo *tcon, >- const char *fromName, const char *toName, >- const struct nls_table *nls_codepage, int remap) >+CIFSSMBRename(const int xid, struct cifsTconInfo *tcon, const char *fromName, >+ const char *toName, const struct cifs_sb_info *cifs_sb) > { > int rc = 0; > RENAME_REQ *pSMB = NULL; >@@ -1910,6 +1909,7 @@ CIFSSMBRename(const int xid, struct cifsTconInfo *tcon, > int bytes_returned; > int name_len, name_len2; > __u16 count; >+ unsigned char *name2; > > cFYI(1, ("In CIFSSMBRename")); > renameRetry: >@@ -1923,32 +1923,25 @@ renameRetry: > cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM | > ATTR_DIRECTORY); > >+ name_len = cifs_path_to_remote(pSMB->OldFileName, fromName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); >+ pSMB->OldFileName[name_len] = 0x04; /* pad */ >+ name2 = &pSMB->OldFileName[name_len + 1]; >+ /* pad is double width on unicode */ > if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->OldFileName, fromName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- pSMB->OldFileName[name_len] = 0x04; /* pad */ >- /* protocol requires ASCII signature byte on Unicode string */ >- pSMB->OldFileName[name_len + 1] = 0x00; >- name_len2 = >- cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2], >- toName, PATH_MAX, nls_codepage, remap); >- name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; >- name_len2 *= 2; /* convert to bytes */ >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(fromName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->OldFileName, fromName, name_len); >- name_len2 = strnlen(toName, PATH_MAX); >- name_len2++; /* trailing null */ >- pSMB->OldFileName[name_len] = 0x04; /* 2nd buffer format */ >- strncpy(&pSMB->OldFileName[name_len + 1], toName, name_len2); >- name_len2++; /* trailing null */ >- name_len2++; /* signature byte */ >+ *name2 = 0x00; >+ name2++; > } >+ name_len2 = cifs_path_to_remote(name2, toName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); >+ name_len2 += 1; /* for trailing NULL + signature byte */ > >+ /* unicode doubles width of trailing null + signature byte */ >+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) >+ name_len2 += 1; >+ > count = 1 /* 1st signature byte */ + name_len + name_len2; > pSMB->hdr.smb_buf_length += count; > pSMB->ByteCount = cpu_to_le16(count); >diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c >index f025d6a..73bb56b 100644 >--- a/fs/cifs/inode.c >+++ b/fs/cifs/inode.c >@@ -1093,10 +1093,7 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry, > goto cifs_rename_exit; > } > >- rc = CIFSSMBRename(xid, pTcon, fromName, toName, >- cifs_sb_source->local_nls, >- cifs_sb_source->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ rc = CIFSSMBRename(xid, pTcon, fromName, toName, cifs_sb_source); > if (rc == -EEXIST) { > /* check if they are the same file because rename of hardlinked > files is a noop */ >@@ -1129,10 +1126,7 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry, > semantics */ > cifs_unlink(target_inode, target_direntry); > rc = CIFSSMBRename(xid, pTcon, fromName, >- toName, >- cifs_sb_source->local_nls, >- cifs_sb_source->mnt_cifs_flags >- & CIFS_MOUNT_MAP_SPECIAL_CHR); >+ toName, cifs_sb_source); > } > kfree(info_buf_source); > } /* if we can not get memory just leave rc as EEXIST */ >------------------------------------------------------------------------------- >cifs-convert-cifssmbcopy-to-ne >------------------------------------------------------------------------------- >[CIFS] convert CIFSSMBCopy to new NLS functions > >From: Jeff Layton <jlayton@redhat.com> > >Signed-off-by: Jeff Layton <jlayton@redhat.com> >--- > > fs/cifs/cifsproto.h | 3 +-- > fs/cifs/cifssmb.c | 42 ++++++++++++++++++------------------------ > 2 files changed, 19 insertions(+), 26 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index 7a0164f..ecd4e8b 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -332,8 +332,7 @@ extern int CIFSSMBCopy(int xid, > const char *fromName, > const __u16 target_tid, > const char *toName, const int flags, >- const struct nls_table *nls_codepage, >- int remap_special_chars); >+ const struct cifs_sb_info *cifs_sb); > extern int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon, > const int notify_subdirs, const __u16 netfid, > __u32 filter, struct file *file, int multishot, >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index 0bb6256..b020fcd 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -2042,13 +2042,14 @@ int CIFSSMBRenameOpenFile(const int xid, struct cifsTconInfo *pTcon, > int > CIFSSMBCopy(const int xid, struct cifsTconInfo *tcon, const char *fromName, > const __u16 target_tid, const char *toName, const int flags, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_sb_info *cifs_sb) > { > int rc = 0; > COPY_REQ *pSMB = NULL; > COPY_RSP *pSMBr = NULL; > int bytes_returned; > int name_len, name_len2; >+ unsigned char *name2; > __u16 count; > > cFYI(1, ("In CIFSSMBCopy")); >@@ -2063,31 +2064,24 @@ copyRetry: > > pSMB->Flags = cpu_to_le16(flags & COPY_TREE); > >+ name_len = cifs_path_to_remote(pSMB->OldFileName, fromName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); >+ pSMB->OldFileName[name_len] = 0x04; /* pad */ >+ name2 = &pSMB->OldFileName[name_len + 1]; >+ /* pad is double width on unicode */ > if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = cifsConvertToUCS((__le16 *) pSMB->OldFileName, >- fromName, PATH_MAX, nls_codepage, >- remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- pSMB->OldFileName[name_len] = 0x04; /* pad */ >- /* protocol requires ASCII signature byte on Unicode string */ >- pSMB->OldFileName[name_len + 1] = 0x00; >- name_len2 = >- cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2], >- toName, PATH_MAX, nls_codepage, remap); >- name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; >- name_len2 *= 2; /* convert to bytes */ >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(fromName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->OldFileName, fromName, name_len); >- name_len2 = strnlen(toName, PATH_MAX); >- name_len2++; /* trailing null */ >- pSMB->OldFileName[name_len] = 0x04; /* 2nd buffer format */ >- strncpy(&pSMB->OldFileName[name_len + 1], toName, name_len2); >- name_len2++; /* trailing null */ >- name_len2++; /* signature byte */ >+ *name2 = 0x00; >+ name2++; > } >+ name_len2 = cifs_path_to_remote(name2, toName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); >+ name_len2 += 1; /* signature byte */ >+ >+ /* unicode doubles width of trailing null + signature byte */ >+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) >+ name_len2 += 1; > > count = 1 /* 1st signature byte */ + name_len + name_len2; > pSMB->hdr.smb_buf_length += count; >------------------------------------------------------------------------------- >cifs-convert-cifscreatehardlin >------------------------------------------------------------------------------- >cifs: convert CIFSCreateHardLink to new NLS scheme > >From: Jeff Layton <jlayton@redhat.com> > >Signed-off-by: Jeff Layton <jlayton@redhat.com> >--- > > fs/cifs/cifsproto.h | 3 +-- > fs/cifs/cifssmb.c | 42 +++++++++++++++++++----------------------- > fs/cifs/link.c | 4 +--- > 3 files changed, 21 insertions(+), 28 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index ecd4e8b..370f677 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -226,8 +226,7 @@ extern int CIFSSMBRenameOpenFile(const int xid, struct cifsTconInfo *pTcon, > extern int CIFSCreateHardLink(const int xid, > struct cifsTconInfo *tcon, > const char *fromName, const char *toName, >- const struct nls_table *nls_codepage, >- int remap_special_chars); >+ const struct cifs_sb_info *cifs_sb); > extern int CIFSUnixCreateHardLink(const int xid, > struct cifsTconInfo *tcon, > const char *fromName, const char *toName, >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index b020fcd..1b83592 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -2262,7 +2262,7 @@ createHardLinkRetry: > int > CIFSCreateHardLink(const int xid, struct cifsTconInfo *tcon, > const char *fromName, const char *toName, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_sb_info *cifs_sb) > { > int rc = 0; > NT_RENAME_REQ *pSMB = NULL; >@@ -2270,6 +2270,7 @@ CIFSCreateHardLink(const int xid, struct cifsTconInfo *tcon, > int bytes_returned; > int name_len, name_len2; > __u16 count; >+ unsigned char *name2; > > cFYI(1, ("In CIFSCreateHardLink")); > winCreateHardLinkRetry: >@@ -2287,30 +2288,25 @@ winCreateHardLinkRetry: > > pSMB->BufferFormat = 0x04; > >+ name_len = cifs_path_to_remote(pSMB->OldFileName, fromName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); >+ pSMB->OldFileName[name_len] = 0x04; /* pad */ >+ >+ name2 = &pSMB->OldFileName[name_len + 1]; >+ /* pad is double width on unicode */ > if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->OldFileName, fromName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; >- pSMB->OldFileName[name_len] = 0; /* pad */ >- pSMB->OldFileName[name_len + 1] = 0x04; >- name_len2 = >- cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2], >- toName, PATH_MAX, nls_codepage, remap); >- name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; >- name_len2 *= 2; /* convert to bytes */ >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(fromName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->OldFileName, fromName, name_len); >- name_len2 = strnlen(toName, PATH_MAX); >- name_len2++; /* trailing null */ >- pSMB->OldFileName[name_len] = 0x04; /* 2nd buffer format */ >- strncpy(&pSMB->OldFileName[name_len + 1], toName, name_len2); >- name_len2++; /* trailing null */ >- name_len2++; /* signature byte */ >+ *name2 = 0x00; >+ name2++; > } >+ name_len2 = cifs_path_to_remote(name2, toName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); >+ name_len2 += 1; /* signature byte */ >+ >+ /* unicode doubles width of trailing null + signature byte */ >+ if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) >+ name_len2 += 1; > > count = 1 /* string type byte */ + name_len + name_len2; > pSMB->hdr.smb_buf_length += count; >diff --git a/fs/cifs/link.c b/fs/cifs/link.c >index ba60e7e..9a66636 100644 >--- a/fs/cifs/link.c >+++ b/fs/cifs/link.c >@@ -61,9 +61,7 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode, > cifs_sb_target); > else { > rc = CIFSCreateHardLink(xid, pTcon, fromName, toName, >- cifs_sb_target->local_nls, >- cifs_sb_target->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ cifs_sb_target); > if ((rc == -EIO) || (rc == -EINVAL)) > rc = -EOPNOTSUPP; > } >------------------------------------------------------------------------------- >cifs-convert-cifssmbgetposixac >------------------------------------------------------------------------------- >cifs: convert CIFSSMBGetPosixACL to new NLS scheme > >From: Jeff Layton <jlayton@redhat.com> > >Signed-off-by: Jeff Layton <jlayton@redhat.com> >--- > > fs/cifs/cifsproto.h | 2 +- > fs/cifs/cifssmb.c | 16 ++++++---------- > fs/cifs/xattr.c | 10 ++-------- > 3 files changed, 9 insertions(+), 19 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index 370f677..490b46c 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -354,7 +354,7 @@ extern int CIFSSMBSetCIFSACL(const int, struct cifsTconInfo *, __u16, > extern int CIFSSMBGetPosixACL(const int xid, struct cifsTconInfo *tcon, > const unsigned char *searchName, > char *acl_inf, const int buflen, const int acl_type, >- const struct nls_table *nls_codepage, int remap_special_chars); >+ const struct cifs_sb_info *cifs_sb); > extern int CIFSSMBSetPosixACL(const int xid, struct cifsTconInfo *tcon, > const unsigned char *fileName, > const char *local_acl, const int buflen, const int acl_type, >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index 1b83592..e51d7dc 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -2761,7 +2761,7 @@ int > CIFSSMBGetPosixACL(const int xid, struct cifsTconInfo *tcon, > const unsigned char *searchName, > char *acl_inf, const int buflen, const int acl_type, >- const struct nls_table *nls_codepage, int remap) >+ const struct cifs_sb_info *cifs_sb) > { > /* SMB_QUERY_POSIX_ACL */ > TRANSACTION2_QPI_REQ *pSMB = NULL; >@@ -2779,18 +2779,14 @@ queryAclRetry: > if (rc) > return rc; > >+ name_len = cifs_path_to_remote(pSMB->FileName, searchName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); >+ >+ /* why is this extra pad only needed for unicode? */ > if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, >- PATH_MAX, nls_codepage, remap); >- name_len++; /* trailing null */ >- name_len *= 2; > pSMB->FileName[name_len] = 0; > pSMB->FileName[name_len+1] = 0; >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(searchName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->FileName, searchName, name_len); > } > > params = 2 /* level */ + 4 /* rsrvd */ + name_len /* incl null */ ; >diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c >index e7ab2bb..006cc56 100644 >--- a/fs/cifs/xattr.c >+++ b/fs/cifs/xattr.c >@@ -248,10 +248,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name, > #ifdef CONFIG_CIFS_POSIX > if (sb->s_flags & MS_POSIXACL) > rc = CIFSSMBGetPosixACL(xid, pTcon, full_path, >- ea_value, buf_size, ACL_TYPE_ACCESS, >- cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ ea_value, buf_size, ACL_TYPE_ACCESS, cifs_sb); > #ifdef CONFIG_CIFS_EXPERIMENTAL > else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) { > __u16 fid; >@@ -279,10 +276,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name, > #ifdef CONFIG_CIFS_POSIX > if (sb->s_flags & MS_POSIXACL) > rc = CIFSSMBGetPosixACL(xid, pTcon, full_path, >- ea_value, buf_size, ACL_TYPE_DEFAULT, >- cifs_sb->local_nls, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR); >+ ea_value, buf_size, ACL_TYPE_DEFAULT, cifs_sb); > #else > cFYI(1, ("query POSIX default ACL not supported yet")); > #endif >------------------------------------------------------------------------------- >cifs-convert-cifsfindfirst-to- >------------------------------------------------------------------------------- >cifs: convert CIFSFindFirst to new NLS scheme > >From: Jeff Layton <jlayton@redhat.com> > >Signed-off-by: Jeff Layton <jlayton@redhat.com> >--- > > fs/cifs/cifsproto.h | 4 ++-- > fs/cifs/cifssmb.c | 41 ++++++++++++++++------------------------- > fs/cifs/readdir.c | 6 ++---- > 3 files changed, 20 insertions(+), 31 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index 490b46c..d4d94d3 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -118,9 +118,9 @@ extern int CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, > const struct nls_table *); > > extern int CIFSFindFirst(const int xid, struct cifsTconInfo *tcon, >- const char *searchName, const struct nls_table *nls_codepage, >+ const char *searchName, const struct cifs_sb_info *cifs_sb, > __u16 *searchHandle, struct cifs_search_info *psrch_inf, >- int map, const char dirsep); >+ const char dirsep); > > extern int CIFSFindNext(const int xid, struct cifsTconInfo *tcon, > __u16 searchHandle, struct cifs_search_info *psrch_inf); >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index e51d7dc..6cec1d3 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -3393,10 +3393,9 @@ UnixQPathInfoRetry: > /* xid, tcon, searchName and codepage are input parms, rest are returned */ > int > CIFSFindFirst(const int xid, struct cifsTconInfo *tcon, >- const char *searchName, >- const struct nls_table *nls_codepage, >- __u16 *pnetfid, >- struct cifs_search_info *psrch_inf, int remap, const char dirsep) >+ const char *searchName, const struct cifs_sb_info *cifs_sb, >+ __u16 *pnetfid, struct cifs_search_info *psrch_inf, >+ const char dirsep) > { > /* level 257 SMB_ */ > TRANSACTION2_FFIRST_REQ *pSMB = NULL; >@@ -3415,32 +3414,24 @@ findFirstRetry: > if (rc) > return rc; > >+ name_len = cifs_path_to_remote(pSMB->FileName, searchName, >+ PATH_MAX, cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE); >+ >+ /* name_len includes null, so must backtrack */ > if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, >- PATH_MAX, nls_codepage, remap); >- /* We can not add the asterik earlier in case >- it got remapped to 0xF03A as if it were part of the >- directory name instead of a wildcard */ >- name_len *= 2; >- pSMB->FileName[name_len] = dirsep; >+ pSMB->FileName[name_len-2] = dirsep; >+ pSMB->FileName[name_len-1] = 0; >+ pSMB->FileName[name_len] = '*'; > pSMB->FileName[name_len+1] = 0; >- pSMB->FileName[name_len+2] = '*'; >+ pSMB->FileName[name_len+2] = 0; /* null terminate */ > pSMB->FileName[name_len+3] = 0; >- name_len += 4; /* now the trailing null */ >- pSMB->FileName[name_len] = 0; /* null terminate just in case */ >+ name_len += 4; >+ } else { >+ pSMB->FileName[name_len-1] = dirsep; >+ pSMB->FileName[name_len] = '*'; > pSMB->FileName[name_len+1] = 0; > name_len += 2; >- } else { /* BB add check for overrun of SMB buf BB */ >- name_len = strnlen(searchName, PATH_MAX); >-/* BB fix here and in unicode clause above ie >- if (name_len > buffersize-header) >- free buffer exit; BB */ >- strncpy(pSMB->FileName, searchName, name_len); >- pSMB->FileName[name_len] = dirsep; >- pSMB->FileName[name_len+1] = '*'; >- pSMB->FileName[name_len+2] = 0; >- name_len += 3; > } > > params = 12 + name_len /* includes null */ ; >diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c >index 5f40ed3..2a60c55 100644 >--- a/fs/cifs/readdir.c >+++ b/fs/cifs/readdir.c >@@ -487,10 +487,8 @@ ffirst_retry: > cifsFile->srch_inf.info_level = SMB_FIND_FILE_DIRECTORY_INFO; > } > >- rc = CIFSFindFirst(xid, pTcon, full_path, cifs_sb->local_nls, >- &cifsFile->netfid, &cifsFile->srch_inf, >- cifs_sb->mnt_cifs_flags & >- CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb)); >+ rc = CIFSFindFirst(xid, pTcon, full_path, cifs_sb, &cifsFile->netfid, >+ &cifsFile->srch_inf, CIFS_DIR_SEP(cifs_sb)); > if (rc == 0) > cifsFile->invalidHandle = false; > if ((rc == -EOPNOTSUPP) && >------------------------------------------------------------------------------- >cifs-convert-cifs_get_name_fro >------------------------------------------------------------------------------- >cifs: convert cifs_get_name_from_search_buf to new NLS routines > >From: Jeff Layton <jlayton@redhat.com> > >Signed-off-by: Jeff Layton <jlayton@redhat.com> >--- > > fs/cifs/readdir.c | 25 ++++++++++++++----------- > 1 files changed, 14 insertions(+), 11 deletions(-) > > >diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c >index 2a60c55..f22053a 100644 >--- a/fs/cifs/readdir.c >+++ b/fs/cifs/readdir.c >@@ -756,7 +756,6 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst, > int rc = 0; > unsigned int len = 0; > char *filename; >- struct nls_table *nlt = cifs_sb->local_nls; > > *pinum = 0; > >@@ -811,19 +810,23 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst, > return -EINVAL; > } > >- if (unicode) { >- /* BB fixme - test with long names */ >- /* Note converted filename can be longer than in unicode */ >- if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR) >- pqst->len = cifs_convertUCSpath((char *)pqst->name, >- (__le16 *)filename, len/2, nlt); >- else >- pqst->len = cifs_strfromUCS_le((char *)pqst->name, >- (__le16 *)filename, len/2, nlt); >- } else { >+ if (unicode) >+ len = len/2; >+ else if (!cifs_sb->remote_nls) { >+ /* just move pointers around -- no need to copy */ > pqst->name = filename; > pqst->len = len; >+ goto hash_and_out; > } >+ >+ /* BB fixme - test with long names */ >+ /* Note converted filename can be longer than in unicode */ >+ pqst->len = cifs_path_to_local((char *) pqst->name, filename, len, >+ cifs_sb, unicode, >+ cifs_sb->mnt_cifs_flags & >+ CIFS_MOUNT_MAP_SPECIAL_CHR); >+ >+hash_and_out: > pqst->hash = full_name_hash(pqst->name, pqst->len); > /* cFYI(1, ("filldir on %s",pqst->name)); */ > return rc; >------------------------------------------------------------------------------- >cifs-convert-cifssmbunixquerys >------------------------------------------------------------------------------- >cifs: convert CIFSSMBUnixQuerySymLink to new nls routines > >From: Jeff Layton <jlayton@redhat.com> > >Signed-off-by: Jeff Layton <jlayton@redhat.com> >--- > > fs/cifs/cifsproto.h | 2 +- > fs/cifs/cifssmb.c | 60 ++++++++++++++++++++------------------------------- > fs/cifs/link.c | 8 ++----- > 3 files changed, 27 insertions(+), 43 deletions(-) > > >diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h >index d4d94d3..109df6f 100644 >--- a/fs/cifs/cifsproto.h >+++ b/fs/cifs/cifsproto.h >@@ -239,7 +239,7 @@ extern int CIFSSMBUnixQuerySymLink(const int xid, > struct cifsTconInfo *tcon, > const unsigned char *searchName, > char *syminfo, const int buflen, >- const struct nls_table *nls_codepage); >+ const struct cifs_sb_info *cifs_sb); > extern int CIFSSMBQueryReparseLinkInfo(const int xid, > struct cifsTconInfo *tcon, > const unsigned char *searchName, >diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c >index 6cec1d3..2eb657e 100644 >--- a/fs/cifs/cifssmb.c >+++ b/fs/cifs/cifssmb.c >@@ -2329,15 +2329,15 @@ int > CIFSSMBUnixQuerySymLink(const int xid, struct cifsTconInfo *tcon, > const unsigned char *searchName, > char *symlinkinfo, const int buflen, >- const struct nls_table *nls_codepage) >+ const struct cifs_sb_info *cifs_sb) > { > /* SMB_QUERY_FILE_UNIX_LINK */ > TRANSACTION2_QPI_REQ *pSMB = NULL; > TRANSACTION2_QPI_RSP *pSMBr = NULL; > int rc = 0; > int bytes_returned; >- int name_len; >- __u16 params, byte_count; >+ int name_len, maxlen; >+ __u16 params, byte_count, data_offset, count; > > cFYI(1, ("In QPathSymLinkInfo (Unix) for path %s", searchName)); > >@@ -2347,17 +2347,11 @@ querySymLinkRetry: > if (rc) > return rc; > >- if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = >- cifs_strtoUCS((__le16 *) pSMB->FileName, searchName, >- PATH_MAX, nls_codepage); >- name_len++; /* trailing null */ >- name_len *= 2; >- } else { /* BB improve the check for buffer overruns BB */ >- name_len = strnlen(searchName, PATH_MAX); >- name_len++; /* trailing null */ >- strncpy(pSMB->FileName, searchName, name_len); >- } >+ /* BB: should we be mapping characters here? */ >+ name_len = _cifs_path_to_remote(pSMB->FileName, searchName, PATH_MAX, >+ cifs_sb, >+ pSMB->hdr.Flags2 & SMBFLG2_UNICODE, >+ false); > > params = 2 /* level */ + 4 /* rsrvd */ + name_len /* incl null */ ; > pSMB->TotalDataCount = 0; >@@ -2392,32 +2386,26 @@ querySymLinkRetry: > /* decode response */ > > rc = validate_t2((struct smb_t2_rsp *)pSMBr); >- if (rc || (pSMBr->ByteCount < 2)) >+ if (rc || (pSMBr->ByteCount < 2)) { > /* BB also check enough total bytes returned */ > rc = -EIO; /* bad smb */ >- else { >- __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); >- __u16 count = le16_to_cpu(pSMBr->t2.DataCount); >- >- if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) { >- name_len = UniStrnlen((wchar_t *) ((char *) >- &pSMBr->hdr.Protocol + data_offset), >- min_t(const int, buflen, count) / 2); >- /* BB FIXME investigate remapping reserved chars here */ >- cifs_strfromUCS_le(symlinkinfo, >- (__le16 *) ((char *)&pSMBr->hdr.Protocol >- + data_offset), >- name_len, nls_codepage); >- } else { >- strncpy(symlinkinfo, >- (char *) &pSMBr->hdr.Protocol + >- data_offset, >- min_t(const int, buflen, count)); >- } >- symlinkinfo[buflen] = 0; >- /* just in case so calling code does not go off the end of buffer */ >+ goto out; > } >+ >+ data_offset = le16_to_cpu(pSMBr->t2.DataOffset); >+ count = le16_to_cpu(pSMBr->t2.DataCount); >+ >+ maxlen = min_t(int, buflen, count); >+ if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) >+ maxlen = maxlen / 2; >+ >+ /* BB: FIXME investigate remapping reserved chars here */ >+ cifs_path_to_local(symlinkinfo, >+ (const char *) &pSMBr->hdr.Protocol + >+ data_offset, maxlen, cifs_sb, >+ pSMBr->hdr.Flags2 & SMBFLG2_UNICODE, false); > } >+out: > cifs_buf_release(pSMB); > if (rc == -EAGAIN) > goto querySymLinkRetry; >diff --git a/fs/cifs/link.c b/fs/cifs/link.c >index 9a66636..afe01d4 100644 >--- a/fs/cifs/link.c >+++ b/fs/cifs/link.c >@@ -134,9 +134,7 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd) > > if (pTcon->ses->capabilities & CAP_UNIX) > rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path, >- target_path, >- PATH_MAX-1, >- cifs_sb->local_nls); >+ target_path, PATH_MAX-1, cifs_sb); > else { > /* BB add read reparse point symlink code here */ > /* rc = CIFSSMBQueryReparseLinkInfo */ >@@ -268,9 +266,7 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen) > /* We could disable this based on pTcon->unix_ext flag instead ... but why? */ > if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) > rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path, >- tmpbuffer, >- len - 1, >- cifs_sb->local_nls); >+ tmpbuffer, len - 1, cifs_sb); > else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { > cERROR(1, ("SFU style symlinks not implemented yet")); > /* add open and read as in fs/cifs/inode.c */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 247489
:
311754
| 316439