From 879d84fe79244612ab4587f69e3162e08f346179 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Tue, 25 Oct 2011 15:32:11 -0400 Subject: [PATCH] Windows: Do not EEXIST exact match during rename AFS Rename operations on the file server will delete a target file if it exists. Do not prevent renames because an exact match of the target name exists in the target directory. Reviewed-on: http://gerrit.openafs.org/5731 Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman (cherry picked from commit 9cf7a628c2ff178b2fa236d2c0a41ca9be315036) Change-Id: I02c32fab18053e1a37811089812f402d351a6666 Reviewed-on: http://gerrit.openafs.org/6040 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsd/cm_vnodeops.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/WINNT/afsd/cm_vnodeops.c b/src/WINNT/afsd/cm_vnodeops.c index c0c93b0e0..64d7c35c5 100644 --- a/src/WINNT/afsd/cm_vnodeops.c +++ b/src/WINNT/afsd/cm_vnodeops.c @@ -3561,21 +3561,28 @@ long cm_Rename(cm_scache_t *oldDscp, fschar_t *oldNamep, clientchar_t *cOldNamep goto done; } - code = cm_Lookup(newDscp, cNewNamep, CM_FLAG_CASEFOLD, userp, reqp, &newScp); - if (code == 0) { - /* found a matching object with the new name */ - if (cm_FidCmp(&oldScp->fid, &newScp->fid)) { - /* and they don't match so return an error */ - osi_Log2(afsd_logp, "cm_Rename newDscp 0x%p cNewName %S new name already exists", - newDscp, osi_LogSaveStringW(afsd_logp, cNewNamep)); + /* Case sensitive lookup. If this succeeds we are done. */ + code = cm_Lookup(newDscp, cNewNamep, 0, userp, reqp, &newScp); + if (code) { + /* + * Case insensitive lookup. If this succeeds, it could have found the + * same file with a name that differs only by case or it could be a + * different file entirely. + */ + code = cm_Lookup(newDscp, cNewNamep, CM_FLAG_CASEFOLD, userp, reqp, &newScp); + if (code == 0) { + /* found a matching object with the new name */ + if (cm_FidCmp(&oldScp->fid, &newScp->fid)) { + /* and they don't match so return an error */ + osi_Log2(afsd_logp, "cm_Rename newDscp 0x%p cNewName %S new name already exists", + newDscp, osi_LogSaveStringW(afsd_logp, cNewNamep)); + code = CM_ERROR_EXISTS; + } + cm_ReleaseSCache(newScp); + newScp = NULL; + } else if (code == CM_ERROR_AMBIGUOUS_FILENAME) { code = CM_ERROR_EXISTS; } - cm_ReleaseSCache(newScp); - newScp = NULL; - } else if (code == CM_ERROR_AMBIGUOUS_FILENAME) { - code = CM_ERROR_EXISTS; - } else { - code = 0; } /* Check for RO volume */ -- 2.39.5