1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-02 08:42:48 +00:00

Change API of mb_copy_t in libmchain so that netsmb can handle

multibyte character share name correctly.

Reviewed by:	bp
This commit is contained in:
R. Imura 2005-07-29 13:22:37 +00:00
parent 1b3b403e9b
commit 080e3a63b3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=148517
4 changed files with 35 additions and 11 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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

View File

@ -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 */