]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE12-windows-rename-warning-20021126
authorJames Peterson <james@abrakus.com>
Wed, 4 Dec 2002 14:26:43 +0000 (14:26 +0000)
committerDerrick Brashear <shadow@dementia.org>
Wed, 4 Dec 2002 14:26:43 +0000 (14:26 +0000)
Currently AFS doesn't handle Explorer operations 'rename' and 'move'
correctly.  Normal operation of 'rename' and 'move' is to warn the operator
when the destination file name already exist.

(cherry picked from commit f5ff298ec5dcc3607621321e5785374bbed591fc)

src/WINNT/afsd/smb.c

index b2a95af7229a5a835846fa5ef955882003fb16a7..21aac83ffc9502d12e9a3606313275c8ccc55d09 100644 (file)
@@ -3831,6 +3831,7 @@ long smb_ReceiveCoreRename(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
         smb_renameRock_t rock;
         cm_scache_t *oldDscp;
         cm_scache_t *newDscp;
+       cm_scache_t *tmpscp;
         char *oldLastNamep;
         char *newLastNamep;
         osi_hyper_t thyper;
@@ -3914,6 +3915,14 @@ long smb_ReceiveCoreRename(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
          */
        thyper.LowPart = 0;             /* search dir from here */
         thyper.HighPart = 0;
+       /* search for file to already exhist, if so return error*/
+
+       code = cm_Lookup(newDscp,newLastNamep,CM_FLAG_CHECKPATH,userp,&req,&tmpscp);
+       if((code != CM_ERROR_NOSUCHFILE) && (code != CM_ERROR_NOSUCHPATH) && (code != CM_ERROR_NOSUCHVOLUME) ) {
+           cm_ReleaseSCache(tmpscp);
+           return CM_ERROR_EXISTS; /* file exist, do not rename, also 
+                                      fixes move*/
+       }
         code = cm_ApplyDir(oldDscp, smb_RenameProc, &rock, &thyper, userp, &req, NULL);
 
         if (code == CM_ERROR_STOPNOW)