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 311754 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]
proof-of-concept patch 1
cifs-nls-very-rough.patch (text/plain), 7.56 KB, created by
Jeff Layton
on 2008-07-14 19:11:51 UTC
(
hide
)
Description:
proof-of-concept patch 1
Filename:
MIME Type:
Creator:
Jeff Layton
Created:
2008-07-14 19:11:51 UTC
Size:
7.56 KB
patch
obsolete
>------------------------------------------------------------------------------- >cifs-add-cifs_nls_convert >------------------------------------------------------------------------------- >[CIFS] add cifs_nls_convert function to convert from one nls to another > >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. >--- > > fs/cifs/cifs_unicode.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ > fs/cifs/cifs_unicode.h | 3 +++ > 2 files changed, 60 insertions(+), 0 deletions(-) > > >diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c >index 7d75272..f827422 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 memcpy */ >+ if (!from_nls || !to_nls) { >+ memcpy(to, from, inlen); >+ /* NULL terminate */ >+ to[inlen] = 0; >+ return inlen; >+ } >+ >+ while (inlen && *from) { >+ /* convert character to unicode */ >+ charlen = from_nls->char2uni(from, inlen, &temp); >+ if (charlen < 1) { >+ cFYI(1, ("strtoUCS: char2uni of %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 > > /* >------------------------------------------------------------------------------- >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 86b4d5f..d6b1a9e 100644 >--- a/fs/cifs/cifsfs.c >+++ b/fs/cifs/cifsfs.c >@@ -185,6 +185,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; >@@ -213,6 +215,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 ba7c104..ed9c674 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; >@@ -1086,6 +1087,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 = >@@ -1906,6 +1922,19 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, > } > } > >+ /* this is needed when non-ascii/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-have-search-name-decoder- >------------------------------------------------------------------------------- >[CIFS] have search name decoder call cifs_nls_convert > >From: Jeff Layton <jlayton@redhat.com> > >Proof of concept/test patch to just have the readdir filler call >cifs_nls_convert to translate names. This is still very rough and >will require a lot of cleanup before it can go upstream. > >The concept does seem to basically work, however... >--- > > fs/cifs/readdir.c | 5 +++-- > 1 files changed, 3 insertions(+), 2 deletions(-) > > >diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c >index 83f3069..0bbb3e3 100644 >--- a/fs/cifs/readdir.c >+++ b/fs/cifs/readdir.c >@@ -822,8 +822,9 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst, > pqst->len = cifs_strfromUCS_le((char *)pqst->name, > (__le16 *)filename, len/2, nlt); > } else { >- pqst->name = filename; >- pqst->len = len; >+ pqst->len = cifs_nls_convert(filename, pqst->name, >+ cifs_sb->remote_nls, >+ cifs_sb->local_nls, len); > } > pqst->hash = full_name_hash(pqst->name, pqst->len); > /* cFYI(1, ("filldir on %s",pqst->name)); */
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