From a61ec3d8166cdedc2125146e2644135d395e23d0 Mon Sep 17 00:00:00 2001 From: takawata Date: Wed, 4 May 2005 15:05:46 +0000 Subject: Make smbfs capable to use 16bit char set in filenames. PR:78110 --- sys/fs/smbfs/smbfs_smb.c | 4 ++-- sys/fs/smbfs/smbfs_subr.c | 36 ++++++++++++++++++++++++++++-------- sys/fs/smbfs/smbfs_subr.h | 2 +- 3 files changed, 31 insertions(+), 11 deletions(-) (limited to 'sys/fs/smbfs') diff --git a/sys/fs/smbfs/smbfs_smb.c b/sys/fs/smbfs/smbfs_smb.c index ea1721e..f45d2ac 100644 --- a/sys/fs/smbfs/smbfs_smb.c +++ b/sys/fs/smbfs/smbfs_smb.c @@ -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; } diff --git a/sys/fs/smbfs/smbfs_subr.c b/sys/fs/smbfs/smbfs_subr.c index 683b2bd..5e04a37 100644 --- a/sys/fs/smbfs/smbfs_subr.c +++ b/sys/fs/smbfs/smbfs_subr.c @@ -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; } diff --git a/sys/fs/smbfs/smbfs_subr.h b/sys/fs/smbfs/smbfs_subr.h index b50ecf8..a72b9e6 100644 --- a/sys/fs/smbfs/smbfs_subr.h +++ b/sys/fs/smbfs/smbfs_subr.h @@ -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); -- cgit v1.1