From c08de092f4058be2867241c48d630062282a5431 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sat, 11 Nov 2006 07:13:48 +0000 Subject: [PATCH] DEVEL15-windows-smb-rename-offline-folders-20061111 FIXES 45692 when offline folders are enabled, the old file name sent in a rename operation is sent in all uppercase even when the file name is not. this patch attempts a case insensitive match after the case sensitive match fails. (cherry picked from commit 7fff96e0cf113a34d3001282807b6bd04375f5b1) --- src/WINNT/afsd/smb.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/WINNT/afsd/smb.c b/src/WINNT/afsd/smb.c index 12eba606fc..ee5755956f 100644 --- a/src/WINNT/afsd/smb.c +++ b/src/WINNT/afsd/smb.c @@ -5272,6 +5272,7 @@ typedef struct smb_renameRock { char *maskp; /* pointer to star pattern of old file name */ int flags; /* tilde, casefold, etc */ char *newNamep; /* ptr to the new file's name */ + int any; } smb_renameRock_t; int smb_RenameProc(cm_scache_t *dscp, cm_dirEntry_t *dep, void *vrockp, osi_hyper_t *offp) @@ -5280,7 +5281,7 @@ int smb_RenameProc(cm_scache_t *dscp, cm_dirEntry_t *dep, void *vrockp, osi_hype smb_renameRock_t *rockp; int caseFold; int match; - char shortName[13]; + char shortName[13]=""; rockp = (smb_renameRock_t *) vrockp; @@ -5296,16 +5297,20 @@ int smb_RenameProc(cm_scache_t *dscp, cm_dirEntry_t *dep, void *vrockp, osi_hype match = smb_V3MatchMask(shortName, rockp->maskp, caseFold); } if (match) { - code = cm_Rename(rockp->odscp, dep->name, + rockp->any = 1; + + code = cm_Rename(rockp->odscp, dep->name, rockp->ndscp, rockp->newNamep, rockp->userp, rockp->reqp); /* if the call worked, stop doing the search now, since we * really only want to rename one file. */ + osi_Log1(smb_logp, "cm_Rename returns %ld", code); if (code == 0) code = CM_ERROR_STOPNOW; } - else code = 0; + else + code = 0; return code; } @@ -5410,6 +5415,7 @@ smb_Rename(smb_vc_t *vcp, smb_packet_t *inp, char * oldPathp, char * newPathp, i rock.maskp = oldLastNamep; rock.flags = ((strchr(oldLastNamep, '~') != NULL) ? SMB_MASKFLAG_TILDE : 0); rock.newNamep = newLastNamep; + rock.any = 0; /* Check if the file already exists; if so return error */ code = cm_Lookup(newDscp,newLastNamep,CM_FLAG_CHECKPATH,userp,&req,&tmpscp); @@ -5453,6 +5459,12 @@ smb_Rename(smb_vc_t *vcp, smb_packet_t *inp, char * oldPathp, char * newPathp, i thyper.HighPart = 0; code = cm_ApplyDir(oldDscp, smb_RenameProc, &rock, &thyper, userp, &req, NULL); + if (code == 0 && !rock.any) { + thyper.LowPart = 0; + thyper.HighPart = 0; + rock.flags |= SMB_MASKFLAG_CASEFOLD; + code = cm_ApplyDir(oldDscp, smb_RenameProc, &rock, &thyper, userp, &req, NULL); + } osi_Log1(smb_logp, "smb_RenameProc returns %ld", code); if (code == CM_ERROR_STOPNOW) @@ -5648,6 +5660,7 @@ smb_ReceiveCoreRename(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp) char *oldPathp; char *newPathp; char *tp; + long code; tp = smb_GetSMBData(inp, NULL); oldPathp = smb_ParseASCIIBlock(tp, &tp); @@ -5658,10 +5671,13 @@ smb_ReceiveCoreRename(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp) OemToChar(newPathp,newPathp); osi_Log2(smb_logp, "smb rename [%s] to [%s]", - osi_LogSaveString(smb_logp, oldPathp), - osi_LogSaveString(smb_logp, newPathp)); + osi_LogSaveString(smb_logp, oldPathp), + osi_LogSaveString(smb_logp, newPathp)); - return smb_Rename(vcp,inp,oldPathp,newPathp,0); + code = smb_Rename(vcp,inp,oldPathp,newPathp,0); + + osi_Log1(smb_logp, "smb rename returns 0x%x", code); + return code; } @@ -5781,6 +5797,7 @@ long smb_ReceiveCoreRemoveDir(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *ou rock.userp = userp; rock.reqp = &req; rock.dscp = dscp; + /* First do a case sensitive match, and if that fails, do a case insensitive match */ code = cm_ApplyDir(dscp, smb_RmdirProc, &rock, &thyper, userp, &req, NULL); if (code == 0 && !rock.any) {