VirtualBox

Ticket #2350 (closed defect: fixed)

Opened 14 years ago

Last modified 14 years ago

MoveFile does not report failure when the target exists => Fixed in 2.0.4

Reported by: angavrilov Owned by:
Component: shared folders Version: VirtualBox 2.0.2
Keywords: git lock rename Cc:
Guest type: Windows Host type: other

Description

As described in  MSDN, MoveFile should fail if the target file exists.

However, when the files are located in a shared folder, it apparently returns success without actually doing anything. It makes using msysgit with repositories located on shared folders impossible, except in read-only mode.

Steps to reproduce with msysgit:
1) Install  MSysGit
2) Create a shared folder and map it to a drive letter
3) Try to create a repository on that drive, i.e. mkdir test; cd test; git init (You'll have to enable the "use from windows command prompt" option in the installer)

It'll output a bunch of errors, and leave a .../.git/config.lock file:

error: could not lock config file E:/Work/test/.git/config
error: could not lock config file E:/Work/test/.git/config
error: could not lock config file E:/Work/test/.git/config
error: could not lock config file E:/Work/test/.git/config

Workaround: if I make it ignore the result of rename(), and try MoveFileEx anyway, it works properly:

--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -869,11 +869,12 @@ int mingw_rename(const char *pold, const char *pnew)
         * Try native rename() first to get errno right.
         * It is based on MoveFile(), which cannot overwrite existing files.
         */
+       int ok = 0;
        if (!rename(pold, pnew))
-               return 0;
-       if (errno != EEXIST)
+               ok++;
+       if (!ok && errno != EEXIST)
                return -1;
-       if (MoveFileEx(pold, pnew, MOVEFILE_REPLACE_EXISTING))
+       if (MoveFileEx(pold, pnew, MOVEFILE_REPLACE_EXISTING) || ok)
                return 0;
        /* TODO: translate more errors */
        if (GetLastError() == ERROR_ACCESS_DENIED) {

Guest: Windows 2000 & XP, Host: Fedora 9

Change History

comment:1 Changed 14 years ago by frank

  • Summary changed from MoveFile does not report failure when the target exists to MoveFile does not report failure when the target exists => Fixed in 2.0.4

Thanks for the report. This problem will be properly fixed in 2.0.4

comment:2 Changed 14 years ago by frank

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.

www.oracle.com
ContactPrivacy policyTerms of Use