Make smbfs capable to use 16bit char set in filenames.

PR:78110
This commit is contained in:
takawata 2005-05-04 15:05:46 +00:00
parent ad22e93c3e
commit a61ec3d816
6 changed files with 39 additions and 30 deletions

View File

@ -473,8 +473,6 @@ smb_ctx_resolve(struct smb_ctx *ctx)
struct sockaddr *sap;
struct sockaddr_nb *salocal, *saserver;
char *cp;
u_char cstbl[256];
u_int i;
int error = 0;
ctx->ct_flags &= ~SMBCF_RESOLVED;
@ -496,7 +494,7 @@ smb_ctx_resolve(struct smb_ctx *ctx)
if (error)
return error;
if (ssn->ioc_localcs[0] == 0)
strcpy(ssn->ioc_localcs, "default"); /* XXX: locale name ? */
strcpy(ssn->ioc_localcs, "ISO8859-1");
error = smb_addiconvtbl("tolower", ssn->ioc_localcs, nls_lower);
if (error)
return error;
@ -504,18 +502,9 @@ smb_ctx_resolve(struct smb_ctx *ctx)
if (error)
return error;
if (ssn->ioc_servercs[0] != 0) {
for(i = 0; i < sizeof(cstbl); i++)
cstbl[i] = i;
nls_mem_toext(cstbl, cstbl, sizeof(cstbl));
error = smb_addiconvtbl(ssn->ioc_servercs, ssn->ioc_localcs, cstbl);
if (error)
return error;
for(i = 0; i < sizeof(cstbl); i++)
cstbl[i] = i;
nls_mem_toloc(cstbl, cstbl, sizeof(cstbl));
error = smb_addiconvtbl(ssn->ioc_localcs, ssn->ioc_servercs, cstbl);
if (error)
return error;
error = kiconv_add_xlat16_cspairs
(ssn->ioc_localcs, ssn->ioc_servercs);
if (error) return error;
}
if (ctx->ct_srvaddr) {
error = nb_resolvehost_in(ctx->ct_srvaddr, &sap);

View File

@ -1449,8 +1449,8 @@ smbfs_findnext(struct smbfs_fctx *ctx, int limit, struct smb_cred *scred)
continue;
break;
}
smbfs_fname_tolocal(SSTOVC(ctx->f_ssp), ctx->f_name, ctx->f_nmlen,
ctx->f_dnp->n_mount->sm_caseopt);
smbfs_fname_tolocal(SSTOVC(ctx->f_ssp), ctx->f_name, &ctx->f_nmlen,
ctx->f_dnp->n_mount->sm_caseopt);
ctx->f_attr.fa_ino = smbfs_getino(ctx->f_dnp, ctx->f_name, ctx->f_nmlen);
return 0;
}

View File

@ -316,13 +316,33 @@ smbfs_fullpath(struct mbchain *mbp, struct smb_vc *vcp, struct smbnode *dnp,
}
int
smbfs_fname_tolocal(struct smb_vc *vcp, char *name, int nmlen, int caseopt)
smbfs_fname_tolocal(struct smb_vc *vcp, char *name, int *nmlen, int caseopt)
{
/* if (caseopt & SMB_CS_UPPER)
iconv_convmem(vcp->vc_toupper, name, name, nmlen);
else if (caseopt & SMB_CS_LOWER)
iconv_convmem(vcp->vc_tolower, name, name, nmlen);*/
if (vcp->vc_tolocal)
iconv_convmem(vcp->vc_tolocal, name, name, nmlen);
return 0;
int copt = (caseopt == SMB_CS_LOWER ? KICONV_FROM_LOWER :
(caseopt == SMB_CS_UPPER ? KICONV_FROM_UPPER : 0));
int error = 0;
int ilen = *nmlen;
int olen;
char *ibuf = name;
char outbuf[SMB_MAXFNAMELEN];
char *obuf = outbuf;
if (vcp->vc_tolocal) {
olen = sizeof(outbuf);
bzero(outbuf, sizeof(outbuf));
/*
error = iconv_conv_case
(vcp->vc_tolocal, NULL, NULL, &obuf, &olen, copt);
if (error) return error;
*/
error = iconv_conv_case
(vcp->vc_tolocal, (const char **)&ibuf, &ilen, &obuf, &olen, copt);
if (!error) {
*nmlen = sizeof(outbuf) - olen;
memcpy(name, outbuf, *nmlen);
}
}
return error;
}

View File

@ -174,7 +174,7 @@ int smbfs_fullpath(struct mbchain *mbp, struct smb_vc *vcp,
int smbfs_smb_lookup(struct smbnode *dnp, const char *name, int nmlen,
struct smbfattr *fap, struct smb_cred *scred);
int smbfs_fname_tolocal(struct smb_vc *vcp, char *name, int nmlen, int caseopt);
int smbfs_fname_tolocal(struct smb_vc *vcp, char *name, int *nmlen, int caseopt);
void smb_time_local2server(struct timespec *tsp, int tzoff, u_long *seconds);
void smb_time_server2local(u_long seconds, int tzoff, struct timespec *tsp);

View File

@ -3,8 +3,8 @@
PROG= smbutil
SRCS= smbutil.c dumptree.c login.c lookup.c view.c print.c
DPADD= ${LIBSMB}
LDADD= -lsmb
DPADD= ${LIBSMB} ${LIBKICONV}
LDADD= -lsmb -lkiconv
CONTRIBDIR= ${.CURDIR}/../../contrib/smbfs
CFLAGS+= -I${CONTRIBDIR}/include

View File

@ -9,8 +9,8 @@ MOUNTDIR= ${.CURDIR}/../../sbin/mount
CONTRIBDIR= ${.CURDIR}/../../contrib/smbfs
CFLAGS+= -DSMBFS -I${MOUNTDIR} -I${CONTRIBDIR}/include
LDADD= -lsmb
DPADD= ${LIBSMB}
LDADD= -lsmb -lkiconv
DPADD= ${LIBSMB} ${LIBKICONV}
# Needs to be dynamically linked for optional dlopen() access to
# userland libiconv (see the -E option).