]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix renames on non-Windows hosts
authorVMware, Inc <>
Tue, 24 Aug 2010 18:28:15 +0000 (11:28 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 24 Aug 2010 18:28:15 +0000 (11:28 -0700)
The check if the target file exists and the rename was not to
replace an existing target was badly coded.
The logic left the status field incorrectly set to file not found
which was fine for not replacing the target but then the rename
was missed due to a check on the status being successful for the
existance check.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/hgfsServer/hgfsServerLinux.c

index bd102316ccb7b0d136ae05a28281b7aae349a392..b6b0b94d711f98049019c96b24ce746a454e2f58 100644 (file)
@@ -3872,24 +3872,23 @@ HgfsPlatformRename(char *localSrcName,     // IN: local path to source file
                    HgfsRenameHint hints)   // IN: rename hints
 {
    HgfsInternalStatus status = 0;
-   int error;
 
    if (hints & HGFS_RENAME_HINT_NO_REPLACE_EXISTING) {
-      status = HgfsPlatformFileExists(localTargetName);
-      if (0 == status) {
+      if (0 == HgfsPlatformFileExists(localTargetName)) {
          status = EEXIST;
+         goto exit;
       }
    }
 
-   if (0 == status) {
-      LOG(4, ("%s: renaming \"%s\" to \"%s\"\n", __FUNCTION__,
-         localSrcName, localTargetName));
-      error = Posix_Rename(localSrcName, localTargetName);
-      if (error) {
-         status = errno;
-         LOG(4, ("%s: error: %s\n", __FUNCTION__, strerror(status)));
-      }
+   LOG(4, ("%s: renaming \"%s\" to \"%s\"\n", __FUNCTION__,
+       localSrcName, localTargetName));
+   status = Posix_Rename(localSrcName, localTargetName);
+   if (status) {
+      status = errno;
+      LOG(4, ("%s: error: %s\n", __FUNCTION__, strerror(status)));
    }
+
+exit:
    return status;
 }