summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorimura <imura@FreeBSD.org>2005-07-29 13:22:37 +0000
committerimura <imura@FreeBSD.org>2005-07-29 13:22:37 +0000
commit3c148b71eb7204eb8ec0f9a9dc000571f0e9730f (patch)
tree549cc36b1d29a5047dca121ca0e375b41b375c0c /sys
parentbea55b64d3f045f1f8013655fd5e3b78e98673a0 (diff)
downloadFreeBSD-src-3c148b71eb7204eb8ec0f9a9dc000571f0e9730f.zip
FreeBSD-src-3c148b71eb7204eb8ec0f9a9dc000571f0e9730f.tar.gz
Change API of mb_copy_t in libmchain so that netsmb can handle
multibyte character share name correctly. Reviewed by: bp
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_mchain.c16
-rw-r--r--sys/netncp/ncp_rq.c12
-rw-r--r--sys/netsmb/smb_subr.c15
-rw-r--r--sys/sys/mchain.h3
4 files changed, 35 insertions, 11 deletions
diff --git a/sys/kern/subr_mchain.c b/sys/kern/subr_mchain.c
index 4f0dab1..dc70af2 100644
--- a/sys/kern/subr_mchain.c
+++ b/sys/kern/subr_mchain.c
@@ -183,6 +183,7 @@ mb_put_mem(struct mbchain *mbp, c_caddr_t source, int size, int type)
caddr_t dst;
c_caddr_t src;
int cplen, error, mleft, count;
+ size_t srclen, dstlen;
m = mbp->mb_cur;
mleft = mbp->mb_mleft;
@@ -199,10 +200,13 @@ mb_put_mem(struct mbchain *mbp, c_caddr_t source, int size, int type)
continue;
}
cplen = mleft > size ? size : mleft;
+ srclen = dstlen = cplen;
dst = mtod(m, caddr_t) + m->m_len;
switch (type) {
case MB_MCUSTOM:
- error = mbp->mb_copy(mbp, source, dst, cplen);
+ srclen = size;
+ dstlen = mleft;
+ error = mbp->mb_copy(mbp, source, dst, &srclen, &dstlen);
if (error)
return error;
break;
@@ -222,11 +226,11 @@ mb_put_mem(struct mbchain *mbp, c_caddr_t source, int size, int type)
bzero(dst, cplen);
break;
}
- size -= cplen;
- source += cplen;
- m->m_len += cplen;
- mleft -= cplen;
- mbp->mb_count += cplen;
+ size -= srclen;
+ source += srclen;
+ m->m_len += dstlen;
+ mleft -= dstlen;
+ mbp->mb_count += dstlen;
}
mbp->mb_cur = m;
mbp->mb_mleft = mleft;
diff --git a/sys/netncp/ncp_rq.c b/sys/netncp/ncp_rq.c
index 6915bfa..b637c9a 100644
--- a/sys/netncp/ncp_rq.c
+++ b/sys/netncp/ncp_rq.c
@@ -151,8 +151,18 @@ ncp_rq_done(struct ncp_rq *rqp)
*/
static int
-ncp_rq_pathstrhelp(struct mbchain *mbp, c_caddr_t src, caddr_t dst, size_t len)
+ncp_rq_pathstrhelp(struct mbchain *mbp, c_caddr_t src, caddr_t dst,
+ size_t *srclen, size_t *dstlen)
{
+ int len;
+
+ if (*srclen < *dstlen) {
+ *dstlen = *srclen;
+ len = (int)*srclen;
+ } else {
+ *srclen = *dstlen;
+ len = (int)*dstlen;
+ }
ncp_pathcopy(src, dst, len, mbp->mb_udata);
return 0;
}
diff --git a/sys/netsmb/smb_subr.c b/sys/netsmb/smb_subr.c
index 0fb48ec..b8dab57 100644
--- a/sys/netsmb/smb_subr.c
+++ b/sys/netsmb/smb_subr.c
@@ -319,11 +319,20 @@ smb_maperror(int eclass, int eno)
}
static int
-smb_copy_iconv(struct mbchain *mbp, c_caddr_t src, caddr_t dst, size_t len)
+smb_copy_iconv(struct mbchain *mbp, c_caddr_t src, caddr_t dst,
+ size_t *srclen, size_t *dstlen)
{
- size_t outlen = len;
+ int error;
+ size_t inlen = *srclen, outlen = *dstlen;
- return iconv_conv((struct iconv_drv*)mbp->mb_udata, &src, &len, &dst, &outlen);
+ error = iconv_conv((struct iconv_drv*)mbp->mb_udata, &src, &inlen,
+ &dst, &outlen);
+ if (inlen != *srclen || outlen != *dstlen) {
+ *srclen -= inlen;
+ *dstlen -= outlen;
+ return 0;
+ } else
+ return error;
}
int
diff --git a/sys/sys/mchain.h b/sys/sys/mchain.h
index 9a11077..23f454b 100644
--- a/sys/sys/mchain.h
+++ b/sys/sys/mchain.h
@@ -96,7 +96,8 @@ betohq(int64_t x)
struct mbuf;
struct mbchain;
-typedef int mb_copy_t(struct mbchain *mbp, c_caddr_t src, caddr_t dst, size_t len);
+typedef int mb_copy_t(struct mbchain *mbp, c_caddr_t src, caddr_t dst,
+ size_t *srclen, size_t *dstlen);
struct mbchain {
struct mbuf * mb_top; /* head of mbufs chain */
OpenPOWER on IntegriCloud