From: VMware, Inc <> Date: Tue, 26 Apr 2011 21:26:44 +0000 (-0700) Subject: lib/file: prep change before overhaul X-Git-Tag: 2011.04.25-402641~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=940597efee460bb6ed6705b812ff5f969926e2be;p=thirdparty%2Fopen-vm-tools.git lib/file: prep change before overhaul The "make temp" functions currently live in file.c and should live in fileTemp.c. In order to move them, remove the Msg_* stuff - this should be Log and Warning - and include the work-around just added to ESX50. After this change and moving the code to its proper place, a full fix for the worked-around problem will be done. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/file/file.c b/open-vm-tools/lib/file/file.c index a6f691a4f..7387db712 100644 --- a/open-vm-tools/lib/file/file.c +++ b/open-vm-tools/lib/file/file.c @@ -706,8 +706,8 @@ File_MakeTempEx2(ConstUnicode dir, // IN: Unicode *presult) // OUT: { int fd = -1; - int err; - uint32 var; + int var; + uint32 i; Unicode path = NULL; @@ -720,21 +720,16 @@ File_MakeTempEx2(ConstUnicode dir, // IN: *presult = NULL; - for (var = 0; var < 0xFFFFFFFF; var++) { - Unicode fileName = NULL; + for (i = 0, var = 0; i < 0xFFFFFFFF; + i++, var += (FileSimpleRandom() >> 8) & 0xFF) { + Unicode fileName; /* construct suffixed pathname to use */ Unicode_Free(path); path = NULL; fileName = (*createNameFunc)(var, createNameFuncData); - - if (fileName == NULL) { - Msg_Append(MSGID(file.maketemp.helperFuncFailed) - "Failed to construct the filename.\n"); - errno = EFAULT; - goto exit; - } + ASSERT(fileName); /* construct base full pathname to use */ path = Unicode_Join(dir, DIRSEPS, fileName, NULL); @@ -750,6 +745,7 @@ File_MakeTempEx2(ConstUnicode dir, // IN: * if a directory already exists with the same name. In such case, * we need to check if a file already exists and ignore EACCES error. */ + if ((fd == -1) && (errno == EACCES) && (File_Exists(path))) { continue; } @@ -765,27 +761,23 @@ File_MakeTempEx2(ConstUnicode dir, // IN: } if (errno != EEXIST) { - err = errno; - Msg_Append(MSGID(file.maketemp.openFailed) - "Failed to create temporary file \"%s\": %s.\n", - UTF8(path), Msg_ErrString()); - errno = err; + Log(LGPFX" Failed to create temporary %s \"%s\": %s.\n", + createTempFile ? "file" : "directory", + UTF8(path), strerror(errno)); goto exit; } } if (fd == -1) { - Msg_Append(MSGID(file.maketemp.fullNamespace) - "Failed to create temporary file \"%s\": The name space is " - "full.\n", UTF8(path)); + Warning(LGPFX" Failed to create temporary %s \"%s\": " + "The name space is full.\n", + createTempFile ? "file" : "directory", UTF8(path)); errno = EAGAIN; } exit: - err = errno; Unicode_Free(path); - errno = err; return fd; }