diff options
Diffstat (limited to 'sys/fs/smbfs/smbfs_subr.c')
-rw-r--r-- | sys/fs/smbfs/smbfs_subr.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/sys/fs/smbfs/smbfs_subr.c b/sys/fs/smbfs/smbfs_subr.c index b775dff..51ee4d5 100644 --- a/sys/fs/smbfs/smbfs_subr.c +++ b/sys/fs/smbfs/smbfs_subr.c @@ -130,7 +130,10 @@ smb_fphelp(struct mbchain *mbp, struct smb_vc *vcp, struct smbnode *np, return smb_put_dmem(mbp, vcp, "\\", 2, caseopt);*/ while (i--) { np = *--npp; - error = mb_put_uint8(mbp, '\\'); + if (SMB_UNICODE_STRINGS(vcp)) + error = mb_put_uint16le(mbp, '\\'); + else + error = mb_put_uint8(mbp, '\\'); if (error) break; error = smb_put_dmem(mbp, vcp, np->n_name, np->n_nmlen, caseopt); @@ -148,6 +151,11 @@ smbfs_fullpath(struct mbchain *mbp, struct smb_vc *vcp, struct smbnode *dnp, int caseopt = SMB_CS_NONE; int error; + if (SMB_UNICODE_STRINGS(vcp)) { + error = mb_put_padbyte(mbp); + if (error) + return error; + } if (SMB_DIALECT(vcp) < SMB_DIALECT_LANMAN1_0) caseopt |= SMB_CS_UPPER; if (dnp != NULL) { @@ -156,7 +164,10 @@ smbfs_fullpath(struct mbchain *mbp, struct smb_vc *vcp, struct smbnode *dnp, return error; } if (name) { - error = mb_put_uint8(mbp, '\\'); + if (SMB_UNICODE_STRINGS(vcp)) + error = mb_put_uint16le(mbp, '\\'); + else + error = mb_put_uint8(mbp, '\\'); if (error) return error; error = smb_put_dmem(mbp, vcp, name, nmlen, caseopt); @@ -164,6 +175,8 @@ smbfs_fullpath(struct mbchain *mbp, struct smb_vc *vcp, struct smbnode *dnp, return error; } error = mb_put_uint8(mbp, 0); + if (SMB_UNICODE_STRINGS(vcp) && error == 0) + error = mb_put_uint8(mbp, 0); return error; } @@ -191,6 +204,17 @@ smbfs_fname_tolocal(struct smb_vc *vcp, char *name, int *nmlen, int caseopt) error = iconv_conv_case (vcp->vc_tolocal, (const char **)&ibuf, &ilen, &obuf, &olen, copt); + if (error && SMB_UNICODE_STRINGS(vcp)) { + /* + * If using unicode, leaving a file name as it was when + * convert fails will cause a problem because the file name + * will contain NULL. + * Here, put '?' and give converted file name. + */ + *obuf = '?'; + olen--; + error = 0; + } if (!error) { *nmlen = sizeof(outbuf) - olen; memcpy(name, outbuf, *nmlen); |