[OpenAFS-devel] Windows NT/XP - Incorrect operation of Rename

James Peterson james@abrakus.com
Wed, 27 Nov 2002 04:58:35 -0800


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.

In order for AFS to operate in the same way the following patch must be
applied (based on v1.2.6):

diff -NurEB --exclude-from=exclude bas/src/WINNT/afsd/smb.c
upd/src/WINNT/afsd/smb.c
--- bas/src/WINNT/afsd/smb.c	2002-07-25 22:14:26.000000000 -0700
+++ upd/src/WINNT/afsd/smb.c	2002-11-20 20:29:49.000000000 -0800
@@ -3831,6 +3831,7 @@
         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 +3914,14 @@
          */
 	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)


James Peterson
"Integrity is the base of Excellence.